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 | zoomRange: false,
|
---|
18 | panRange: false
|
---|
19 | },
|
---|
20 | xaxis: {
|
---|
21 | mode: "time",
|
---|
22 | twelveHourClock: false
|
---|
23 | },
|
---|
24 | zoom: {
|
---|
25 | interactive: true
|
---|
26 | },
|
---|
27 | pan: {
|
---|
28 | interactive: true
|
---|
29 | }
|
---|
30 | };
|
---|
31 |
|
---|
32 | $scope.fillChartOptions = {
|
---|
33 | grid: {
|
---|
34 | borderWidth: 1,
|
---|
35 | labelMargin: 15
|
---|
36 | },
|
---|
37 | series: {
|
---|
38 | shadowSize: 0,
|
---|
39 | lines: {
|
---|
40 | show: true,
|
---|
41 | fill: true
|
---|
42 | }
|
---|
43 | },
|
---|
44 | yaxis: {
|
---|
45 | zoomRange: false,
|
---|
46 | panRange: false
|
---|
47 | },
|
---|
48 | xaxis: {
|
---|
49 | mode: "time",
|
---|
50 | twelveHourClock: false
|
---|
51 | },
|
---|
52 | zoom: {
|
---|
53 | interactive: true
|
---|
54 | },
|
---|
55 | pan: {
|
---|
56 | interactive: true
|
---|
57 | }
|
---|
58 | };
|
---|
59 |
|
---|
60 |
|
---|
61 | $scope.fromDate = new Date();
|
---|
62 | $scope.toDate = new Date();
|
---|
63 |
|
---|
64 | $scope.fromIsOpen = false;
|
---|
65 | $scope.toIsOpen = false;
|
---|
66 |
|
---|
67 | $scope.openFromDateSelection = function ($event) {
|
---|
68 | $event.preventDefault();
|
---|
69 | $event.stopPropagation();
|
---|
70 | $scope.toIsOpen = false;
|
---|
71 | $scope.fromIsOpen = true;
|
---|
72 | };
|
---|
73 |
|
---|
74 | $scope.openToDateSelection = function ($event) {
|
---|
75 | $event.preventDefault();
|
---|
76 | $event.stopPropagation();
|
---|
77 | $scope.fromIsOpen = false;
|
---|
78 | $scope.toIsOpen = true;
|
---|
79 | };
|
---|
80 |
|
---|
81 | $scope.dateOptions = {
|
---|
82 | formatYear: 'yy',
|
---|
83 | startingDay: 1
|
---|
84 | };
|
---|
85 |
|
---|
86 | $scope.cpuSeries = [[]];
|
---|
87 | $scope.coreSeries = [[]];
|
---|
88 | $scope.memorySeries = [[]];
|
---|
89 |
|
---|
90 | var updateCharts = function () {
|
---|
91 | dataService.getStatusHistory({ start: ConvertFromDate($scope.fromDate), end: ConvertToDate($scope.toDate) }, function (status) {
|
---|
92 | var noOfStatus = status.length;
|
---|
93 | var cpuSeries = [];
|
---|
94 | var coreSeries = [[], []];
|
---|
95 | var memorySeries = [[], []];
|
---|
96 | for (var i = 0; i < noOfStatus; ++i) {
|
---|
97 | var curStatus = status[i];
|
---|
98 | var cpuData = Math.round(curStatus.CpuUtilizationStatus.ActiveCpuUtilization);
|
---|
99 | cpuSeries.push([curStatus.Timestamp, cpuData]);
|
---|
100 | coreSeries[0].push([curStatus.Timestamp, curStatus.CoreStatus.ActiveCores]);
|
---|
101 | coreSeries[1].push([curStatus.Timestamp, curStatus.CoreStatus.CalculatingCores]);
|
---|
102 | memorySeries[0].push([curStatus.Timestamp, curStatus.MemoryStatus.ActiveMemory]);
|
---|
103 | memorySeries[1].push([curStatus.Timestamp, curStatus.MemoryStatus.UsedMemory]);
|
---|
104 | }
|
---|
105 | $scope.cpuSeries = [{ data: cpuSeries, label: " CPU Utilization", color: "#f7921d" }];
|
---|
106 | $scope.coreSeries = [
|
---|
107 | { data: coreSeries[0], label: " Total Cores", color: "LightGreen" },
|
---|
108 | { data: coreSeries[1], label: " Used Cores", color: "LightPink" }
|
---|
109 | ];
|
---|
110 | $scope.memorySeries = [
|
---|
111 | { data: memorySeries[0], label: " Total Memory", color: "LightGreen" },
|
---|
112 | { data: memorySeries[1], label: " Used Memory", color: "LightPink" }
|
---|
113 | ];
|
---|
114 |
|
---|
115 | });
|
---|
116 | };
|
---|
117 |
|
---|
118 | $scope.$watch('fromDate', function (newValue, oldValue) {
|
---|
119 | updateCharts();
|
---|
120 | });
|
---|
121 | $scope.$watch('toDate', function (newValue, oldValue) {
|
---|
122 | updateCharts();
|
---|
123 | });
|
---|
124 | }]
|
---|
125 | );
|
---|
126 | })(); |
---|