##// END OF EJS Templates
dashboard: avoid double ajax calls
ergo -
Show More
@@ -1,667 +1,666 b''
1 // # Copyright (C) 2010-2016 RhodeCode GmbH
1 // # Copyright (C) 2010-2016 RhodeCode GmbH
2 // #
2 // #
3 // # This program is free software: you can redistribute it and/or modify
3 // # This program is free software: you can redistribute it and/or modify
4 // # it under the terms of the GNU Affero General Public License, version 3
4 // # it under the terms of the GNU Affero General Public License, version 3
5 // # (only), as published by the Free Software Foundation.
5 // # (only), as published by the Free Software Foundation.
6 // #
6 // #
7 // # This program is distributed in the hope that it will be useful,
7 // # This program is distributed in the hope that it will be useful,
8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 // # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // # GNU General Public License for more details.
10 // # GNU General Public License for more details.
11 // #
11 // #
12 // # You should have received a copy of the GNU Affero General Public License
12 // # You should have received a copy of the GNU Affero General Public License
13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 // # along with this program. If not, see <http://www.gnu.org/licenses/>.
14 // #
14 // #
15 // # This program is dual-licensed. If you wish to learn more about the
15 // # This program is dual-licensed. If you wish to learn more about the
16 // # AppEnlight Enterprise Edition, including its added features, Support
16 // # AppEnlight Enterprise Edition, including its added features, Support
17 // # services, and proprietary license terms, please see
17 // # services, and proprietary license terms, please see
18 // # https://rhodecode.com/licenses/
18 // # https://rhodecode.com/licenses/
19
19
20 angular.module('appenlight.components.indexDashboardView', [])
20 angular.module('appenlight.components.indexDashboardView', [])
21 .component('indexDashboardView', {
21 .component('indexDashboardView', {
22 templateUrl: 'components/views/index-dashboard/index-dashboard.html',
22 templateUrl: 'components/views/index-dashboard/index-dashboard.html',
23 controller: IndexDashboardController
23 controller: IndexDashboardController
24 });
24 });
25
25
26 IndexDashboardController.$inject = ['$rootScope', '$scope', '$location','$cookies', '$interval', 'stateHolder', 'applicationsPropertyResource', 'AeConfig'];
26 IndexDashboardController.$inject = ['$rootScope', '$scope', '$location','$cookies', '$interval', 'stateHolder', 'applicationsPropertyResource', 'AeConfig'];
27
27
28 function IndexDashboardController($rootScope, $scope, $location, $cookies, $interval, stateHolder, applicationsPropertyResource, AeConfig) {
28 function IndexDashboardController($rootScope, $scope, $location, $cookies, $interval, stateHolder, applicationsPropertyResource, AeConfig) {
29 var vm = this;
29 var vm = this;
30 stateHolder.section = 'dashboard';
30 stateHolder.section = 'dashboard';
31 vm.timeOptions = {};
31 vm.timeOptions = {};
32 var allowed = ['1h', '4h', '12h', '24h', '1w', '2w', '1M'];
32 var allowed = ['1h', '4h', '12h', '24h', '1w', '2w', '1M'];
33 _.each(allowed, function (key) {
33 _.each(allowed, function (key) {
34 if (allowed.indexOf(key) !== -1) {
34 if (allowed.indexOf(key) !== -1) {
35 vm.timeOptions[key] = AeConfig.timeOptions[key];
35 vm.timeOptions[key] = AeConfig.timeOptions[key];
36 }
36 }
37 });
37 });
38 vm.stateHolder = stateHolder;
38 vm.stateHolder = stateHolder;
39 vm.urls = AeConfig.urls;
39 vm.urls = AeConfig.urls;
40 vm.applications = stateHolder.AeUser.applications_map;
40 vm.applications = stateHolder.AeUser.applications_map;
41 vm.show_dashboard = false;
41 vm.show_dashboard = false;
42 vm.resource = null;
42 vm.resource = null;
43 vm.graphType = {selected: null};
43 vm.graphType = {selected: null};
44 vm.timeSpan = vm.timeOptions['1h'];
44 vm.timeSpan = vm.timeOptions['1h'];
45 vm.trendingReports = [];
45 vm.trendingReports = [];
46 vm.exceptions = 0;
46 vm.exceptions = 0;
47 vm.satisfyingRequests = 0;
47 vm.satisfyingRequests = 0;
48 vm.toleratedRequests = 0;
48 vm.toleratedRequests = 0;
49 vm.frustratingRequests = 0;
49 vm.frustratingRequests = 0;
50 vm.uptimeStats = 0;
50 vm.uptimeStats = 0;
51 vm.apdexStats = [];
51 vm.apdexStats = [];
52 vm.seriesRequestsData = [];
52 vm.seriesRequestsData = [];
53 vm.seriesMetricsData = [];
53 vm.seriesMetricsData = [];
54 vm.seriesSlowData = [];
54 vm.seriesSlowData = [];
55 vm.slowCalls = [];
55 vm.slowCalls = [];
56 vm.slowURIS = [];
56 vm.slowURIS = [];
57
57
58 vm.reportChartConfig = {
58 vm.reportChartConfig = {
59 data: {
59 data: {
60 json: [],
60 json: [],
61 xFormat: '%Y-%m-%dT%H:%M:%S'
61 xFormat: '%Y-%m-%dT%H:%M:%S'
62 },
62 },
63 color: {
63 color: {
64 pattern: ['#6baed6', '#e6550d', '#74c476', '#fdd0a2', '#8c564b']
64 pattern: ['#6baed6', '#e6550d', '#74c476', '#fdd0a2', '#8c564b']
65 },
65 },
66 axis: {
66 axis: {
67 x: {
67 x: {
68 type: 'timeseries',
68 type: 'timeseries',
69 tick: {
69 tick: {
70 culling: {
70 culling: {
71 max: 6 // the number of tick texts will be adjusted to less than this value
71 max: 6 // the number of tick texts will be adjusted to less than this value
72 },
72 },
73 format: '%Y-%m-%d %H:%M'
73 format: '%Y-%m-%d %H:%M'
74 }
74 }
75 },
75 },
76 y: {
76 y: {
77 tick: {
77 tick: {
78 count: 5,
78 count: 5,
79 format: d3.format('.2s')
79 format: d3.format('.2s')
80 }
80 }
81 }
81 }
82 },
82 },
83 subchart: {
83 subchart: {
84 show: true,
84 show: true,
85 size: {
85 size: {
86 height: 20
86 height: 20
87 }
87 }
88 },
88 },
89 size: {
89 size: {
90 height: 250
90 height: 250
91 },
91 },
92 zoom: {
92 zoom: {
93 rescale: true
93 rescale: true
94 },
94 },
95 grid: {
95 grid: {
96 x: {
96 x: {
97 show: true
97 show: true
98 },
98 },
99 y: {
99 y: {
100 show: true
100 show: true
101 }
101 }
102 },
102 },
103 tooltip: {
103 tooltip: {
104 format: {
104 format: {
105 title: function (d) {
105 title: function (d) {
106 return '' + d;
106 return '' + d;
107 },
107 },
108 value: function (v) {
108 value: function (v) {
109 return v
109 return v
110 }
110 }
111 }
111 }
112 }
112 }
113 };
113 };
114 vm.reportChartData = {};
114 vm.reportChartData = {};
115
115
116 vm.reportSlowChartConfig = {
116 vm.reportSlowChartConfig = {
117 data: {
117 data: {
118 json: [],
118 json: [],
119 xFormat: '%Y-%m-%dT%H:%M:%S'
119 xFormat: '%Y-%m-%dT%H:%M:%S'
120 },
120 },
121 color: {
121 color: {
122 pattern: ['#6baed6', '#e6550d', '#74c476', '#fdd0a2', '#8c564b']
122 pattern: ['#6baed6', '#e6550d', '#74c476', '#fdd0a2', '#8c564b']
123 },
123 },
124 axis: {
124 axis: {
125 x: {
125 x: {
126 type: 'timeseries',
126 type: 'timeseries',
127 tick: {
127 tick: {
128 culling: {
128 culling: {
129 max: 6 // the number of tick texts will be adjusted to less than this value
129 max: 6 // the number of tick texts will be adjusted to less than this value
130 },
130 },
131 format: '%Y-%m-%d %H:%M'
131 format: '%Y-%m-%d %H:%M'
132 }
132 }
133 },
133 },
134 y: {
134 y: {
135 tick: {
135 tick: {
136 count: 5,
136 count: 5,
137 format: d3.format('.2s')
137 format: d3.format('.2s')
138 }
138 }
139 }
139 }
140 },
140 },
141 subchart: {
141 subchart: {
142 show: true,
142 show: true,
143 size: {
143 size: {
144 height: 20
144 height: 20
145 }
145 }
146 },
146 },
147 size: {
147 size: {
148 height: 250
148 height: 250
149 },
149 },
150 zoom: {
150 zoom: {
151 rescale: true
151 rescale: true
152 },
152 },
153 grid: {
153 grid: {
154 x: {
154 x: {
155 show: true
155 show: true
156 },
156 },
157 y: {
157 y: {
158 show: true
158 show: true
159 }
159 }
160 },
160 },
161 tooltip: {
161 tooltip: {
162 format: {
162 format: {
163 title: function (d) {
163 title: function (d) {
164 return '' + d;
164 return '' + d;
165 },
165 },
166 value: function (v) {
166 value: function (v) {
167 return v
167 return v
168 }
168 }
169 }
169 }
170 }
170 }
171 };
171 };
172 vm.reportSlowChartData = {};
172 vm.reportSlowChartData = {};
173
173
174 vm.metricsChartConfig = {
174 vm.metricsChartConfig = {
175 data: {
175 data: {
176 json: [],
176 json: [],
177 xFormat: '%Y-%m-%dT%H:%M:%S',
177 xFormat: '%Y-%m-%dT%H:%M:%S',
178 keys: {
178 keys: {
179 x: 'x',
179 x: 'x',
180 value: ["main", "sql", "nosql", "tmpl", "remote", "custom"]
180 value: ["main", "sql", "nosql", "tmpl", "remote", "custom"]
181 },
181 },
182 names: {
182 names: {
183 main: 'View/Application logic',
183 main: 'View/Application logic',
184 sql: 'Relational database queries',
184 sql: 'Relational database queries',
185 nosql: 'NoSql datastore calls',
185 nosql: 'NoSql datastore calls',
186 tmpl: 'Template rendering',
186 tmpl: 'Template rendering',
187 custom: 'Custom timed calls',
187 custom: 'Custom timed calls',
188 remote: 'Requests to remote resources'
188 remote: 'Requests to remote resources'
189 },
189 },
190 type: 'area',
190 type: 'area',
191 groups: [["main", "sql", "nosql", "remote", "custom", "tmpl"]],
191 groups: [["main", "sql", "nosql", "remote", "custom", "tmpl"]],
192 order: null
192 order: null
193 },
193 },
194 color: {
194 color: {
195 pattern: ['#6baed6', '#c7e9c0', '#fd8d3c', '#d6616b', '#ffcc00', '#c6dbef']
195 pattern: ['#6baed6', '#c7e9c0', '#fd8d3c', '#d6616b', '#ffcc00', '#c6dbef']
196 },
196 },
197 axis: {
197 axis: {
198 x: {
198 x: {
199 type: 'timeseries',
199 type: 'timeseries',
200 tick: {
200 tick: {
201 culling: {
201 culling: {
202 max: 6 // the number of tick texts will be adjusted to less than this value
202 max: 6 // the number of tick texts will be adjusted to less than this value
203 },
203 },
204 format: '%Y-%m-%d %H:%M'
204 format: '%Y-%m-%d %H:%M'
205 }
205 }
206 },
206 },
207 y: {
207 y: {
208 tick: {
208 tick: {
209 count: 5,
209 count: 5,
210 format: d3.format('.2f')
210 format: d3.format('.2f')
211 }
211 }
212 }
212 }
213 },
213 },
214 point: {
214 point: {
215 show: false
215 show: false
216 },
216 },
217 subchart: {
217 subchart: {
218 show: true,
218 show: true,
219 size: {
219 size: {
220 height: 20
220 height: 20
221 }
221 }
222 },
222 },
223 size: {
223 size: {
224 height: 350
224 height: 350
225 },
225 },
226 zoom: {
226 zoom: {
227 rescale: true
227 rescale: true
228 },
228 },
229 grid: {
229 grid: {
230 x: {
230 x: {
231 show: true
231 show: true
232 },
232 },
233 y: {
233 y: {
234 show: true
234 show: true
235 }
235 }
236 },
236 },
237 tooltip: {
237 tooltip: {
238 format: {
238 format: {
239 title: function (d) {
239 title: function (d) {
240 return '' + d;
240 return '' + d;
241 },
241 },
242 value: function (v) {
242 value: function (v) {
243 return v
243 return v
244 }
244 }
245 }
245 }
246 }
246 }
247 };
247 };
248 vm.metricsChartData = {};
248 vm.metricsChartData = {};
249
249
250 vm.responseChartConfig = {
250 vm.responseChartConfig = {
251 data: {
251 data: {
252 json: [],
252 json: [],
253 xFormat: '%Y-%m-%dT%H:%M:%S'
253 xFormat: '%Y-%m-%dT%H:%M:%S'
254 },
254 },
255 color: {
255 color: {
256 pattern: ['#d6616b', '#6baed6', '#fd8d3c']
256 pattern: ['#d6616b', '#6baed6', '#fd8d3c']
257 },
257 },
258 axis: {
258 axis: {
259 x: {
259 x: {
260 type: 'timeseries',
260 type: 'timeseries',
261 tick: {
261 tick: {
262 culling: {
262 culling: {
263 max: 6 // the number of tick texts will be adjusted to less than this value
263 max: 6 // the number of tick texts will be adjusted to less than this value
264 },
264 },
265 format: '%Y-%m-%d %H:%M'
265 format: '%Y-%m-%d %H:%M'
266 }
266 }
267 },
267 },
268 y: {
268 y: {
269 tick: {
269 tick: {
270 count: 5,
270 count: 5,
271 format: d3.format('.2f')
271 format: d3.format('.2f')
272 }
272 }
273 }
273 }
274 },
274 },
275 point: {
275 point: {
276 show: false
276 show: false
277 },
277 },
278 subchart: {
278 subchart: {
279 show: true,
279 show: true,
280 size: {
280 size: {
281 height: 20
281 height: 20
282 }
282 }
283 },
283 },
284 size: {
284 size: {
285 height: 350
285 height: 350
286 },
286 },
287 zoom: {
287 zoom: {
288 rescale: true
288 rescale: true
289 },
289 },
290 grid: {
290 grid: {
291 x: {
291 x: {
292 show: true
292 show: true
293 },
293 },
294 y: {
294 y: {
295 show: true
295 show: true
296 }
296 }
297 },
297 },
298 tooltip: {
298 tooltip: {
299 format: {
299 format: {
300 title: function (d) {
300 title: function (d) {
301 return '' + d;
301 return '' + d;
302 },
302 },
303 value: function (v) {
303 value: function (v) {
304 return v
304 return v
305 }
305 }
306 }
306 }
307 }
307 }
308 };
308 };
309 vm.responseChartData = {};
309 vm.responseChartData = {};
310
310
311 vm.requestsChartConfig = {
311 vm.requestsChartConfig = {
312 data: {
312 data: {
313 json: [],
313 json: [],
314 xFormat: '%Y-%m-%dT%H:%M:%S'
314 xFormat: '%Y-%m-%dT%H:%M:%S'
315 },
315 },
316 color: {
316 color: {
317 pattern: ['#d6616b', '#6baed6', '#fd8d3c']
317 pattern: ['#d6616b', '#6baed6', '#fd8d3c']
318 },
318 },
319 axis: {
319 axis: {
320 x: {
320 x: {
321 type: 'timeseries',
321 type: 'timeseries',
322 tick: {
322 tick: {
323 culling: {
323 culling: {
324 max: 6 // the number of tick texts will be adjusted to less than this value
324 max: 6 // the number of tick texts will be adjusted to less than this value
325 },
325 },
326 format: '%Y-%m-%d %H:%M'
326 format: '%Y-%m-%d %H:%M'
327 }
327 }
328 },
328 },
329 y: {
329 y: {
330 tick: {
330 tick: {
331 count: 5,
331 count: 5,
332 format: d3.format('.2f')
332 format: d3.format('.2f')
333 }
333 }
334 }
334 }
335 },
335 },
336 point: {
336 point: {
337 show: false
337 show: false
338 },
338 },
339 subchart: {
339 subchart: {
340 show: true,
340 show: true,
341 size: {
341 size: {
342 height: 20
342 height: 20
343 }
343 }
344 },
344 },
345 size: {
345 size: {
346 height: 350
346 height: 350
347 },
347 },
348 zoom: {
348 zoom: {
349 rescale: true
349 rescale: true
350 },
350 },
351 grid: {
351 grid: {
352 x: {
352 x: {
353 show: true
353 show: true
354 },
354 },
355 y: {
355 y: {
356 show: true
356 show: true
357 }
357 }
358 },
358 },
359 tooltip: {
359 tooltip: {
360 format: {
360 format: {
361 title: function (d) {
361 title: function (d) {
362 return '' + d;
362 return '' + d;
363 },
363 },
364 value: function (v) {
364 value: function (v) {
365 return v
365 return v
366 }
366 }
367 }
367 }
368 }
368 }
369 };
369 };
370 vm.requestsChartData = {};
370 vm.requestsChartData = {};
371
371
372 vm.loading = {
372 vm.loading = {
373 'apdex': true,
373 'apdex': true,
374 'reports': true,
374 'reports': true,
375 'graphs': true,
375 'graphs': true,
376 'slowCalls': true,
376 'slowCalls': true,
377 'slowURIS': true,
377 'slowURIS': true,
378 'requestsBreakdown': true,
378 'requestsBreakdown': true,
379 'series': true
379 'series': true
380 };
380 };
381 vm.stream = {paused: false, filtered: false, messages: [], reports: []};
381 vm.stream = {paused: false, filtered: false, messages: [], reports: []};
382
382
383 $rootScope.$on('channelstream-message.front_dashboard.new_topic', function(event, message){
383 $rootScope.$on('channelstream-message.front_dashboard.new_topic', function(event, message){
384 var ws_report = message.message.report;
384 var ws_report = message.message.report;
385 if (ws_report.http_status != 500) {
385 if (ws_report.http_status != 500) {
386 return
386 return
387 }
387 }
388 if (vm.stream.paused == true) {
388 if (vm.stream.paused == true) {
389 return
389 return
390 }
390 }
391 if (vm.stream.filtered && ws_report.resource_id != vm.resource) {
391 if (vm.stream.filtered && ws_report.resource_id != vm.resource) {
392 return
392 return
393 }
393 }
394 var should_insert = true;
394 var should_insert = true;
395 _.each(vm.stream.reports, function (report) {
395 _.each(vm.stream.reports, function (report) {
396 if (report.report_id == ws_report.report_id) {
396 if (report.report_id == ws_report.report_id) {
397 report.occurences = ws_report.occurences;
397 report.occurences = ws_report.occurences;
398 should_insert = false;
398 should_insert = false;
399 }
399 }
400 });
400 });
401 if (should_insert) {
401 if (should_insert) {
402 if (vm.stream.reports.length > 7) {
402 if (vm.stream.reports.length > 7) {
403 vm.stream.reports.pop();
403 vm.stream.reports.pop();
404 }
404 }
405 vm.stream.reports.unshift(ws_report);
405 vm.stream.reports.unshift(ws_report);
406 }
406 }
407 });
407 });
408
408
409 vm.determineStartState = function () {
409 vm.determineStartState = function () {
410 if (stateHolder.AeUser.applications.length) {
410 if (stateHolder.AeUser.applications.length) {
411 vm.resource = Number($location.search().resource);
411 vm.resource = Number($location.search().resource);
412
412
413 if (!vm.resource){
413 if (!vm.resource){
414 var cookieResource = $cookies.getObject('resource');
414 var cookieResource = $cookies.getObject('resource');
415 console.log('cookieResource', cookieResource);
415 console.log('cookieResource', cookieResource);
416
416
417 if (cookieResource) {
417 if (cookieResource) {
418 vm.resource = cookieResource;
418 vm.resource = cookieResource;
419 }
419 }
420 else{
420 else{
421 vm.resource = stateHolder.AeUser.applications[0].resource_id;
421 vm.resource = stateHolder.AeUser.applications[0].resource_id;
422 }
422 }
423 }
423 }
424 }
424 }
425
425
426 var timespan = $location.search().timespan;
426 var timespan = $location.search().timespan;
427
427
428 if(_.has(vm.timeOptions, timespan)){
428 if(_.has(vm.timeOptions, timespan)){
429 vm.timeSpan = vm.timeOptions[timespan];
429 vm.timeSpan = vm.timeOptions[timespan];
430 }
430 }
431 else{
431 else{
432 vm.timeSpan = vm.timeOptions['1h'];
432 vm.timeSpan = vm.timeOptions['1h'];
433 }
433 }
434
434
435 var graphType = $location.search().graphtype;
435 var graphType = $location.search().graphtype;
436 if(!graphType){
436 if(!graphType){
437 vm.graphType = {selected: 'metrics_graphs'};
437 vm.graphType = {selected: 'metrics_graphs'};
438 }
438 }
439 else{
439 else{
440 vm.graphType = {selected: graphType};
440 vm.graphType = {selected: graphType};
441 }
441 }
442 vm.updateSearchParams();
442 vm.updateSearchParams();
443 };
443 };
444
444
445 vm.updateSearchParams = function () {
445 vm.updateSearchParams = function () {
446 $location.search('resource', vm.resource);
446 $location.search('resource', vm.resource);
447 $location.search('timespan', vm.timeSpan.key);
447 $location.search('timespan', vm.timeSpan.key);
448 $location.search('graphtype', vm.graphType.selected);
448 $location.search('graphtype', vm.graphType.selected);
449 stateHolder.resource = vm.resource;
449 stateHolder.resource = vm.resource;
450
450
451 if (vm.resource){
451 if (vm.resource){
452 $cookies.putObject('resource', vm.resource,
452 $cookies.putObject('resource', vm.resource,
453 {expires:new Date(3000, 1, 1)});
453 {expires:new Date(3000, 1, 1)});
454 }
454 }
455 vm.refreshData();
455 vm.refreshData();
456 };
456 };
457
457
458 vm.refreshData = function () {
458 vm.refreshData = function () {
459 vm.fetchApdexStats();
459 vm.fetchApdexStats();
460 vm.fetchTrendingReports();
460 vm.fetchTrendingReports();
461 vm.fetchMetrics();
461 vm.fetchMetrics();
462 vm.fetchRequestsBreakdown();
462 vm.fetchRequestsBreakdown();
463 vm.fetchSlowCalls();
463 vm.fetchSlowCalls();
464 };
464 };
465
465
466 vm.changedTimeSpan = function(){
466 vm.changedTimeSpan = function(){
467 vm.startDateFilter = timeSpanToStartDate(vm.timeSpan.key);
467 vm.startDateFilter = timeSpanToStartDate(vm.timeSpan.key);
468 vm.refreshData();
468 vm.refreshData();
469 };
469 };
470
470
471 vm.intervalId = $interval(function () {
471 vm.intervalId = $interval(function () {
472 if (_.contains(['30m', "1h"], vm.timeSpan.key)) {
472 if (_.contains(['30m', "1h"], vm.timeSpan.key)) {
473 // don't do anything if window is unfocused
473 // don't do anything if window is unfocused
474 if(document.hidden === true){
474 if(document.hidden === true){
475 return ;
475 return ;
476 }
476 }
477 vm.refreshData();
477 vm.refreshData();
478 }
478 }
479 }, 60000);
479 }, 60000);
480
480
481 vm.fetchApdexStats = function () {
481 vm.fetchApdexStats = function () {
482 vm.loading.apdex = true;
482 vm.loading.apdex = true;
483 vm.apdexStats = applicationsPropertyResource.query({
483 vm.apdexStats = applicationsPropertyResource.query({
484 'key': 'apdex_stats',
484 'key': 'apdex_stats',
485 'resourceId': vm.resource,
485 'resourceId': vm.resource,
486 "start_date": timeSpanToStartDate(vm.timeSpan.key)
486 "start_date": timeSpanToStartDate(vm.timeSpan.key)
487 },
487 },
488 function (data) {
488 function (data) {
489 vm.loading.apdex = false;
489 vm.loading.apdex = false;
490
490
491 vm.exceptions = _.reduce(data, function (memo, row) {
491 vm.exceptions = _.reduce(data, function (memo, row) {
492 return memo + row.errors;
492 return memo + row.errors;
493 }, 0);
493 }, 0);
494 vm.satisfyingRequests = _.reduce(data, function (memo, row) {
494 vm.satisfyingRequests = _.reduce(data, function (memo, row) {
495 return memo + row.satisfying_requests;
495 return memo + row.satisfying_requests;
496 }, 0);
496 }, 0);
497 vm.toleratedRequests = _.reduce(data, function (memo, row) {
497 vm.toleratedRequests = _.reduce(data, function (memo, row) {
498 return memo + row.tolerated_requests;
498 return memo + row.tolerated_requests;
499 }, 0);
499 }, 0);
500 vm.frustratingRequests = _.reduce(data, function (memo, row) {
500 vm.frustratingRequests = _.reduce(data, function (memo, row) {
501 return memo + row.frustrating_requests;
501 return memo + row.frustrating_requests;
502 }, 0);
502 }, 0);
503 if (data.length) {
503 if (data.length) {
504 vm.uptimeStats = data[0].uptime;
504 vm.uptimeStats = data[0].uptime;
505 }
505 }
506
506
507 },
507 },
508 function () {
508 function () {
509 vm.loading.apdex = false;
509 vm.loading.apdex = false;
510 }
510 }
511 );
511 );
512 }
512 }
513
513
514 vm.fetchMetrics = function () {
514 vm.fetchMetrics = function () {
515 vm.loading.series = true;
515 vm.loading.series = true;
516 applicationsPropertyResource.query({
516 applicationsPropertyResource.query({
517 'resourceId': vm.resource,
517 'resourceId': vm.resource,
518 'key': vm.graphType.selected,
518 'key': vm.graphType.selected,
519 "start_date": timeSpanToStartDate(vm.timeSpan.key)
519 "start_date": timeSpanToStartDate(vm.timeSpan.key)
520 }, function (data) {
520 }, function (data) {
521 if (vm.graphType.selected == 'metrics_graphs') {
521 if (vm.graphType.selected == 'metrics_graphs') {
522 vm.metricsChartData = {
522 vm.metricsChartData = {
523 json: data,
523 json: data,
524 xFormat: '%Y-%m-%dT%H:%M:%S',
524 xFormat: '%Y-%m-%dT%H:%M:%S',
525 keys: {
525 keys: {
526 x: 'x',
526 x: 'x',
527 value: ["main", "sql", "nosql", "tmpl", "remote", "custom"]
527 value: ["main", "sql", "nosql", "tmpl", "remote", "custom"]
528 },
528 },
529 names: {
529 names: {
530 main: 'View/Application logic',
530 main: 'View/Application logic',
531 sql: 'Relational database queries',
531 sql: 'Relational database queries',
532 nosql: 'NoSql datastore calls',
532 nosql: 'NoSql datastore calls',
533 tmpl: 'Template rendering',
533 tmpl: 'Template rendering',
534 custom: 'Custom timed calls',
534 custom: 'Custom timed calls',
535 remote: 'Requests to remote resources'
535 remote: 'Requests to remote resources'
536 },
536 },
537 type: 'area',
537 type: 'area',
538 groups: [["main", "sql", "nosql", "remote", "custom", "tmpl"]],
538 groups: [["main", "sql", "nosql", "remote", "custom", "tmpl"]],
539 order: null
539 order: null
540 };
540 };
541 }
541 }
542 else if (vm.graphType.selected == 'report_graphs') {
542 else if (vm.graphType.selected == 'report_graphs') {
543 vm.reportChartData = {
543 vm.reportChartData = {
544 json: data,
544 json: data,
545 xFormat: '%Y-%m-%dT%H:%M:%S',
545 xFormat: '%Y-%m-%dT%H:%M:%S',
546 keys: {
546 keys: {
547 x: 'x',
547 x: 'x',
548 value: ["not_found", "report"]
548 value: ["not_found", "report"]
549 },
549 },
550 names: {
550 names: {
551 report: 'Errors',
551 report: 'Errors',
552 not_found: '404\'s requests'
552 not_found: '404\'s requests'
553 },
553 },
554 type: 'bar'
554 type: 'bar'
555 };
555 };
556 }
556 }
557 else if (vm.graphType.selected == 'slow_report_graphs') {
557 else if (vm.graphType.selected == 'slow_report_graphs') {
558 vm.reportSlowChartData = {
558 vm.reportSlowChartData = {
559 json: data,
559 json: data,
560 xFormat: '%Y-%m-%dT%H:%M:%S',
560 xFormat: '%Y-%m-%dT%H:%M:%S',
561 keys: {
561 keys: {
562 x: 'x',
562 x: 'x',
563 value: ["slow_report"]
563 value: ["slow_report"]
564 },
564 },
565 names: {
565 names: {
566 slow_report: 'Slow reports'
566 slow_report: 'Slow reports'
567 },
567 },
568 type: 'bar'
568 type: 'bar'
569 };
569 };
570 }
570 }
571 else if (vm.graphType.selected == 'response_graphs') {
571 else if (vm.graphType.selected == 'response_graphs') {
572 vm.responseChartData = {
572 vm.responseChartData = {
573 json: data,
573 json: data,
574 xFormat: '%Y-%m-%dT%H:%M:%S',
574 xFormat: '%Y-%m-%dT%H:%M:%S',
575 keys: {
575 keys: {
576 x: 'x',
576 x: 'x',
577 value: ["today", "days_ago_2", "days_ago_7"]
577 value: ["today", "days_ago_2", "days_ago_7"]
578 },
578 },
579 names: {
579 names: {
580 today: 'Today',
580 today: 'Today',
581 "days_ago_2": '2 days ago',
581 "days_ago_2": '2 days ago',
582 "days_ago_7": '7 days ago'
582 "days_ago_7": '7 days ago'
583 }
583 }
584 };
584 };
585 }
585 }
586 else if (vm.graphType.selected == 'requests_graphs') {
586 else if (vm.graphType.selected == 'requests_graphs') {
587 vm.requestsChartData = {
587 vm.requestsChartData = {
588 json: data,
588 json: data,
589 xFormat: '%Y-%m-%dT%H:%M:%S',
589 xFormat: '%Y-%m-%dT%H:%M:%S',
590 keys: {
590 keys: {
591 x: 'x',
591 x: 'x',
592 value: ["requests"]
592 value: ["requests"]
593 },
593 },
594 names: {
594 names: {
595 requests: 'Requests/s'
595 requests: 'Requests/s'
596 }
596 }
597 };
597 };
598 }
598 }
599 vm.loading.series = false;
599 vm.loading.series = false;
600 }, function(){
600 }, function(){
601 vm.loading.series = false;
601 vm.loading.series = false;
602 });
602 });
603 }
603 }
604
604
605 vm.fetchSlowCalls = function () {
605 vm.fetchSlowCalls = function () {
606 vm.loading.slowCalls = true;
606 vm.loading.slowCalls = true;
607 applicationsPropertyResource.query({
607 applicationsPropertyResource.query({
608 'resourceId': vm.resource,
608 'resourceId': vm.resource,
609 "start_date": timeSpanToStartDate(vm.timeSpan.key),
609 "start_date": timeSpanToStartDate(vm.timeSpan.key),
610 'key': 'slow_calls'
610 'key': 'slow_calls'
611 }, function (data) {
611 }, function (data) {
612 vm.slowCalls = data;
612 vm.slowCalls = data;
613 vm.loading.slowCalls = false;
613 vm.loading.slowCalls = false;
614 }, function () {
614 }, function () {
615 vm.loading.slowCalls = false;
615 vm.loading.slowCalls = false;
616 });
616 });
617 }
617 }
618
618
619 vm.fetchRequestsBreakdown = function () {
619 vm.fetchRequestsBreakdown = function () {
620 vm.loading.requestsBreakdown = true;
620 vm.loading.requestsBreakdown = true;
621 applicationsPropertyResource.query({
621 applicationsPropertyResource.query({
622 'resourceId': vm.resource,
622 'resourceId': vm.resource,
623 "start_date": timeSpanToStartDate(vm.timeSpan.key),
623 "start_date": timeSpanToStartDate(vm.timeSpan.key),
624 'key': 'requests_breakdown'
624 'key': 'requests_breakdown'
625 }, function (data) {
625 }, function (data) {
626 vm.requestsBreakdown = data;
626 vm.requestsBreakdown = data;
627 vm.loading.requestsBreakdown = false;
627 vm.loading.requestsBreakdown = false;
628 }, function () {
628 }, function () {
629 vm.loading.requestsBreakdown = false;
629 vm.loading.requestsBreakdown = false;
630 });
630 });
631 }
631 }
632
632
633 vm.fetchTrendingReports = function () {
633 vm.fetchTrendingReports = function () {
634
634
635 if (vm.graphType.selected == 'slow_report_graphs') {
635 if (vm.graphType.selected == 'slow_report_graphs') {
636 var report_type = 'slow';
636 var report_type = 'slow';
637 }
637 }
638 else {
638 else {
639 var report_type = 'error';
639 var report_type = 'error';
640 }
640 }
641
641
642 vm.loading.reports = true;
642 vm.loading.reports = true;
643 vm.trendingReports = applicationsPropertyResource.query({
643 vm.trendingReports = applicationsPropertyResource.query({
644 'key': 'trending_reports',
644 'key': 'trending_reports',
645 'resourceId': vm.resource,
645 'resourceId': vm.resource,
646 "start_date": timeSpanToStartDate(vm.timeSpan.key),
646 "start_date": timeSpanToStartDate(vm.timeSpan.key),
647 "report_type": report_type
647 "report_type": report_type
648 },
648 },
649 function () {
649 function () {
650 vm.loading.reports = false;
650 vm.loading.reports = false;
651 },
651 },
652 function () {
652 function () {
653 vm.loading.reports = false;
653 vm.loading.reports = false;
654 }
654 }
655 );
655 );
656 };
656 };
657
657
658 $scope.$on('$destroy',function(){
658 $scope.$on('$destroy',function(){
659 $interval.cancel(vm.intervalId);
659 $interval.cancel(vm.intervalId);
660 });
660 });
661
661
662 if (stateHolder.AeUser.applications.length){
662 if (stateHolder.AeUser.applications.length){
663 vm.show_dashboard = true;
663 vm.show_dashboard = true;
664 vm.determineStartState();
664 vm.determineStartState();
665 vm.refreshData();
666 }
665 }
667 }
666 }
General Comments 0
You need to be logged in to leave comments. Login now