[12477] | 1 | (function () {
|
---|
| 2 | var module = appStatisticsPlugin.getAngularModule();
|
---|
| 3 | module.controller('app.statistics.jobsCtrl',
|
---|
[12516] | 4 | ['$scope', '$interval', 'app.statistics.jobService', function ($scope, $interval, jobService) {
|
---|
[12525] | 5 | var first = true;
|
---|
| 6 | $scope.isAdministrator = false;
|
---|
[12516] | 7 | $scope.interval = defaultPageUpdateInterval;
|
---|
| 8 | $scope.completedJobCurPage = 1;
|
---|
| 9 | $scope.completedJobPageSize = 20;
|
---|
| 10 |
|
---|
| 11 | var getAllJobs = function() {
|
---|
| 12 | jobService.getAllJobs({ completed: false }, function(jobs) {
|
---|
[12477] | 13 | $scope.jobs = jobs;
|
---|
| 14 | });
|
---|
| 15 | };
|
---|
[12484] | 16 |
|
---|
[12516] | 17 | var getCompletedJobs = function() {
|
---|
| 18 | jobService.getJobs({ page: $scope.completedJobCurPage, size: $scope.completedJobPageSize, completed: true },
|
---|
| 19 | function (jobPage) {
|
---|
| 20 | $scope.completedJobPage = jobPage;
|
---|
| 21 | }
|
---|
| 22 | );
|
---|
[12484] | 23 | };
|
---|
| 24 |
|
---|
[12525] | 25 | var getAllActiveJobsFromAllUsers = function () {
|
---|
| 26 | jobService.getAllActiveJobsFromAllUsers({}, function (jobs) {
|
---|
| 27 | $scope.isAdministrator = true;
|
---|
| 28 | $scope.allUsersJobs = jobs;
|
---|
| 29 | });
|
---|
| 30 | };
|
---|
| 31 |
|
---|
[12516] | 32 | $scope.changeCompletedJobPage = function () {
|
---|
| 33 | update();
|
---|
| 34 | };
|
---|
| 35 |
|
---|
| 36 | var update = function () {
|
---|
| 37 | getAllJobs();
|
---|
[12525] | 38 | if (first || $scope.isAdministrator) {
|
---|
| 39 | getAllActiveJobsFromAllUsers();
|
---|
| 40 | }
|
---|
[12516] | 41 | getCompletedJobs();
|
---|
| 42 | };
|
---|
| 43 |
|
---|
| 44 | $scope.updateInterval = $interval(update, $scope.interval);
|
---|
| 45 | var cancelInterval = $scope.$on('$locationChangeSuccess', function () {
|
---|
| 46 | $interval.cancel($scope.updateInterval);
|
---|
| 47 | cancelInterval();
|
---|
| 48 | });
|
---|
| 49 | update(); // init page
|
---|
[12525] | 50 | first = false;
|
---|
[12477] | 51 | }]
|
---|
| 52 | );
|
---|
| 53 | })(); |
---|