summaryrefslogtreecommitdiffstats
path: root/app/common/directives/syslog-filter.js
blob: cdd32ae044d2ec3ca8e98470539f9bad74a6ba7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
window.angular && (function(angular) {
  'use strict';

  angular.module('app.common.directives').directive('syslogFilter', [
    'APIUtils',
    function(APIUtils) {
      return {
        'restrict': 'E',
        'template': require('./syslog-filter.html'),
        'controller': [
          '$rootScope', '$scope', 'dataService', '$location',
          function($rootScope, $scope, dataService, $location) {
            $scope.dataService = dataService;

            $scope.toggleSeverityAll = function() {
              $scope.selectedSeverityList = [];
            };

            $scope.toggleSeverity = function(severity) {
              if (severity == 'All') {
                $scope.selectedSeverityList = [];
                return;
              }

              var index = $scope.selectedSeverityList.indexOf(severity);
              if (index > -1) {
                $scope.selectedSeverityList.splice(index, 1);
              } else {
                $scope.selectedSeverityList.push(severity);
              }
              if ($scope.selectedSeverityList.length >=
                  ($scope.severityList.length - 1)) {
                $scope.selectedSeverityList = [];
              }
            };

            $scope.selectType = function(type) {
              $scope.selectedType = type;
              $scope.typeFilter = false;
            };
          }
        ]
      };
    }
  ]);
})(window.angular);
OpenPOWER on IntegriCloud