1 | (function () {
|
---|
2 | var module = appStatusPlugin.getAngularModule();
|
---|
3 | module.controller('app.status.historyCtrl',
|
---|
4 | ['$scope', '$interval', 'app.status.data.service',
|
---|
5 | function ($scope, $interval, dataService) {
|
---|
6 | $scope.chartOptions = {
|
---|
7 | grid: {
|
---|
8 | borderWidth: 1,
|
---|
9 | labelMargin: 15
|
---|
10 | },
|
---|
11 | series: {
|
---|
12 | shadowSize: 0
|
---|
13 | },
|
---|
14 | yaxis: {
|
---|
15 | min: 0,
|
---|
16 | max: 100
|
---|
17 | },
|
---|
18 | xaxis: {
|
---|
19 | mode: "time",
|
---|
20 | twelveHourClock: false
|
---|
21 | }
|
---|
22 | };
|
---|
23 |
|
---|
24 | $scope.fillChartOptions = {
|
---|
25 | grid: {
|
---|
26 | borderWidth: 1,
|
---|
27 | labelMargin: 15
|
---|
28 | },
|
---|
29 | series: {
|
---|
30 | shadowSize: 0,
|
---|
31 | lines: {
|
---|
32 | show: true,
|
---|
33 | fill: true
|
---|
34 | }
|
---|
35 | },
|
---|
36 | xaxis: {
|
---|
37 | mode: "time",
|
---|
38 | twelveHourClock: false
|
---|
39 | }
|
---|
40 | };
|
---|
41 |
|
---|
42 | $scope.fromDate = new Date();
|
---|
43 | $scope.toDate = new Date();
|
---|
44 |
|
---|
45 | $scope.fromIsOpen = false;
|
---|
46 | $scope.toIsOpen = false;
|
---|
47 |
|
---|
48 | $scope.openFromDateSelection = function ($event) {
|
---|
49 | $event.preventDefault();
|
---|
50 | $event.stopPropagation();
|
---|
51 | $scope.toIsOpen = false;
|
---|
52 | $scope.fromIsOpen = true;
|
---|
53 | };
|
---|
54 |
|
---|
55 | $scope.openToDateSelection = function ($event) {
|
---|
56 | $event.preventDefault();
|
---|
57 | $event.stopPropagation();
|
---|
58 | $scope.fromIsOpen = false;
|
---|
59 | $scope.toIsOpen = true;
|
---|
60 | };
|
---|
61 |
|
---|
62 | $scope.dateOptions = {
|
---|
63 | formatYear: 'yy',
|
---|
64 | startingDay: 1
|
---|
65 | };
|
---|
66 |
|
---|
67 | $scope.cpuSeries = [[]];
|
---|
68 | $scope.coreSeries = [[]];
|
---|
69 | $scope.memorySeries = [[]];
|
---|
70 |
|
---|
71 | $scope.updateCharts = function () {
|
---|
72 | dataService.getStatusHistory({ start: ConvertFromDate($scope.fromDate), end: ConvertToDate($scope.toDate) }, function (status) {
|
---|
73 | var noOfStatus = status.length;
|
---|
74 | var cpuSeries = [];
|
---|
75 | var coreSeries = [[], []];
|
---|
76 | var memorySeries = [[], []];
|
---|
77 | for (var i = 0; i < noOfStatus; ++i) {
|
---|
78 | var curStatus = status[i];
|
---|
79 | var cpuData = Math.round(curStatus.CpuUtilizationStatus.ActiveCpuUtilization);
|
---|
80 | cpuSeries.push([curStatus.Timestamp, cpuData]);
|
---|
81 | coreSeries[0].push([curStatus.Timestamp, curStatus.CoreStatus.ActiveCores]);
|
---|
82 | coreSeries[1].push([curStatus.Timestamp, curStatus.CoreStatus.CalculatingCores]);
|
---|
83 | memorySeries[0].push([curStatus.Timestamp, curStatus.MemoryStatus.ActiveMemory]);
|
---|
84 | memorySeries[1].push([curStatus.Timestamp, curStatus.MemoryStatus.UsedMemory]);
|
---|
85 | }
|
---|
86 | $scope.cpuSeries = [{ data: cpuSeries, label: " CPU Utilization", color: "#f7921d" }];
|
---|
87 | $scope.coreSeries = [
|
---|
88 | { data: coreSeries[0], label: " Total Cores", color: "LightGreen" },
|
---|
89 | { data: coreSeries[1], label: " Used Cores", color: "LightPink" }
|
---|
90 | ];
|
---|
91 | $scope.memorySeries = [
|
---|
92 | { data: memorySeries[0], label: " Total Memory", color: "LightGreen" },
|
---|
93 | { data: memorySeries[1], label: " Used Memory", color: "LightPink" }
|
---|
94 | ];
|
---|
95 |
|
---|
96 | });
|
---|
97 | };
|
---|
98 | $scope.updateCharts();
|
---|
99 | }]
|
---|
100 | );
|
---|
101 | })(); |
---|