angular
  .module('horizon.dashboard.project.vitrage')
  .directive('hzAlarms', hzAlarms);

function hzAlarms() {
  var directive = {
    templateUrl: STATIC_URL + 'dashboard/project/components/alarms/alarms.html',
    restrict: 'E',
    scope: {
      selected: '='
    },
    controller: AlarmsController,
    controllerAs: 'alarmsCtrl'
  };

  AlarmsController.$inject = ['$scope', 'modalSrv', 'timeSrv', 'vitrageTopologySrv'];
  return directive;

  function AlarmsController($scope, modalSrv, timeSrv, vitrageTopologySrv) {
    var alarmsCtrl = this;
    alarmsCtrl.timezone = timeSrv.getHorizonTimezone();
    alarmsCtrl.dateFormat = timeSrv.longDateFormat;

    $scope.$watch('selected', function(newData, oldData) {
      if (newData != oldData) {
        console.log('selected ', newData);
        vitrageTopologySrv.getAlarms(newData.vitrage_id).then(function(result) {
          alarmsCtrl.computeAlarms = result.data;
        });
      }
    });

    alarmsCtrl.onAlarmClick = function(alarm) {
      var modalOptions = {
        animation: true,
        templateUrl: STATIC_URL + 'dashboard/project/components/rca/rcaContainer.html',
        controller: 'RcaContainerController',
        windowClass: 'app-modal-window',
        resolve: {alarm: function() {
          return alarm;
        }}
      };

      modalSrv.show(modalOptions);
    }
  }
}


angular
  .module('horizon.dashboard.project.vitrage')
  .directive('hzAlarms', hzAlarms);

function hzAlarms() {
  var directive = {
    templateUrl: STATIC_URL + 'dashboard/project/components/alarms/alarms.html',
    restrict: 'E',
    scope: {
      selected: '='
    },
    controller: AlarmsController,
    controllerAs: 'alarmsCtrl'
  };

  AlarmsController.$inject = ['$scope', 'modalSrv', 'timeSrv', 'vitrageTopologySrv'];
  return directive;

  function AlarmsController($scope, modalSrv, timeSrv, vitrageTopologySrv) {
    var alarmsCtrl = this;
    alarmsCtrl.timezone = timeSrv.getHorizonTimezone();
    alarmsCtrl.dateFormat = timeSrv.longDateFormat;

    $scope.$watch('selected', function(newData, oldData) {
      if (newData != oldData) {
        console.log('selected ', newData);
	var config = {vitrage_id: newData.vitrage_id};
        vitrageTopologySrv.getAlarms(config).then(function(result) {
          alarmsCtrl.computeAlarms = result.data;
        });
      }
    });

    alarmsCtrl.onAlarmClick = function(alarm) {
      var modalOptions = {
        animation: true,
        templateUrl: STATIC_URL + 'dashboard/project/components/rca/rcaContainer.html',
        controller: 'RcaContainerController',
        windowClass: 'app-modal-window',
        resolve: {alarm: function() {
          return alarm;
        }}
      };

      modalSrv.show(modalOptions);
    }
  }
}


Make the alarm list in Vitrage Topology view related to the selected entity
Make the alarm list in Vitrage Topology view  related to the selected entity

Change-Id: I1de754ada13262ffa0f7a76de2c1b390f31a36f6
story: #2004725
task: # 28763
