1 | (function () {
|
---|
2 | var module = appStatisticsPlugin.getAngularModule();
|
---|
3 | module.controller('app.statistics.jobsCtrl',
|
---|
4 | ['$scope', '$interval', 'app.statistics.jobService', function ($scope, $interval, jobService) {
|
---|
5 | $scope.interval = defaultPageUpdateInterval;
|
---|
6 | $scope.completedJobCurPage = 1;
|
---|
7 | $scope.completedJobPageSize = 20;
|
---|
8 |
|
---|
9 | var getAllJobs = function() {
|
---|
10 | jobService.getAllJobs({ completed: false }, function(jobs) {
|
---|
11 | $scope.jobs = jobs;
|
---|
12 | var length = $scope.jobs.length;
|
---|
13 | for (var i = 0; i < length; ++i) {
|
---|
14 | $scope.jobs[i].DateCreated = CSharpDateToString($scope.jobs[i].DateCreated);
|
---|
15 | }
|
---|
16 | });
|
---|
17 | };
|
---|
18 |
|
---|
19 | var getCompletedJobs = function() {
|
---|
20 | jobService.getJobs({ page: $scope.completedJobCurPage, size: $scope.completedJobPageSize, completed: true },
|
---|
21 | function (jobPage) {
|
---|
22 | $scope.completedJobPage = jobPage;
|
---|
23 | var length = $scope.completedJobPage.Jobs.length;
|
---|
24 | for (var i = 0; i < length; ++i) {
|
---|
25 | $scope.completedJobPage.Jobs[i].DateCreated = CSharpDateToString($scope.completedJobPage.Jobs[i].DateCreated);
|
---|
26 | $scope.completedJobPage.Jobs[i].DateCompleted = CSharpDateToString($scope.completedJobPage.Jobs[i].DateCompleted);
|
---|
27 | }
|
---|
28 | }
|
---|
29 | );
|
---|
30 | };
|
---|
31 |
|
---|
32 | $scope.changeCompletedJobPage = function () {
|
---|
33 | update();
|
---|
34 | };
|
---|
35 |
|
---|
36 | var update = function () {
|
---|
37 | getAllJobs();
|
---|
38 | getCompletedJobs();
|
---|
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 | })(); |
---|