1window.angular && (function(angular) {
2  'use strict';
3
4  angular.module('app.common.directives').directive('syslogFilter', [
5    'APIUtils',
6    function(APIUtils) {
7      return {
8        'restrict': 'E',
9        'template': require('./syslog-filter.html'),
10        'controller': [
11          '$rootScope', '$scope', 'dataService', '$location',
12          function($rootScope, $scope, dataService, $location) {
13            $scope.dataService = dataService;
14
15            $scope.toggleSeverityAll = function() {
16              $scope.selectedSeverityList = [];
17            };
18
19            $scope.toggleSeverity = function(severity) {
20              if (severity == 'All') {
21                $scope.selectedSeverityList = [];
22                return;
23              }
24
25              var index = $scope.selectedSeverityList.indexOf(severity);
26              if (index > -1) {
27                $scope.selectedSeverityList.splice(index, 1);
28              } else {
29                $scope.selectedSeverityList.push(severity);
30              }
31              if ($scope.selectedSeverityList.length >=
32                  ($scope.severityList.length - 1)) {
33                $scope.selectedSeverityList = [];
34              }
35            };
36
37            $scope.selectType = function(type) {
38              $scope.selectedType = type;
39              $scope.typeFilter = false;
40            };
41          }
42        ]
43      };
44    }
45  ]);
46})(window.angular);
47