Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/jobs/details/jobDetailsCtrl.js @ 15682

Last change on this file since 15682 was 12551, checked in by dglaser, 9 years ago

#2388:

HeuristicLab.Services.Hive.DataAccess-3.3:

  • updated database schema
  • updated sql scripts
  • updated HiveStatisticsGenerator

HeuristicLab.Services.WebApp-3.3:

  • merged from trunk

HeuristicLab.Services.WebApp.Status-3.3:

  • updated data api controller

HeuristicLab.Services.WebApp.Statistics-3.3:

  • added exception page
  • improved jobs, clients, users and groups page
File size: 4.1 KB
Line 
1(function () {
2    var module = appStatisticsPlugin.getAngularModule();
3    module.controller('app.statistics.jobDetailsCtrl',
4        ['$scope', '$interval', '$stateParams', 'app.statistics.jobService', 'app.statistics.taskService', '$modal',
5        function ($scope, $interval, $stateParams, jobService, taskService, $modal) {
6            $scope.interval = defaultPageUpdateInterval;
7            $scope.curTaskPage = 1;
8            $scope.taskPageSize = 12;
9
10            var getJobDetails = function () {
11                jobService.getJobDetails({ id: $stateParams.id }, function (job) {
12                    $scope.job = job;
13                    $scope.job.CalculatingWaitingRatio = ($scope.job.TotalCalculatingTime / $scope.job.TotalWaitingTime);
14
15                    var length = job.TasksStates.length;
16                    var total = 0;
17                    var jsStates = [];
18                    for (var i = 0; i < length; ++i) {
19                        var state = job.TasksStates[i];
20                        var selected = true;
21                        if (isDefined($scope.states)) {
22                            for (var j = 0; j < $scope.states.length; ++j) {
23                                if (state.State == $scope.states[j].State) {
24                                    selected = $scope.states[j].Selected;
25                                    break;
26                                }
27                            }
28                        }
29                        jsStates.push({
30                            State: state.State,
31                            Count: state.Count,
32                            Selected: selected
33                        });
34                        total += state.Count;
35                    }
36                    $scope.totalJobTasks = total;
37                    $scope.states = jsStates;
38                    getTasks();
39                });
40            };
41
42            var getTasks = function () {
43                var states = [];
44                var length = $scope.states.length;
45                for (var i = 0; i < length; ++i) {
46                    var state = $scope.states[i];
47                    if (state.Selected) {
48                        states.push(state.State);
49                    }
50                }
51
52                taskService.getTasksByJobId({ id: $stateParams.id, page: $scope.curTaskPage, size: $scope.taskPageSize }, states,
53                    function (taskPage) {
54                        $scope.taskPage = taskPage;
55                    }
56                );
57            };
58
59            $scope.changeTaskPage = function () {
60                getJobDetails();
61                $('html, body').animate({
62                    scrollTop: $("#job-filter-header").offset().top
63                }, 10);
64            };
65
66            $scope.filterState = function (state) {
67                state.Selected = !state.Selected;
68                $scope.curTaskPage = 1;
69                getJobDetails();
70            };
71
72            $scope.openDialog = function (taskNo, task) {
73                $scope.currentTaskNo = taskNo;
74                $scope.currentTask = task;
75                $modal.open({
76                    templateUrl: 'plugin=statistics&view=WebApp/jobs/details/jobTaskDetailsDialog.cshtml',
77                    controller: 'app.statistics.jobTaskDetailsDialogCtrl',
78                    windowClass: 'app-modal-window',
79                    resolve: {
80                        task: function() {
81                            return $scope.currentTask;
82                        },
83                        taskNo: function() {
84                            return $scope.currentTaskNo;
85                        }
86                    }
87                });
88            };
89
90            var update = function () {
91                getJobDetails();
92            };
93
94            $scope.updateInterval = $interval(update, $scope.interval);
95            var cancelInterval = $scope.$on('$locationChangeSuccess', function () {
96                $interval.cancel($scope.updateInterval);
97                cancelInterval();
98            });
99            update(); // init page
100        }]
101    );
102})();
Note: See TracBrowser for help on using the repository browser.