Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/groups/details/groupDetailsCtrl.js @ 12551

Last change on this file since 12551 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: 6.4 KB
Line 
1(function () {
2    var module = appStatisticsPlugin.getAngularModule();
3    module.controller('app.statistics.groupDetailsCtrl',
4        ['$scope', '$stateParams', '$interval', 'app.statistics.clientService', 'app.statistics.groupService',
5        function ($scope, $stateParams, $interval, clientService, groupService) {
6            $scope.interval = defaultPageUpdateInterval;
7            $scope.curClientsPage = 1;
8            $scope.clientsPageSize = 20;
9
10
11            // details
12            $scope.knobOptions = {
13                'fgColor': "#f7921d",
14                'angleOffset': -125,
15                'angleArc': 250,
16                'readOnly': true,
17                'width': "80%",
18                'targetvalue': "100",
19                'format': function (value) {
20                    return value;
21                },
22                draw: function () {
23                    $(this.i).val(this.cv + '%');
24                }
25            };
26
27            $scope.knobData = {
28                cores: 0,
29                cpu: 0,
30                memory: 0
31            };
32
33            var getGroupDetails = function() {
34                groupService.getGroupDetails({ id: $stateParams.id }, function (group) {
35                    $scope.group = group;
36                    $scope.knobData.cores = (group.UsedCores / group.TotalCores) * 100;
37                    $scope.knobData.cpu = group.ActiveCpuUtilization;
38                    $scope.knobData.memory = (group.UsedMemory / group.TotalMemory) * 100;
39
40                    var length = group.TasksStates.length;
41                    var total = 0;
42                    for (var i = 0; i < length; ++i) {
43                        total += group.TasksStates[i].Count;
44                    }
45                    $scope.totalGroupTasks = total;
46                });
47            };
48
49            var getClients = function () {
50                clientService.getClientsByGroupId({id: $stateParams.id, page: $scope.curClientsPage, size: $scope.clientsPageSize, expired: false },
51                    function (clientPage) {
52                        $scope.clientPage = clientPage;
53                    }
54                );
55            };
56
57            // charts
58            $scope.chartOptions = {
59                grid: {
60                    borderWidth: 1,
61                    labelMargin: 15
62                },
63                series: {
64                    shadowSize: 0
65                },
66                yaxis: {
67                    min: 0,
68                    max: 100,
69                    zoomRange: false,
70                    panRange: false
71                },
72                xaxis: {
73                    mode: "time",
74                    twelveHourClock: false
75                }
76            };
77
78            $scope.fillChartOptions = {
79                grid: {
80                    borderWidth: 1,
81                    labelMargin: 15
82                },
83                series: {
84                    shadowSize: 0,
85                    lines: {
86                        show: true,
87                        fill: true
88                    }
89                },
90                yaxis: {
91                    zoomRange: false,
92                    panRange: false
93                },
94                xaxis: {
95                    mode: "time",
96                    twelveHourClock: false
97                }
98            };
99
100            $scope.fromDate = new Date();
101            $scope.toDate = new Date();
102
103            $scope.fromIsOpen = false;
104            $scope.toIsOpen = false;
105
106            $scope.openFromDateSelection = function ($event) {
107                $event.preventDefault();
108                $event.stopPropagation();
109                $scope.toIsOpen = false;
110                $scope.fromIsOpen = true;
111            };
112
113            $scope.openToDateSelection = function ($event) {
114                $event.preventDefault();
115                $event.stopPropagation();
116                $scope.fromIsOpen = false;
117                $scope.toIsOpen = true;
118            };
119
120            $scope.dateOptions = {
121                formatYear: 'yy',
122                startingDay: 1
123            };
124
125            $scope.cpuSeries = [[]];
126            $scope.coreSeries = [[]];
127            $scope.memorySeries = [[]];
128
129            $scope.updateCharts = function () {
130                clientService.getClientHistoryByGroupId({ id: $stateParams.id, start: ConvertFromDate($scope.fromDate), end: ConvertToDate($scope.toDate) }, function (status) {
131                    var noOfStatus = status.length;
132                    var cpuSeries = [];
133                    var coreSeries = [[], []];
134                    var memorySeries = [[], []];
135                    for (var i = 0; i < noOfStatus; ++i) {
136                        var curStatus = status[i];
137                        var cpuData = Math.round(curStatus.CpuUtilization);
138                        cpuSeries.push([curStatus.Timestamp, cpuData]);
139                        coreSeries[0].push([curStatus.Timestamp, curStatus.TotalCores]);
140                        coreSeries[1].push([curStatus.Timestamp, curStatus.UsedCores]);
141                        memorySeries[0].push([curStatus.Timestamp, curStatus.TotalMemory]);
142                        memorySeries[1].push([curStatus.Timestamp, curStatus.UsedMemory]);
143                    }
144                    $scope.cpuSeries = [{ data: cpuSeries, label: "&nbsp;CPU Utilization", color: "#f7921d" }];
145                    $scope.coreSeries = [
146                        { data: coreSeries[0], label: "&nbsp;Total Cores", color: "LightGreen" },
147                        { data: coreSeries[1], label: "&nbsp;Used Cores", color: "LightPink" }
148                    ];
149                    $scope.memorySeries = [
150                        { data: memorySeries[0], label: "&nbsp;Total Memory", color: "LightGreen" },
151                        { data: memorySeries[1], label: "&nbsp;Used Memory", color: "LightPink" }
152                    ];
153
154                });
155            };
156
157            var update = function () {
158                getGroupDetails();
159                getClients();
160            };
161
162            $scope.updateInterval = $interval(update, $scope.interval);
163            var cancelInterval = $scope.$on('$locationChangeSuccess', function () {
164                $interval.cancel($scope.updateInterval);
165                cancelInterval();
166            });
167            update(); // init page
168            $scope.updateCharts();
169        }]
170    );
171})();
Note: See TracBrowser for help on using the repository browser.