1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
angular.module('zmApp.controllers').controller('zmApp.EventsGraphsCtrl', function ($ionicPlatform, $scope, ZMDataModel, $ionicSideMenuDelegate, $rootScope, $http) {
console.log("Inside Graphs controller");
$scope.openMenu = function () {
$ionicSideMenuDelegate.toggleLeft();
}
$scope.navTitle = 'Tab Page';
$scope.leftButtons = [{
type: 'button-icon icon ion-navicon',
tap: function (e) {
$scope.toggleMenu();
}
}];
$scope.anotherChart = function()
{
//alert ("Well I got called!");
$scope.chart2Object = {}; //test
$scope.chart2Object.data = [
['Monitor', 'Events', {
role: 'style'
}, {
role: 'annotation'
}],
['', 0, '', ''] // needed to get rid of the initial error of charts
];
$scope.chart2Object.type = "BarChart";
$scope.chart2Object.options = {
title: 'Events per monitor PER HOUR',
height: $rootScope.devHeight,
animation: {
duration: 700,
easing: 'out',
startup: 'false',
},
}
var monitors = [];
console.log("*** Grabbing lists of events and monitors ");
ZMDataModel.getMonitors(0).then(function (data) {
monitors = data;
var loginData = ZMDataModel.getLogin();
//var events = ZMDataModel.getAllPreexistingEvents();
// lets get the event count for all
for (var i = 0; i < monitors.length; i++) {
(function (j) {
//monevents[monitors[j].Monitor.Id].monName = monitors[j].Monitor.Name;
var url = loginData.apiurl +
"/events/index/MonitorId:" + monitors[j].Monitor.Id +
".json?page=1";
console.log("Monitor event URL:" + url);
$http.get(url)
.success(function (data) {
console.log("**** EVENT COUNT FOR MONITOR " +
monitors[j].Monitor.Id + " IS " + data.pagination.count);
console.log("Pushing " + monitors[j].Monitor.Name +
" AND " + data.pagination.count);
$scope.chart2Object.data.push
([monitors[j].Monitor.Name, data.pagination.count,
'opacity: 0.4', data.pagination.count]);
})
.error(function (data) {
console.log("**** EVENT COUNT FOR MONITOR " +
monitors[i].Monitor.Id + " IS ERROR ");
$scope.chart2Object.data.push([monitors[j].Monitor.Name,
0, 'opacity: 0.4', 0]);
});
})(i); // j
} //for
});
}; // scope function
$scope.chartObject = {}; //test
$scope.chartObject.data = [
['Monitor', 'Events', {
role: 'style'
}, {
role: 'annotation'
}],
['', 0, '', ''] // needed to get rid of the initial error of charts
];
$scope.chartObject.type = "BarChart";
$scope.chartObject.options = {
title: 'Events per monitor',
height: $rootScope.devHeight,
animation: {
duration: 700,
easing: 'out',
startup: 'false',
},
}
var monitors = [];
console.log("*** Grabbing lists of events and monitors ");
ZMDataModel.getMonitors(0).then(function (data) {
monitors = data;
var loginData = ZMDataModel.getLogin();
//var events = ZMDataModel.getAllPreexistingEvents();
// lets get the event count for all
for (var i = 0; i < monitors.length; i++) {
(function (j) {
//monevents[monitors[j].Monitor.Id].monName = monitors[j].Monitor.Name;
var url = loginData.apiurl +
"/events/index/MonitorId:" + monitors[j].Monitor.Id +
".json?page=1";
console.log("Monitor event URL:" + url);
$http.get(url)
.success(function (data) {
console.log("**** EVENT COUNT FOR MONITOR " +
monitors[j].Monitor.Id + " IS " + data.pagination.count);
console.log("Pushing " + monitors[j].Monitor.Name +
" AND " + data.pagination.count);
$scope.chartObject.data.push
([monitors[j].Monitor.Name, data.pagination.count,
'opacity: 0.4', data.pagination.count]);
})
.error(function (data) {
console.log("**** EVENT COUNT FOR MONITOR " +
monitors[i].Monitor.Id + " IS ERROR ");
$scope.chartObject.data.push([monitors[j].Monitor.Name,
0, 'opacity: 0.4', 0]);
});
})(i); // j
} //for
});
});
|