<commit_before>/*
 * Copyright (c) 2016 highstreet technologies GmbH and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

define(['app/mwtnSpectrum/mwtnSpectrum.module',
        'app/mwtnSpectrum/mwtnSpectrum.services',
        'app/mwtnCommons/mwtnCommons.services'], function(mwtnSpectrumApp) {

  mwtnSpectrumApp.register.controller('mwtnSpectrumCtrl', ['$scope', '$rootScope', 'uiGridConstants','$mwtnSpectrum', '$mwtnLog', 'OnfNetworkElement', 'MicrowavePhysicalSection',
                                                           function($scope, $rootScope, uiGridConstants, $mwtnSpectrum, $mwtnLog, OnfNetworkElement, MicrowavePhysicalSection) {

    var COMPONENT = 'mwtnSpectrumCtrl';
    $mwtnLog.info({component: COMPONENT, message: 'mwtnSpectrumCtrl started!'});

    $rootScope['section_logo'] = 'src/app/mwtnSpectrum/images/mwtnSpectrum.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'

    $scope.interference = {
        alarmStatus: 'cleared'
    };

    $scope.execute = function() {
      $mwtnSpectrum.execute().then(function(success) {
        $scope.interference.alarmStatus = 'raised';
      }, function(error) {
        $scope.interference.alarmStatus = 'cleared';
      });
    };
    $scope.clear = function() {
      console.log("Cleared");
      $scope.interference.alarmStatus = 'cleared';
    };

    var updateAirInterface = function(spec, data) {
      if (data) {
        var radioSignalID = data.airInterfaceConfiguration.radioSignalID;      
        $scope.gridOptions.data.map(function(row){
          if (row.name === spec.nodeId && row.radioSignalID === radioSignalID) {
            row.actualTxFrequency = data.airInterfaceConfiguration.txFrequency;
            row.actualRxFrequency = data.airInterfaceConfiguration.rxFrequency;
          }
        });
      } else {
        $scope.gridOptions.data.map(function(row){
          if (row.nodeId === spec.nodeId) {
            row.actualTxFrequency = '?';
            row.actualRxFrequency = '?';
          }
        });
      }
    };
    
    $scope.processing = false;
    $scope.refresh = function() {
      $scope.processing = true;
      $mwtnSpectrum.refresh().then(function(success){
        $scope.processing = false;
        $scope.gridOptions.data = success.airInterfaces;
        success.actualNodes.map(function(actualNode){
          if (actualNode.connectionStatus !== 'connected') {
            return;
          }
          var revision = '2016-09-01';
          $mwtnSpectrum.getActualNetworkElement(actualNode.id, revision).then(function(onfNe){
            var aOnfNe = new OnfNetworkElement(onfNe.NetworkElement);
            aOnfNe.getLTPMwpsList().map(function(ltp){
              var spec = {
                nodeId: actualNode.id,
                revision: revision,
                pacId: 'airinterface',
                layerProtocolId: ltp._lpList[0].uuid,
                partId: 'Configuration'
              };
              $mwtnSpectrum.getPacParts(spec).then(function(success){
                updateAirInterface(spec, success);
              }, function(error){
                updateAirInterface(spec, error);
              });
            });
          }, function(error){
            // do nothing
          });
        });
      }, function(error){
        $scope.processing = false;
        $scope.gridOptions.data = [];
      });
    };

    $scope.highlightFilteredHeader = $mwtnSpectrum.highlightFilteredHeader;

    var requiredNesConnectionStatusCellTemplate = [
       '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
       '  <i ng-show="grid.getCellValue(row, col) === \'connected\'" class="fa fa-signal" aria-hidden="true"></i>',
       '  <span>{{grid.getCellValue(row, col)}}</span>',
       '</div>'].join('');

    var actualTxFrequencyCellTemplate = [
     '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
     '  <span ng-class="{\'mismatch\': {{row.entity.plannedTxFrequency}} - grid.getCellValue(row, col) === 0}">{{grid.getCellValue(row, col)}}</span>',
     '</div>'].join('');

    var actualRxFrequencyCellTemplate = [
     '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
     '  <span ng-class="{\'mismatch\': {{row.entity.plannedRxFrequency}} - grid.getCellValue(row, col) === 0}">{{grid.getCellValue(row, col)}}</span>',
     '</div>'].join('');
  <commit_msg>bug fix<commit_after>/*
 * Copyright (c) 2016 highstreet technologies GmbH and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

define(['app/mwtnSpectrum/mwtnSpectrum.module',
        'app/mwtnSpectrum/mwtnSpectrum.services',
        'app/mwtnCommons/mwtnCommons.services'], function(mwtnSpectrumApp) {

  mwtnSpectrumApp.register.controller('mwtnSpectrumCtrl', ['$scope', '$rootScope', 'uiGridConstants','$mwtnSpectrum', '$mwtnLog', 'OnfNetworkElement', 'MicrowavePhysicalSection',
                                                           function($scope, $rootScope, uiGridConstants, $mwtnSpectrum, $mwtnLog, OnfNetworkElement, MicrowavePhysicalSection) {

    var COMPONENT = 'mwtnSpectrumCtrl';
    $mwtnLog.info({component: COMPONENT, message: 'mwtnSpectrumCtrl started!'});

    $rootScope['section_logo'] = 'src/app/mwtnSpectrum/images/mwtnSpectrum.png'; // Add your topbar logo location here such as 'assets/images/logo_topology.gif'

    $scope.interference = {
        alarmStatus: 'cleared'
    };

    $scope.execute = function() {
      $mwtnSpectrum.execute().then(function(success) {
        $scope.interference.alarmStatus = 'raised';
      }, function(error) {
        $scope.interference.alarmStatus = 'cleared';
      });
    };
    $scope.clear = function() {
      console.log("Cleared");
      $scope.interference.alarmStatus = 'cleared';
    };

    var updateAirInterface = function(spec, data) {
      if (data) {
        var radioSignalID = data.airInterfaceConfiguration.radioSignalID;      
        $scope.gridOptions.data.map(function(row){
          if (row.name === spec.nodeId && row.radioSignalID === radioSignalID) {
            row.actualTxFrequency = data.airInterfaceConfiguration.txFrequency;
            row.actualRxFrequency = data.airInterfaceConfiguration.rxFrequency;
          }
        });
      } else {
        $scope.gridOptions.data.map(function(row){
          if (row.nodeId === spec.nodeId) {
            row.actualTxFrequency = '?';
            row.actualRxFrequency = '?';
          }
        });
      }
    };
    
    $scope.processing = false;
    $scope.refresh = function() {
      $scope.processing = true;
      $mwtnSpectrum.refresh().then(function(success){
        $scope.processing = false;
        $scope.gridOptions.data = success.airInterfaces;
        success.actualNodes.map(function(actualNode){
          if (actualNode.connectionStatus !== 'connected') {
            return;
          }
          var revision = '2016-09-01';
          $mwtnSpectrum.getActualNetworkElement(actualNode.id, revision).then(function(onfNe){
            var aOnfNe = new OnfNetworkElement(onfNe.NetworkElement);
            aOnfNe.getLTPMwpsList().map(function(ltp){
              var spec = {
                nodeId: actualNode.id,
                revision: revision,
                pacId: 'airinterface',
                layerProtocolId: ltp._lpList[0].uuid,
                partId: 'Configuration'
              };
              $mwtnSpectrum.getPacParts(spec).then(function(success){
                updateAirInterface(spec, success);
              }, function(error){
                updateAirInterface(spec, error);
              });
            });
          }, function(error){
            // do nothing
          });
        });
      }, function(error){
        $scope.processing = false;
        $scope.gridOptions.data = [];
      });
    };

    $scope.highlightFilteredHeader = $mwtnSpectrum.highlightFilteredHeader;

    var requiredNesConnectionStatusCellTemplate = [
       '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
       '  <i ng-show="grid.getCellValue(row, col) === \'connected\'" class="fa fa-signal" aria-hidden="true"></i>',
       '  <span>{{grid.getCellValue(row, col)}}</span>',
       '</div>'].join('');

    var actualTxFrequencyCellTemplate = [
     '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
     '  <span ng-class="{\'mismatch\': {{row.entity.plannedTxFrequency}} === grid.getCellValue(row, col) }">{{grid.getCellValue(row, col)}}</span>',
     '</div>'].join('');

    var actualRxFrequencyCellTemplate = [
     '<div class="ui-grid-cell-contents" ng-class="{ \'green\': grid.getCellValue(row, col) === \'connected\'}"}>',
     '  <span ng-class="{\'mismatch\': {{row.entity.plannedRxFrequency}} === grid.getCellValue(row, col) }">{{grid.getCellValue(row, col)}}</span>',
     '</div>'].join('');
  
{'fraction_non_alphanumeric': 0.15391102677630192, 'fraction_numerical': 0.003795066413662239, 'mean_word_length': 2.660108024691358, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4633282', 'n_tokens_mistral': 2946, 'n_tokens_neox': 2769, 'n_words': 449}