Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApp/clients/details/clientDetailsCtrl.js @ 12584

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

#2388: Changed all files to connect to localhost / sqlexpress

HeuristicLab.Services.Hive-3.3:

  • Added Converter.cs and NewHiveService.cs, both will be integrated into existing HiveService.cs and Convert.cs when all methods are successfully implemented

HeuristicLab.Services.Hive.Web.Hive-3.3:

  • Added publish profiles

HeuristicLab.Services.WebApp.Statistics-3.3:

  • Added functionality to download TaskData as .hl file
File size: 9.1 KB
Line 
1(function () {
2    var module = appStatisticsPlugin.getAngularModule();
3    module.controller('app.statistics.clientDetailsCtrl',
4        ['$scope', '$stateParams', '$interval', 'app.statistics.clientService', 'app.statistics.taskService', '$modal',
5        function ($scope, $stateParams, $interval, clientService, taskService, $modal) {
6            $scope.curUserId = '00000000-0000-0000-0000-000000000000';
7            $scope.curUserName = 'All Users';
8            $scope.interval = defaultPageUpdateInterval;
9            $scope.curTaskPage = 1;
10            $scope.taskPageSize = 12;
11
12            // details
13            $scope.knobOptions = {
14                'fgColor': "#f7921d",
15                'angleOffset': -125,
16                'angleArc': 250,
17                'readOnly': true,
18                'width': "80%",
19                'targetvalue': "100",
20                'format': function (value) {
21                    return value;
22                },
23                draw: function () {
24                    $(this.i).val(this.cv + '%');
25                }
26            };
27
28            $scope.knobData = {
29                cores: 0,
30                cpu: 0,
31                memory: 0
32            };
33
34            var getClientDetails = function () {
35                clientService.getClientDetails({ id: $stateParams.id }, function (client) {
36                    $scope.client = client;
37                    $scope.knobData.cores = (client.UsedCores / client.TotalCores) * 100;
38                    $scope.knobData.cpu = client.CpuUtilization;
39                    $scope.knobData.memory = (client.UsedMemory / client.TotalMemory) * 100;
40
41                    var length = client.TasksStates.length;
42                    var total = 0;
43                    var jsStates = [];
44                    for (var i = 0; i < length; ++i) {
45                        var state = client.TasksStates[i];
46                        var selected = true;
47                        if (isDefined($scope.states)) {
48                            for (var j = 0; j < $scope.states.length; ++j) {
49                                if (state.State == $scope.states[j].State) {
50                                    selected = $scope.states[j].Selected;
51                                    break;
52                                }
53                            }
54                        }
55                        jsStates.push({
56                            State: state.State,
57                            Count: state.Count,
58                            Selected: selected
59                        });
60                        total += state.Count;
61                    }
62                    $scope.totalClientTasks = total;
63                    $scope.states = jsStates;
64                    getTasks();
65                });
66            };
67
68            // tasks
69            var getTasks = function () {
70                var states = [];
71                var length = $scope.states.length;
72                for (var i = 0; i < length; ++i) {
73                    var state = $scope.states[i];
74                    if (state.Selected) {
75                        states.push(state.State);
76                    }
77                }
78
79                taskService.getTasksByClientId({ id: $stateParams.id, page: $scope.curTaskPage, size: $scope.taskPageSize, userId: $scope.curUserId }, states,
80                    function (taskPage) {
81                        $scope.taskPage = taskPage;
82                    }
83                );
84            };
85
86            $scope.changeTaskPage = function () {
87                getClientDetails();
88                $('html, body').animate({
89                    scrollTop: $("#tasks-filter").offset().top
90                }, 10);
91            };
92
93            $scope.filterTaskState = function (state) {
94                state.Selected = !state.Selected;
95                $scope.curTaskPage = 1;
96                getClientDetails();
97            };
98
99            $scope.userChanged = function(id, name) {
100                $scope.curUserId = id;
101                $scope.curUserName = name;
102                $scope.curTaskPage = 1;
103                getClientDetails();
104            };
105
106            $scope.openDialog = function (taskNo, task) {
107                $scope.currentTaskNo = taskNo;
108                $scope.currentTask = task;
109                $modal.open({
110                    templateUrl: 'plugin=statistics&view=WebApp/clients/details/clientTaskDetailsDialog.cshtml',
111                    controller: 'app.statistics.clientTaskDetailsDialogCtrl',
112                    windowClass: 'app-modal-window',
113                    resolve: {
114                        task: function () {
115                            return $scope.currentTask;
116                        },
117                        taskNo: function () {
118                            return $scope.currentTaskNo;
119                        }
120                    }
121                });
122            };
123
124            // charts
125            $scope.chartOptions = {
126                grid: {
127                    borderWidth: 1,
128                    labelMargin: 15
129                },
130                series: {
131                    shadowSize: 0
132                },
133                yaxis: {
134                    min: 0,
135                    max: 100,
136                    zoomRange: false,
137                    panRange: false
138                },
139                xaxis: {
140                    mode: "time",
141                    twelveHourClock: false
142                }
143            };
144
145            $scope.fillChartOptions = {
146                grid: {
147                    borderWidth: 1,
148                    labelMargin: 15
149                },
150                series: {
151                    shadowSize: 0,
152                    lines: {
153                        show: true,
154                        fill: true
155                    }
156                },
157                yaxis: {
158                    zoomRange: false,
159                    panRange: false
160                },
161                xaxis: {
162                    mode: "time",
163                    twelveHourClock: false
164                }
165            };
166
167            $scope.fromDate = new Date();
168            $scope.toDate = new Date();
169
170            $scope.fromIsOpen = false;
171            $scope.toIsOpen = false;
172
173            $scope.openFromDateSelection = function ($event) {
174                $event.preventDefault();
175                $event.stopPropagation();
176                $scope.toIsOpen = false;
177                $scope.fromIsOpen = true;
178            };
179
180            $scope.openToDateSelection = function ($event) {
181                $event.preventDefault();
182                $event.stopPropagation();
183                $scope.fromIsOpen = false;
184                $scope.toIsOpen = true;
185            };
186
187            $scope.dateOptions = {
188                formatYear: 'yy',
189                startingDay: 1
190            };
191
192            $scope.cpuSeries = [[]];
193            $scope.coreSeries = [[]];
194            $scope.memorySeries = [[]];
195
196            $scope.updateCharts = function () {
197                clientService.getClientHistory({ id: $stateParams.id, start: ConvertFromDate($scope.fromDate), end: ConvertToDate($scope.toDate) }, function (status) {
198                    var noOfStatus = status.length;
199                    var cpuSeries = [];
200                    var coreSeries = [[], []];
201                    var memorySeries = [[], []];
202                    for (var i = 0; i < noOfStatus; ++i) {
203                        var curStatus = status[i];
204                        var cpuData = Math.round(curStatus.CpuUtilization);
205                        cpuSeries.push([curStatus.Timestamp, cpuData]);
206                        coreSeries[0].push([curStatus.Timestamp, curStatus.TotalCores]);
207                        coreSeries[1].push([curStatus.Timestamp, curStatus.UsedCores]);
208                        memorySeries[0].push([curStatus.Timestamp, curStatus.TotalMemory]);
209                        memorySeries[1].push([curStatus.Timestamp, curStatus.UsedMemory]);
210                    }
211                    $scope.cpuSeries = [{ data: cpuSeries, label: "&nbsp;CPU Utilization", color: "#f7921d" }];
212                    $scope.coreSeries = [
213                        { data: coreSeries[0], label: "&nbsp;Total Cores", color: "LightGreen" },
214                        { data: coreSeries[1], label: "&nbsp;Used Cores", color: "LightPink" }
215                    ];
216                    $scope.memorySeries = [
217                        { data: memorySeries[0], label: "&nbsp;Total Memory", color: "LightGreen" },
218                        { data: memorySeries[1], label: "&nbsp;Used Memory", color: "LightPink" }
219                    ];
220
221                });
222            };
223
224            var update = function () {
225                getClientDetails();
226            };
227
228            $scope.updateInterval = $interval(update, $scope.interval);
229            var cancelInterval = $scope.$on('$locationChangeSuccess', function () {
230                $interval.cancel($scope.updateInterval);
231                cancelInterval();
232            });
233            update(); // init page
234            $scope.updateCharts();
235        }]
236    );
237})();
Note: See TracBrowser for help on using the repository browser.