2 * Copyright (c) 2016 highstreet technologies GmbH and others. All rights reserved.
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
9 define(['app/mwtnClosedLoop/mwtnClosedLoop.module','app/mwtnClosedLoop/mwtnClosedLoop.services','app/mwtnCommons/mwtnCommons.services'], function(mwtnClosedLoopApp) {
11 mwtnClosedLoopApp.register.controller('mwtnClosedLoopCtrl', ['$scope', '$rootScope', 'uiGridConstants', '$mwtnClosedLoop', '$mwtnCommons', '$mwtnLog', 'OnfNetworkElement', 'MicrowavePhysicalSection',
12 function($scope, $rootScope, uiGridConstants, $mwtnClosedLoop, $mwtnCommons, $mwtnLog, OnfNetworkElement, MicrowavePhysicalSection) {
14 var COMPONENT = 'mwtnClosedLoopCtrl';
15 $mwtnLog.info({component: COMPONENT, message: 'Started!'});
17 $rootScope.section_logo = 'src/app/mwtnClosedLoop/images/mwtnClosedLoop.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'
19 $scope.timerOptionList = [
20 {id : '5seconds', name : "5 seconds"},
21 {id : '30seconds', name : "30 seconds"},
22 {id : '1minute', name : "One minute"},
23 {id : '2minutes', name : "Two minutes"},
24 {id : '30minutes', name : "30 minutes"},
25 {id : '1hour', name : "One hour"}];
27 var clearMessages = function() {
28 $scope.info = undefined;
29 $scope.error = undefined;
32 $scope.executeNow = function() {
34 $mwtnCommons.executeClosedLoopAutomation().then(function(message){
35 $mwtnLog.info({component: 'mwtnClosedLoopCtrl', message: 'Closed loop automation was started'});
36 $scope.info = 'Closed loop automation was executed: ' + new Date().toISOString().toHumanReadableTimeFormat();
39 $mwtnLog.error({component: 'mwtnClosedLoopCtrl', message: 'Cannot execute Closed Loop Automation'});
40 $scope.error = 'Cannot execute Closed Loop Automation';
45 $scope.save = function() {
47 $mwtnCommons.saveClosedLoopAutomation($scope.timerEnabled, $scope.timerOption).then(function(message){
48 $mwtnLog.info({component: 'mwtnClosedLoopCtrl', message: 'Timer was changed'});
49 $scope.info = 'Timer was changed';
52 $mwtnLog.error({component: 'mwtnClosedLoopCtrl', message: 'Cannot save timer'});
53 $scope.error = 'Cannot save timer';
58 $scope.read = function() {
60 $mwtnCommons.readClosedLoopAutomation().then(function(message){
61 $scope.timerEnabled = message.data.output.enabled;
62 $scope.timerOption = message.data.output.option;
65 $mwtnLog.error({component: 'mwtnClosedLoopCtrl', message: 'Cannot read configuration data from the server'});
66 $scope.error = 'Cannot read configuration data from the server';
73 var updateAirInterface = function(spec, data) {
75 var radioSignalID = data.airInterfaceConfiguration.radioSignalID;
76 $scope.gridOptions.data.map(function(row){
77 if (row.name === spec.nodeId && row.radioSignalID === radioSignalID) {
78 row.actualAirInterfaceName = data.airInterfaceConfiguration.airInterfaceName;
82 $scope.gridOptions.data.map(function(row){
83 if (row.nodeId === spec.nodeId) {
84 row.actualAirInterfaceName = '?';
90 $scope.processing = false;
91 $scope.refresh = function() {
92 $scope.processing = true;
93 $mwtnClosedLoop.refresh().then(function(success){
94 $scope.processing = false;
95 $scope.gridOptions.data = success.airInterfaces;
96 success.actualNodes.map(function(actualNode){
97 if (actualNode.connectionStatus !== 'connected') {
100 var revision = '2016-09-01';
101 $mwtnClosedLoop.getActualNetworkElement(actualNode.id, revision).then(function(onfNe){
102 var aOnfNe = new OnfNetworkElement(onfNe.NetworkElement);
103 aOnfNe.getLTPMwpsList().map(function(ltp){
105 nodeId: actualNode.id,
107 pacId: 'airinterface',
108 layerProtocolId: ltp._lpList[0].uuid,
109 partId: 'Configuration'
111 $mwtnClosedLoop.getPacParts(spec).then(function(success){
112 updateAirInterface(spec, success);
114 updateAirInterface(spec, error);
122 $scope.processing = false;
123 $scope.gridOptions.data = [];
127 $scope.highlightFilteredHeader = $mwtnClosedLoop.highlightFilteredHeader;
129 var requiredNesConnectionStatusCellTemplate = [
130 '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
131 ' <i ng-show="grid.getCellValue(row, col) === \'connected\'" class="fa fa-link" aria-hidden="true"></i>',
132 ' <span>{{grid.getCellValue(row, col)}}</span>',
135 // ng-class="{\'mismatch\': {{row.entity.plannedAirInterfaceName}} !== grid.getCellValue(row, col) }"
136 var actualAirinterfaceNameTemplate = [
137 '<div class="ui-grid-cell-contents">',
138 ' <span>{{grid.getCellValue(row, col)}}</span>',
141 $scope.gridOptions = JSON.parse(JSON.stringify($mwtnClosedLoop.gridOptions));
142 $scope.gridOptions.columnDefs = [
143 { field: 'id', type: 'number', displayName: 'Id', headerCellClass: $scope.highlightFilteredHeader, width : 50, cellClass: 'number', pinnedLeft : true , sort: {
144 direction: uiGridConstants.ASC,
148 { field: 'name', type: 'string', displayName: 'Name', headerCellClass: $scope.highlightFilteredHeader, width : 140 },
149 { field: 'connectionStatus', type: 'string', displayName: 'Connection status', headerCellClass: $scope.highlightFilteredHeader, width : 150, cellTemplate: requiredNesConnectionStatusCellTemplate },
150 { field: 'radioSignalID', type: 'string', displayName: 'Radio signal id', headerCellClass: $scope.highlightFilteredHeader, width : 130 },
151 { field: 'plannedAirInterfaceName', type: 'string', displayName: 'Planned airinterface name', headerCellClass: $scope.highlightFilteredHeader, width : 200 },
152 { field: 'actualAirInterfaceName', type: 'string', displayName: 'Actual airinterface name', headerCellClass: $scope.highlightFilteredHeader, width : 250, cellTemplate: actualAirinterfaceNameTemplate},