Add seed code for sdnr app based on ONF Centennial
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / mwtnPerformanceHistory / mwtnPerformanceHistory-module / src / main / resources / mwtnPerformanceHistory / mwtnPerformanceHistory.controller.js
1 /*
2  * @copyright 2017 highstreet technologies GmbH and others.  All rights reserved.
3  *
4  * @license
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9
10 define(['app/mwtnPerformanceHistory/mwtnPerformanceHistory.module',
11   'app/mwtnPerformanceHistory/mwtnPerformanceHistory.services'],
12   function (mwtnPerformanceHistoryoryApp) {
13
14     mwtnPerformanceHistoryoryApp.register.controller('mwtnPerformanceHistoryCtrl', ['$scope', '$rootScope', '$window', '$translate', '$mwtnLog', '$mwtnPerformanceHistory', 'uiGridConstants', 'OnfNetworkElement',
15       function ($scope, $rootScope, $window, $translate, $mwtnLog, $mwtnPerformanceHistory, uiGridConstants, OnfNetworkElement) {
16
17       var COMPONENT = 'mwtnPerformanceHistory';
18       $mwtnLog.info({ component: COMPONENT, message: 'mwtn historical Performance started!' });
19
20       $rootScope.section_logo = 'src/app/mwtnPerformanceHistory/images/mwtnPerformance.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'
21
22       var globalFilter;
23
24       $scope.selecteditem = {};
25
26       //time selector
27       $scope.selecteditem.timePeriod = "15 minutes";
28       $scope.timePeriods = ["15 minutes", "24 hours"];
29
30       //interface selector
31       $scope.selecteditem.selectedLtpId = undefined;
32       $scope.availableLtpIds = [];
33
34       //stateobject
35       $scope.state = {};
36       $scope.state.filter = false;
37       $scope.state.sort = false;
38       $scope.state.lastfilter = null;
39       $scope.state.lastSort = null;
40       $scope.state.grid = null;
41
42       //perf log configuration
43       $scope.gridOptionsPerformance826 = {
44         paginationPageSizes: [25, 100, 1000, 10000],
45         paginationPageSize: 25,
46         useExternalPagination: true,
47         useExternalSorting: true,
48         enablePaginationControls: true,
49         enableFiltering: true,
50         useExternalFiltering: true,
51         enableGridMenu: true,
52         columnDefs: [
53           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
54           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
55           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
56           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
57           {
58             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
59               direction: uiGridConstants.ASC,
60               priority: 1
61             }
62           },
63           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
64
65           { field: 'es', type: 'string', displayName: 'ES', width: 70 },
66           { field: 'ses', type: 'string', displayName: 'SES', width: 70 },
67           { field: 'uas', type: 'string', displayName: 'UAS', width: 70 }
68
69         ],
70         data: 'performance826',
71         onRegisterApi: function (gridApi) {
72           $scope.performancegridApi = gridApi;
73           $scope.performancegridApi.core.on.filterChanged($scope, $scope.filter);
74           $scope.performancegridApi.core.on.sortChanged($scope, $scope.sortChanged);
75           $scope.sortChanged($scope.performancegridApi.grid, [$scope.gridOptionsPerformance826.columnDefs[1]]);
76
77           $scope.performancegridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
78             getPage($scope.gridOptionsPerformance826);
79           });
80         }
81       };
82
83       //receive lvl configuration
84       $scope.gridOptionsReceiveLevel = {
85         paginationPageSizes: [25, 100, 1000, 10000],
86         paginationPageSize: 25,
87         useExternalPagination: true,
88         useExternalSorting: true,
89         enablePaginationControls: true,
90         enableFiltering: true,
91         useExternalFiltering: true,
92         enableGridMenu: true,
93         columnDefs: [
94           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
95           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
96           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
97           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
98           {
99             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
100               direction: uiGridConstants.ASC,
101               priority: 1
102             }
103           },
104           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
105           { field: 'rxmin', type: 'string', displayName: 'Rx min', width: 90 },
106           { field: 'rxavg', type: 'string', displayName: 'Rx avg', width: 90 },
107           { field: 'rxmax', type: 'string', displayName: 'Rx max', width: 90 }
108         ],
109         data: 'receiveLevel',
110         onRegisterApi: function (gridApi) {
111           $scope.recvGridApi = gridApi;
112           $scope.recvGridApi.core.on.filterChanged($scope, $scope.filter);
113           $scope.recvGridApi.core.on.sortChanged($scope, $scope.sortChanged);
114           $scope.sortChanged($scope.recvGridApi.grid, [$scope.gridOptionsReceiveLevel.columnDefs[1]]);
115
116           $scope.recvGridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
117             getPage($scope.gridOptionsReceiveLevel);
118           });
119         }
120       };
121
122       //transmission lvl configuration
123       $scope.gridOptionsTransmissionLevel = {
124         paginationPageSizes: [25, 100, 1000, 10000],
125         paginationPageSize: 25,
126         useExternalPagination: true,
127         useExternalSorting: true,
128         enablePaginationControls: true,
129         enableFiltering: true,
130         useExternalFiltering: true,
131         enableGridMenu: true,
132         columnDefs: [
133           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
134           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
135           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
136           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
137           {
138             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
139               direction: uiGridConstants.ASC,
140               priority: 1
141             }
142           },
143           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
144           { field: 'txmin', type: 'string', displayName: 'Tx min', width: 90 },
145           { field: 'txavg', type: 'string', displayName: 'Tx avg', width: 90 },
146           { field: 'txmax', type: 'string', displayName: 'Tx max', width: 90 }
147         ],
148         data: 'transmissionLevel',
149         onRegisterApi: function (gridApi) {
150           $scope.transmissionGridApi = gridApi;
151           $scope.transmissionGridApi.core.on.filterChanged($scope, $scope.filter);
152           $scope.transmissionGridApi.core.on.sortChanged($scope, $scope.sortChanged);
153           $scope.sortChanged($scope.transmissionGridApi.grid, [$scope.gridOptionsTransmissionLevel.columnDefs[1]]);
154
155           $scope.transmissionGridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
156             getPage($scope.gridOptionsTransmissionLevel);
157           });
158         }
159       };
160
161       //modulation configuration
162       $scope.gridOptionsModulation = {
163         paginationPageSizes: [25, 100, 1000, 10000],
164         paginationPageSize: 25,
165         useExternalPagination: true,
166         useExternalSorting: true,
167         enablePaginationControls: true,
168         enableFiltering: true,
169         useExternalFiltering: true,
170         enableGridMenu: true,
171         columnDefs: [
172           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
173           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
174           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
175           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
176           {
177             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
178               direction: uiGridConstants.ASC,
179               priority: 1
180             }
181           },
182           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
183           { field: 'time2S', type: 'string', displayName: 'QAM2S', width: 90 },
184           { field: 'time2', type: 'string', displayName: 'QAM2', width: 90 },
185           { field: 'time2L', type: 'string', displayName: 'QAM2L', width: 90 },
186           { field: 'time4S', type: 'string', displayName: 'QAM4S', width: 90 },
187           { field: 'time4', type: 'string', displayName: 'QAM4', width: 90 },
188           { field: 'time4L', type: 'string', displayName: 'QAM4L', width: 90 },
189           { field: 'time16S', type: 'string', displayName: 'QAM16S', width: 90 },
190           { field: 'time16', type: 'string', displayName: 'QAM16', width: 90 },
191           { field: 'time16L', type: 'string', displayName: 'QAM16L', width: 90 },
192           { field: 'time32S', type: 'string', displayName: 'QAM32S', width: 90 },
193           { field: 'time32', type: 'string', displayName: 'QAM32', width: 90 },
194           { field: 'time32L', type: 'string', displayName: 'QAM32L', width: 90 },
195           { field: 'time64S', type: 'string', displayName: 'QAM64S', width: 90 },
196           { field: 'time64', type: 'string', displayName: 'QAM64', width: 90 },
197           { field: 'time64L', type: 'string', displayName: 'QAM64L', width: 90 },
198           { field: 'time128S', type: 'string', displayName: 'QAM128S', width: 90 },
199           { field: 'time128', type: 'string', displayName: 'QAM128', width: 90 },
200           { field: 'time128L', type: 'string', displayName: 'QAM128L', width: 90 },
201           { field: 'time256S', type: 'string', displayName: 'QAM256S', width: 90 },
202           { field: 'time256', type: 'string', displayName: 'QAM256', width: 90 },
203           { field: 'time256L', type: 'string', displayName: 'QAM256L', width: 90 },
204           { field: 'time512S', type: 'string', displayName: 'QAM512S', width: 90 },
205           { field: 'time512', type: 'string', displayName: 'QAM512', width: 90 },
206           { field: 'time512L', type: 'string', displayName: 'QAM512L', width: 90 },
207           { field: 'time1024S', type: 'string', displayName: 'QAM1024S', width: 90 },
208           { field: 'time1024', type: 'string', displayName: 'QAM1024', width: 90 },
209           { field: 'time1024L', type: 'string', displayName: 'QAM1024L', width: 90 },
210           { field: 'time2048S', type: 'string', displayName: 'QAM2048S', width: 90 },
211           { field: 'time2048', type: 'string', displayName: 'QAM2048', width: 90 },
212           { field: 'time2048L', type: 'string', displayName: 'QAM2048L', width: 90 },
213           { field: 'time4096S', type: 'string', displayName: 'QAM4096S', width: 90 },
214           { field: 'time4096', type: 'string', displayName: 'QAM4096', width: 90 },
215           { field: 'time4096L', type: 'string', displayName: 'QAM4096L', width: 90 },
216           { field: 'time8192S', type: 'string', displayName: 'QAM8192S', width: 90 },
217           { field: 'time8192', type: 'string', displayName: 'QAM8192', width: 90 },
218           { field: 'time8192L', type: 'string', displayName: 'QAM8192L', width: 90 }
219
220
221         ],
222         data: 'modulation',
223         onRegisterApi: function (gridApi) {
224           $scope.gridApi = gridApi;
225           $scope.gridApi.core.on.filterChanged($scope, $scope.filter);
226           $scope.gridApi.core.on.sortChanged($scope, $scope.sortChanged);
227           $scope.sortChanged($scope.gridApi.grid, [$scope.gridOptionsModulation.columnDefs[1]]);
228
229           $scope.gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
230             getPage($scope.gridOptionsModulation);
231           });
232         }
233       };
234
235       //temperature configuration
236       $scope.gridOptionsTemperature = {
237         paginationPageSizes: [25, 100, 1000, 10000],
238         paginationPageSize: 25,
239         useExternalPagination: true,
240         useExternalSorting: true,
241         enablePaginationControls: true,
242         enableFiltering: true,
243         useExternalFiltering: true,
244         enableGridMenu: true,
245         columnDefs: [
246           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
247           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
248           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
249           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
250           {
251             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
252               direction: uiGridConstants.ASC,
253               priority: 1
254             }
255           },
256           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
257           { field: 'rfTempMin', type: 'string', displayName: 'Rf Temp Min  [°C]', width: 90 },
258           { field: 'rfTempAvg', type: 'string', displayName: 'Rf Temp Avg  [°C]', width: 90 },
259           { field: 'rfTempMax', type: 'string', displayName: 'Rf Temp Max  [°C]', width: 90 }
260
261         ],
262         data: 'temperature',
263         onRegisterApi: function (gridApi) {
264           $scope.gridTemperatureApi = gridApi;
265           $scope.gridTemperatureApi.core.on.filterChanged($scope, $scope.filter);
266           $scope.gridTemperatureApi.core.on.sortChanged($scope, $scope.sortChanged);
267           $scope.sortChanged($scope.gridTemperatureApi.grid, [$scope.gridOptionsTemperature.columnDefs[1]]);
268
269           $scope.gridTemperatureApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
270             getPage($scope.gridOptionsTemperature);
271           });
272         }
273       }
274
275       //SNIR configuration
276       $scope.gridOptionsSnir = {
277         paginationPageSizes: [25, 100, 1000, 10000],
278         paginationPageSize: 25,
279         useExternalPagination: true,
280         useExternalSorting: true,
281         enablePaginationControls: true,
282         enableFiltering: true,
283         useExternalFiltering: true,
284         enableGridMenu: true,
285         columnDefs: [
286           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
287           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
288           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
289           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
290           {
291             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
292               direction: uiGridConstants.ASC,
293               priority: 1
294             }
295           },
296           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
297           { field: 'snirMin', type: 'string', displayName: [$translate.instant('MWTN_SNIR_MIN'),'[dB]'].join(' '), width: 90 },
298           { field: 'snirAvg', type: 'string', displayName: [$translate.instant('MWTN_SNIR_AVG'),'[dB]'].join(' '), width: 90 },
299           { field: 'snirMax', type: 'string', displayName: [$translate.instant('MWTN_SNIR_MAX'),'[dB]'].join(' '), width: 90 }
300         ],
301         data: 'snir',
302         onRegisterApi: function (gridApi) {
303           $scope.gridSNIRApi = gridApi;
304           $scope.gridSNIRApi.core.on.filterChanged($scope, $scope.filter);
305           $scope.gridSNIRApi.core.on.sortChanged($scope, $scope.sortChanged);
306           $scope.sortChanged($scope.gridSNIRApi.grid, [$scope.gridOptionsSnir.columnDefs[1]]);
307
308           $scope.gridSNIRApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
309             getPage($scope.gridOptionsSnir);
310           });
311         }
312       }
313
314       //CPD Configuration
315       $scope.gridOptionsCrossPolarDiscrimination = {
316         paginationPageSizes: [25, 100, 1000, 10000],
317         paginationPageSize: 25,
318         useExternalPagination: true,
319         useExternalSorting: true,
320         enablePaginationControls: true,
321         enableFiltering: true,
322         useExternalFiltering: true,
323         enableGridMenu: true,
324         columnDefs: [
325           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
326           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
327           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90 },
328           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
329           {
330             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
331               direction: uiGridConstants.ASC,
332               priority: 1
333             }
334           },
335           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
336           { field: 'xpdMin', type: 'string', displayName: 'CPD min  [dB]', width: 90 },
337           { field: 'xpdAvg', type: 'string', displayName: 'CPD avg  [dB]', width: 90 },
338           { field: 'xpdMax', type: 'string', displayName: 'CPD max  [dB]', width: 90 }
339
340         ],
341         data: 'crossPolarDiscrimination',
342         onRegisterApi: function (gridApi) {
343           $scope.gridXpdApi = gridApi;
344           $scope.gridXpdApi.core.on.filterChanged($scope, $scope.filter);
345           $scope.gridXpdApi.core.on.sortChanged($scope, $scope.sortChanged);
346           $scope.sortChanged($scope.gridOptionsCrossPolarDiscrimination, [$scope.gridOptionsCrossPolarDiscrimination.columnDefs[1]]);
347
348           $scope.gridXpdApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
349             getPage($scope.gridOptionsCrossPolarDiscrimination);
350           });
351         }
352       }
353
354       //ethernet perf configuration
355       $scope.gridOptionsPerformanceEthernetContainer = {
356         paginationPageSizes: [25, 100, 1000, 10000],
357         paginationPageSize: 25,
358         useExternalPagination: true,
359         useExternalSorting: true,
360         enablePaginationControls: true,
361         enableFiltering: true,
362         useExternalFiltering: true,
363         enableGridMenu: true,
364         columnDefs: [
365           { field: 'layerProtocol', type: 'string', displayName: 'Layer Protocol Name', width: 90, visible: false },
366           { field: 'id', type: 'string', displayName: $translate.instant('MWTN_LTP'), width: 200, visible: false },
367           { field: 'radiosignal', type: 'string', displayName: 'Radio Signal Id', width: 90, visible: false },
368           { field: 'scannerId', type: 'string', displayName: 'Scanner Id', width: 90 },
369           {
370             field: 'timestamp', type: 'string', displayName: 'End time', width: 200, sort: {
371               direction: uiGridConstants.ASC,
372               priority: 1
373             }
374           },
375           { field: 'suspectInterval', type: 'string', displayName: 'Suspect Interval Flag', width: 100 },
376           { field: 'txEthernetBytesMaxS', type: 'number', displayName: 'Tx BytesMaxS', width: 90 },
377           { field: 'txEthernetBytesMaxM', type: 'number', displayName: 'Tx BytesMaxM', width: 90 },
378           { field: 'txEthernetBytesSum', type: 'number', displayName: 'Tx BytesSum', width: 90 }
379
380         ],
381         data: 'performanceEthernetContainer',
382         onRegisterApi: function (gridApi) {
383           $scope.gridPerfEthernetApi = gridApi;
384           $scope.gridPerfEthernetApi.core.on.filterChanged($scope, $scope.filter);
385           $scope.gridPerfEthernetApi.core.on.sortChanged($scope, $scope.sortChanged);
386           $scope.sortChanged($scope.gridPerfEthernetApi.grid, [$scope.gridOptionsPerformanceEthernetContainer.columnDefs[1]]);
387
388           $scope.gridPerfEthernetApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
389             getPage($scope.gridOptionsPerformanceEthernetContainer);
390           });
391         }
392       };
393
394       //filter 
395       $scope.filter = function () {
396         var grid = this.grid;
397         var columns = [];
398
399         //get all columns where data was typed in
400         angular.forEach(grid.columns, function (value, key) {
401           if (value.filters[0].term) {
402             var col = findColumn(value.field);
403             if (col === "time-stamp") {
404               //convert timestamp to db format
405               var timestamp = $mwtnPerformanceHistory.TimeStampToONFFormat(value.filters[0].term);
406               columns.push({ column: col, value: timestamp });
407             }
408             else
409               columns.push({ column: col, value: value.filters[0].term }); //create column object
410           }
411         });
412
413         if (columns.length == 0) { //all filter data cleared away
414           $scope.state.filter = false;
415           $scope.state.lastfilter = null;
416
417           //get unfiltered data
418           getData($scope.state.lastSort, $scope.state.lastfilter, grid.options, null, null).then(function (response) {
419             if (response.data.hits.hits) {
420               processRequestInGrid(response, grid.options);
421
422             }
423           });
424
425         } else {
426           //base filter string
427           var filter = { "query": { "bool": { "must": [] } } };
428
429           //create filter objects
430           var prefixs = [];
431           prefixs.push({ prefix: globalFilter });
432
433           columns.map(function (obj) {
434             var prefixObj = {};
435             prefixObj[obj.column] = obj.value;//add  like: {column: "fault.counter", value: "1"} => {"fault.counter":1}
436             prefixs.push({ prefix: prefixObj }); // => {"prefix":{...}}
437           });
438
439           //add objects to must property
440           filter.query.bool.must = prefixs;
441
442           //save filter
443           $scope.state.lastfilter = filter;
444           $scope.state.filter = true;
445
446           getData($scope.state.lastSort, $scope.state.lastfilter, grid.options, filter, null).then(function (response) {
447             if (response.data.hits.total > 0) { //only, when hits exist
448               processRequestInGrid(response, grid.options);
449               //$scope.gridOptionsAlarmLog.totalItems = response.data.hits.total;
450             } else {
451               //clear data from list
452               $scope[grid.options.data] = [];
453               grid.options.totalItems = 0;
454
455             }
456           });
457         }
458       };
459
460       $scope.sortChanged = function (grid, sortColumns) {    // sortColumns is an array containing just the column sorted in the grid
461
462
463         if (sortColumns && sortColumns.length > 0) {
464           if (sortColumns[0].sort) {
465             var name = sortColumns[0].field; // the field (name) of the column sorted
466             var direction = sortColumns[0].sort.direction // the direction of the column sorted: "desc" or "asc"
467             sort(direction, findColumn(name), grid);
468           }
469         } else if (sortColumns) {
470           $scope.state.sort = false;
471           $scope.state.lastSort = null;
472
473           //get unsorted data
474           getData($scope.state.lastSort, $scope.state.lastfilter, grid.options, null, null).then(function (response) {
475             if (response.data.hits.hits) {
476               processRequestInGrid(response, grid.options);
477             }
478           });
479         }
480       };
481
482       var sort = function (direction, columnName, grid) {
483         switch (direction) {
484           case uiGridConstants.ASC:
485
486             //create sort object
487             var sortObj = {};
488             sortObj[columnName] = { order: 'asc' };
489             var sort = [sortObj];
490             //save last sort
491             $scope.state.lastSort = sort;
492
493             getData($scope.state.lastSort, $scope.state.lastfilter, grid.options, null, sort).then(function (response) {
494               if (response.data.hits.hits) {
495                 processRequestInGrid(response, grid.options);
496                 $scope.state.sort = true;
497
498               }
499             });
500
501             break;
502
503           case uiGridConstants.DESC:
504
505             var sortObj = {};
506             sortObj[columnName] = { order: 'desc' };
507             var sort = [sortObj];
508             $scope.state.lastSort = sort;
509
510             getData($scope.state.lastSort, $scope.state.lastfilter, grid.options, null, sort).then(function (response) {
511               if (response.data.hits.hits) {
512                 processRequestInGrid(response, grid.options);
513                 $scope.state.sort = true;
514               }
515             });
516             break;
517
518           case undefined:
519
520             $scope.state.sort = false;
521             $scope.state.lastSort = null;
522
523             getData($scope.state.lastSort, $scope.state.lastfilter, grid.options, null, null)
524               .then(function (response) {
525                 if (response.data.hits.hits) {
526                   processRequestInGrid(response, grid.options);
527                 }
528               });
529
530             break;
531         }
532       }
533
534       function findColumn(name) {
535
536         if (name === "timestamp") { return "time-stamp"; }
537         else if (name === "layerprotocol") { return "layer-protocol-name"; }
538         else if (name === "id") { return "uuid-interface"; }
539         else if (name === "suspectInterval") { return "suspect-interval-flag"; }
540         else if (name === "scannerId") { return "scanner-id"; }
541         else if (name === "radiosignal") { return "radio-signal-id"; }
542         else if (name === "es") { return "performance-data.es"; }
543         else if (name === "ses") { return "performance-data.ses"; }
544         else if (name === "uas") { return "performance-data.unavailability"; }
545         else if (name === "rxmin") { return "performance-data.rx-level-min"; }
546         else if (name === "rxmax") { return "performance-data.rx-level-max"; }
547         else if (name === "rxavg") { return "performance-data.rx-level-avg"; }
548         else if (name === "txmin") { return "performance-data.tx-level-min"; }
549         else if (name === "txmax") { return "performance-data.tx-level-max"; }
550         else if (name === "txavg") { return "performance-data.tx-level-avg"; }
551         else if (name === "Tx BytesMaxS") { return "performance-data.tx-ethernet-bytes-max-s"; }
552         else if (name === "Tx BytesMaxM") { return "performance-data.tx-ethernet-bytes-max-m"; }
553         else if (name === "Tx BytesSum") { return "performance-data.tx-ethernet-bytes-sum"; }
554         else if (name === "xpdMin") { return "performance-data.xpd-min"; }
555         else if (name === "xpdAvg") { return "performance-data.xpd-avg"; }
556         else if (name === "xpdMax") { return "performance-data.xpd-max"; }
557         else if (name === "snirMin") { return "performance-data.snir-min"; }
558         else if (name === "snirAvg") { return "performance-data.snir-avg"; }
559         else if (name === "snirMax") { return "performance-data.snir-max"; }
560         else if (name === "rfTempMin") { return "performance-data.rf-temp-min"; }
561         else if (name === "rfTempAvg") { return "performance-data.rf-temp-avg"; }
562         else if (name === "rfTempMax") { return "performance-data.rf-temp-max"; }
563         else if (name === "time2S") { return "performance-data.time2-states-s"; }
564         else if (name === "time2") { return "performance-data.time2-states"; }
565         else if (name === "time2L") { return "performance-data.time2-states-l"; }
566         else if (name === "time4S") { return "performance-data.time4-states-s"; }
567         else if (name === "time4") { return "performance-data.time4-states"; }
568         else if (name === "time4L") { return "performance-data.time4-states-l"; }
569         else if (name === "time16S") { return "performance-data.time16-states-s"; }
570         else if (name === "time16") { return "performance-data.time16-states"; }
571         else if (name === "time16L") { return "performance-data.time16-states-l"; }
572         else if (name === "time32S") { return "performance-data.time32-states-s"; }
573         else if (name === "time32") { return "performance-data.time32-states"; }
574         else if (name === "time32L") { return "performance-data.time32-states-l"; }
575         else if (name === "time64S") { return "performance-data.time64-states-s"; }
576         else if (name === "time64") { return "performance-data.time64-states"; }
577         else if (name === "time64L") { return "performance-data.time64-states-l"; }
578         else if (name === "time128S") { return "performance-data.time128-states-s"; }
579         else if (name === "time128") { return "performance-data.time128-states"; }
580         else if (name === "time128L") { return "performance-data.time128-states-l"; }
581         else if (name === "time256S") { return "performance-data.time256-states-s"; }
582         else if (name === "time256") { return "performance-data.time256-states"; }
583         else if (name === "time256L") { return "performance-data.time256-states-l"; }
584         else if (name === "time512S") { return "performance-data.time512-states-s"; }
585         else if (name === "time512") { return "performance-data.time512-states"; }
586         else if (name === "time512L") { return "performance-data.time512-states-l"; }
587         else if (name === "time1024S") { return "performance-data.time1024-states-s"; }
588         else if (name === "time1024") { return "performance-data.time1024-states"; }
589         else if (name === "time1024L") { return "performance-data.time1024-states-l"; }
590         else if (name === "time2048S") { return "performance-data.time2048-states-s"; }
591         else if (name === "time2048") { return "performance-data.time2048-states"; }
592         else if (name === "time2048L") { return "performance-data.time2048-states-l"; }
593         else if (name === "time4096S") { return "performance-data.time4096-states-s"; }
594         else if (name === "time4096") { return "performance-data.time4096-states"; }
595         else if (name === "time4096L") { return "performance-data.time4096-states-l"; }
596         else if (name === "time8192S") { return "performance-data.time8192-states-s"; }
597         else if (name === "time8192") { return "performance-data.time8192-states"; }
598         else if (name === "time8192L") { return "performance-data.time8192-states-l"; }
599
600
601       };
602
603       var checkData = function (value) {
604         if (value === -1 || value === undefined) return undefined;
605         else return value;
606       };
607
608       var getPage = function (grid) {
609
610         //from, how many, sort, filter
611         getData($scope.state.lastSort, $scope.state.lastfilter, grid, null, null)
612           .then(function (data) {
613
614             processRequestInGrid(data, grid);
615           });
616       };
617
618       var processRequestInGrid = function (response, grid) {
619         // console.log(grid.data);
620         switch (grid.data) {
621           case "performance826":
622             var list = [];
623
624             response.data.hits.hits.map(function (entry) {
625               var item = {
626                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
627                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
628                 layerProtocol: entry._source['layer-protocol-name'],
629                 suspectInterval: entry._source['suspect-interval-flag'],
630                 scannerId: entry._source['scanner-id'],
631                 es: checkData(entry._source['performance-data'].es),
632                 ses: checkData(entry._source['performance-data'].ses),
633                 uas: checkData(entry._source['performance-data'].unavailability),
634                 radiosignal: entry._source['radio-signal-id']
635               };
636
637               list.push(item);
638
639             });
640             $scope.performance826 = list;
641             $scope.gridOptionsPerformance826.totalItems = response.data.hits.total;
642             break;
643           case "transmissionLevel":
644             var list = [];
645
646             response.data.hits.hits.map(function (entry) {
647               var item = {
648                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
649                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
650                 layerProtocol: entry._source['layer-protocol-name'],
651                 suspectInterval: entry._source['suspect-interval-flag'],
652                 scannerId: entry._source['scanner-id'],
653                 txmin: checkData(entry._source['performance-data']['tx-level-min']),
654                 txavg: checkData(entry._source['performance-data']['tx-level-avg']),
655                 txmax: checkData(entry._source['performance-data']['tx-level-max']),
656                 radiosignal: entry._source['radio-signal-id']
657               };
658
659               list.push(item);
660
661             });
662             $scope.transmissionLevel = list;
663             $scope.gridOptionsTransmissionLevel.totalItems = response.data.hits.total;
664
665             break;
666           case "receiveLevel":
667
668             var list = [];
669
670             response.data.hits.hits.map(function (entry) {
671               var item = {
672                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
673                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
674                 layerProtocol: entry._source['layer-protocol-name'],
675                 suspectInterval: entry._source['suspect-interval-flag'],
676                 scannerId: entry._source['scanner-id'],
677                 rxmin: checkData(entry._source['performance-data']['rx-level-min']),
678                 rxavg: checkData(entry._source['performance-data']['rx-level-avg']),
679                 rxmax: checkData(entry._source['performance-data']['rx-level-max']),
680                 radiosignal: entry._source['radio-signal-id']
681               };
682
683               list.push(item);
684
685             });
686             $scope.receiveLevel = list;
687             $scope.gridOptionsReceiveLevel.totalItems = response.data.hits.total;
688
689             break;
690           case "modulation":
691
692             var list = [];
693
694             response.data.hits.hits.map(function (entry) {
695               var item = {
696                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
697                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
698                 layerProtocol: entry._source['layer-protocol-name'],
699                 suspectInterval: entry._source['suspect-interval-flag'],
700                 scannerId: entry._source['scanner-id'],
701                 time2S: checkData(entry._source['performance-data']['time2-states-s']),
702                 time2: checkData(entry._source['performance-data']['time2-states']),
703                 time2L: checkData(entry._source['performance-data']['time2-states-l']),
704                 time4S: checkData(entry._source['performance-data']['time4-states-s']),
705                 time4: checkData(entry._source['performance-data']['time4-states']),
706                 time4L: checkData(entry._source['performance-data']['time4-states-l']),
707                 time16S: checkData(entry._source['performance-data']['time16-states-s']),
708                 time16: checkData(entry._source['performance-data']['time16-states']),
709                 time16L: checkData(entry._source['performance-data']['time16-states-l']),
710                 time32S: checkData(entry._source['performance-data']['time32-states-s']),
711                 time32: checkData(entry._source['performance-data']['time32-states']),
712                 time32L: checkData(entry._source['performance-data']['time32-states-l']),
713                 time64S: checkData(entry._source['performance-data']['time64-states-s']),
714                 time64: checkData(entry._source['performance-data']['time64-states']),
715                 time64L: checkData(entry._source['performance-data']['time64-states-l']),
716                 time128S: checkData(entry._source['performance-data']['time128-states-s']),
717                 time128: checkData(entry._source['performance-data']['time128-states']),
718                 time128L: checkData(entry._source['performance-data']['time128-states-l']),
719                 time256S: checkData(entry._source['performance-data']['time256-states-s']),
720                 time256: checkData(entry._source['performance-data']['time256-states']),
721                 time256L: checkData(entry._source['performance-data']['time256-states-l']),
722                 time512S: checkData(entry._source['performance-data']['time512-states-s']),
723                 time512: checkData(entry._source['performance-data']['time512-states']),
724                 time512L: checkData(entry._source['performance-data']['time512-states-l']),
725                 time1024S: checkData(entry._source['performance-data']['time1024-states-s']),
726                 time1024: checkData(entry._source['performance-data']['time1024-states']),
727                 time1024L: checkData(entry._source['performance-data']['time1024-states-l']),
728                 time2048S: checkData(entry._source['performance-data']['time2048-states-s']),
729                 time2048: checkData(entry._source['performance-data']['time2048-states']),
730                 time2048L: checkData(entry._source['performance-data']['time2048-states-l']),
731                 time4096S: checkData(entry._source['performance-data']['time4096-states-s']),
732                 time4096: checkData(entry._source['performance-data']['time4096-states']),
733                 time4096L: checkData(entry._source['performance-data']['time4096-states-l']),
734                 time8192S: checkData(entry._source['performance-data']['time8192-states-s']),
735                 time8192: checkData(entry._source['performance-data']['time8192-states']),
736                 time8192L: checkData(entry._source['performance-data']['time8192-states-l']),
737                 radiosignal: entry._source['radio-signal-id']
738               };
739
740               list.push(item);
741
742             });
743             $scope.modulation = list;
744             $scope.gridOptionsModulation.totalItems = response.data.hits.total;
745
746             break;
747
748           case "temperature":
749             var list = [];
750
751             response.data.hits.hits.map(function (entry) {
752               var item = {
753                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
754                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
755                 layerProtocol: entry._source['layer-protocol-name'],
756                 suspectInterval: entry._source['suspect-interval-flag'],
757                 scannerId: entry._source['scanner-id'],
758                 rfTempMin: entry._source['performance-data']['rf-temp-min'],
759                 rfTempAvg: entry._source['performance-data']['rf-temp-avg'],
760                 rfTempMax: entry._source['performance-data']['rf-temp-max'],
761                 radiosignal: entry._source['radio-signal-id']
762               };
763
764               list.push(item);
765
766             });
767             $scope.temperature = list;
768             $scope.gridOptionsTemperature.totalItems = response.data.hits.total;
769
770             break;
771
772           case "snir":
773             var list = [];
774
775             response.data.hits.hits.map(function (entry) {
776               var item = {
777                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
778                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
779                 layerProtocol: entry._source['layer-protocol-name'],
780                 suspectInterval: entry._source['suspect-interval-flag'],
781                 scannerId: entry._source['scanner-id'],
782                 snirMin: entry._source['performance-data']['snir-min'],
783                 snirAvg: entry._source['performance-data']['snir-avg'],
784                 snirMax: entry._source['performance-data']['snir-max'],
785                 radiosignal: entry._source['radio-signal-id']
786               };
787
788               list.push(item);
789
790             });
791             $scope.snir = list;
792             $scope.gridOptionsSnir.totalItems = response.data.hits.total;
793
794             break;
795
796           case "crossPolarDiscrimination":
797             var list = [];
798
799             response.data.hits.hits.map(function (entry) {
800               var item = {
801                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
802                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
803                 layerProtocol: entry._source['layer-protocol-name'],
804                 suspectInterval: entry._source['suspect-interval-flag'],
805                 scannerId: entry._source['scanner-id'],
806                 xpdMin: entry._source['performance-data']['xpd-min'],
807                 xpdAvg: entry._source['performance-data']['xpd-avg'],
808                 xpdMax: entry._source['performance-data']['xpd-max'],
809                 radiosignal: entry._source['radio-signal-id']
810
811               };
812
813               list.push(item);
814
815             });
816             $scope.crossPolarDiscrimination = list;
817             $scope.gridOptionsCrossPolarDiscrimination.totalItems = response.data.hits.total;
818
819             break;
820
821
822           case "performanceEthernetContainer":
823
824             var list = [];
825
826             response.data.hits.hits.map(function (entry) {
827               var item = {
828                 timestamp: $mwtnPerformanceHistory.formatTimeStamp(entry._source['time-stamp']),
829                 id: $scope.onfNetworkElement.getLpById(entry._source['uuid-interface']).getLabel() || entry._source['uuid-interface'],
830                 layerProtocol: entry._source['layer-protocol-name'],
831                 suspectInterval: entry._source['suspect-interval-flag'],
832                 scannerId: entry._source['scanner-id'],
833                 period: entry._source['granularity-period'],
834                 txEthernetBytesMaxS: checkData(entry._source['performance-data']['tx-ethernet-bytes-max-s']),
835                 txEthernetBytesMaxM: checkData(entry._source['performance-data']['tx-ethernet-bytes-max-m']),
836                 txEthernetBytesSum: checkData(entry._source['performance-data']['tx-ethernet-bytes-sum'])
837
838               };
839
840               list.push(item);
841
842             });
843             $scope.performanceEthernetContainer = list;
844             $scope.gridOptionsPerformanceEthernetContainer.totalItems = response.data.hits.total;
845
846             break;
847         }
848       };
849
850       var getData = function (sort, query, grid, currFilter, currSort) {
851
852         // console.log(grid);
853         var pagesize;
854         var pagenr;
855
856         switch (grid.data) { //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)
857           case 'performance826':
858             pagesize = $scope.gridOptionsPerformance826.paginationPageSize;
859             pagenr = $scope.gridOptionsPerformance826.paginationCurrentPage;
860             break;
861
862           case 'receiveLevel':
863             pagesize = $scope.gridOptionsReceiveLevel.paginationPageSize;
864             pagenr = $scope.gridOptionsReceiveLevel.paginationCurrentPage;
865             break;
866
867           case 'transmissionLevel':
868             pagesize = $scope.gridOptionsTransmissionLevel.paginationPageSize;
869             pagenr = $scope.gridOptionsTransmissionLevel.paginationCurrentPage;
870             break;
871
872           case 'modulation':
873             pagesize = $scope.gridOptionsModulation.paginationPageSize;
874             pagenr = $scope.gridOptionsModulation.paginationCurrentPage;
875             break;
876
877           case 'temperature':
878             pagesize = $scope.gridOptionsTemperature.paginationPageSize;
879             pagenr = $scope.gridOptionsTemperature.paginationCurrentPage;
880             break;
881
882           case 'snir':
883             pagesize = $scope.gridOptionsSnir.paginationPageSize;
884             pagenr = $scope.gridOptionsSnir.paginationCurrentPage;
885             break;
886
887           case 'crossPolarDiscrimination':
888             pagesize = $scope.gridOptionsCrossPolarDiscrimination.paginationPageSize;
889             pagenr = $scope.gridOptionsCrossPolarDiscrimination.paginationCurrentPage;
890             break;
891
892           case 'performanceEthernetContainer':
893             pagesize = $scope.gridOptionsPerformanceEthernetContainer.paginationPageSize;
894             pagenr = $scope.gridOptionsPerformanceEthernetContainer.paginationCurrentPage;
895             break;
896           
897           default:
898             $mwtnLog.warning({component: COMPONENT, message: ['Unexpected grid.data', grid.data, '!'].join(' ')});
899         }
900
901         if (grid !== undefined) {
902
903           if ($scope.state.grid === null || $scope.state.grid === undefined) {
904             $scope.state.grid = grid.data;
905           }
906
907           //check, if sort/filter params are for current grid
908           if ($scope.state.grid !== grid.data) {
909             $scope.state.sort = false;
910             $scope.state.lastSort = null;
911             $scope.state.filter = false;
912             $scope.state.lastfilter = null;
913             if (currSort !== null) {
914               sort = currSort;
915             } else {
916               sort = null;
917             }
918
919             if (currFilter !== null) {
920               query = currFilter;
921             } else {
922               query = null;
923             }
924
925             //update current grid
926             $scope.state.grid = grid.data;
927           }
928         }
929
930         if (!sort) { //default sort value
931           sort = [{ 'time-stamp': { order: 'desc' } }];
932           //sort=[];
933         }
934         if (!query) { //default filter value
935           query = { query: { bool: { must: [{ prefix: globalFilter }] } } };
936         }
937
938         //add layer protocol selector to filter query
939         var localQuery = angular.copy(query); //copy the object for adding layerprotocol locally
940         var lpn = $scope.layerProtocol;
941         if (lpn === 'ETC' && $scope.revision.contains('2016')) lpn = 'ETH-CTP';
942         localQuery.query.bool.must.push({ prefix: { "layer-protocol-name": lpn } });
943
944         //add interface selector to filter query
945         if ($scope.selecteditem.selectedLtpId) {
946           localQuery.query.bool.must.push({ prefix: { "uuid-interface": $scope.selecteditem.selectedLtpId } });
947         }
948
949         var selected15minPeriod = true;
950         if ($scope.selecteditem.timePeriod !== $scope.timePeriods[0]) selected15minPeriod = false;
951         console.warn('selected15minPeriod', selected15minPeriod);
952         return $mwtnPerformanceHistory.getFilteredSortedData((pagenr - 1) * pagesize, pagesize, sort, localQuery, selected15minPeriod);
953       };
954
955       /**
956        * function to calculate the current open tab
957        * @param status - Object of current tab opening information
958        * @param previousStatus - optional Object of previous tab opening information
959        * @return latest opened tab key or undefined, in case none is currently open
960        */
961       var getKey = function(status, previousStatus) {
962         var result = Object.keys(status).filter(function(key){
963           return status[key] === true && !(previousStatus && previousStatus[key])
964         });
965         if (result.length > 0) {
966           return result[0];
967         }
968       }
969
970       // events  
971       $scope.status = { performance826: true, performanceEthernetContainer: false };
972       $scope.spinner = {};
973
974       $scope.$watch(function() {
975         return $scope.selecteditem;
976       }, function (newValue, oldValue) {
977         console.warn('selecteditem###', newValue, oldValue, $scope.networkElementId );
978
979         if (newValue.selectedLtpId && newValue.selectedLtpId !== oldValue.selectedLtpId && $scope.onfNetworkElement) {
980           $scope.layerProtocol = $scope.onfNetworkElement.getLpById(newValue.selectedLtpId).getLayer();
981
982           $scope.performance826 = [];
983           $scope.receiveLevel = [];
984           $scope.transmissionLevel = [];
985           $scope.modulation = [];
986           $scope.temperature = [];
987           $scope.performanceEthernetContainer = [];
988           $scope.snir = [];
989           $scope.crossPolarDiscrimination = [];
990           $scope.jsonvalue = [];
991
992           // if all tabs are closed - open first.
993           var isOneTabOpen = Object.keys($scope.status).filter(function(key){
994             return $scope.status[key] === true; 
995           }).length > 0;
996           if (!isOneTabOpen) {
997             $scope.status = { performance826: $scope.layerProtocol === 'MWPS', performanceEthernetContainer: $scope.layerProtocol === 'ETC' };
998           }
999         }
1000
1001         chooseGrid(getKey($scope.status));
1002
1003       }, true);
1004       
1005
1006       $scope.$watch('status', function (status, oldValue) {
1007         console.warn('status', status, oldValue,$scope.networkElementId );
1008         if ($scope.networkElementId && status && status !== oldValue) {
1009           chooseGrid(getKey(status, oldValue));
1010         }
1011       }, true);
1012
1013
1014       // $scope.$watch(function(){
1015       //   $scope.selecteditem.timePeriod;
1016       // }, function (newValue, oldValue) {
1017       //   console.warn('timePeriod', status, oldValue,$scope.networkElementId );
1018       //   if (newValue && oldValue !== "" && newValue !== oldValue) {
1019       //     chooseGrid(getKey($scope.status));
1020       //   }
1021       // }, true);
1022
1023       $scope.collapseAll = function () {
1024         // close all groups
1025         Object.keys($scope.status).map(function (group) {
1026           $scope.status[group] = false;
1027         });
1028         Object.keys($scope.spinner).map(function (group) {
1029           $scope.spinner[group] = false;
1030         });
1031       };
1032
1033       var order = $mwtnPerformanceHistory.layerProtocolNameOrder;
1034
1035       /**
1036        * @function updateNe 
1037        * A function, which updates onfNetworkElement by new data.
1038        * @param {*} data New data recieved from OpenDaylight via RestConf
1039        */
1040       var updateNe = function(data) {
1041         if (!data) return;
1042         // update onfNetworkElement
1043         switch ($scope.revision) {
1044           case '2016-08-09':
1045           case '2016-08-11':
1046           case '2016-09-01':
1047           case '2017-02-17':
1048           case '2017-03-20':
1049           case '2017-03-24':
1050             // console.log(JSON.stringify(data));        
1051             $scope.onfNetworkElement = new OnfNetworkElement(data['network-element']);
1052             $scope.onfLtps = $scope.onfNetworkElement.getLogicalTerminationPoints().filter(function(ltp){
1053               return ltp.getLayer() === 'MWPS' || ltp.getLayer() === 'ETC';
1054             }).sort(function(a, b){
1055               if(order[a.getLayer()] < order[b.getLayer()]) return 1;
1056               if(order[a.getLayer()] > order[b.getLayer()]) return -1;
1057               if(a.getId() < b.getId()) return -1;
1058               if(a.getId() > b.getId()) return 1;
1059               return 0;
1060             });
1061             $scope.availableLtpIds = $scope.onfLtps.map(function(ltp){
1062               return {key: ltp.getLayerProtocols()[0].getId(), label:ltp.getLabel()};
1063             });
1064             if ($scope.availableLtpIds.length > 0) {
1065               $scope.selecteditem.selectedLtpId = $scope.availableLtpIds[0].key;
1066             }
1067             break;
1068           default:
1069             $mwtnLog.info({component: COMPONENT, message: ['The ONF Microwave Model revision', $scope.revision, ' is not supported (yet)!'].join(' ')});
1070             $scope.onfNetworkElement = {};
1071             $scope.onfLtps = {};
1072         }
1073       };
1074
1075       var updatePart = function(spec, data) {
1076         switch (spec.pacId) {
1077           case 'ne':
1078             updateNe(data);
1079             break;
1080         }
1081       };
1082
1083       //get data on ne selection
1084       $scope.$watch('networkElement', function (neId, oldValue) {
1085         console.warn('networkElement', neId, oldValue,$scope.networkElementId );
1086         
1087         if (neId && neId !== '' && neId !== oldValue) {
1088           $scope.selecteditem.selectedLtpId = undefined;
1089           var revision;
1090           $scope.networkElements.map(function (ne) {
1091             if (ne.id === neId) revision = ne.revision;
1092           });
1093           $scope.networkElementId = neId;
1094           $scope.revision = revision;
1095
1096           //get data
1097           var filter = { "query": { "bool": { "must": [{ "prefix": { "node-name": $scope.networkElementId } }] } } };
1098           // var filter={"query":{"bool":{"must":[{"prefix":{"node-name": "new"}}]}}}; //first part of my local simulator name
1099           globalFilter = filter.query.bool.must[0].prefix;
1100           $scope.state.filter = true;
1101           $scope.state.lastfilter = filter;
1102           $scope.state.sort = false;
1103           $scope.state.lastSort = null;
1104
1105           // get onf network element data
1106           var spec = {
1107             nodeId: $scope.networkElementId,
1108             revision: $scope.revision,
1109             pacId: 'ne'
1110           };
1111           console.warn('PM HIstory getPacPMHistory', JSON.stringify(spec));
1112           $mwtnPerformanceHistory.getPacParts(spec).then(function(success){
1113             $scope.collapseAll();
1114             // console.warn('PM HIstory getPacPMHistory', JSON.stringify(success));
1115             updatePart(spec, $mwtnPerformanceHistory.yangifyObject(success));
1116           }, function(error){
1117             console.error(JSON.stringify(error));
1118             $scope.collapseAll();
1119             updatePart(spec, error);
1120           });
1121         }
1122       });
1123
1124       var chooseGrid = function (key) {
1125         if (!$scope.networkElementId || !key) return;
1126
1127             switch (key) {
1128
1129               case 'performance826':
1130                 getData(null, null, $scope.gridOptionsPerformance826).then(function (response) {
1131                   if (response.data.hits.hits) {
1132                     processRequestInGrid(response, $scope.gridOptionsPerformance826);
1133                   }
1134                 });
1135                 break;
1136
1137               case 'receiveLevel':
1138                 getData(null, null, $scope.gridOptionsReceiveLevel).then(function (response) {
1139                   if (response.data.hits.hits) {
1140                     processRequestInGrid(response, $scope.gridOptionsReceiveLevel);
1141                   }
1142                 });
1143                 break;
1144
1145               case 'transmissionLevel':
1146                 getData(null, null, $scope.gridOptionsTransmissionLevel).then(function (response) {
1147                   if (response.data.hits.hits) {
1148                     processRequestInGrid(response, $scope.gridOptionsTransmissionLevel);
1149                   }
1150                 });
1151                 break;
1152
1153               case 'modulation':
1154                 getData(null, null, $scope.gridOptionsModulation).then(function (response) {
1155                   if (response.data.hits.hits) {
1156                     processRequestInGrid(response, $scope.gridOptionsModulation);
1157                   }
1158                 });
1159                 break;
1160
1161               case 'temperature':
1162                 getData(null, null, $scope.gridOptionsTemperature).then(function (response) {
1163                   if (response.data.hits.hits) {
1164                     processRequestInGrid(response, $scope.gridOptionsTemperature);
1165                   }
1166                 });
1167                 break;
1168
1169               case 'snir':
1170                 getData(null, null, $scope.gridOptionsSnir).then(function (response) {
1171                   if (response.data.hits.hits) {
1172                     processRequestInGrid(response, $scope.gridOptionsSnir);
1173                   }
1174                 });
1175                 break;
1176
1177               case 'crossPolarDiscrimination':
1178                 getData(null, null, $scope.gridOptionsCrossPolarDiscrimination).then(function (response) {
1179                   if (response.data.hits.hits) {
1180                     processRequestInGrid(response, $scope.gridOptionsCrossPolarDiscrimination);
1181                   }
1182                 });
1183                 break;
1184
1185               case 'performanceEthernetContainer':
1186                 getData(null, null, $scope.gridOptionsPerformanceEthernetContainer).then(function (response) {
1187                   if (response.data.hits.hits) {
1188                     processRequestInGrid(response, $scope.gridOptionsPerformanceEthernetContainer);
1189                   }
1190                 });
1191                 break;
1192             }
1193             $window.dispatchEvent(new Event("resize"));
1194       };
1195     }]);
1196   });