Free cookie consent management tool by TermsFeed Policy Generator

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

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

#2388:

HeuristicLab.Services.WebApp.Status-3.3:
HeuristicLab.Services.WebApp.Statistics-3.3:

  • Added 'Last 6 Months' and 'Last Year' to the QuickSelection

HeuristicLab.Services.WebApp.Statistics-3.3:

  • Added Group Name to expired clients
File size: 8.9 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.quickSelectionList = [
107                { id: 0, name: 'Custom' },
108                { id: 1, name: 'Today' },
109                { id: 2, name: 'Yesterday' },
110                { id: 3, name: 'Last 7 Days' },
111                { id: 4, name: 'Last 30 Days' },
112                { id: 5, name: 'Last 6 Months' },
113                { id: 6, name: 'Last Year' }
114            ];
115            $scope.changeQuickSelection = function (quickSelection) {
116                var today = new Date();
117                var oneDayInMs = 24 * 60 * 60 * 1000;
118                switch (quickSelection.id) {
119                    case 1:
120                        $scope.fromDate = new Date(today.valueOf());
121                        $scope.toDate = new Date(today.valueOf());
122                        break;
123                    case 2:
124                        $scope.fromDate = new Date(today.valueOf() - oneDayInMs);
125                        $scope.toDate = new Date(today.valueOf() - oneDayInMs);
126                        break;
127                    case 3:
128                        $scope.fromDate = new Date(today.valueOf() - (7 * oneDayInMs));
129                        $scope.toDate = new Date(today.valueOf());
130                        break;
131                    case 4:
132                        $scope.fromDate = new Date(today.valueOf() - (30 * oneDayInMs));
133                        $scope.toDate = new Date(today.valueOf());
134                        break;
135                    case 5:
136                        var month = today.getMonth() - 6;
137                        if (month < 0) {
138                            month += 12;
139                        }
140                        $scope.fromDate = new Date(today.valueOf());
141                        $scope.fromDate.setMonth(month);
142                        $scope.toDate = new Date(today.valueOf());
143                        break;
144                    case 6:
145                        $scope.fromDate = new Date(today.valueOf());
146                        $scope.fromDate.setFullYear(today.getFullYear() - 1);
147                        $scope.toDate = new Date(today.valueOf());
148                        break;
149                }
150                $scope.curQuickSelection = quickSelection;
151            };
152            // set default 'today'
153            $scope.changeQuickSelection($scope.quickSelectionList[1]);
154
155            $scope.openFromDateSelection = function ($event) {
156                $event.preventDefault();
157                $event.stopPropagation();
158                $scope.toIsOpen = false;
159                $scope.fromIsOpen = true;
160                $scope.curQuickSelection = $scope.quickSelectionList[0];
161            };
162
163            $scope.openToDateSelection = function ($event) {
164                $event.preventDefault();
165                $event.stopPropagation();
166                $scope.fromIsOpen = false;
167                $scope.toIsOpen = true;
168                $scope.curQuickSelection = $scope.quickSelectionList[0];
169            };
170
171            $scope.dateOptions = {
172                formatYear: 'yy',
173                startingDay: 1
174            };
175
176            $scope.cpuSeries = [[]];
177            $scope.coreSeries = [[]];
178            $scope.memorySeries = [[]];
179
180            $scope.updateCharts = function () {
181                clientService.getClientHistoryByGroupId({ id: $stateParams.id, start: ConvertFromDate($scope.fromDate), end: ConvertToDate($scope.toDate) }, function (status) {
182                    var noOfStatus = status.length;
183                    var cpuSeries = [];
184                    var coreSeries = [[], []];
185                    var memorySeries = [[], []];
186                    for (var i = 0; i < noOfStatus; ++i) {
187                        var curStatus = status[i];
188                        var cpuData = Math.round(curStatus.CpuUtilization);
189                        cpuSeries.push([curStatus.Timestamp, cpuData]);
190                        coreSeries[0].push([curStatus.Timestamp, curStatus.TotalCores]);
191                        coreSeries[1].push([curStatus.Timestamp, curStatus.UsedCores]);
192                        memorySeries[0].push([curStatus.Timestamp, curStatus.TotalMemory]);
193                        memorySeries[1].push([curStatus.Timestamp, curStatus.UsedMemory]);
194                    }
195                    $scope.cpuSeries = [{ data: cpuSeries, label: "&nbsp;CPU Utilization", color: "#f7921d" }];
196                    $scope.coreSeries = [
197                        { data: coreSeries[0], label: "&nbsp;Total Cores", color: "LightGreen" },
198                        { data: coreSeries[1], label: "&nbsp;Used Cores", color: "LightPink" }
199                    ];
200                    $scope.memorySeries = [
201                        { data: memorySeries[0], label: "&nbsp;Total Memory", color: "LightGreen" },
202                        { data: memorySeries[1], label: "&nbsp;Used Memory", color: "LightPink" }
203                    ];
204
205                });
206            };
207
208            var update = function () {
209                getGroupDetails();
210                getClients();
211            };
212
213            $scope.updateInterval = $interval(update, $scope.interval);
214            var cancelInterval = $scope.$on('$locationChangeSuccess', function () {
215                $interval.cancel($scope.updateInterval);
216                cancelInterval();
217            });
218            update(); // init page
219            $scope.updateCharts();
220        }]
221    );
222})();
Note: See TracBrowser for help on using the repository browser.