bb3ac9c26a7b3c6d3c6162f4c09e0d2c1a41516c
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / mwtnPerformanceLink / mwtnPerformanceLink-module / src / main / resources / mwtnPerformanceLink / mwtnPerformanceLink.controller.js
1 /*
2  * Copyright (c) 2016 highstreet technologies GmbH and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 define(['app/mwtnPerformanceLink/mwtnPerformanceLink.module',
10   'app/mwtnPerformanceLink/mwtnPerformanceLink.services'],
11   function (mwtnPerformanceLinkApp) {
12
13     mwtnPerformanceLinkApp.register.controller('mwtnPerformanceLinkCtrl', ['$scope', '$rootScope', '$window', '$translate', '$mwtnLog', '$mwtnPerformanceLink', 'uiGridConstants',
14       function ($scope, $rootScope, $window, $translate, $mwtnLog, $mwtnPerformanceLink, uiGridConstants) {
15
16         var COMPONENT = 'mwtnPerformanceLink';
17         $mwtnLog.info({ component: COMPONENT, message: 'mwtn Link Performance started!' });
18
19         $rootScope.section_logo = 'src/app/mwtnPerformanceLink/images/mwtnPerformance.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'
20     
21         var globalFilter;
22
23         //time selector
24         $scope.timePeriod = "15 minutes";
25         $scope.timePeriods = ["15 minutes", "24 hours"];
26
27         //interface selector
28         $scope.selectedLtpIdA = 'Select LTP';
29         $scope.selectedLtpIdB = 'Select LTP';
30         $scope.availableLtpIdsA = ['Select LTP'];
31         $scope.availableLtpIdsB = ['Select LTP'];
32
33         var formatTimeStamp = function(timeStamp) {
34           var result = $mwtnPerformanceLink.formatTimeStamp(timeStamp);
35           // 2017-06-22 14:52:21.0 UTC -> 2017-06-22 14:52 UTC
36           var array = result.split(' ');
37           if (array && array.length === 3) {
38             result = [array[0], array[1].slice(0,-5), array[2]].join(' ');
39           }
40           return result;
41         };
42
43         var initNodeList = function (nodes) {
44           $scope.networkElements = [];
45           nodes.map(function (ne) {
46             // revision detection should go to commons
47             if (ne['netconf-node-topology:connection-status'] === 'connected' && ne['netconf-node-topology:available-capabilities'] && ne['netconf-node-topology:available-capabilities']['available-capability']) {
48               ne['netconf-node-topology:available-capabilities']['available-capability'].map(function (cap) {
49                 if (cap.contains('CoreModel-CoreNetworkModule-ObjectClasses')) {
50                   ne.onfCoreModelRevision = cap.split('?revision=')[1].substring(0, 10);
51                 } else if (cap.contains('MicrowaveModel-ObjectClasses-AirInterface')) {
52                   ne.onfAirInterfaceRevision = cap.split('?revision=')[1].substring(0, 10);
53                 } else if (!ne.onfAirInterfaceRevision && cap.contains('MicrowaveModel-ObjectClasses')) {
54                   ne.onfAirInterfaceRevision = cap.split('?revision=')[1].substring(0, 10);
55                 }
56               });
57               if (ne.onfAirInterfaceRevision) {
58                 $scope.networkElements.push({ id: ne['node-id'], revision: ne.onfAirInterfaceRevision });
59               }
60             }
61           });
62           $scope.networkElements.sort(function (a, b) {
63             if (a.id < b.id) return -1;
64             if (a.id > b.id) return 1;
65             return 0;
66           });
67
68           // select one of the nodes
69           // var select = parseInt(Math.random() * $scope.networkElements.length);
70           // $scope.networkElementA = $scope.networkElements[select].id;
71           // $scope.networkElementB = $scope.networkElements[select].id;
72         };
73
74         var initLinkIds = function () {
75           var functionId = 'sdnperformance';
76           var docType = 'historicalperformance15min';
77           if ($scope.timePeriod !== $scope.timePeriods[0]) {
78             docType = 'historicalperformance24h';
79           }
80           var aggregations = {
81             "size":0,
82             "aggregations": {
83               "radio-signal-id": {
84                 "terms": {
85                   "field": "radio-signal-id"
86                 }
87               }
88             }
89           };
90           $mwtnPerformanceLink.getAggregations(functionId, docType, aggregations).then(function (success) {
91             $scope.linkIds = success.data.aggregations['radio-signal-id'].buckets.map(function(bucket){
92               return bucket.key;
93             });
94           }, function (error) {
95             console.log(error);
96             $scope.linkIds = [];
97           });
98         };
99
100         $mwtnPerformanceLink.getMountPoints().then(function (mountpoints) {
101           initNodeList(mountpoints);
102           initLinkIds();
103         }, function (error) {
104           $scope.networkElements = [];
105         });
106
107         //table stuff
108
109         //data visible on screen
110         $scope.performance826 = [];
111         $scope.receiveLevel = [];
112         $scope.transmissionLevel = [];
113         $scope.modulation = [];
114         $scope.temperature = [];
115         $scope.snir = [];
116         $scope.crossPolarDiscrimination = [];
117
118         $scope.paginationOptions = {
119           pageNumber: 1,
120           pageSize: 2,
121           sort: null
122         };
123
124         //page sizes, based on time period
125         $scope.pageSizes = function () {
126           var arr;
127           if ($scope.timePeriod && $scope.timePeriod === "15 minutes") {
128
129             arr = [96, (96 * 2), (96 * 7)];
130
131           } else {
132             arr = [7, 30, (30 * 3), (30 * 6), (30 * 12)];
133           }
134           return arr;
135         };
136
137         //init page sizes
138         $scope.selectPageSize = function () {
139
140           if ($scope.timePeriod && $scope.timePeriod === "15 minutes") {
141
142             return 96;
143
144           } else {
145             return 7;
146           }
147
148         };
149
150         $scope.itemsMessage = function () {
151           if ($scope.timePeriod && $scope.timePeriod === "15 minutes") {
152             return "15 minutes items per page";
153           } else {
154             return "24 hours items per page";
155           }
156         };
157
158
159         $scope.paginationStatusMessage = function (grid) {
160           if (grid === 'receiveLevel') {
161             let start = ($scope.gridOptionsReceiveLevel.paginationCurrentPage - 1) * $scope.gridOptionsReceiveLevel.paginationPageSize + 1;
162             let end = ($scope.gridOptionsReceiveLevel.paginationCurrentPage - 1) * $scope.gridOptionsReceiveLevel.paginationPageSize + 1 + $scope.receiveLevel.length - 1;
163             let total = $scope.gridOptionsReceiveLevel.totalItems;
164             let message = "Showing {0} to {1} of {2} items";
165             return message.format(start, end, total);
166           }
167           else if (grid === 'transmissionLevel') {
168             let start = ($scope.gridOptionsTransmissionLevel.paginationCurrentPage - 1) * $scope.gridOptionsTransmissionLevel.paginationPageSize + 1;
169             let end = ($scope.gridOptionsTransmissionLevel.paginationCurrentPage - 1) * $scope.gridOptionsTransmissionLevel.paginationPageSize + 1 + $scope.transmissionLevel.length - 1;
170             let total = $scope.gridOptionsTransmissionLevel.totalItems;
171             let message = "Showing {0} to {1} of {2} items";
172             return message.format(start, end, total);
173           }
174           else if (grid === 'modulation') {
175             let start = ($scope.gridOptionsModulation.paginationCurrentPage - 1) * $scope.gridOptionsModulation.paginationPageSize + 1;
176             let end = ($scope.gridOptionsModulation.paginationCurrentPage - 1) * $scope.gridOptionsModulation.paginationPageSize + 1 + $scope.modulation.length - 1;
177             let total = $scope.gridOptionsModulation.totalItems;
178             let message = "Showing {0} to {1} of {2} items";
179             return message.format(start, end, total);
180
181           } else if (grid === 'temperature') {
182             let start = ($scope.gridOptionsTemperature.paginationCurrentPage - 1) * $scope.gridOptionsTemperature.paginationPageSize + 1;
183             let end = ($scope.gridOptionsTemperature.paginationCurrentPage - 1) * $scope.gridOptionsTemperature.paginationPageSize + 1 + $scope.temperature.length - 1;
184             let total = $scope.gridOptionsTemperature.totalItems;
185             let message = "Showing {0} to {1} of {2} items";
186             return message.format(start, end, total);
187
188           } else if (grid === 'snir') {
189             let start = ($scope.gridOptionsSnir.paginationCurrentPage - 1) * $scope.gridOptionsSnir.paginationPageSize + 1;
190             let end = ($scope.gridOptionsSnir.paginationCurrentPage - 1) * $scope.gridOptionsSnir.paginationPageSize + 1 + $scope.snir.length - 1;
191             let total = $scope.gridOptionsSnir.totalItems;
192             let message = "Showing {0} to {1} of {2} items";
193             return message.format(start, end, total);
194
195           } else if (grid === 'crossPolarDiscrimination') {
196             let start = ($scope.gridOptionsCrossPolarDiscrimination.paginationCurrentPage - 1) * $scope.gridOptionsCrossPolarDiscrimination.paginationPageSize + 1;
197             let end = ($scope.gridOptionsCrossPolarDiscrimination.paginationCurrentPage - 1) * $scope.gridOptionsCrossPolarDiscrimination.paginationPageSize + 1 + $scope.crossPolarDiscrimination.length - 1;
198             let total = $scope.gridOptionsCrossPolarDiscrimination.totalItems;
199             let message = "Showing {0} to {1} of {2} items";
200             return message.format(start, end, total);
201           }
202         };
203
204         //seek page based on grid
205         $scope.seekPage = function (page, grid) {
206           if (!page) {
207             page = 1;
208             return;
209           }
210           switch (grid) {
211             case 'receiveLevel': $scope.recvGridApi.pagination.seek(parseInt(page));
212               break;
213
214             case 'transmissionLevel': $scope.transmissionGridApi.pagination.seek(parseInt(page));
215               break;
216
217             case 'modulation': $scope.gridApi.pagination.seek(parseInt(page));
218               break;
219
220             case 'temperature': $scope.gridTemperatureApi.pagination.seek(parseInt(page));
221               break;
222
223             case 'snir': $scope.gridSNIRApi.pagination.seek(parseInt(page));
224               break;
225
226             case 'crossPolarDiscrimination': $scope.gridXpdApi.pagination.seek(parseInt(page));
227               break;
228           }
229
230         };
231         //table configuration
232
233         //receive lvl configuration
234         $scope.gridOptionsReceiveLevel = {
235           paginationPageSizes: $scope.pageSizes(),
236           paginationPageSize: $scope.selectPageSize(),
237           useExternalPagination: true,
238           enablePaginationControls: false,
239           enableFiltering: false,
240           enableSorting: false,
241           enableGridMenu: true,
242           columnDefs: [
243             { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
244             { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
245             { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
246             { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
247             { field: 'timestamp', type: 'string', displayName: 'End time', width: 200 },
248             { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
249             { field: 'rxmina', type: 'string', displayName: 'Rx min A', width: 90 },
250             { field: 'rxavga', type: 'string', displayName: 'Rx avg A', width: 90 },
251             { field: 'rxmaxa', type: 'string', displayName: 'Rx max A', width: 90 },
252             { field: 'rxminb', type: 'string', displayName: 'Rx min B', width: 90 },
253             { field: 'rxavgb', type: 'string', displayName: 'Rx avg B', width: 90 },
254             { field: 'rxmaxb', type: 'string', displayName: 'Rx max B', width: 90 }
255           ],
256           data: 'receiveLevel',
257           onRegisterApi: function (gridApi) {
258             $scope.recvGridApi = gridApi;
259             $scope.recvGridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
260               $scope.paginationOptions.pageNumber = newPage;
261               $scope.paginationOptions.pageSize = pageSize;
262               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, "receiveLevel");
263             });
264           }
265         };
266
267         $scope.gridOptionsTransmissionLevel = {
268           paginationPageSizes: $scope.pageSizes(),
269           paginationPageSize: $scope.selectPageSize(),
270           useExternalPagination: true,
271           enablePaginationControls: false,
272           enableFiltering: false,
273           enableSorting: false,
274           enableGridMenu: true,
275           columnDefs: [
276             { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
277             { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
278             { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
279             { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
280             { field: 'timestamp', type: 'string', displayName: 'End time', width: 200 },
281             { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
282             { field: 'txmina', type: 'string', displayName: 'Tx min A', width: 90 },
283             { field: 'txavga', type: 'string', displayName: 'Tx avg A', width: 90 },
284             { field: 'txmaxa', type: 'string', displayName: 'Tx max A', width: 90 },
285             { field: 'txminb', type: 'string', displayName: 'Tx min B', width: 90 },
286             { field: 'txavgb', type: 'string', displayName: 'Tx avg B', width: 90 },
287             { field: 'txmaxb', type: 'string', displayName: 'Tx max B', width: 90 }
288           ],
289           data: 'transmissionLevel',
290           onRegisterApi: function (gridApi) {
291             $scope.transmissionGridApi = gridApi;
292             $scope.transmissionGridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
293               $scope.paginationOptions.pageNumber = newPage;
294               $scope.paginationOptions.pageSize = pageSize;
295               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, "transmissionLevel");
296             });
297           }
298         };
299
300         $scope.gridOptionsModulation = {
301           paginationPageSizes: $scope.pageSizes(),
302           paginationPageSize: $scope.selectPageSize(),
303           useExternalPagination: true,
304           enablePaginationControls: false,
305           enableFiltering: false,
306           enableSorting: false,
307           enableGridMenu: true,
308           columnDefs: [
309             { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
310             { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
311             { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
312             { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
313             { field: 'timestamp', type: 'string', displayName: 'End time', width: 200 },
314             { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
315             { field: 'time2Sa', type: 'string', displayName: 'QAM2S A', width: 90 },
316             { field: 'time2a', type: 'string', displayName: 'QAM2 A', width: 90 },
317             { field: 'time2La', type: 'string', displayName: 'QAM2L A', width: 90 },
318             { field: 'time4Sa', type: 'string', displayName: 'QAM4S A', width: 90 },
319             { field: 'time4a', type: 'string', displayName: 'QAM4 A', width: 90 },
320             { field: 'time4La', type: 'string', displayName: 'QAM4L A', width: 90 },
321             { field: 'time16Sa', type: 'string', displayName: 'QAM16S A', width: 90 },
322             { field: 'time16a', type: 'string', displayName: 'QAM16 A', width: 90 },
323             { field: 'time16La', type: 'string', displayName: 'QAM16L A', width: 90 },
324             { field: 'time32Sa', type: 'string', displayName: 'QAM32S A', width: 90 },
325             { field: 'time32a', type: 'string', displayName: 'QAM32 A', width: 90 },
326             { field: 'time32La', type: 'string', displayName: 'QAM32L A', width: 90 },
327             { field: 'time64Sa', type: 'string', displayName: 'QAM64S A', width: 90 },
328             { field: 'time64a', type: 'string', displayName: 'QAM64 A', width: 90 },
329             { field: 'time64La', type: 'string', displayName: 'QAM64L A', width: 90 },
330             { field: 'time128Sa', type: 'string', displayName: 'QAM128S A', width: 90 },
331             { field: 'time128a', type: 'string', displayName: 'QAM128 A', width: 90 },
332             { field: 'time128La', type: 'string', displayName: 'QAM128L A', width: 90 },
333             { field: 'time256Sa', type: 'string', displayName: 'QAM256S A', width: 90 },
334             { field: 'time256a', type: 'string', displayName: 'QAM256 A', width: 90 },
335             { field: 'time256La', type: 'string', displayName: 'QAM256L A', width: 90 },
336             { field: 'time512Sa', type: 'string', displayName: 'QAM512S A', width: 90 },
337             { field: 'time512a', type: 'string', displayName: 'QAM512 A', width: 90 },
338             { field: 'time512La', type: 'string', displayName: 'QAM512L A', width: 90 },
339             { field: 'time1024Sa', type: 'string', displayName: 'QAM1024S A', width: 90 },
340             { field: 'time1024a', type: 'string', displayName: 'QAM1024 A', width: 90 },
341             { field: 'time1024La', type: 'string', displayName: 'QAM1024L A', width: 90 },
342             { field: 'time2048Sa', type: 'string', displayName: 'QAM2048S A', width: 90 },
343             { field: 'time2048a', type: 'string', displayName: 'QAM2048 A', width: 90 },
344             { field: 'time2048La', type: 'string', displayName: 'QAM2048L A', width: 90 },
345             { field: 'time4096Sa', type: 'string', displayName: 'QAM4096S A', width: 90 },
346             { field: 'time4096a', type: 'string', displayName: 'QAM4096 A', width: 90 },
347             { field: 'time4096La', type: 'string', displayName: 'QAM4096L A', width: 90 },
348             { field: 'time8192Sa', type: 'string', displayName: 'QAM8192S A', width: 90 },
349             { field: 'time8192a', type: 'string', displayName: 'QAM8192 A', width: 90 },
350             { field: 'time8192La', type: 'string', displayName: 'QAM8192L A', width: 90 },
351
352             { field: 'time2Sb', type: 'string', displayName: 'QAM2S B', width: 90 },
353             { field: 'time2b', type: 'string', displayName: 'QAM2 B', width: 90 },
354             { field: 'time2Lb', type: 'string', displayName: 'QAM2L B', width: 90 },
355             { field: 'time4Sb', type: 'string', displayName: 'QAM4S B', width: 90 },
356             { field: 'time4b', type: 'string', displayName: 'QAM4 B', width: 90 },
357             { field: 'time4Lb', type: 'string', displayName: 'QAM4L B', width: 90 },
358             { field: 'time16Sb', type: 'string', displayName: 'QAM16S B', width: 90 },
359             { field: 'time16b', type: 'string', displayName: 'QAM16 B', width: 90 },
360             { field: 'time16Lb', type: 'string', displayName: 'QAM16L B', width: 90 },
361             { field: 'time32Sb', type: 'string', displayName: 'QAM32S B', width: 90 },
362             { field: 'time32b', type: 'string', displayName: 'QAM32 B', width: 90 },
363             { field: 'time32Lb', type: 'string', displayName: 'QAM32L B', width: 90 },
364             { field: 'time64Sb', type: 'string', displayName: 'QAM64S B', width: 90 },
365             { field: 'time64b', type: 'string', displayName: 'QAM64 B', width: 90 },
366             { field: 'time64Lb', type: 'string', displayName: 'QAM64L B', width: 90 },
367             { field: 'time128Sb', type: 'string', displayName: 'QAM128S B', width: 90 },
368             { field: 'time128b', type: 'string', displayName: 'QAM128 B', width: 90 },
369             { field: 'time128Lb', type: 'string', displayName: 'QAM128L B', width: 90 },
370             { field: 'time256Sb', type: 'string', displayName: 'QAM256S B', width: 90 },
371             { field: 'time256b', type: 'string', displayName: 'QAM256 B', width: 90 },
372             { field: 'time256Lb', type: 'string', displayName: 'QAM256L B', width: 90 },
373             { field: 'time512Sb', type: 'string', displayName: 'QAM512S B', width: 90 },
374             { field: 'time512b', type: 'string', displayName: 'QAM512 B', width: 90 },
375             { field: 'time512Lb', type: 'string', displayName: 'QAM512L B', width: 90 },
376             { field: 'time1024Sb', type: 'string', displayName: 'QAM1024S B', width: 90 },
377             { field: 'time1024b', type: 'string', displayName: 'QAM1024 B', width: 90 },
378             { field: 'time1024Lb', type: 'string', displayName: 'QAM1024L B', width: 90 },
379             { field: 'time2048Sb', type: 'string', displayName: 'QAM2048S B', width: 90 },
380             { field: 'time2048b', type: 'string', displayName: 'QAM2048 B', width: 90 },
381             { field: 'time2048Lb', type: 'string', displayName: 'QAM2048L B', width: 90 },
382             { field: 'time4096Sb', type: 'string', displayName: 'QAM4096S B', width: 90 },
383             { field: 'time4096b', type: 'string', displayName: 'QAM4096 B', width: 90 },
384             { field: 'time4096Lb', type: 'string', displayName: 'QAM4096L B', width: 90 },
385             { field: 'time8192Sb', type: 'string', displayName: 'QAM8192S B', width: 90 },
386             { field: 'time8192b', type: 'string', displayName: 'QAM8192 B', width: 90 },
387             { field: 'time8192Lb', type: 'string', displayName: 'QAM8192L B', width: 90 }
388           ],
389           data: 'modulation',
390           onRegisterApi: function (gridApi) {
391             $scope.gridApi = gridApi;
392             $scope.gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
393               $scope.paginationOptions.pageNumber = newPage;
394               $scope.paginationOptions.pageSize = pageSize;
395               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, "modulation");
396             });
397           }
398         };
399
400         $scope.gridOptionsTemperature = {
401           paginationPageSizes: $scope.pageSizes(),
402           paginationPageSize: $scope.selectPageSize(),
403           useExternalPagination: true,
404           enablePaginationControls: false,
405           enableFiltering: false,
406           enableSorting: false,
407           enableGridMenu: true,
408           columnDefs: [
409             { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
410             { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
411             { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
412             { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
413             { field: 'timestamp', type: 'string', displayName: 'End time', width: 200 },
414             { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
415             { field: 'rfTempMina', type: 'string', displayName: 'Rf Temp Min A  [&deg;C]', width: 90 },
416             { field: 'rfTempAvga', type: 'string', displayName: 'Rf Temp Avg A[&deg;C]', width: 90 },
417             { field: 'rfTempMaxa', type: 'string', displayName: 'Rf Temp Max A  [&deg;C]', width: 90 },
418             { field: 'rfTempMinb', type: 'string', displayName: 'Rf Temp Min B [&deg;C]', width: 90 },
419             { field: 'rfTempAvgb', type: 'string', displayName: 'Rf Temp Avg B [&deg;C]', width: 90 },
420             { field: 'rfTempMaxb', type: 'string', displayName: 'Rf Temp Max B [&deg;C]', width: 90 }
421
422           ],
423           data: 'temperature',
424           onRegisterApi: function (gridApi) {
425             $scope.gridTemperatureApi = gridApi;
426             $scope.gridTemperatureApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
427               $scope.paginationOptions.pageNumber = newPage;
428               $scope.paginationOptions.pageSize = pageSize;
429               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, "temperature");
430             });
431           }
432         };
433
434         $scope.gridOptionsSnir = {
435           paginationPageSizes: $scope.pageSizes(),
436           paginationPageSize: $scope.selectPageSize(),
437           useExternalPagination: true,
438           enablePaginationControls: false,
439           enableFiltering: false,
440           enableSorting: false,
441           enableGridMenu: true,
442           columnDefs: [
443             { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
444             { field: 'id', type: 'string', displayName: 'Termination point', width: 200, visible: false },
445             { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
446             { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
447             { field: 'timestamp', type: 'string', displayName: 'End time', width: 200 },
448             { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
449             { field: 'snirMin', type: 'string', displayName: [$translate.instant('MWTN_SNIR_MIN'), 'A', '[dB]'].join(' '), width: 90 },
450             { field: 'snirAvg', type: 'string', displayName: [$translate.instant('MWTN_SNIR_AVG'), 'A', '[dB]'].join(' '), width: 90 },
451             { field: 'snirMax', type: 'string', displayName: [$translate.instant('MWTN_SNIR_MAX'), 'A', '[dB]'].join(' '), width: 90 },
452             { field: 'snirMin', type: 'string', displayName: [$translate.instant('MWTN_SNIR_MIN'), 'B', '[dB]'].join(' '), width: 90 },
453             { field: 'snirAvg', type: 'string', displayName: [$translate.instant('MWTN_SNIR_AVG'), 'B', '[dB]'].join(' '), width: 90 },
454             { field: 'snirMax', type: 'string', displayName: [$translate.instant('MWTN_SNIR_MAX'), 'B', '[dB]'].join(' '), width: 90 }
455           ],
456           data: 'snir',
457           onRegisterApi: function (gridApi) {
458             $scope.gridSNIRApi = gridApi;
459             $scope.gridSNIRApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
460               $scope.paginationOptions.pageNumber = newPage;
461               $scope.paginationOptions.pageSize = pageSize;
462               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, "snir");
463             });
464           }
465         };
466
467
468         $scope.gridOptionsCrossPolarDiscrimination = {
469           paginationPageSizes: $scope.pageSizes(),
470           paginationPageSize: $scope.selectPageSize(),
471           useExternalPagination: true,
472           enablePaginationControls: false,
473           enableFiltering: false,
474           enableSorting: false,
475           enableGridMenu: true,
476           columnDefs: [
477             { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
478             { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
479             { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
480             { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
481             { field: 'timestamp', type: 'string', displayName: 'End time', width: 200 },
482             { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
483             { field: 'xpdMina', type: 'string', displayName: 'CPD min A [dB]', width: 90 },
484             { field: 'xpdAvga', type: 'string', displayName: 'CPD avg A [dB]', width: 90 },
485             { field: 'xpdMaxa', type: 'string', displayName: 'CPD max A [dB]', width: 90 },
486             { field: 'xpdMinb', type: 'string', displayName: 'CPD min B [dB]', width: 90 },
487             { field: 'xpdAvgb', type: 'string', displayName: 'CPD avg B [dB]', width: 90 },
488             { field: 'xpdMaxb', type: 'string', displayName: 'CPD max B [dB]', width: 90 }
489           ],
490           data: 'crossPolarDiscrimination',
491           onRegisterApi: function (gridApi) {
492             $scope.gridXpdApi = gridApi;
493             $scope.gridXpdApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
494               $scope.paginationOptions.pageNumber = newPage;
495               $scope.paginationOptions.pageSize = pageSize;
496               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, "crossPolarDiscrimination");
497             });
498           }
499         };
500         
501         //sanitize -1 to no value
502         var checkData = function (value) {
503           if (value === -1 || value === undefined) return undefined;
504           else return value;
505         };
506
507         var calculateMissingTimestamp = function (lastTimestamp, missingNr) {
508           var dateInMS = Date.parse(lastTimestamp);
509           return new Date(dateInMS + ((missingNr * 15) * 60000))
510                       .toISOString()
511                       .toHumanReadableTimeFormat()
512                       .replace('.000', '.0');
513         };
514
515         var processResponseForGrid = function (dataA, dataB, grid) {
516           // console.log(grid);
517           switch (grid) {
518             case "transmissionLevel":
519               var list = [];
520               var lookupMap = new Map(); //add data based on timestamp
521
522               dataA.data.hits.hits.map(function (entry, index) {
523                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
524                 lookupMap.set(timeStamp, index); //add timestamp and index to map
525                 var item = {
526                   timestamp: timeStamp,
527                   id: entry._source['uuid-interface'],
528                   layerProtocol: entry._source['layer-protocol-name'],
529                   suspectInterval: entry._source['suspect-interval-flag'],
530                   scannerId: entry._source['scanner-id'],
531                   txmina: checkData(entry._source['performance-data']['tx-level-min']),
532                   txavga: checkData(entry._source['performance-data']['tx-level-avg']),
533                   txmaxa: checkData(entry._source['performance-data']['tx-level-max']),
534                   'radiosignal': entry._source['radio-signal-id']
535                 };
536                 list.push(item);
537               });
538
539               dataB.data.hits.hits.map(function (entry) {
540                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
541                 var index = lookupMap.get(timeStamp); //look for timestamp in map
542                 if (index !== undefined) { //if a timestamp was found
543                   list[index].txminb = checkData(entry._source['performance-data']['tx-level-min']); //add data to b side of element
544                   list[index].txavgb = checkData(entry._source['performance-data']['tx-level-avg']);
545                   list[index].txmaxb = checkData(entry._source['performance-data']['tx-level-max']);
546                 } else {
547                   if (list[0].timestamp === $mwtnPerformanceLink.formatTimeStamp(timeStamp)) { //look, if first element in list is same (first element in map is never found against an equals)
548                     list[0].txminb = checkData(entry._source['performance-data']['tx-level-min']); //add data to b side of element
549                     list[0].txavgb = checkData(entry._source['performance-data']['tx-level-avg']);
550                     list[0].txmaxb = checkData(entry._source['performance-data']['tx-level-max']);
551                   }
552                   else { //add new element for b side to list
553                     list.push({
554                       timestamp: timeStamp,
555                       id: entry._source['uuid-interface'],
556                       layerProtocol: entry._source['layer-protocol-name'],
557                       suspectInterval: entry._source['suspect-interval-flag'],
558                       scannerId: entry._source['scanner-id'],
559                       txminb: checkData(entry._source['performance-data']['tx-level-min']),
560                       txavgb: checkData(entry._source['performance-data']['tx-level-avg']),
561                       txmaxb: checkData(entry._source['performance-data']['tx-level-max']),
562                       'radiosignal': entry._source['radio-signal-id']
563                     });
564                   }
565                 }
566               });
567
568               $scope.transmissionLevel = list; //add list to databound table list
569               $scope.gridOptionsTransmissionLevel.totalItems = getMaxItems(dataA.data.hits.total, dataB.data.hits.total);
570               break;
571
572             case "receiveLevel":
573
574               var list = [];
575               var lookupMap = new Map();
576
577               dataA.data.hits.hits.map(function (entry, index) {
578                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
579                 lookupMap.set(timeStamp, index);
580                 var item = {
581                   timestamp: timeStamp,
582                   id: entry._source['uuid-interface'],
583                   layerProtocol: entry._source['layer-protocol-name'],
584                   suspectInterval: entry._source['suspect-interval-flag'],
585                   scannerId: entry._source['scanner-id'],
586                   rxmina: checkData(entry._source['performance-data']['rx-level-min']),
587                   rxavga: checkData(entry._source['performance-data']['rx-level-avg']),
588                   rxmaxa: checkData(entry._source['performance-data']['rx-level-max']),
589                   'radiosignal': entry._source['radio-signal-id']
590                 };
591
592                 list.push(item);
593               });
594
595               dataB.data.hits.hits.map(function (entry) {
596                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
597                 var index = lookupMap.get(timeStamp);
598                 if (index !== undefined) {
599                   list[index].rxminb = checkData(entry._source['performance-data']['rx-level-min']);
600                   list[index].rxavgb = checkData(entry._source['performance-data']['rx-level-avg']);
601                   list[index].rxmaxb = checkData(entry._source['performance-data']['rx-level-max']);
602                 } else {
603                   if (list[0].timestamp === $mwtnPerformanceLink.formatTimeStamp(timeStamp)) {
604                     list[0].rxminb = checkData(entry._source['performance-data']['rx-level-min']);
605                     list[0].rxavgb = checkData(entry._source['performance-data']['rx-level-avg']);
606                     list[0].rxmaxb = checkData(entry._source['performance-data']['rx-level-max']);
607                   } else {
608                     list.push({
609                       timestamp: timeStamp,
610                       id: entry._source['uuid-interface'],
611                       layerProtocol: entry._source['layer-protocol-name'],
612                       suspectInterval: entry._source['suspect-interval-flag'],
613                       scannerId: entry._source['scanner-id'],
614                       rxminb: checkData(entry._source['performance-data']['rx-level-min']),
615                       rxavgb: checkData(entry._source['performance-data']['rx-level-avg']),
616                       rxmaxb: checkData(entry._source['performance-data']['rx-level-max']),
617                       'radiosignal': entry._source['radio-signal-id']
618                     });
619                   }
620                 }
621
622               });
623
624
625               $scope.receiveLevel = list;
626               $scope.gridOptionsReceiveLevel.totalItems = getMaxItems(dataA.data.hits.total, dataB.data.hits.total);
627
628               break;
629
630             case "modulation":
631
632               var list = [];
633
634               var lookupMap = new Map();
635
636               dataA.data.hits.hits.map(function (entry, index) {
637                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
638                 lookupMap.set(timeStamp, index);
639                 var item = {
640                   timestamp: timeStamp,
641                   id: entry._source['uuid-interface'],
642                   layerProtocol: entry._source['layer-protocol-name'],
643                   suspectInterval: entry._source['suspect-interval-flag'],
644                   scannerId: entry._source['scanner-id'],
645                   'time2Sa': checkData(entry._source['performance-data']['time2-states-s']),
646                   'time2a': checkData(entry._source['performance-data']['time2-states']),
647                   'time2La': checkData(entry._source['performance-data']['time2-states-l']),
648                   'time4Sa': checkData(entry._source['performance-data']['time4-states-s']),
649                   'time4a': checkData(entry._source['performance-data']['time4-states']),
650                   'time4La': checkData(entry._source['performance-data']['time4-states-l']),
651                   'time16Sa': checkData(entry._source['performance-data']['time16-states-s']),
652                   'time16a': checkData(entry._source['performance-data']['time16-states']),
653                   'time16La': checkData(entry._source['performance-data']['time16-states-l']),
654                   'time32Sa': checkData(entry._source['performance-data']['time32-states-s']),
655                   'time32a': checkData(entry._source['performance-data']['time32-states']),
656                   'time32La': checkData(entry._source['performance-data']['time32-states-l']),
657                   'time64Sa': checkData(entry._source['performance-data']['time64-states-s']),
658                   'time64a': checkData(entry._source['performance-data']['time64-states']),
659                   'time64La': checkData(entry._source['performance-data']['time64-states-l']),
660                   'time128Sa': checkData(entry._source['performance-data']['time128-states-s']),
661                   'time128a': checkData(entry._source['performance-data']['time128-states']),
662                   'time128La': checkData(entry._source['performance-data']['time128-states-l']),
663                   'time256Sa': checkData(entry._source['performance-data']['time256-states-s']),
664                   'time256a': checkData(entry._source['performance-data']['time256-states']),
665                   'time256La': checkData(entry._source['performance-data']['time256-states-l']),
666                   'time512Sa': checkData(entry._source['performance-data']['time512-states-s']),
667                   'time512a': checkData(entry._source['performance-data']['time512-states']),
668                   'time512La': checkData(entry._source['performance-data']['time512-states-l']),
669                   'time1024Sa': checkData(entry._source['performance-data']['time1024-states-s']),
670                   'time1024a': checkData(entry._source['performance-data']['time1024-states']),
671                   'time1024La': checkData(entry._source['performance-data']['time1024-states-l']),
672                   'time2048Sa': checkData(entry._source['performance-data']['time2048-states-s']),
673                   'time2048a': checkData(entry._source['performance-data']['time2048-states']),
674                   'time2048La': checkData(entry._source['performance-data']['time2048-states-l']),
675                   'time4096Sa': checkData(entry._source['performance-data']['time4096-states-s']),
676                   'time4096a': checkData(entry._source['performance-data']['time4096-states']),
677                   'time4096La': checkData(entry._source['performance-data']['time4096-states-l']),
678                   'time8192Sa': checkData(entry._source['performance-data']['time8192-states-s']),
679                   'time8192a': checkData(entry._source['performance-data']['time8192-states']),
680                   'time8192La': checkData(entry._source['performance-data']['time8192-states-l']),
681                   'radiosignal': entry._source['radio-signal-id']
682                 };
683
684                 list.push(item);
685
686               });
687
688               dataB.data.hits.hits.map(function (entry) {
689                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
690                 var index = lookupMap.get(timeStamp);
691                 if (index !== undefined) {
692
693                   list[index].time2Sb = checkData(entry._source['performance-data']['time2-states-s']);
694                   list[index].time2b = checkData(entry._source['performance-data']['time2-states']);
695                   list[index].time2Lb = checkData(entry._source['performance-data']['time2-states-l']);
696                   list[index].time4Sb = checkData(entry._source['performance-data']['time4-states-s']);
697                   list[index].time4b = checkData(entry._source['performance-data']['time4-states']);
698                   list[index].time4Lb = checkData(entry._source['performance-data']['time4-states-l']);
699                   list[index].time16Sb = checkData(entry._source['performance-data']['time16-states-s']);
700                   list[index].time16b = checkData(entry._source['performance-data']['time16-states']);
701                   list[index].time16Lb = checkData(entry._source['performance-data']['time16-states-l']);
702                   list[index].time32Sb = checkData(entry._source['performance-data']['time32-states-s']);
703                   list[index].time32b = checkData(entry._source['performance-data']['time32-states']);
704                   list[index].time32Lb = checkData(entry._source['performance-data']['time32-states-l']);
705                   list[index].time64Sb = checkData(entry._source['performance-data']['time64-states-s']);
706                   list[index].time64b = checkData(entry._source['performance-data']['time64-states']);
707                   list[index].time64Lb = checkData(entry._source['performance-data']['time64-states-l']);
708                   list[index].time128Sb = checkData(entry._source['performance-data']['time128-states-s']);
709                   list[index].time128b = checkData(entry._source['performance-data']['time128-states']);
710                   list[index].time128Lb = checkData(entry._source['performance-data']['time128-states-l']);
711                   list[index].time256Sb = checkData(entry._source['performance-data']['time256-states-s']);
712                   list[index].time256b = checkData(entry._source['performance-data']['time256-states']);
713                   list[index].time256Lb = checkData(entry._source['performance-data']['time256-states-l']);
714                   list[index].time512Sb = checkData(entry._source['performance-data']['time512-states-s']);
715                   list[index].time512b = checkData(entry._source['performance-data']['time512-states']);
716                   list[index].time512Lb = checkData(entry._source['performance-data']['time512-states-l']);
717                   list[index].time1024Sb = checkData(entry._source['performance-data']['time1024-states-s']);
718                   list[index].time1024b = checkData(entry._source['performance-data']['time1024-states']);
719                   list[index].time1024Lb = checkData(entry._source['performance-data']['time1024-states-l']);
720                   list[index].time2048Sb = checkData(entry._source['performance-data']['time2048-states-s']);
721                   list[index].time2048b = checkData(entry._source['performance-data']['time2048-states']);
722                   list[index].time2048Lb = checkData(entry._source['performance-data']['time2048-states-l']);
723                   list[index].time4096Sb = checkData(entry._source['performance-data']['time4096-states-s']);
724                   list[index].time4096b = checkData(entry._source['performance-data']['time4096-states']);
725                   list[index].time4096Lb = checkData(entry._source['performance-data']['time4096-states-l']);
726                   list[index].time8192Sb = checkData(entry._source['performance-data']['time8192-states-s']);
727                   list[index].time8192b = checkData(entry._source['performance-data']['time8192-states']);
728                   list[index].time8192Lb = checkData(entry._source['performance-data']['time8192-states-l']);
729                 } else {
730                   if (list[0].timestamp === $mwtnPerformanceLink.formatTimeStamp(timeStamp)) {
731                     list[index].time2Sb = checkData(entry._source['performance-data']['time2-states-s']);
732                     list[0].time2b = checkData(entry._source['performance-data']['time2-states']);
733                     list[0].time2Lb = checkData(entry._source['performance-data']['time2-states-l']);
734                     list[0].time4Sb = checkData(entry._source['performance-data']['time4-states-s']);
735                     list[0].time4b = checkData(entry._source['performance-data']['time4-states']);
736                     list[0].time4Lb = checkData(entry._source['performance-data']['time4-states-l']);
737                     list[0].time16Sb = checkData(entry._source['performance-data']['time16-states-s']);
738                     list[0].time16b = checkData(entry._source['performance-data']['time16-states']);
739                     list[0].time16Lb = checkData(entry._source['performance-data']['time16-states-l']);
740                     list[0].time32Sb = checkData(entry._source['performance-data']['time32-states-s']);
741                     list[0].time32b = checkData(entry._source['performance-data']['time32-states']);
742                     list[0].time32Lb = checkData(entry._source['performance-data']['time32-states-l']);
743                     list[0].time64Sb = checkData(entry._source['performance-data']['time64-states-s']);
744                     list[0].time64b = checkData(entry._source['performance-data']['time64-states']);
745                     list[0].time64Lb = checkData(entry._source['performance-data']['time64-states-l']);
746                     list[0].time128Sb = checkData(entry._source['performance-data']['time128-states-s']);
747                     list[0].time128b = checkData(entry._source['performance-data']['time128-states']);
748                     list[0].time128Lb = checkData(entry._source['performance-data']['time128-states-l']);
749                     list[0].time256Sb = checkData(entry._source['performance-data']['time256-states-s']);
750                     list[0].time256b = checkData(entry._source['performance-data']['time256-states']);
751                     list[0].time256Lb = checkData(entry._source['performance-data']['time256-states-l']);
752                     list[0].time512Sb = checkData(entry._source['performance-data']['time512-states-s']);
753                     list[0].time512b = checkData(entry._source['performance-data']['time512-states']);
754                     list[0].time512Lb = checkData(entry._source['performance-data']['time512-states-l']);
755                     list[0].time1024Sb = checkData(entry._source['performance-data']['time1024-states-s']);
756                     list[0].time1024b = checkData(entry._source['performance-data']['time1024-states']);
757                     list[0].time1024Lb = checkData(entry._source['performance-data']['time1024-states-l']);
758                     list[0].time2048Sb = checkData(entry._source['performance-data']['time2048-states-s']);
759                     list[0].time2048b = checkData(entry._source['performance-data']['time2048-states']);
760                     list[0].time2048Lb = checkData(entry._source['performance-data']['time2048-states-l']);
761                     list[0].time4096Sb = checkData(entry._source['performance-data']['time4096-states-s']);
762                     list[0].time4096b = checkData(entry._source['performance-data']['time4096-states']);
763                     list[0].time4096Lb = checkData(entry._source['performance-data']['time4096-states-l']);
764                     list[0].time8192Sb = checkData(entry._source['performance-data']['time8192-states-s']);
765                     list[0].time8192b = checkData(entry._source['performance-data']['time8192-states']);
766                     list[0].time8192Lb = checkData(entry._source['performance-data']['time8192-states-l']);
767                   }
768                   else {
769                     var item = {
770                       timestamp: timeStamp,
771                       id: entry._source['uuid-interface'],
772                       layerProtocol: entry._source['layer-protocol-name'],
773                       suspectInterval: entry._source['suspect-interval-flag'],
774                       scannerId: entry._source['scanner-id'],
775                       'time2Sb': checkData(entry._source['performance-data']['time2-states-s']),
776                       'time2b': checkData(entry._source['performance-data']['time2-states']),
777                       'time2Lb': checkData(entry._source['performance-data']['time2-states-l']),
778                       'time4Sb': checkData(entry._source['performance-data']['time4-states-s']),
779                       'time4b': checkData(entry._source['performance-data']['time4-states']),
780                       'time4Lb': checkData(entry._source['performance-data']['time4-states-l']),
781                       'time16Sb': checkData(entry._source['performance-data']['time16-states-s']),
782                       'time16b': checkData(entry._source['performance-data']['time16-states']),
783                       'time16Lb': checkData(entry._source['performance-data']['time16-states-l']),
784                       'time32Sb': checkData(entry._source['performance-data']['time32-states-s']),
785                       'time32b': checkData(entry._source['performance-data']['time32-states']),
786                       'time32Lb': checkData(entry._source['performance-data']['time32-states-l']),
787                       'time64Sb': checkData(entry._source['performance-data']['time64-states-s']),
788                       'time64b': checkData(entry._source['performance-data']['time64-states']),
789                       'time64Lb': checkData(entry._source['performance-data']['time64-states-l']),
790                       'time128Sb': checkData(entry._source['performance-data']['time128-states-s']),
791                       'time128b': checkData(entry._source['performance-data']['time128-states']),
792                       'time128Lb': checkData(entry._source['performance-data']['time128-states-l']),
793                       'time256Sb': checkData(entry._source['performance-data']['time256-states-s']),
794                       'time256b': checkData(entry._source['performance-data']['time256-states']),
795                       'time256Lb': checkData(entry._source['performance-data']['time256-states-l']),
796                       'time512Sb': checkData(entry._source['performance-data']['time512-states-s']),
797                       'time512b': checkData(entry._source['performance-data']['time512-states']),
798                       'time512Lb': checkData(entry._source['performance-data']['time512-states-l']),
799                       'time1024Sb': checkData(entry._source['performance-data']['time1024-states-s']),
800                       'time1024b': checkData(entry._source['performance-data']['time1024-states']),
801                       'time1024Lb': checkData(entry._source['performance-data']['time1024-states-l']),
802                       'time2048Sb': checkData(entry._source['performance-data']['time2048-states-s']),
803                       'time2048b': checkData(entry._source['performance-data']['time2048-states']),
804                       'time2048Lb': checkData(entry._source['performance-data']['time2048-states-l']),
805                       'time4096Sb': checkData(entry._source['performance-data']['time4096-states-s']),
806                       'time4096b': checkData(entry._source['performance-data']['time4096-states']),
807                       'time4096Lb': checkData(entry._source['performance-data']['time4096-states-l']),
808                       'time8192Sb': checkData(entry._source['performance-data']['time8192-states-s']),
809                       'time8192b': checkData(entry._source['performance-data']['time8192-states']),
810                       'time8192Lb': checkData(entry._source['performance-data']['time8192-states-l']),
811                       'radiosignal': entry._source['radio-signal-id']
812                     };
813
814                     list.push(item);
815                   }
816                 }
817               });
818               $scope.modulation = list;
819               $scope.gridOptionsModulation.totalItems = getMaxItems(dataA.data.hits.total, dataB.data.hits.total);
820
821               break;
822
823             case "temperature":
824
825               var list = [];
826               var lookupMap = new Map();
827
828               dataA.data.hits.hits.map(function (entry, index) {
829                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
830                 lookupMap.set(timeStamp, index);
831                 var item = {
832                   'timestamp': $mwtnPerformanceLink.formatTimeStamp(timeStamp),
833                   id: entry._source['uuid-interface'],
834                   layerProtocol: entry._source['layer-protocol-name'],
835                   suspectInterval: entry._source['suspect-interval-flag'],
836                   scannerId: entry._source['scanner-id'],
837                   rfTempMina: entry._source['performance-data']['rf-temp-min'],
838                   rfTempAvga: entry._source['performance-data']['rf-temp-avg'],
839                   rfTempMaxa: entry._source['performance-data']['rf-temp-max'],
840                   'radiosignal': entry._source['radio-signal-id']
841                 };
842
843                 list.push(item);
844               });
845
846               dataB.data.hits.hits.map(function (entry) {
847                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
848                 var index = lookupMap.get(timeStamp);
849                 if (index !== undefined) {
850                   list[index].rfTempMinb = entry._source['performance-data']['rf-temp-min'];
851                   list[index].rfTempMaxb = entry._source['performance-data']['rf-temp-max'];
852                   list[index].rfTempAvgb = entry._source['performance-data']['rf-temp-avg'];
853                 } else {
854                   if (list[0].timestamp === $mwtnPerformanceLink.formatTimeStamp(timeStamp)) {
855                     list[0].rfTempMinb = entry._source['performance-data']['rf-temp-min'];
856                     list[0].rfTempMaxb = entry._source['performance-data']['rf-temp-max'];
857                     list[0].rfTempAvgb = entry._source['performance-data']['rf-temp-avg'];
858                   } else {
859                     list.push({
860                       'timestamp': $mwtnPerformanceLink.formatTimeStamp(timeStamp),
861                       id: entry._source['uuid-interface'],
862                       layerProtocol: entry._source['layer-protocol-name'],
863                       suspectInterval: entry._source['suspect-interval-flag'],
864                       scannerId: entry._source['scanner-id'],
865                       rfTempMinb: entry._source['performance-data']['rf-temp-min'],
866                       rfTempAvgb: entry._source['performance-data']['rf-temp-avg'],
867                       rfTempMaxb: entry._source['performance-data']['rf-temp-max'],
868                       'radiosignal': entry._source['radio-signal-id']
869                     });
870                   }
871                 }
872               });
873
874               $scope.temperature = list;
875               $scope.gridOptionsTemperature.totalItems = getMaxItems(dataA.data.hits.total, dataB.data.hits.total);
876
877               break;
878
879             case "snir":
880
881               var list = [];
882               var lookupMap = new Map();
883
884               dataA.data.hits.hits.map(function (entry, index) {
885                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
886                 lookupMap.set(timeStamp, index);
887                 var item = {
888                   'timestamp': $mwtnPerformanceLink.formatTimeStamp(timeStamp),
889                   id: entry._source['uuid-interface'],
890                   layerProtocol: entry._source['layer-protocol-name'],
891                   suspectInterval: entry._source['suspect-interval-flag'],
892                   scannerId: entry._source['scanner-id'],
893                   snirMina: entry._source['performance-data']['snir-min'],
894                   snirAvga: entry._source['performance-data']['snir-avg'],
895                   snirMaxa: entry._source['performance-data']['snir-max'],
896                   'radiosignal': entry._source['radio-signal-id']
897                 };
898
899                 list.push(item);
900               });
901
902               dataB.data.hits.hits.map(function (entry) {
903                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);  
904                 var index = lookupMap.get(timeStamp);
905                 if (index !== undefined) {
906                   list[index].snirMinb = entry._source['performance-data']['snir-min'];
907                   list[index].snirMaxb = entry._source['performance-data']['snir-max'];
908                   list[index].snirAvgb = entry._source['performance-data']['snir-max'];
909                 }
910                 else {
911                   if (list[0].timestamp === $mwtnPerformanceLink.formatTimeStamp(timeStamp)) {
912                     list[0].snirMinb = entry._source['performance-data']['snir-min'];
913                     list[0].snirMaxb = entry._source['performance-data']['snir-max'];
914                     list[0].snirAvgb = entry._source['performance-data']['snir-max'];
915                   } else {
916                     list.push({
917                       'timestamp': $mwtnPerformanceLink.formatTimeStamp(timeStamp),
918                       id: entry._source['uuid-interface'],
919                       layerProtocol: entry._source['layer-protocol-name'],
920                       suspectInterval: entry._source['suspect-interval-flag'],
921                       scannerId: entry._source['scanner-id'],
922                       snirMinb: entry._source['performance-data']['snir-min'],
923                       snirAvgb: entry._source['performance-data']['snir-avg'],
924                       snirMaxb: entry._source['performance-data']['snir-max'],
925                       'radiosignal': entry._source['radio-signal-id']
926                     });
927                   }
928                 }
929               });
930               $scope.snir = list;
931               $scope.gridOptionsSnir.totalItems = getMaxItems(dataA.data.hits.total, dataB.data.hits.total);
932
933               break;
934
935             case "crossPolarDiscrimination":
936               var list = [];
937
938               var lookupMap = new Map();
939
940               dataA.data.hits.hits.map(function (entry, index) {
941                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
942                 lookupMap.set(timeStamp, index);
943                 var item = {
944                   'timestamp': $mwtnPerformanceLink.formatTimeStamp(timeStamp),
945                   id: entry._source['uuid-interface'],
946                   layerProtocol: entry._source['layer-protocol-name'],
947                   suspectInterval: entry._source['suspect-interval-flag'],
948                   scannerId: entry._source['scanner-id'],
949                   xpdMina: entry._source['performance-data']['xpd-min'],
950                   xpdAvga: entry._source['performance-data']['xpd-avg'],
951                   xpdMaxa: entry._source['performance-data']['xpd-max'],
952                   'radiosignal': entry._source['radio-signal-id']
953
954                 };
955
956                 list.push(item);
957
958               });
959
960               dataB.data.hits.hits.map(function (entry) {
961                 var timeStamp = formatTimeStamp(entry._source['time-stamp']);
962                 var index = lookupMap.get(timeStamp);
963                 if (index !== undefined) {
964                   list[index].xpdMinb = entry._source['performance-data']['xpd-min'];
965                   list[index].xpdMaxb = entry._source['performance-data']['xpd-max'];
966                   list[index].xpdAvgb = entry._source['performance-data']['xpd-avg'];
967                 }
968                 else {
969                   if (list[0].timestamp === $mwtnPerformanceLink.formatTimeStamp(timeStamp)) {
970
971                     list[0].xpdMinb = entry._source['performance-data']['xpd-min'];
972                     list[0].xpdMaxb = entry._source['performance-data']['xpd-max'];
973                     list[0].xpdAvgb = entry._source['performance-data']['xpd-avg'];
974
975                   } else {
976                     list.push({
977                       'timestamp': $mwtnPerformanceLink.formatTimeStamp(timeStamp),
978                       id: entry._source['uuid-interface'],
979                       layerProtocol: entry._source['layer-protocol-name'],
980                       suspectInterval: entry._source['suspect-interval-flag'],
981                       scannerId: entry._source['scanner-id'],
982                       xpdMinb: entry._source['performance-data']['xpd-min'],
983                       xpdAvgb: entry._source['performance-data']['xpd-avg'],
984                       xpdMaxb: entry._source['performance-data']['xpd-max'],
985                       'radiosignal': entry._source['radio-signal-id']
986
987                     });
988                   }
989
990                 }
991               });
992
993               $scope.crossPolarDiscrimination = list;
994               $scope.gridOptionsCrossPolarDiscrimination.totalItems = getMaxItems(dataA.data.hits.total, dataB.data.hits.total);
995
996               break;
997           }
998         };
999
1000
1001         var getMaxItems = function (a, b) {
1002           if ($scope.networkElementA === $scope.networkElementB && $scope.selectedLtpIdA === $scope.selectedLtpIdB) {
1003             //assume same network element and intefaces selected, return only 1 length
1004             return a;
1005           } else {
1006             return a + b;
1007           }
1008         }
1009
1010         //get data for pm link interafces / ne's from db
1011         var getDataFromNEs = function (networkElementA, selectedLtpIdA, networkElementB, selectedLtpIdB, grid) {
1012           var pagesize;
1013           var pagenr;
1014
1015           switch (grid) { //get pagesize / nr according to current grid (else everything gets messy => wana get next page in grid a, get next page for grid b too)
1016             case 'receiveLevel':
1017               pagesize = $scope.gridOptionsReceiveLevel.paginationPageSize;
1018               pagenr = $scope.gridOptionsReceiveLevel.paginationCurrentPage;
1019               break;
1020
1021             case 'transmissionLevel':
1022               pagesize = $scope.gridOptionsTransmissionLevel.paginationPageSize;
1023               pagenr = $scope.gridOptionsTransmissionLevel.paginationCurrentPage;
1024               break;
1025
1026             case 'modulation':
1027               pagesize = $scope.gridOptionsModulation.paginationPageSize;
1028               pagenr = $scope.gridOptionsModulation.paginationCurrentPage;
1029               break;
1030
1031             case 'temperature':
1032               pagesize = $scope.gridOptionsTemperature.paginationPageSize;
1033               pagenr = $scope.gridOptionsTemperature.paginationCurrentPage;
1034               break;
1035
1036             case 'snir':
1037               pagesize = $scope.gridOptionsSnir.paginationPageSize;
1038               pagenr = $scope.gridOptionsSnir.paginationCurrentPage;
1039               break;
1040
1041             case 'crossPolarDiscrimination':
1042               pagesize = $scope.gridOptionsCrossPolarDiscrimination.paginationPageSize;
1043               pagenr = $scope.gridOptionsCrossPolarDiscrimination.paginationCurrentPage;
1044
1045               break;
1046           }
1047
1048           var dataA;
1049           var dataB;
1050           getData((pagenr - 1) * pagesize, pagesize, networkElementA, selectedLtpIdA).then(function (response) {
1051             dataA = response;
1052             getData((pagenr - 1) * pagesize, pagesize, networkElementB, selectedLtpIdB).then(function (response) {
1053               dataB = response;
1054               drawLineChart(dataA, dataB, grid);
1055               processResponseForGrid(dataA, dataB, grid);
1056             });
1057           });
1058         };
1059
1060         //override points on graphs
1061         var overridePoints = function (series, overrideArray) {
1062
1063
1064           let patternArray = ['rect', 'triangle', 'point', 'rectRot'];
1065           let patternCounter = 0;
1066
1067
1068           for (let i = 0; i < series.length; i++) {
1069
1070             overrideArray[i].pointStyle = patternArray[patternCounter];
1071             patternCounter++;
1072
1073             if (patternCounter === 4) patternCounter = 0;
1074             overrideArray[i].pointRadius = 10;
1075           }
1076
1077         };
1078
1079         var drawLineChart = function (dataA, dataB, grid) {
1080
1081           //create a sorted lookup array
1082
1083           var tempSet = new Set(); //remove duplicate timestamps
1084
1085           dataA.data.hits.hits.map(function (item) {
1086             tempSet.add($mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']));
1087           });
1088
1089           dataB.data.hits.hits.map(function (item) {
1090             tempSet.add($mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']));
1091           });
1092
1093           // console.log(tempSet);
1094           var tempArr = Array.from(tempSet); //create an array from unique timestamps
1095
1096           tempArr.sort(function (a, b) { //sort it
1097             if (a > b) { return 1; }
1098             else if (a < b) { return -1; }
1099             else {
1100               return 0;
1101             }
1102           });
1103
1104           //process data according to grid
1105           switch (grid) {
1106             case 'receiveLevel': {
1107
1108               //chart specific data
1109               $scope.receiveData = [];
1110               $scope.receiveSeries = [];
1111               $scope.receiveLabels = [];
1112               $scope.receiveDatasetOverride = [];
1113
1114               $scope.receiveOptions = {
1115                 scales: {
1116                   xAxes: [{
1117                     type: 'linear',
1118                     position: 'bottom',
1119                     afterTickToLabelConversion: function (data) { //adds our custom timestamp labels
1120
1121                       var xLabels = data.ticks;
1122                       xLabels.forEach(function (labels, i) {
1123                         var timestamp = $scope.toolTipMap.get(parseInt(labels));
1124                         if (parseInt(labels) == labels)
1125                           xLabels[i] = timestamp;
1126                         else
1127                           xLabels[i] = '';
1128                       });
1129
1130                       //calculate last timestamp if label is missing
1131                       if (xLabels[xLabels.length - 1] === undefined) {
1132                         var timestamp = $scope.toolTipMap.get($scope.toolTipMap.size - 1);
1133                         let stopper = true;
1134                         let counter = 0;
1135                         let labelLength = xLabels.length - 1;
1136                         while (stopper) {
1137                           if (labelLength % 10 == 0) {
1138                             stopper = false;
1139                           } else {
1140                             labelLength++;
1141                             counter++;
1142                           }
1143                         }
1144
1145                         xLabels[xLabels.length - 1] = calculateMissingTimestamp(timestamp, counter);
1146                       }
1147
1148
1149
1150                     }
1151                   }],
1152                   yAxes: [
1153                     {
1154                       id: 'y-axis-1',
1155                       type: 'linear',
1156                       display: true,
1157                       position: 'left'
1158                     }
1159                   ]
1160                 },
1161                 tooltips: {
1162                   enabled: true,
1163                   mode: 'point',
1164                   callbacks: {
1165                     title: function (tooltipItem, data) { //picks right tool tip
1166                       var vaue = $scope.toolTipMap.get(tooltipItem[0].xLabel); //changes int label to timestamp
1167                       return vaue;
1168                     }
1169                   }
1170                 },
1171                 legend: {
1172                   display: true,
1173                   position: "bottom"
1174                 }
1175               };
1176
1177               $scope.testMap = new Map();
1178               $scope.toolTipMap = new Map();
1179
1180               tempArr.map(function (item, index) {
1181                 $scope.testMap.set(item, index);
1182                 $scope.toolTipMap.set(index, item);
1183               });
1184
1185               //process a side
1186
1187               var maxListA = [];
1188               var minListA = [];
1189               var avgListA = [];
1190
1191               //add data to array
1192               dataA.data.hits.hits.map(function (item, index) {
1193                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
1194
1195                 var test = $scope.testMap.get(timestamp);
1196                 if (test) {
1197                   maxListA.push({ x: test, y: item._source['performance-data']['rx-level-max'] });
1198                   minListA.push({ x: test, y: item._source['performance-data']['rx-level-min'] });
1199                   avgListA.push({ x: test, y: item._source['performance-data']['rx-level-avg'] });
1200                 } else {
1201                   maxListA.push({ x: 0, y: item._source['performance-data']['rx-level-max'] }); //for some odd reason first is not found, although available within map
1202                   minListA.push({ x: 0, y: item._source['performance-data']['rx-level-min'] });
1203                   avgListA.push({ x: 0, y: item._source['performance-data']['rx-level-avg'] });
1204                 }
1205               });
1206
1207               //add series names and data
1208               $scope.receiveSeries.push('Rx max A', 'Rx min A', 'Rx avg A');
1209
1210
1211               $scope.receiveData.push(maxListA);
1212               $scope.receiveData.push(minListA);
1213               $scope.receiveData.push(avgListA);
1214
1215               //add y axis override
1216               $scope.receiveDatasetOverride.push({ yAxisID: 'y-axis-1' });
1217               $scope.receiveDatasetOverride.push({ yAxisID: 'y-axis-1' });
1218               $scope.receiveDatasetOverride.push({ yAxisID: 'y-axis-1' });
1219
1220
1221               //process b side
1222
1223               var maxListB = [];
1224               var minListB = [];
1225               var avgListB = [];
1226
1227               dataB.data.hits.hits.map(function (item, index) {
1228                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
1229
1230                 var test = $scope.testMap.get(timestamp);
1231                 if (test) {
1232                   maxListB.push({ x: test, y: item._source['performance-data']['rx-level-max'] });
1233                   minListB.push({ x: test, y: item._source['performance-data']['rx-level-min'] });
1234                   avgListB.push({ x: test, y: item._source['performance-data']['rx-level-avg'] });
1235                 } else {
1236                   maxListB.push({ x: 0, y: item._source['performance-data']['rx-level-max'] });
1237                   minListB.push({ x: 0, y: item._source['performance-data']['rx-level-min'] });
1238                   avgListB.push({ x: 0, y: item._source['performance-data']['rx-level-avg'] });
1239                   console.log("timestamp" + timestamp + "at first position in map" + $scope.testMap.get(timestamp) + "wasnt found.");
1240                 }
1241               });
1242
1243               //add series names and data 
1244               $scope.receiveSeries.push('Rx max B', 'Rx min B', 'Rx avg B');
1245
1246               $scope.receiveData.push(maxListB);
1247               $scope.receiveData.push(minListB);
1248               $scope.receiveData.push(avgListB);
1249
1250               //add y axis override id 
1251               $scope.receiveDatasetOverride.push({ yAxisID: 'y-axis-1' });
1252               $scope.receiveDatasetOverride.push({ yAxisID: 'y-axis-1' });
1253               $scope.receiveDatasetOverride.push({ yAxisID: 'y-axis-1' });
1254
1255               overridePoints($scope.receiveSeries, $scope.receiveDatasetOverride);
1256
1257
1258             }
1259
1260               break;
1261
1262             case 'transmissionLevel': {
1263
1264               $scope.transmissionData = [];
1265               $scope.transmissionSeries = [];
1266               $scope.transmissionDatasetOverride = [];
1267
1268               $scope.transmissionOptions = {
1269                 scales: {
1270                   xAxes: [{
1271                     type: 'linear',
1272                     position: 'bottom',
1273                     afterTickToLabelConversion: function (data) { //adds our custom timestamp labels
1274
1275                       var xLabels = data.ticks;
1276                       xLabels.forEach(function (labels, i) {
1277                         var timestamp = $scope.transmissiontoolTipMap.get(parseInt(labels));
1278                         if (parseInt(labels) == labels)
1279                           xLabels[i] = timestamp;
1280                         else
1281                           xLabels[i] = '';
1282
1283                       });
1284
1285                       //calculate last timestamp if label is missing
1286                       if (xLabels[xLabels.length - 1] === undefined) {
1287                         let timestamp = $scope.transmissiontoolTipMap.get($scope.transmissiontoolTipMap.size - 1);
1288                         let stopper = true;
1289                         let counter = 0;
1290                         let labelLength = xLabels.length - 1;
1291                         while (stopper) {
1292                           if (labelLength % 10 == 0) {
1293                             stopper = false;
1294                           } else {
1295                             labelLength++;
1296                             counter++;
1297                           }
1298                         }
1299
1300                         xLabels[xLabels.length - 1] = calculateMissingTimestamp(timestamp, counter);
1301                       }
1302                     }
1303                   }],
1304                   yAxes: [
1305                     {
1306                       id: 'y-axis-1',
1307                       type: 'linear',
1308                       display: true,
1309                       position: 'left'
1310                     }
1311                   ]
1312                 },
1313                 tooltips: {
1314                   enabled: true,
1315                   mode: 'point',
1316                   callbacks: {
1317                     title: function (tooltipItem, data) { //picks right tool tip
1318                       var vaue = $scope.transmissiontoolTipMap.get(tooltipItem[0].xLabel);
1319                       return vaue;
1320                     }
1321                   }
1322                 },
1323                 legend: {
1324                   display: true,
1325                   position: "bottom"
1326                 }
1327               };
1328
1329
1330               $scope.transmissiontestMap = new Map();
1331               $scope.transmissiontoolTipMap = new Map();
1332
1333               tempArr.map(function (item, index) {
1334                 $scope.transmissiontestMap.set(item, index);
1335                 $scope.transmissiontoolTipMap.set(index, item);
1336               });
1337
1338               var maxListA = [];
1339               var minListA = [];
1340               var avgListA = [];
1341
1342               dataA.data.hits.hits.map(function (item, index) {
1343                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
1344
1345                 var test = $scope.transmissiontestMap.get(timestamp);
1346                 if (test) {
1347                   maxListA.push({ x: test, y: item._source['performance-data']['tx-level-max'] });
1348                   minListA.push({ x: test, y: item._source['performance-data']['tx-level-min'] });
1349                   avgListA.push({ x: test, y: item._source['performance-data']['tx-level-avg'] });
1350                 } else {
1351
1352                   maxListA.push({ x: 0, y: item._source['performance-data']['tx-level-max'] });
1353                   minListA.push({ x: 0, y: item._source['performance-data']['tx-level-min'] });
1354                   avgListA.push({ x: 0, y: item._source['performance-data']['tx-level-avg'] });
1355                 }
1356               });
1357
1358               $scope.transmissionSeries.push('Tx max A', 'Tx min A', 'Tx avg A');
1359
1360
1361               $scope.transmissionData.push(maxListA);
1362               $scope.transmissionData.push(minListA);
1363               $scope.transmissionData.push(avgListA);
1364
1365               $scope.transmissionDatasetOverride.push({ yAxisID: 'y-axis-1' });
1366               $scope.transmissionDatasetOverride.push({ yAxisID: 'y-axis-1' });
1367               $scope.transmissionDatasetOverride.push({ yAxisID: 'y-axis-1' });
1368
1369               var maxListB = [];
1370               var minListB = [];
1371               var avgListB = [];
1372
1373               dataB.data.hits.hits.map(function (item, index) {
1374                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
1375                 var test = $scope.transmissiontestMap.get(timestamp);
1376                 if (test) {
1377                   maxListB.push({ x: test, y: item._source['performance-data']['tx-level-max'] });
1378                   minListB.push({ x: test, y: item._source['performance-data']['tx-level-min'] });
1379                   avgListB.push({ x: test, y: item._source['performance-data']['tx-level-avg'] });
1380                 } else {
1381
1382                   maxListB.push({ x: 0, y: item._source['performance-data']['tx-level-max'] });
1383                   minListB.push({ x: 0, y: item._source['performance-data']['tx-level-min'] });
1384                   avgListB.push({ x: 0, y: item._source['performance-data']['tx-level-avg'] });
1385                 }
1386               });
1387
1388               $scope.transmissionSeries.push('Tx max B', 'Tx min B', 'Tx avg B');
1389
1390               $scope.transmissionData.push(maxListB);
1391               $scope.transmissionData.push(minListB);
1392               $scope.transmissionData.push(avgListB);
1393
1394               $scope.transmissionDatasetOverride.push({ yAxisID: 'y-axis-1' });
1395               $scope.transmissionDatasetOverride.push({ yAxisID: 'y-axis-1' });
1396               $scope.transmissionDatasetOverride.push({ yAxisID: 'y-axis-1' });
1397
1398               overridePoints($scope.transmissionSeries, $scope.transmissionDatasetOverride);
1399             }
1400
1401               break;
1402
1403             case 'modulation': {
1404
1405               $scope.modulationData = [];
1406               $scope.modultaionSeries = [];
1407               $scope.modulationDatasetOverride = [];
1408
1409               $scope.modulationOptions = {
1410                 scales: {
1411                   xAxes: [{
1412                     type: 'linear',
1413                     position: 'bottom',
1414                     afterTickToLabelConversion: function (data) { //adds our custom timestamp labels
1415
1416                       var xLabels = data.ticks;
1417                       xLabels.forEach(function (labels, i) {
1418                         var timestamp = $scope.modLabelMap.get(parseInt(labels));
1419                         if (parseInt(labels) == labels)
1420                           xLabels[i] = timestamp;
1421                         else
1422                           xLabels[i] = '';
1423
1424                       });
1425
1426                       //calculate last timestamp if label is missing
1427                       if (xLabels[xLabels.length - 1] === undefined) {
1428                         var timestamp = $scope.modLabelMap.get($scope.modLabelMap.size - 1);
1429                         let stopper = true;
1430                         let counter = 0;
1431                         let labelLength = xLabels.length - 1;
1432                         while (stopper) {
1433                           if (labelLength % 10 == 0) {
1434                             stopper = false;
1435                           } else {
1436                             labelLength++;
1437                             counter++;
1438                           }
1439
1440                         }
1441
1442                         xLabels[xLabels.length - 1] = calculateMissingTimestamp(timestamp, counter);
1443                       }
1444                     }
1445                   }],
1446                   yAxes: [
1447                     {
1448                       id: 'y-axis-1',
1449                       type: 'linear',
1450                       display: true,
1451                       position: 'left'
1452                     }
1453                   ]
1454                 },
1455                 tooltips: {
1456                   enabled: true,
1457                   mode: 'point',
1458                   callbacks: {
1459                     title: function (tooltipItem, data) { //picks right tool tip
1460
1461                       var vaue = $scope.modtestMap.get(tooltipItem[0].xLabel);
1462                       return vaue;
1463                     }
1464                   }
1465                 },
1466                 legend: {
1467                   display: true,
1468                   position: "bottom"
1469                 }
1470
1471               };
1472
1473               $scope.modtestMap = new Map();
1474               $scope.modLabelMap = new Map();
1475
1476               tempArr.map(function (item, index) {
1477                 $scope.modtestMap.set(item, index);
1478                 $scope.modLabelMap.set(index, item);
1479               });
1480
1481               var time2S = [];
1482               var time2 = [];
1483               var time2L = [];
1484               var time4S = [];
1485               var time4 = [];
1486               var time4L = [];
1487               var time16S = [];
1488               var time16 = [];
1489               var time16L = [];
1490               var time32S = [];
1491               var time32 = [];
1492               var time32L = [];
1493               var time64S = [];
1494               var time64 = [];
1495               var time64L = [];
1496               var time128S = [];
1497               var time128 = [];
1498               var time128L = [];
1499               var time256S = [];
1500               var time256 = [];
1501               var time256L = [];
1502               var time512S = [];
1503               var time512 = [];
1504               var time512L = [];
1505               var time1024S = [];
1506               var time1024 = [];
1507               var time1024L = [];
1508               var time2048S = [];
1509               var time2048 = [];
1510               var time2048L = [];
1511               var time4096S = [];
1512               var time4096 = [];
1513               var time4096L = [];
1514               var time8192S = [];
1515               var time8192 = [];
1516               var time8192L = [];
1517
1518               dataA.data.hits.hits.map(function (item, index) {
1519                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
1520
1521                 var test = $scope.modtestMap.get(timestamp);
1522                 if (test) {
1523
1524                   //check if data is not undefined, if yes: add
1525                   let t2s = checkData(item._source['performance-data']['time2-states-s']);
1526                   if (t2s != undefined)
1527                     time2S.push({ x: test, y: t2s });
1528
1529                   let t2 = checkData(item._source['performance-data']['time2-states']);
1530                   if (t2 != undefined)
1531                     time2.push({ x: test, y: t2 });
1532
1533                   let t2L = checkData(item._source['performance-data']['time2-states-l']);
1534                   if (t2L != undefined)
1535                     time2L.push({ x: test, y: t2L });
1536
1537                   let t4s = checkData(item._source['performance-data']['time4-states-s']);
1538                   if (t4s != undefined)
1539                     time4S.push({ x: test, y: t4s });
1540
1541                   let t4 = checkData(item._source['performance-data']['time4-states']);
1542                   if (t4 != undefined)
1543                     time4.push({ x: test, y: t4 });
1544
1545                   let t4L = checkData(item._source['performance-data']['time4-states-l']);
1546                   if (t4L != undefined)
1547                     time4L.push({ x: test, y: t4L });
1548
1549                   let t16s = checkData(item._source['performance-data']['time16-states-s']);
1550                   if (t16s != undefined)
1551                     time16S.push({ x: test, y: t16s });
1552
1553
1554                   let t16 = checkData(item._source['performance-data']['time16-states']);
1555                   if (t16 != undefined)
1556                     time16.push({ x: test, y: t16 });
1557
1558
1559                   let t16L = checkData(item._source['performance-data']['time16-states-l']);
1560                   if (t16L != undefined)
1561                     time16L.push({ x: test, y: t16L });
1562
1563                   let t32s = checkData(item._source['performance-data']['time32-states-s']);
1564                   if (t32s != undefined)
1565                     time32S.push({ x: test, y: t32s });
1566
1567                   let t32 = checkData(item._source['performance-data']['time32-states']);
1568                   if (t32 != undefined)
1569                     time32.push({ x: test, y: t32 });
1570
1571
1572                   let t32L = checkData(item._source['performance-data']['time32-states-l']);
1573                   if (t32L != undefined)
1574                     time32L.push({ x: test, y: t32L });
1575
1576
1577
1578                   let t64s = checkData(item._source['performance-data']['time64-states-s']);
1579                   if (t64s != undefined)
1580                     time64S.push({ x: test, y: t64s });
1581
1582                   let t64 = checkData(item._source['performance-data']['time64-states']);
1583                   if (t64 != undefined)
1584                     time64.push({ x: test, y: t64 });
1585
1586                   let t64L = checkData(item._source['performance-data']['time64-states-l']);
1587                   if (t64L != undefined)
1588                     time64L.push({ x: test, y: t64L });
1589
1590
1591                   let t128s = checkData(item._source['performance-data']['time128-states-s']);
1592                   if (t128s != undefined)
1593                     time128S.push({ x: test, y: t128s });
1594
1595                   let t128 = checkData(item._source['performance-data']['time128-states']);
1596                   if (t128 != undefined)
1597                     time128.push({ x: test, y: t128 });
1598
1599                   let t128L = checkData(item._source['performance-data']['time128-states-l']);
1600                   if (t128L != undefined)
1601                     time128L.push({ x: test, y: t128L });
1602
1603
1604                   let t256s = checkData(item._source['performance-data']['time256-states-s']);
1605                   if (t256s != undefined)
1606                     time256S.push({ x: test, y: t256s });
1607
1608                   let t256 = checkData(item._source['performance-data']['time256-states']);
1609                   if (t256 != undefined)
1610                     time256.push({ x: test, y: t256 });
1611
1612                   let t256L = checkData(item._source['performance-data']['time256-states-l']);
1613                   if (t256L != undefined)
1614                     time256L.push({ x: test, y: t256L });
1615
1616                   let t512s = checkData(item._source['performance-data']['time512-states-s']);
1617                   if (t512s != undefined)
1618                     time512S.push({ x: test, y: t512s });
1619
1620                   let t512 = checkData(item._source['performance-data']['time512-states']);
1621                   if (t512 != undefined)
1622                     time512.push({ x: test, y: t512 });
1623
1624                   let t512L = checkData(item._source['performance-data']['time512-states-l']);
1625                   if (t512L != undefined)
1626                     time512L.push({ x: test, y: t512L });
1627
1628                   let t1024s = checkData(item._source['performance-data']['time1024-states-s']);
1629                   if (t1024s != undefined)
1630                     time1024S.push({ x: test, y: t1024s });
1631
1632                   let t1024 = checkData(item._source['performance-data']['time1024-states']);
1633                   if (t1024 != undefined)
1634                     time1024.push({ x: test, y: t1024 });
1635
1636                   let t1024L = checkData(item._source['performance-data']['time1024-states-l']);
1637                   if (t1024L != undefined)
1638                     time1024L.push({ x: test, y: t1024L });
1639
1640                   let t2048s = checkData(item._source['performance-data']['time2048-states-s']);
1641                   if (t2048s != undefined)
1642                     time2048S.push({ x: test, y: t2048s });
1643
1644                   let t2048 = checkData(item._source['performance-data']['time2048-states']);
1645                   if (t2048 != undefined)
1646                     time2048.push({ x: test, y: t2048 });
1647
1648                   let t2048L = checkData(item._source['performance-data']['time2048-states-l']);
1649                   if (t2048L != undefined)
1650                     time2048L.push({ x: test, y: t2048L });
1651
1652                   let t4096s = checkData(item._source['performance-data']['time4096-states-s']);
1653                   if (t4096s != undefined)
1654                     time4096S.push({ x: test, y: t4096s });
1655
1656                   let t4096 = checkData(item._source['performance-data']['time4096-states']);
1657                   if (t4096 != undefined)
1658                     time4096.push({ x: test, y: t4096 });
1659
1660                   let t4096L = checkData(item._source['performance-data']['time4096-states-l']);
1661                   if (t4096L != undefined)
1662                     time4096L.push({ x: test, y: t4096L });
1663
1664                   let t8192s = checkData(item._source['performance-data']['time8192-states-s']);
1665                   if (t8192s != undefined)
1666                     time8192S.push({ x: test, y: t8192s });
1667
1668                   let t8192 = checkData(item._source['performance-data']['time8192-states']);
1669                   if (t8192 != undefined)
1670                     time8192.push({ x: test, y: t8192 });
1671
1672                   let t8192L = checkData(item._source['performance-data']['time8192-states-l']);
1673                   if (t8192L != undefined)
1674                     time8192L.push({ x: test, y: t8192L });
1675
1676                 } else {
1677
1678                   let t2s = checkData(item._source['performance-data']['time2-states-s']);
1679                   if (t2s != undefined)
1680                     time2S.push({ x: 0, y: t2s });
1681
1682                   let t2 = checkData(item._source['performance-data']['time2-states']);
1683                   if (t2 != undefined)
1684                     time2.push({ x: 0, y: t2 });
1685
1686                   let t2L = checkData(item._source['performance-data']['time2-states-l']);
1687                   if (t2L != undefined)
1688                     time2L.push({ x: 0, y: t2L });
1689
1690                   let t4s = checkData(item._source['performance-data']['time4-states-s']);
1691                   if (t4s != undefined)
1692                     time4S.push({ x: 0, y: t4s });
1693
1694                   let t4 = checkData(item._source['performance-data']['time4-states']);
1695                   if (t4 != undefined)
1696                     time4.push({ x: 0, y: t4 });
1697
1698                   let t4L = checkData(item._source['performance-data']['time4-states-l']);
1699                   if (t4L != undefined)
1700                     time4L.push({ x: 0, y: t4L });
1701
1702                   let t16s = checkData(item._source['performance-data']['time16-states-s']);
1703                   if (t16s != undefined)
1704                     time16S.push({ x: 0, y: t16s });
1705
1706
1707                   let t16 = checkData(item._source['performance-data']['time16-states']);
1708                   if (t16 != undefined)
1709                     time16.push({ x: 0, y: t16 });
1710
1711
1712                   let t16L = checkData(item._source['performance-data']['time16-states-l']);
1713                   if (t16L != undefined)
1714                     time16L.push({ x: 0, y: t16L });
1715
1716                   let t32s = checkData(item._source['performance-data']['time32-states-s']);
1717                   if (t32s != undefined)
1718                     time32S.push({ x: 0, y: t32s });
1719
1720                   let t32 = checkData(item._source['performance-data']['time32-states']);
1721                   if (t32 != undefined)
1722                     time32.push({ x: 0, y: t32 });
1723
1724
1725                   let t32L = checkData(item._source['performance-data']['time32-states-l']);
1726                   if (t32L != undefined)
1727                     time32L.push({ x: 0, y: t32L });
1728
1729                   let t64s = checkData(item._source['performance-data']['time64-states-s']);
1730                   if (t64s != undefined)
1731                     time64S.push({ x: 0, y: t64s });
1732
1733                   let t64 = checkData(item._source['performance-data']['time64-states']);
1734                   if (t64 != undefined)
1735                     time64.push({ x: 0, y: t64 });
1736
1737                   let t64L = checkData(item._source['performance-data']['time64-states-l']);
1738                   if (t64L != undefined)
1739                     time64L.push({ x: 0, y: t64L });
1740
1741
1742                   let t128s = checkData(item._source['performance-data']['time128-states-s']);
1743                   if (t128s != undefined)
1744                     time128S.push({ x: 0, y: t128s });
1745
1746                   let t128 = checkData(item._source['performance-data']['time128-states']);
1747                   if (t128 != undefined)
1748                     time128.push({ x: 0, y: t128 });
1749
1750                   let t128L = checkData(item._source['performance-data']['time128-states-l']);
1751                   if (t128L != undefined)
1752                     time128L.push({ x: 0, y: t128L });
1753
1754
1755                   let t256s = checkData(item._source['performance-data']['time256-states-s']);
1756                   if (t256s != undefined)
1757                     time256S.push({ x: 0, y: t256s });
1758
1759                   let t256 = checkData(item._source['performance-data']['time256-states']);
1760                   if (t256 != undefined)
1761                     time256.push({ x: 0, y: t256 });
1762
1763                   let t256L = checkData(item._source['performance-data']['time256-states-l']);
1764                   if (t256L != undefined)
1765                     time256L.push({ x: 0, y: t256L });
1766
1767                   let t512s = checkData(item._source['performance-data']['time512-states-s']);
1768                   if (t512s != undefined)
1769                     time512S.push({ x: 0, y: t512s });
1770
1771                   let t512 = checkData(item._source['performance-data']['time512-states']);
1772                   if (t512 != undefined)
1773                     time512.push({ x: 0, y: t512 });
1774
1775                   let t512L = checkData(item._source['performance-data']['time512-states-l']);
1776                   if (t512L != undefined)
1777                     time512L.push({ x: 0, y: t512L });
1778
1779                   let t1024s = checkData(item._source['performance-data']['time1024-states-s']);
1780                   if (t1024s != undefined)
1781                     time1024S.push({ x: 0, y: t1024s });
1782
1783                   let t1024 = checkData(item._source['performance-data']['time1024-states']);
1784                   if (t1024 != undefined)
1785                     time1024.push({ x: 0, y: t1024 });
1786
1787                   let t1024L = checkData(item._source['performance-data']['time1024-states-l']);
1788                   if (t1024L != undefined)
1789                     time1024L.push({ x: 0, y: t1024L });
1790
1791                   let t2048s = checkData(item._source['performance-data']['time2048-states-s']);
1792                   if (t2048s != undefined)
1793                     time2048S.push({ x: 0, y: t2048s });
1794
1795                   let t2048 = checkData(item._source['performance-data']['time2048-states']);
1796                   if (t2048 != undefined)
1797                     time2048.push({ x: 0, y: t2048 });
1798
1799                   let t2048L = checkData(item._source['performance-data']['time2048-states-l']);
1800                   if (t2048L != undefined)
1801                     time2048L.push({ x: 0, y: t2048L });
1802
1803                   let t4096s = checkData(item._source['performance-data']['time4096-states-s']);
1804                   if (t4096s != undefined)
1805                     time4096S.push({ x: 0, y: t4096s });
1806
1807                   let t4096 = checkData(item._source['performance-data']['time4096-states']);
1808                   if (t4096 != undefined)
1809                     time4096.push({ x: 0, y: t4096 });
1810
1811                   let t4096L = checkData(item._source['performance-data']['time4096-states-l']);
1812                   if (t4096L != undefined)
1813                     time4096L.push({ x: 0, y: t4096L });
1814
1815                   let t8192s = checkData(item._source['performance-data']['time8192-states-s']);
1816                   if (t8192s != undefined)
1817                     time8192S.push({ x: 0, y: t8192s });
1818
1819                   let t8192 = checkData(item._source['performance-data']['time8192-states']);
1820                   if (t8192 != undefined)
1821                     time8192.push({ x: 0, y: t8192 });
1822
1823                   let t8192L = checkData(item._source['performance-data']['time8192-states-l']);
1824                   if (t8192L != undefined)
1825                     time8192L.push({ x: 0, y: t8192L });
1826
1827                 }
1828               });
1829
1830               //check, if array has items, if yes: add series and data to chart
1831               //reduces amount of labels shown in chart => shows only series' with data
1832               if (time2S.length > 0) {
1833                 $scope.modultaionSeries.push('QAM2S A');
1834                 $scope.modulationData.push(time2S);
1835               }
1836
1837               if (time2.length > 0) {
1838                 $scope.modultaionSeries.push('QAM2 A');
1839                 $scope.modulationData.push(time2);
1840               }
1841
1842               if (time2L.length > 0) {
1843                 $scope.modultaionSeries.push('QAM2L A');
1844                 $scope.modulationData.push(time2L);
1845               }
1846
1847               if (time4S.length > 0) {
1848                 $scope.modultaionSeries.push('QAM4S A');
1849                 $scope.modulationData.push(time4S);
1850               }
1851
1852               if (time4.length > 0) {
1853                 $scope.modultaionSeries.push('QAM4 A');
1854                 $scope.modulationData.push(time4);
1855               }
1856
1857               if (time4L.length > 0) {
1858                 $scope.modultaionSeries.push('QAM4L A');
1859                 $scope.modulationData.push(time4L);
1860               }
1861
1862               if (time16S.length > 0) {
1863                 $scope.modultaionSeries.push('QAM16S A');
1864                 $scope.modulationData.push(time16S);
1865               }
1866
1867
1868               if (time16.length > 0) {
1869                 $scope.modultaionSeries.push('QAM16 A');
1870                 $scope.modulationData.push(time16);
1871               }
1872
1873               if (time16L.length > 0) {
1874                 $scope.modultaionSeries.push('QAM16L A');
1875                 $scope.modulationData.push(time16L);
1876               }
1877
1878               if (time32S.length > 0) {
1879                 $scope.modulationData.push(time32S);
1880                 $scope.modultaionSeries.push('QAM32S A');
1881               }
1882
1883               if (time32.length > 0) {
1884                 $scope.modulationData.push(time32);
1885                 $scope.modultaionSeries.push('QAM32 A');
1886               }
1887
1888               if (time32L.length > 0) {
1889                 $scope.modulationData.push(time32L);
1890                 $scope.modultaionSeries.push('QAM32L A');
1891               }
1892
1893
1894               if (time64S.length > 0) {
1895                 $scope.modulationData.push(time64S);
1896                 $scope.modultaionSeries.push('QAM64S A');
1897               }
1898
1899
1900               if (time64.length > 0) {
1901                 $scope.modulationData.push(time64);
1902                 $scope.modultaionSeries.push('QAM64 A');
1903               }
1904
1905               if (time64L.length > 0) {
1906                 $scope.modulationData.push(time64L);
1907                 $scope.modultaionSeries.push('QAM64L A');
1908               }
1909
1910
1911               if (time128S.length > 0) {
1912                 $scope.modultaionSeries.push('QAM128S A');
1913                 $scope.modulationData.push(time128S);
1914               }
1915
1916               if (time128.length > 0) {
1917                 $scope.modultaionSeries.push('QAM128 A');
1918                 $scope.modulationData.push(time128);
1919               }
1920
1921               if (time128L.length > 0) {
1922                 $scope.modultaionSeries.push('QAM128L A');
1923                 $scope.modulationData.push(time128L);
1924               }
1925
1926               if (time256S.length > 0) {
1927                 $scope.modulationData.push(time256S);
1928                 $scope.modultaionSeries.push('QAM256S A');
1929               }
1930
1931               if (time256.length > 0) {
1932                 $scope.modulationData.push(time256);
1933                 $scope.modultaionSeries.push('QAM256 A');
1934               }
1935
1936               if (time256L.length > 0) {
1937                 $scope.modulationData.push(time256L);
1938                 $scope.modultaionSeries.push('QAM256L A');
1939               }
1940
1941               if (time512S.length > 0) {
1942                 $scope.modultaionSeries.push('QAM512S A');
1943                 $scope.modulationData.push(time512S);
1944               }
1945
1946               if (time512.length > 0) {
1947                 $scope.modultaionSeries.push('QAM512 A');
1948                 $scope.modulationData.push(time512);
1949               }
1950
1951               if (time512S.length > 0) {
1952                 $scope.modultaionSeries.push('QAM512S A');
1953                 $scope.modulationData.push(time512S);
1954               }
1955
1956               if (time512.length > 0) {
1957                 $scope.modultaionSeries.push('QAM512 A');
1958                 $scope.modulationData.push(time512);
1959               }
1960
1961               if (time512L.length > 0) {
1962                 $scope.modultaionSeries.push('QAM512L A');
1963                 $scope.modulationData.push(time512L);
1964
1965               }
1966
1967               if (time1024S.length > 0) {
1968                 $scope.modultaionSeries.push('QAM1024S A');
1969                 $scope.modulationData.push(time1024S);
1970               }
1971
1972               if (time1024.length > 0) {
1973                 $scope.modultaionSeries.push('QAM1024 A');
1974                 $scope.modulationData.push(time1024);
1975               }
1976
1977
1978               if (time1024L.length > 0) {
1979                 $scope.modultaionSeries.push('QAM1024L A');
1980                 $scope.modulationData.push(time1024L);
1981               }
1982
1983
1984               if (time2048S.length > 0) {
1985                 $scope.modultaionSeries.push('QAM2048S A');
1986                 $scope.modulationData.push(time2048S);
1987               }
1988
1989               if (time2048.length > 0) {
1990                 $scope.modultaionSeries.push('QAM2048 A');
1991                 $scope.modulationData.push(time2048);
1992               }
1993
1994               if (time2048L.length > 0) {
1995                 $scope.modultaionSeries.push('QAM2048L A');
1996                 $scope.modulationData.push(time2048L);
1997
1998               }
1999
2000               if (time4096S.length > 0) {
2001                 $scope.modultaionSeries.push('QAM4096S A');
2002                 $scope.modulationData.push(time4096S);
2003               }
2004
2005               if (time4096.length > 0) {
2006                 $scope.modultaionSeries.push('QAM4096 A');
2007                 $scope.modulationData.push(time4096);
2008               }
2009
2010
2011               if (time4096L.length > 0) {
2012                 $scope.modultaionSeries.push('QAM4096L A');
2013                 $scope.modulationData.push(time4096L);
2014               }
2015
2016               if (time8192S.length > 0) {
2017                 $scope.modultaionSeries.push('QAM8192S A');
2018                 $scope.modulationData.push(time8192S);
2019               }
2020
2021
2022               if (time8192.length > 0) {
2023                 $scope.modultaionSeries.push('QAM8192 A');
2024                 $scope.modulationData.push(time8192);
2025               }
2026
2027               if (time8192L.length > 0) {
2028                 $scope.modultaionSeries.push('QAM8192L A');
2029                 $scope.modulationData.push(time8192L);
2030               }
2031
2032               //process data for b side
2033
2034               time2S = [];
2035               time2 = [];
2036               time2L = [];
2037               time4S = [];
2038               time4 = [];
2039               time4L = [];
2040               time16S = [];
2041               time16 = [];
2042               time16L = [];
2043               time32S = [];
2044               time32 = [];
2045               time32L = [];
2046               time64S = [];
2047               time64 = [];
2048               time64L = [];
2049               time128S = [];
2050               time128 = [];
2051               time128L = [];
2052               time256S = [];
2053               time256 = [];
2054               time256L = [];
2055               time512S = [];
2056               time512 = [];
2057               time512L = [];
2058               time1024S = [];
2059               time1024 = [];
2060               time1024L = [];
2061               time2048S = [];
2062               time2048 = [];
2063               time2048L = [];
2064               time4096S = [];
2065               time4096 = [];
2066               time4096L = [];
2067               time8192S = [];
2068               time8192 = [];
2069               time8192L = [];
2070
2071               dataB.data.hits.hits.map(function (item, index) {
2072                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
2073                 var test = $scope.modtestMap.get(timestamp);
2074                 if (test) {
2075                   let t2s = checkData(item._source['performance-data']['time2-states-s']);
2076                   if (t2s != undefined)
2077                     time2S.push({ x: test, y: t2s });
2078
2079                   let t2 = checkData(item._source['performance-data']['time2-states']);
2080                   if (t2 != undefined)
2081                     time2.push({ x: test, y: t2 });
2082
2083                   let t2L = checkData(item._source['performance-data']['time2-states-l']);
2084                   if (t2L != undefined)
2085                     time2L.push({ x: test, y: t2L });
2086
2087                   let t4s = checkData(item._source['performance-data']['time4-states-s']);
2088                   if (t4s != undefined)
2089                     time4S.push({ x: test, y: t4s });
2090
2091                   let t4 = checkData(item._source['performance-data']['time4-states']);
2092                   if (t4 != undefined)
2093                     time4.push({ x: test, y: t4 });
2094
2095                   let t4L = checkData(item._source['performance-data']['time4-states-l']);
2096                   if (t4L != undefined)
2097                     time4L.push({ x: test, y: t4L });
2098
2099                   let t16s = checkData(item._source['performance-data']['time16-states-s']);
2100                   if (t16s != undefined)
2101                     time16S.push({ x: test, y: t16s });
2102
2103
2104                   let t16 = checkData(item._source['performance-data']['time16-states']);
2105                   if (t16 != undefined)
2106                     time16.push({ x: test, y: t16 });
2107
2108
2109                   let t16L = checkData(item._source['performance-data']['time16-states-l']);
2110                   if (t16L != undefined)
2111                     time16L.push({ x: test, y: t16L });
2112
2113                   let t32s = checkData(item._source['performance-data']['time32-states-s']);
2114                   if (t32s != undefined)
2115                     time32S.push({ x: test, y: t32s });
2116
2117                   let t32 = checkData(item._source['performance-data']['time32-states']);
2118                   if (t32 != undefined)
2119                     time32.push({ x: test, y: t32 });
2120
2121
2122                   let t32L = checkData(item._source['performance-data']['time32-states-l']);
2123                   if (t32L != undefined)
2124                     time32L.push({ x: test, y: t32L });
2125
2126
2127
2128                   let t64s = checkData(item._source['performance-data']['time64-states-s']);
2129                   if (t64s != undefined)
2130                     time64S.push({ x: test, y: t64s });
2131
2132                   let t64 = checkData(item._source['performance-data']['time64-states']);
2133                   if (t64 != undefined)
2134                     time64.push({ x: test, y: t64 });
2135
2136                   let t64L = checkData(item._source['performance-data']['time64-states-l']);
2137                   if (t64L != undefined)
2138                     time64L.push({ x: test, y: t64L });
2139
2140
2141                   let t128s = checkData(item._source['performance-data']['time128-states-s']);
2142                   if (t128s != undefined)
2143                     time128S.push({ x: test, y: t128s });
2144
2145                   let t128 = checkData(item._source['performance-data']['time128-states']);
2146                   if (t128 != undefined)
2147                     time128.push({ x: test, y: t128 });
2148
2149                   let t128L = checkData(item._source['performance-data']['time128-states-l']);
2150                   if (t128L != undefined)
2151                     time128L.push({ x: test, y: t128L });
2152
2153
2154                   let t256s = checkData(item._source['performance-data']['time256-states-s']);
2155                   if (t256s != undefined)
2156                     time256S.push({ x: test, y: t256s });
2157
2158                   let t256 = checkData(item._source['performance-data']['time256-states']);
2159                   if (t256 != undefined)
2160                     time256.push({ x: test, y: t256 });
2161
2162                   let t256L = checkData(item._source['performance-data']['time256-states-l']);
2163                   if (t256L != undefined)
2164                     time256L.push({ x: test, y: t256L });
2165
2166                   let t512s = checkData(item._source['performance-data']['time512-states-s']);
2167                   if (t512s != undefined)
2168                     time512S.push({ x: test, y: t512s });
2169
2170                   let t512 = checkData(item._source['performance-data']['time512-states']);
2171                   if (t512 != undefined)
2172                     time512.push({ x: test, y: t512 });
2173
2174                   let t512L = checkData(item._source['performance-data']['time512-states-l']);
2175                   if (t512L != undefined)
2176                     time512L.push({ x: test, y: t512L });
2177
2178                   let t1024s = checkData(item._source['performance-data']['time1024-states-s']);
2179                   if (t1024s != undefined)
2180                     time1024S.push({ x: test, y: t1024s });
2181
2182                   let t1024 = checkData(item._source['performance-data']['time1024-states']);
2183                   if (t1024 != undefined)
2184                     time1024.push({ x: test, y: t1024 });
2185
2186                   let t1024L = checkData(item._source['performance-data']['time1024-states-l']);
2187                   if (t1024L != undefined)
2188                     time1024L.push({ x: test, y: t1024L });
2189
2190                   let t2048s = checkData(item._source['performance-data']['time2048-states-s']);
2191                   if (t2048s != undefined)
2192                     time2048S.push({ x: test, y: t2048s });
2193
2194                   let t2048 = checkData(item._source['performance-data']['time2048-states']);
2195                   if (t2048 != undefined)
2196                     time2048.push({ x: test, y: t2048 });
2197
2198                   let t2048L = checkData(item._source['performance-data']['time2048-states-l']);
2199                   if (t2048L != undefined)
2200                     time2048L.push({ x: test, y: t2048L });
2201
2202                   let t4096s = checkData(item._source['performance-data']['time4096-states-s']);
2203                   if (t4096s != undefined)
2204                     time4096S.push({ x: test, y: t4096s });
2205
2206                   let t4096 = checkData(item._source['performance-data']['time4096-states']);
2207                   if (t4096 != undefined)
2208                     time4096.push({ x: test, y: t4096 });
2209
2210                   let t4096L = checkData(item._source['performance-data']['time4096-states-l']);
2211                   if (t4096L != undefined)
2212                     time4096L.push({ x: test, y: t4096L });
2213
2214                   let t8192s = checkData(item._source['performance-data']['time8192-states-s']);
2215                   if (t8192s != undefined)
2216                     time8192S.push({ x: test, y: t8192s });
2217
2218                   let t8192 = checkData(item._source['performance-data']['time8192-states']);
2219                   if (t8192 != undefined)
2220                     time8192.push({ x: test, y: t8192 });
2221
2222                   let t8192L = checkData(item._source['performance-data']['time8192-states-l']);
2223                   if (t8192L != undefined)
2224                     time8192L.push({ x: test, y: t8192L });
2225
2226                 } else {
2227
2228                   let t2s = checkData(item._source['performance-data']['time2-states-s']);
2229                   if (t2s != undefined)
2230                     time2S.push({ x: 0, y: t2s });
2231
2232                   let t2 = checkData(item._source['performance-data']['time2-states']);
2233                   if (t2 != undefined)
2234                     time2.push({ x: 0, y: t2 });
2235
2236                   let t2L = checkData(item._source['performance-data']['time2-states-l']);
2237                   if (t2L != undefined)
2238                     time2L.push({ x: 0, y: t2L });
2239
2240                   let t4s = checkData(item._source['performance-data']['time4-states-s']);
2241                   if (t4s != undefined)
2242                     time4S.push({ x: 0, y: t4s });
2243
2244                   let t4 = checkData(item._source['performance-data']['time4-states']);
2245                   if (t4 != undefined)
2246                     time4.push({ x: 0, y: t4 });
2247
2248                   let t4L = checkData(item._source['performance-data']['time4-states-l']);
2249                   if (t4L != undefined)
2250                     time4L.push({ x: 0, y: t4L });
2251
2252                   let t16s = checkData(item._source['performance-data']['time16-states-s']);
2253                   if (t16s != undefined)
2254                     time16S.push({ x: 0, y: t16s });
2255
2256
2257                   let t16 = checkData(item._source['performance-data']['time16-states']);
2258                   if (t16 != undefined)
2259                     time16.push({ x: 0, y: t16 });
2260
2261
2262                   let t16L = checkData(item._source['performance-data']['time16-states-l']);
2263                   if (t16L != undefined)
2264                     time16L.push({ x: 0, y: t16L });
2265
2266                   let t32s = checkData(item._source['performance-data']['time32-states-s']);
2267                   if (t32s != undefined)
2268                     time32S.push({ x: 0, y: t32s });
2269
2270                   let t32 = checkData(item._source['performance-data']['time32-states']);
2271                   if (t32 != undefined)
2272                     time32.push({ x: 0, y: t32 });
2273
2274
2275                   let t32L = checkData(item._source['performance-data']['time32-states-l']);
2276                   if (t32L != undefined)
2277                     time32L.push({ x: 0, y: t32L });
2278
2279                   let t64s = checkData(item._source['performance-data']['time64-states-s']);
2280                   if (t64s != undefined)
2281                     time64S.push({ x: 0, y: t64s });
2282
2283                   let t64 = checkData(item._source['performance-data']['time64-states']);
2284                   if (t64 != undefined)
2285                     time64.push({ x: 0, y: t64 });
2286
2287                   let t64L = checkData(item._source['performance-data']['time64-states-l']);
2288                   if (t64L != undefined)
2289                     time64L.push({ x: 0, y: t64L });
2290
2291
2292                   let t128s = checkData(item._source['performance-data']['time128-states-s']);
2293                   if (t128s != undefined)
2294                     time128S.push({ x: 0, y: t128s });
2295
2296                   let t128 = checkData(item._source['performance-data']['time128-states']);
2297                   if (t128 != undefined)
2298                     time128.push({ x: 0, y: t128 });
2299
2300                   let t128L = checkData(item._source['performance-data']['time128-states-l']);
2301                   if (t128L != undefined)
2302                     time128L.push({ x: 0, y: t128L });
2303
2304
2305                   let t256s = checkData(item._source['performance-data']['time256-states-s']);
2306                   if (t256s != undefined)
2307                     time256S.push({ x: 0, y: t256s });
2308
2309                   let t256 = checkData(item._source['performance-data']['time256-states']);
2310                   if (t256 != undefined)
2311                     time256.push({ x: 0, y: t256 });
2312
2313                   let t256L = checkData(item._source['performance-data']['time256-states-l']);
2314                   if (t256L != undefined)
2315                     time256L.push({ x: 0, y: t256L });
2316
2317                   let t512s = checkData(item._source['performance-data']['time512-states-s']);
2318                   if (t512s != undefined)
2319                     time512S.push({ x: 0, y: t512s });
2320
2321                   let t512 = checkData(item._source['performance-data']['time512-states']);
2322                   if (t512 != undefined)
2323                     time512.push({ x: 0, y: t512 });
2324
2325                   let t512L = checkData(item._source['performance-data']['time512-states-l']);
2326                   if (t512L != undefined)
2327                     time512L.push({ x: 0, y: t512L });
2328
2329                   let t1024s = checkData(item._source['performance-data']['time1024-states-s']);
2330                   if (t1024s != undefined)
2331                     time1024S.push({ x: 0, y: t1024s });
2332
2333                   let t1024 = checkData(item._source['performance-data']['time1024-states']);
2334                   if (t1024 != undefined)
2335                     time1024.push({ x: 0, y: t1024 });
2336
2337                   let t1024L = checkData(item._source['performance-data']['time1024-states-l']);
2338                   if (t1024L != undefined)
2339                     time1024L.push({ x: 0, y: t1024L });
2340
2341                   let t2048s = checkData(item._source['performance-data']['time2048-states-s']);
2342                   if (t2048s != undefined)
2343                     time2048S.push({ x: 0, y: t2048s });
2344
2345                   let t2048 = checkData(item._source['performance-data']['time2048-states']);
2346                   if (t2048 != undefined)
2347                     time2048.push({ x: 0, y: t2048 });
2348
2349                   let t2048L = checkData(item._source['performance-data']['time2048-states-l']);
2350                   if (t2048L != undefined)
2351                     time2048L.push({ x: 0, y: t2048L });
2352
2353                   let t4096s = checkData(item._source['performance-data']['time4096-states-s']);
2354                   if (t4096s != undefined)
2355                     time4096S.push({ x: 0, y: t4096s });
2356
2357                   let t4096 = checkData(item._source['performance-data']['time4096-states']);
2358                   if (t4096 != undefined)
2359                     time4096.push({ x: 0, y: t4096 });
2360
2361                   let t4096L = checkData(item._source['performance-data']['time4096-states-l']);
2362                   if (t4096L != undefined)
2363                     time4096L.push({ x: 0, y: t4096L });
2364
2365                   let t8192s = checkData(item._source['performance-data']['time8192-states-s']);
2366                   if (t8192s != undefined)
2367                     time8192S.push({ x: 0, y: t8192s });
2368
2369                   let t8192 = checkData(item._source['performance-data']['time8192-states']);
2370                   if (t8192 != undefined)
2371                     time8192.push({ x: 0, y: t8192 });
2372
2373                   let t8192L = checkData(item._source['performance-data']['time8192-states-l']);
2374                   if (t8192L != undefined)
2375                     time8192L.push({ x: 0, y: t8192L });
2376
2377                 }
2378               });
2379
2380               if (time2S.length > 0) {
2381                 $scope.modultaionSeries.push('QAM2S B');
2382                 $scope.modulationData.push(time2S);
2383               }
2384
2385               if (time2.length > 0) {
2386                 $scope.modultaionSeries.push('QAM2 B');
2387                 $scope.modulationData.push(time2);
2388               }
2389
2390               if (time2L.length > 0) {
2391                 $scope.modultaionSeries.push('QAM2L B');
2392                 $scope.modulationData.push(time2L);
2393               }
2394
2395               if (time4S.length > 0) {
2396                 $scope.modultaionSeries.push('QAM4S B');
2397                 $scope.modulationData.push(time4S);
2398               }
2399
2400               if (time4.length > 0) {
2401                 $scope.modultaionSeries.push('QAM4 B');
2402                 $scope.modulationData.push(time4);
2403               }
2404
2405               if (time4L.length > 0) {
2406                 $scope.modultaionSeries.push('QAM4L B');
2407                 $scope.modulationData.push(time4L);
2408               }
2409
2410               if (time16S.length > 0) {
2411                 $scope.modultaionSeries.push('QAM16S B');
2412                 $scope.modulationData.push(time16S);
2413               }
2414
2415
2416               if (time16.length > 0) {
2417                 $scope.modultaionSeries.push('QAM16 B');
2418                 $scope.modulationData.push(time16);
2419               }
2420
2421
2422               if (time16L.length > 0) {
2423                 $scope.modultaionSeries.push('QAM16L B');
2424                 $scope.modulationData.push(time16L);
2425               }
2426
2427               if (time32S.length > 0) {
2428                 $scope.modulationData.push(time32S);
2429                 $scope.modultaionSeries.push('QAM32S B');
2430               }
2431
2432               if (time32.length > 0) {
2433                 $scope.modulationData.push(time32);
2434                 $scope.modultaionSeries.push('QAM32 B');
2435               }
2436
2437               if (time32L.length > 0) {
2438                 $scope.modulationData.push(time32L);
2439                 $scope.modultaionSeries.push('QAM32L B');
2440               }
2441
2442
2443               if (time64S.length > 0) {
2444                 $scope.modulationData.push(time64S);
2445                 $scope.modultaionSeries.push('QAM64S B');
2446               }
2447
2448
2449               if (time64.length > 0) {
2450                 $scope.modulationData.push(time64);
2451                 $scope.modultaionSeries.push('QAM64 B');
2452               }
2453
2454               if (time64L.length > 0) {
2455                 $scope.modulationData.push(time64L);
2456                 $scope.modultaionSeries.push('QAM64L B');
2457               }
2458
2459
2460               if (time128S.length > 0) {
2461                 $scope.modultaionSeries.push('QAM128S B');
2462                 $scope.modulationData.push(time128S);
2463               }
2464
2465               if (time128.length > 0) {
2466                 $scope.modultaionSeries.push('QAM128 B');
2467                 $scope.modulationData.push(time128);
2468               }
2469
2470               if (time128L.length > 0) {
2471                 $scope.modultaionSeries.push('QAM128L B');
2472                 $scope.modulationData.push(time128L);
2473               }
2474
2475               if (time256S.length > 0) {
2476                 $scope.modulationData.push(time256S);
2477                 $scope.modultaionSeries.push('QAM256S B');
2478               }
2479
2480               if (time256.length > 0) {
2481                 $scope.modulationData.push(time256);
2482                 $scope.modultaionSeries.push('QAM256 B');
2483               }
2484
2485               if (time256L.length > 0) {
2486                 $scope.modulationData.push(time256L);
2487                 $scope.modultaionSeries.push('QAM256L B');
2488               }
2489
2490               if (time512S.length > 0) {
2491                 $scope.modultaionSeries.push('QAM512S B');
2492                 $scope.modulationData.push(time512S);
2493
2494               }
2495
2496               if (time512.length > 0) {
2497                 $scope.modultaionSeries.push('QAM512 B');
2498                 $scope.modulationData.push(time512);
2499
2500               }
2501
2502               if (time512S.length > 0) {
2503                 $scope.modultaionSeries.push('QAM512S B');
2504                 $scope.modulationData.push(time512S);
2505               }
2506
2507               if (time512.length > 0) {
2508                 $scope.modultaionSeries.push('QAM512 B');
2509                 $scope.modulationData.push(time512);
2510               }
2511
2512               if (time512L.length > 0) {
2513                 $scope.modultaionSeries.push('QAM512L B');
2514                 $scope.modulationData.push(time512L);
2515               }
2516
2517               if (time1024S.length > 0) {
2518                 $scope.modultaionSeries.push('QAM1024S B');
2519                 $scope.modulationData.push(time1024S);
2520
2521               }
2522
2523               if (time1024.length > 0) {
2524                 $scope.modultaionSeries.push('QAM1024 B');
2525                 $scope.modulationData.push(time1024);
2526               }
2527
2528
2529               if (time1024L.length > 0) {
2530                 $scope.modultaionSeries.push('QAM1024L B');
2531                 $scope.modulationData.push(time1024L);
2532
2533               }
2534
2535
2536               if (time2048S.length > 0) {
2537                 $scope.modultaionSeries.push('QAM2048S B');
2538                 $scope.modulationData.push(time2048S);
2539
2540               }
2541
2542               if (time2048.length > 0) {
2543                 $scope.modultaionSeries.push('QAM2048 B');
2544                 $scope.modulationData.push(time2048);
2545               }
2546
2547               if (time2048L.length > 0) {
2548                 $scope.modultaionSeries.push('QAM2048L B');
2549                 $scope.modulationData.push(time2048L);
2550               }
2551
2552               if (time4096S.length > 0) {
2553                 $scope.modultaionSeries.push('QAM4096S B');
2554                 $scope.modulationData.push(time4096S);
2555               }
2556
2557               if (time4096.length > 0) {
2558                 $scope.modultaionSeries.push('QAM4096 B');
2559                 $scope.modulationData.push(time4096);
2560               }
2561
2562
2563               if (time4096L.length > 0) {
2564                 $scope.modultaionSeries.push('QAM4096L B');
2565                 $scope.modulationData.push(time4096L);
2566
2567               }
2568
2569               if (time8192S.length > 0) {
2570                 $scope.modultaionSeries.push('QAM8192S B');
2571                 $scope.modulationData.push(time8192S);
2572
2573               }
2574
2575
2576               if (time8192.length > 0) {
2577                 $scope.modultaionSeries.push('QAM8192 B');
2578                 $scope.modulationData.push(time8192);
2579
2580               }
2581
2582               if (time8192L.length > 0) {
2583                 $scope.modultaionSeries.push('QAM8192L B');
2584                 $scope.modulationData.push(time8192L);
2585
2586               }
2587
2588               let patternArray = ['rect', 'triangle', 'point', 'cross'];
2589               let patternCounter = 0;
2590
2591               //add y axis override and remove color below graph for all items in chart series
2592               for (let i = 0; i < $scope.modultaionSeries.length; i++) {
2593                 $scope.modulationDatasetOverride.push({ yAxisID: 'y-axis-1' });
2594                 $scope.modulationDatasetOverride[i].fill = false;
2595
2596                 //override points in graph
2597                 $scope.modulationDatasetOverride[i].pointStyle = patternArray[patternCounter];
2598                 patternCounter++;
2599                 if (patternCounter === 4) patternCounter = 0;
2600                 $scope.modulationDatasetOverride[i].pointRadius = 10;
2601
2602               }
2603             }
2604
2605               break;
2606
2607             case 'temperature': {
2608
2609               $scope.tempData = [];
2610               $scope.tempSeries = [];
2611               $scope.tempDatasetOverride = [];
2612
2613               $scope.tempOptions = {
2614                 scales: {
2615                   xAxes: [{
2616                     type: 'linear',
2617                     position: 'bottom',
2618                     afterTickToLabelConversion: function (data) { //adds our custom timestamp labels
2619
2620                       var xLabels = data.ticks;
2621                       xLabels.forEach(function (labels, i) {
2622                         var timestamp = $scope.tempLabelMap.get(parseInt(labels));
2623                         if (parseInt(labels) == labels)
2624                           xLabels[i] = timestamp;
2625                         else
2626                           xLabels[i] = '';
2627                       });
2628
2629                       //calculate last timestamp if label is missing
2630                       if (xLabels[xLabels.length - 1] === undefined) {
2631                         var timestamp = $scope.tempLabelMap.get($scope.tempLabelMap.size - 1);
2632                         let stopper = true;
2633                         let counter = 0;
2634                         let labelLength = xLabels.length - 1;
2635                         while (stopper) {
2636                           if (labelLength % 10 == 0) {
2637                             stopper = false;
2638                           } else {
2639                             labelLength++;
2640                             counter++;
2641                           }
2642                         }
2643
2644                         xLabels[xLabels.length - 1] = calculateMissingTimestamp(timestamp, counter);
2645                       }
2646                     }
2647                   }],
2648                   yAxes: [
2649                     {
2650                       id: 'y-axis-1',
2651                       type: 'linear',
2652                       display: true,
2653                       position: 'left'
2654                     }
2655                   ]
2656                 },
2657                 tooltips: {
2658                   enabled: true,
2659                   mode: 'point',
2660                   callbacks: {
2661                     title: function (tooltipItem, data) { //picks right tool tip
2662
2663                       var vaue = $scope.tempLabelMap.get(tooltipItem[0].xLabel);
2664                       return vaue;
2665                     }
2666                   }
2667                 },
2668                 legend: {
2669                   display: true,
2670                   position: "bottom"
2671                 }
2672               };
2673
2674               $scope.temptestMap = new Map();
2675               $scope.tempLabelMap = new Map();
2676
2677
2678               tempArr.map(function (item, index) {
2679                 $scope.temptestMap.set(item, index);
2680                 $scope.tempLabelMap.set(index, item);
2681               });
2682
2683               //process data for a side
2684               var maxListA = [];
2685               var minListA = [];
2686               var avgListA = [];
2687
2688               dataA.data.hits.hits.map(function (item, index) {
2689                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
2690
2691                 var test = $scope.temptestMap.get(timestamp);
2692                 if (test) {
2693                   maxListA.push({ x: test, y: item._source['performance-data']['rf-temp-max'] });
2694                   minListA.push({ x: test, y: item._source['performance-data']['rf-temp-min'] });
2695                   avgListA.push({ x: test, y: item._source['performance-data']['rf-temp-avg'] });
2696                 } else {
2697
2698                   maxListA.push({ x: 0, y: item._source['performance-data']['rf-temp-max'] });
2699                   minListA.push({ x: 0, y: item._source['performance-data']['rf-temp-min'] });
2700                   avgListA.push({ x: 0, y: item._source['performance-data']['rf-temp-avg'] });
2701                 }
2702               });
2703
2704               $scope.tempSeries.push('Rf temp max A', 'Rf temp min A', 'Rf temp avg A');
2705
2706
2707               $scope.tempData.push(maxListA);
2708               $scope.tempData.push(minListA);
2709               $scope.tempData.push(avgListA);
2710
2711               $scope.tempDatasetOverride.push({ yAxisID: 'y-axis-1' });
2712               $scope.tempDatasetOverride.push({ yAxisID: 'y-axis-1' });
2713               $scope.tempDatasetOverride.push({ yAxisID: 'y-axis-1' });
2714
2715               //process data fro side b
2716
2717               var maxListB = [];
2718               var minListB = [];
2719               var avgListB = [];
2720
2721               dataB.data.hits.hits.map(function (item, index) {
2722                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
2723                 var test = $scope.temptestMap.get(timestamp);
2724                 if (test) {
2725                   maxListB.push({ x: test, y: item._source['performance-data']['rf-temp-max'] });
2726                   minListB.push({ x: test, y: item._source['performance-data']['rf-temp-min'] });
2727                   avgListB.push({ x: test, y: item._source['performance-data']['rf-temp-avg'] });
2728                 } else {
2729
2730                   maxListB.push({ x: 0, y: item._source['performance-data']['rf-temp-max'] });
2731                   minListB.push({ x: 0, y: item._source['performance-data']['rf-temp-min'] });
2732                   avgListB.push({ x: 0, y: item._source['performance-data']['rf-temp-avg'] });
2733                 }
2734               });
2735
2736               $scope.tempSeries.push('Rf temp max B', 'Rf temp min B', 'Rf temp avg B');
2737
2738
2739
2740               $scope.tempData.push(maxListB);
2741               $scope.tempData.push(minListB);
2742               $scope.tempData.push(avgListB);
2743
2744               $scope.tempDatasetOverride.push({ yAxisID: 'y-axis-1' });
2745               $scope.tempDatasetOverride.push({ yAxisID: 'y-axis-1' });
2746               $scope.tempDatasetOverride.push({ yAxisID: 'y-axis-1' });
2747
2748               overridePoints($scope.tempSeries, $scope.tempDatasetOverride);
2749             }
2750               break;
2751
2752             case 'snir': {
2753
2754               $scope.snirChartData = [];
2755               $scope.snirSeries = [];
2756               $scope.snirsetOverride = [];
2757
2758               $scope.snirOptions = {
2759                 scales: {
2760                   xAxes: [{
2761                     type: 'linear',
2762                     position: 'bottom',
2763                     afterTickToLabelConversion: function (data) { //adds our custom timestamp labels
2764
2765                       var xLabels = data.ticks;
2766                       xLabels.forEach(function (labels, i) {
2767                         var timestamp = $scope.snirLabelMap.get(parseInt(labels));
2768                         if (parseInt(labels) == labels)
2769                           xLabels[i] = timestamp;
2770                         else
2771                           xLabels[i] = '';
2772                       });
2773
2774                       //calculate last timestamp if label is missing
2775                       if (xLabels[xLabels.length - 1] === undefined) {
2776                         var timestamp = $scope.snirLabelMap.get($scope.snirLabelMap.size - 1);
2777                         let stopper = true;
2778                         let counter = 0;
2779                         let labelLength = xLabels.length - 1;
2780                         while (stopper) {
2781                           if (labelLength % 10 == 0) {
2782                             stopper = false;
2783                           } else {
2784                             labelLength++;
2785                             counter++;
2786                           }
2787                         }
2788
2789                         xLabels[xLabels.length - 1] = calculateMissingTimestamp(timestamp, counter);
2790                       }
2791                     }
2792                   }],
2793                   yAxes: [
2794                     {
2795                       id: 'y-axis-1',
2796                       type: 'linear',
2797                       display: true,
2798                       position: 'left'
2799                     }
2800                   ]
2801                 },
2802                 tooltips: {
2803                   enabled: true,
2804                   mode: 'point',
2805                   callbacks: {
2806                     title: function (tooltipItem, data) { //picks right tool tip
2807
2808                       var vaue = $scope.snirLabelMap.get(tooltipItem[0].xLabel);
2809                       return vaue;
2810                     }
2811                   }
2812                 },
2813                 legend: {
2814                   display: true,
2815                   position: "bottom"
2816                 }
2817               };
2818
2819               $scope.snirtestMap = new Map();
2820               $scope.snirLabelMap = new Map();
2821
2822               tempArr.map(function (item, index) {
2823                 $scope.snirtestMap.set(item, index);
2824                 $scope.snirLabelMap.set(index, item);
2825               });
2826
2827               var maxListA = [];
2828               var minListA = [];
2829               var avgListA = [];
2830
2831               dataA.data.hits.hits.map(function (item, index) {
2832                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
2833
2834                 var test = $scope.snirtestMap.get(timestamp);
2835                 if (test) {
2836                   maxListA.push({ x: test, y: item._source['performance-data']['rf-temp-max'] });
2837                   minListA.push({ x: test, y: item._source['performance-data']['rf-temp-min'] });
2838                   avgListA.push({ x: test, y: item._source['performance-data']['rf-temp-avg'] });
2839                 } else {
2840                   maxListA.push({ x: 0, y: item._source['performance-data']['rf-temp-max'] });
2841                   minListA.push({ x: 0, y: item._source['performance-data']['rf-temp-min'] });
2842                   avgListA.push({ x: 0, y: item._source['performance-data']['rf-temp-avg'] });
2843                 }
2844               });
2845
2846               $scope.snirSeries.push('Snir max A', 'Snir min A', 'Snir avg A');
2847
2848
2849               $scope.snirChartData.push(maxListA);
2850               $scope.snirChartData.push(minListA);
2851               $scope.snirChartData.push(avgListA);
2852
2853               $scope.snirsetOverride.push({ yAxisID: 'y-axis-1' });
2854               $scope.snirsetOverride.push({ yAxisID: 'y-axis-1' });
2855               $scope.snirsetOverride.push({ yAxisID: 'y-axis-1' });
2856
2857               var maxListB = [];
2858               var minListB = [];
2859               var avgListB = [];
2860
2861               dataB.data.hits.hits.map(function (item, index) {
2862                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
2863                 var test = $scope.snirtestMap.get(timestamp);
2864                 if (test) {
2865                   maxListB.push({ x: test, y: item._source['performance-data']['rf-temp-max'] });
2866                   minListB.push({ x: test, y: item._source['performance-data']['rf-temp-min'] });
2867                   avgListB.push({ x: test, y: item._source['performance-data']['rf-temp-avg'] });
2868                 } else {
2869                   maxListB.push({ x: 0, y: item._source['performance-data']['rf-temp-max'] });
2870                   minListB.push({ x: 0, y: item._source['performance-data']['rf-temp-min'] });
2871                   avgListB.push({ x: 0, y: item._source['performance-data']['rf-temp-avg'] });
2872                 }
2873               });
2874
2875               $scope.snirSeries.push('Snir max B', 'Snir min B', 'Snir avg B');
2876
2877
2878
2879               $scope.snirChartData.push(maxListB);
2880               $scope.snirChartData.push(minListB);
2881               $scope.snirChartData.push(avgListB);
2882
2883               $scope.snirsetOverride.push({ yAxisID: 'y-axis-1' });
2884               $scope.snirsetOverride.push({ yAxisID: 'y-axis-1' });
2885               $scope.snirsetOverride.push({ yAxisID: 'y-axis-1' });
2886
2887               overridePoints($scope.snirSeries, $scope.snirsetOverride);
2888             }
2889               break;
2890
2891             case 'crossPolarDiscrimination': {
2892
2893               $scope.xpdChartData = [];
2894               $scope.xpdSeries = [];
2895               $scope.crossPolarDiscriminationsetOverride = [];
2896
2897               $scope.xpdOptions = {
2898                 scales: {
2899                   xAxes: [{
2900
2901                     type: 'linear',
2902                     position: 'bottom',
2903                     afterTickToLabelConversion: function (data) { //adds our custom timestamp labels
2904
2905                       var xLabels = data.ticks;
2906                       xLabels.forEach(function (labels, i) {
2907                         var timestamp = $scope.xpdLabelMap.get(parseInt(labels));
2908                         if (parseInt(labels) == labels)
2909                           xLabels[i] = timestamp;
2910                         else
2911                           xLabels[i] = '';
2912
2913                       });
2914
2915                       //calculate last timestamp if label is missing
2916                       if (xLabels[xLabels.length - 1] === undefined) {
2917                         var timestamp = $scope.xpdLabelMap.get($scope.xpdLabelMap.size - 1);
2918                         let stopper = true;
2919                         let counter = 0;
2920                         let labelLength = xLabels.length - 1;
2921                         while (stopper) {
2922                           if (labelLength % 10 == 0) {
2923                             stopper = false;
2924                           } else {
2925                             labelLength++;
2926                             counter++;
2927                           }
2928                         }
2929
2930                         xLabels[xLabels.length - 1] = calculateMissingTimestamp(timestamp, counter);
2931                       }
2932                     }
2933                   }],
2934                   yAxes: [
2935                     {
2936                       id: 'y-axis-1',
2937                       type: 'linear',
2938                       display: true,
2939                       position: 'left'
2940                     }
2941                   ]
2942                 },
2943                 tooltips: {
2944                   enabled: true,
2945                   mode: 'point',
2946                   callbacks: {
2947                     title: function (tooltipItem, data) { //picks right tool tip
2948
2949                       var vaue = $scope.xpdLabelMap.get(tooltipItem[0].xLabel);
2950                       return vaue;
2951                     }
2952                   }
2953                 },
2954                 legend: {
2955                   display: true,
2956                   position: "bottom"
2957                 }
2958               };
2959
2960               $scope.xpdtestMap = new Map();
2961               $scope.xpdLabelMap = new Map();
2962
2963               tempArr.map(function (item, index) {
2964                 $scope.xpdtestMap.set(item, index);
2965                 $scope.xpdLabelMap.set(index, item);
2966               });
2967
2968               var maxListA = [];
2969               var minListA = [];
2970               var avgListA = [];
2971
2972               dataA.data.hits.hits.map(function (item, index) {
2973                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
2974
2975                 var test = $scope.xpdtestMap.get(timestamp);
2976                 if (test) {
2977                   maxListA.push({ x: test, y: item._source['performance-data']['xpd-max'] });
2978                   minListA.push({ x: test, y: item._source['performance-data']['xpd-min'] });
2979                   avgListA.push({ x: test, y: item._source['performance-data']['xpd-avg'] });
2980                 } else {
2981                   maxListA.push({ x: 0, y: item._source['performance-data']['xpd-max'] });
2982                   minListA.push({ x: 0, y: item._source['performance-data']['xpd-min'] });
2983                   avgListA.push({ x: 0, y: item._source['performance-data']['xpd-avg'] });
2984                 }
2985               });
2986
2987               $scope.xpdSeries.push('CPD max A', 'CPD min A', 'CPD avg A');
2988
2989
2990               $scope.xpdChartData.push(maxListA);
2991               $scope.xpdChartData.push(minListA);
2992               $scope.xpdChartData.push(avgListA);
2993
2994               $scope.crossPolarDiscriminationsetOverride.push({ yAxisID: 'y-axis-1' });
2995               $scope.crossPolarDiscriminationsetOverride.push({ yAxisID: 'y-axis-1' });
2996               $scope.crossPolarDiscriminationsetOverride.push({ yAxisID: 'y-axis-1' });
2997
2998               var maxListB = [];
2999               var minListB = [];
3000               var avgListB = [];
3001
3002               dataB.data.hits.hits.map(function (item, index) {
3003                 var timestamp = $mwtnPerformanceLink.formatTimeStamp(item._source['time-stamp']);
3004                 var test = $scope.xpdtestMap.get(timestamp);
3005                 if (test) {
3006                   maxListB.push({ x: test, y: item._source['performance-data']['xpd-max'] });
3007                   minListB.push({ x: test, y: item._source['performance-data']['xpd-min'] });
3008                   avgListB.push({ x: test, y: item._source['performance-data']['xpd-avg'] });
3009                 } else {
3010                   maxListB.push({ x: 0, y: item._source['performance-data']['xpd-max'] });
3011                   minListB.push({ x: 0, y: item._source['performance-data']['xpd-min'] });
3012                   avgListB.push({ x: 0, y: item._source['performance-data']['xpd-avg'] });
3013                 }
3014               });
3015
3016               $scope.xpdSeries.push('CPD max B', 'CPD min B', 'CPD avg B');
3017
3018               $scope.xpdChartData.push(maxListB);
3019               $scope.xpdChartData.push(minListB);
3020               $scope.xpdChartData.push(avgListB);
3021
3022               $scope.crossPolarDiscriminationsetOverride.push({ yAxisID: 'y-axis-1' });
3023               $scope.crossPolarDiscriminationsetOverride.push({ yAxisID: 'y-axis-1' });
3024               $scope.crossPolarDiscriminationsetOverride.push({ yAxisID: 'y-axis-1' });
3025
3026               overridePoints($scope.xpdSeries, $scope.crossPolarDiscriminationsetOverride);
3027
3028             }
3029               break;
3030
3031           }
3032         };
3033
3034         var getColor = function (hexcolorCode) {
3035           var color = {
3036             backgroundColor: hexcolorCode, pointBackgroundColor: hexcolorCode,
3037             pointHoverBackgroundColor: hexcolorCode,
3038             borderColor: hexcolorCode,
3039             pointBorderColor: hexcolorCode,
3040             pointHoverBorderColor: hexcolorCode,
3041             fill: false
3042           };
3043           return color;
3044         };
3045
3046         var getData = function (from, size, networkElement, selectedLtpId) {
3047
3048           var sort = [{ "time-stamp": { order: 'desc' } }];
3049
3050           var query = { "query": { "bool": { "must": [{ prefix: { "node-name": networkElement } }] } } };
3051
3052
3053           //add layer protocol selector to filter query
3054           query.query.bool.must.push({ prefix: { "layer-protocol-name": "MWPS" } });
3055
3056           //add interface selector to filter query
3057           if (selectedLtpId && selectedLtpId !== 'Select LTP') {
3058             query.query.bool.must.push({ prefix: { "uuid-interface": selectedLtpId } });
3059           }
3060
3061           var selected15minPeriod = true;
3062           if ($scope.timePeriod !== $scope.timePeriods[0]) selected15minPeriod = false;
3063
3064           return $mwtnPerformanceLink.getFilteredSortedData(from, size, sort, query, selected15minPeriod);
3065         };
3066
3067         $scope.status = { ne: false };
3068         $scope.spinner = { ne: false };
3069
3070         // events  
3071         $scope.$watch('linkId', function (newValue, oldValue) {
3072           if (newValue && oldValue !== "" && newValue !== oldValue) {
3073
3074             var functionId = 'sdnperformance';
3075             var docType = 'historicalperformance15min';
3076             if ($scope.timePeriod !== $scope.timePeriods[0]) {
3077               docType = 'historicalperformance24h';
3078             }
3079             var aggregations = {
3080               "size":0,
3081               "query": {
3082                 "match": {
3083                   "radio-signal-id": newValue
3084                 }
3085               },
3086               "aggregations": {
3087                 "node-name": {
3088                   "terms": {
3089                     "field": "node-name"
3090                   }
3091                 },
3092                 "ltp": {
3093                   "terms": {
3094                     "field": "uuid-interface"
3095                   }
3096                 }
3097               }
3098             };
3099             $mwtnPerformanceLink.getAggregations(functionId, docType, aggregations).then(function (success) {
3100               console.log(JSON.stringify(success));
3101               var nodes = success.data.aggregations['node-name'].buckets.map(function(bucket){
3102                 return bucket.key;
3103               });
3104               console.warn(nodes);
3105               if (nodes.length = 0) {
3106                 $scope.networkElementA = '';
3107                 $scope.networkElementB = '';
3108               } else if (nodes.length = 1) {
3109                 $scope.networkElementA = nodes[0];
3110                 $scope.networkElementB = '';
3111               } else if (nodes.length = 2) {
3112                 $scope.networkElementA = nodes[0];
3113                 $scope.networkElementB = nodes[1]
3114               } else {
3115                 $scope.networkElementA = nodes[0];
3116                 $scope.networkElementB = nodes[1]
3117                 console.warn('Check nodes for radio signal id: ' + newValue + ' ' + JSON.stringify(nodes));
3118               }
3119               var ltps  = success.data.aggregations['ltp'].buckets.map(function(bucket){
3120                 return bucket.key;
3121               });
3122               if (ltps.length = 0) {
3123                 $scope.selectedLtpIdA = '';
3124                 $scope.selectedLtpIdB = '';
3125               } else if (ltps.length = 1) {
3126                 $scope.selectedLtpIdA = ltps[0];
3127                 $scope.selectedLtpIdB = ltps[0];
3128               } else if (ltps.length = 2) {
3129                 // TODO Who belongs to whom - just guessing ;/
3130                 $scope.selectedLtpIdA = ltps[0];
3131                 $scope.selectedLtpIdB = ltps[1]
3132               } else {
3133                 $scope.selectedLtpIdA = ltps[0];
3134                 $scope.selectedLtpIdB = ltps[1]
3135                 console.warn('Check ltps for radio signal id: ' + newValue + ' ' + JSON.stringify(nodes));
3136               }
3137             }, function (error) {
3138               console.log(error);
3139               $scope.networkElementA = '';
3140               $scope.networkElementB = '';
3141               $scope.selectedLtpIdA = '';
3142               $scope.selectedLtpIdB = '';
3143             });
3144           }
3145         });
3146
3147         $scope.$watch('selectedLtpIdA', function (newValue, oldValue) {
3148           if (newValue && oldValue !== "" && newValue !== oldValue) {
3149             //TODO: get data based on open grids
3150             Object.keys($scope.status).map(function (key) {
3151               if ($scope.status[key]) {
3152                 $scope.defaultColors = [];
3153                 $scope.defaultColors.push(getColor('#0062ff'));
3154                 $scope.defaultColors.push(getColor('#b9341b'));
3155                 $scope.defaultColors.push(getColor('#f0141f'));
3156                 $scope.defaultColors.push(getColor('#4c7759'));
3157                 $scope.defaultColors.push(getColor('#55b64e'));
3158                 $scope.defaultColors.push(getColor("#6c8995"));
3159
3160                 getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, key)
3161                 $window.dispatchEvent(new Event("resize"));
3162               }
3163             });
3164           }
3165
3166         }, true);
3167
3168         $scope.$watch('selectedLtpIdB', function (newValue, oldValue) {
3169           if (newValue && oldValue !== "" && newValue !== oldValue && newValue != 'Select LTP') {
3170             Object.keys($scope.status).map(function (key) {
3171               if ($scope.status[key]) {
3172                 $scope.defaultColors = [];
3173                 $scope.defaultColors.push(getColor('#0062ff'));
3174                 $scope.defaultColors.push(getColor('#b9341b'));
3175                 $scope.defaultColors.push(getColor('#f0141f'));
3176                 $scope.defaultColors.push(getColor('#4c7759'));
3177                 $scope.defaultColors.push(getColor('#55b64e'));
3178                 $scope.defaultColors.push(getColor("#6c8995"));
3179
3180                 getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, key)
3181                 $window.dispatchEvent(new Event("resize"));
3182               }
3183             });
3184           }
3185
3186         }, true);
3187
3188         $scope.$watch('status', function (status, oldValue) {
3189           Object.keys(status).map(function (key) {
3190             if ($scope.networkElementIdA && $scope.networkElementIdB && status[key] && status[key] !== oldValue[key]) {
3191
3192
3193               //add a set of default colors for line graphs with 6 values
3194               $scope.defaultColors = [];
3195               $scope.defaultColors.push(getColor('#0062ff'));
3196               $scope.defaultColors.push(getColor('#b9341b'));
3197               $scope.defaultColors.push(getColor('#f0141f'));
3198               $scope.defaultColors.push(getColor('#4c7759'));
3199               $scope.defaultColors.push(getColor('#55b64e'));
3200               $scope.defaultColors.push(getColor("#6c8995"));
3201
3202               getDataFromNEs($scope.networkElementIdA, $scope.selectedLtpIdA, $scope.networkElementIdB, $scope.selectedLtpIdB, key)
3203               $window.dispatchEvent(new Event("resize"));
3204
3205             }
3206
3207           });
3208         }, true);
3209
3210         $scope.$watch('timePeriod', function (newValue, oldValue) {
3211
3212           if (newValue && oldValue !== "" && newValue !== oldValue) {
3213
3214             //change page sizes and tell gridapi to update
3215
3216             $scope.gridOptionsReceiveLevel.paginationPageSizes = $scope.pageSizes();
3217             $scope.gridOptionsReceiveLevel.paginationPageSize = $scope.gridOptionsReceiveLevel.paginationPageSizes[0];
3218             $scope.recvGridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
3219
3220             $scope.gridOptionsTransmissionLevel.paginationPageSizes = $scope.pageSizes();
3221             $scope.gridOptionsTransmissionLevel.paginationPageSize = $scope.gridOptionsTransmissionLevel.paginationPageSizes[0];
3222             $scope.transmissionGridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
3223
3224
3225             $scope.gridOptionsModulation.paginationPageSizes = $scope.pageSizes();
3226             $scope.gridOptionsModulation.paginationPageSize = $scope.gridOptionsModulation.paginationPageSizes[0];
3227             $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
3228
3229             $scope.gridOptionsTemperature.paginationPageSizes = $scope.pageSizes();
3230             $scope.gridOptionsTemperature.paginationPageSize = $scope.gridOptionsTemperature.paginationPageSizes[0];
3231             $scope.gridTemperatureApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
3232
3233             $scope.gridOptionsSnir.paginationPageSizes = $scope.pageSizes();
3234             $scope.gridOptionsSnir.paginationPageSize = $scope.gridOptionsSnir.paginationPageSizes[0];
3235             $scope.gridSNIRApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
3236
3237             $scope.gridOptionsCrossPolarDiscrimination.paginationPageSizes = $scope.pageSizes();
3238             $scope.gridOptionsCrossPolarDiscrimination.paginationPageSize = $scope.gridOptionsCrossPolarDiscrimination.paginationPageSizes[0];
3239             $scope.gridXpdApi.core.notifyDataChange(uiGridConstants.dataChange.OPTIONS);
3240
3241             //get new interface data
3242             getInterfaces($scope.networkElementIdA, $scope.availableLtpIdsA);
3243             getInterfaces($scope.networkElementIdB, $scope.availableLtpIdsB);
3244           }
3245
3246         }, true);
3247
3248         $scope.collapseAll = function () {
3249           // close all groups
3250           Object.keys($scope.status).map(function (group) {
3251             $scope.status[group] = false;
3252           });
3253           Object.keys($scope.spinner).map(function (group) {
3254             $scope.spinner[group] = false;
3255           });
3256         };
3257
3258         //get data on ne selection
3259
3260         $scope.$watch('networkElementA', function (neId, oldValue) {
3261           if (neId && neId !== '' && neId !== oldValue) {
3262             var revision;
3263             $scope.networkElements.map(function (ne) {
3264               if (ne.id === neId) revision = ne.revision;
3265             });
3266             $scope.networkElementIdA = neId;
3267             $scope.revisionA = revision;
3268
3269             getInterfaces(neId, $scope.availableLtpIdsA);
3270             $scope.collapseAll();
3271
3272           }
3273         });
3274
3275         $scope.$watch('networkElementB', function (neId, oldValue) {
3276           if (neId && neId !== '' && neId !== oldValue) {
3277             var revision;
3278             $scope.networkElements.map(function (ne) {
3279               if (ne.id === neId) revision = ne.revision;
3280             });
3281             $scope.networkElementIdB = neId;
3282             $scope.revisionB = revision;
3283
3284             getInterfaces(neId, $scope.availableLtpIdsB);
3285             $scope.collapseAll();
3286
3287           }
3288         });
3289
3290         var getInterfaces = function (networkElement, networkList) {
3291
3292           //clear interface array
3293           var length = networkList.length;
3294           networkList.splice(1, length);
3295
3296           //request to get interfaces
3297           var aggr = {
3298             "size": 0,
3299             "aggregations": {
3300               "neinterfaces": {
3301                 "filter": {
3302                   "bool": {
3303                     "must": [
3304                       {
3305                         "term": {
3306                           "node-name": networkElement
3307                         }
3308                       },
3309                       {
3310                         "term": {
3311                           "layer-protocol-name": "MWPS"
3312                         }
3313                       }
3314                     ]
3315                   }
3316                 },
3317                 "aggregations": {
3318                   "interfaces": {
3319                     "terms": {
3320                       "field": "uuid-interface"
3321                     }
3322                   }
3323                 }
3324               }
3325             }
3326           };
3327
3328
3329           var selected15minPeriod = true;
3330           if ($scope.timePeriod !== $scope.timePeriods[0]) selected15minPeriod = false;
3331
3332           $mwtnPerformanceLink.getInterfaces(aggr, selected15minPeriod).then(function (response) {
3333
3334             if (response.data.aggregations.neinterfaces.interfaces.buckets.length >= 0) {
3335               response.data.aggregations.neinterfaces.interfaces.buckets.map(function (item) {
3336                 networkList.push(item.key);
3337               });
3338             }
3339
3340
3341           });
3342         };
3343
3344
3345       }]);
3346   });