1 | (function () {
|
---|
2 | var module = appStatisticsPlugin.getAngularModule();
|
---|
3 | module.controller('app.statistics.clientsCtrl',
|
---|
4 | ['$scope', '$interval', 'app.statistics.clientService',
|
---|
5 | function ($scope, $interval, clientService) {
|
---|
6 | $scope.interval = defaultPageUpdateInterval;
|
---|
7 | $scope.curClientsPage = 1;
|
---|
8 | $scope.clientsPageSize = 20;
|
---|
9 | $scope.curExpiredClientsPage = 1;
|
---|
10 | $scope.expiredClientsPageSize = 20;
|
---|
11 |
|
---|
12 | var getClients = function () {
|
---|
13 | clientService.getClients({ page: $scope.curClientsPage, size: $scope.clientsPageSize, expired: false },
|
---|
14 | function (clientPage) {
|
---|
15 | $scope.clientPage = clientPage;
|
---|
16 | }
|
---|
17 | );
|
---|
18 | };
|
---|
19 |
|
---|
20 | var getExpiredClients = function() {
|
---|
21 | clientService.getClients({ page: $scope.curExpiredClientsPage, size: $scope.expiredClientsPageSize, expired: true },
|
---|
22 | function (clientPage) {
|
---|
23 | $scope.expiredClientPage = clientPage;
|
---|
24 | }
|
---|
25 | );
|
---|
26 | };
|
---|
27 |
|
---|
28 | var update = function () {
|
---|
29 | getClients();
|
---|
30 | getExpiredClients();
|
---|
31 | };
|
---|
32 |
|
---|
33 | $scope.changeClientsPage = function () {
|
---|
34 | update();
|
---|
35 | };
|
---|
36 |
|
---|
37 | $scope.changeExpiredClientsPage = function () {
|
---|
38 | update();
|
---|
39 | };
|
---|
40 |
|
---|
41 | $scope.updateInterval = $interval(update, $scope.interval);
|
---|
42 | var cancelInterval = $scope.$on('$locationChangeSuccess', function () {
|
---|
43 | $interval.cancel($scope.updateInterval);
|
---|
44 | cancelInterval();
|
---|
45 | });
|
---|
46 | update(); // init page
|
---|
47 |
|
---|
48 | }]
|
---|
49 | );
|
---|
50 | })(); |
---|