Assign image keyname and pubkey at vnf level
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / ux / mwtnSpectrum / mwtnSpectrum-module / src / main / resources / mwtnSpectrum / mwtnSpectrum.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/mwtnSpectrum/mwtnSpectrum.module',
10         'app/mwtnSpectrum/mwtnSpectrum.services',
11         'app/mwtnCommons/mwtnCommons.services'], function(mwtnSpectrumApp) {
12
13   mwtnSpectrumApp.register.controller('mwtnSpectrumCtrl', ['$scope', '$rootScope', 'uiGridConstants','$mwtnSpectrum', '$mwtnLog', 'OnfNetworkElement', 'MicrowavePhysicalSection',
14                                                            function($scope, $rootScope, uiGridConstants, $mwtnSpectrum, $mwtnLog, OnfNetworkElement, MicrowavePhysicalSection) {
15
16     var COMPONENT = 'mwtnSpectrumCtrl';
17     $mwtnLog.info({component: COMPONENT, message: 'mwtnSpectrumCtrl started!'});
18
19     $rootScope.section_logo = 'src/app/mwtnSpectrum/images/mwtnSpectrum.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'
20    
21     $scope.interference = {
22         alarmStatus: 'cleared'
23     };
24
25     $scope.execute = function() {
26       $scope.interference.alarmStatus = 'raised';
27       $mwtnSpectrum.execute().then(function(success) {
28         $scope.interference.alarmStatus = 'cleared';
29       }, function(error) {
30         $scope.interference.alarmStatus = 'cleared';
31       });
32     };
33     $scope.clear = function() {
34       console.log("Cleared");
35       $scope.interference.alarmStatus = 'cleared';
36     };
37
38     var updateAirInterface = function(spec, data) {
39       if (data) {
40         var radioSignalID = data.airInterfaceConfiguration.radioSignalID;      
41         $scope.gridOptions.data.map(function(row){
42           if (row.name === spec.nodeId && row.radioSignalID === radioSignalID) {
43             row.actualTxFrequency = data.airInterfaceConfiguration.txFrequency;
44             row.actualRxFrequency = data.airInterfaceConfiguration.rxFrequency;
45           }
46         });
47       } else {
48         $scope.gridOptions.data.map(function(row){
49           if (row.nodeId === spec.nodeId) {
50             row.actualTxFrequency = '?';
51             row.actualRxFrequency = '?';
52           }
53         });
54       }
55     };
56     
57     $scope.processing = false;
58     $scope.refresh = function() {
59       $scope.processing = true;
60       $scope.interference.alarmStatus = 'cleared';
61       $mwtnSpectrum.refresh().then(function(success){
62         $scope.processing = false;
63         $scope.gridOptions.data = success.airInterfaces;
64         success.actualNodes.map(function(actualNode){
65           if (actualNode.connectionStatus !== 'connected') {
66             return;
67           }
68           var revision = '2016-09-01';
69           $mwtnSpectrum.getActualNetworkElement(actualNode.id, revision).then(function(onfNe){
70             var aOnfNe = new OnfNetworkElement(onfNe.NetworkElement);
71             aOnfNe.getLTPMwpsList().map(function(ltp){
72               var spec = {
73                 nodeId: actualNode.id,
74                 revision: revision,
75                 pacId: 'airinterface',
76                 layerProtocolId: ltp._lpList[0].uuid,
77                 partId: 'Configuration'
78               };
79               $mwtnSpectrum.getPacParts(spec).then(function(success){
80                 updateAirInterface(spec, success);
81               }, function(error){
82                 updateAirInterface(spec, error);
83               });
84             });
85           }, function(error){
86             // do nothing
87           });
88         });
89       }, function(error){
90         $scope.processing = false;
91         $scope.gridOptions.data = [];
92       });
93     };
94
95     $scope.highlightFilteredHeader = $mwtnSpectrum.highlightFilteredHeader;
96
97     var requiredNesConnectionStatusCellTemplate = [
98        '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
99        '  <i ng-show="grid.getCellValue(row, col) === \'connected\'" class="fa fa-link" aria-hidden="true"></i>',
100        '  <span>{{grid.getCellValue(row, col)}}</span>',
101        '</div>'].join('');
102
103     var actualTxFrequencyCellTemplate = [
104      '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
105      '  <span ng-class="{\'mismatch\': {{row.entity.plannedTxFrequency}} !== grid.getCellValue(row, col) }">{{grid.getCellValue(row, col)}}</span>',
106      '</div>'].join('');
107
108     var actualRxFrequencyCellTemplate = [
109      '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
110      '  <span ng-class="{\'mismatch\': {{row.entity.plannedRxFrequency}} !== grid.getCellValue(row, col) }">{{grid.getCellValue(row, col)}}</span>',
111      '</div>'].join('');
112   
113     $scope.gridOptions = JSON.parse(JSON.stringify($mwtnSpectrum.gridOptions));
114     $scope.gridOptions.columnDefs = [
115      { field: 'id', type: 'number', displayName: 'Id',  headerCellClass: $scope.highlightFilteredHeader, width : 50, cellClass: 'number', pinnedLeft : true , sort: {
116        direction: uiGridConstants.ASC,
117        ignoreSort: false,
118        priority: 0
119       }},
120      { field: 'name', type: 'string', displayName: 'Name',  headerCellClass: $scope.highlightFilteredHeader, width : 140 },
121      { field: 'connectionStatus', type: 'string', displayName: 'Connection status',  headerCellClass: $scope.highlightFilteredHeader, width : 150, cellTemplate: requiredNesConnectionStatusCellTemplate },
122      { field: 'airInterfaceName', type: 'string', displayName: 'Airinterface name',  headerCellClass: $scope.highlightFilteredHeader, width : 140 },
123      { field: 'radioSignalID', type: 'string', displayName: 'Radio signal id',  headerCellClass: $scope.highlightFilteredHeader, width : 130 },
124      { field: 'plannedTxFrequency',  type: 'number', displayName: 'TX (plan)',  headerCellClass: $scope.highlightFilteredHeader, width : 110, cellClass: 'number' },
125      { field: 'actualTxFrequency',  type: 'number', displayName: 'TX (actual)',  headerCellClass: $scope.highlightFilteredHeader, width : 110, cellClass: 'number', cellTemplate: actualTxFrequencyCellTemplate},
126      { field: 'plannedRxFrequency',  type: 'number', displayName: 'RX (plan)',  headerCellClass: $scope.highlightFilteredHeader, width : 110, cellClass: 'number' },
127      { field: 'actualRxFrequency',  type: 'number', displayName: 'RX (actual)',  headerCellClass: $scope.highlightFilteredHeader, width : 110, cellClass: 'number', cellTemplate: actualRxFrequencyCellTemplate}
128      ];
129
130     $scope.refresh();
131
132   }]);
133
134
135 });