18b4828a6SIftekharul Islamwindow.angular && (function (angular) {
28b4828a6SIftekharul Islam    'use strict';
38b4828a6SIftekharul Islam
48b4828a6SIftekharul Islam    angular
58b4828a6SIftekharul Islam        .module('app.common.directives')
68b4828a6SIftekharul Islam        .directive('logFilter', ['APIUtils', function (APIUtils) {
78b4828a6SIftekharul Islam            return {
88b4828a6SIftekharul Islam                'restrict': 'E',
9*bbcf670aSEd Tanous                'template': require('./log-filter.html'),
108b4828a6SIftekharul Islam                'controller': ['$rootScope', '$scope','dataService', '$location', function($rootScope, $scope, dataService, $location){
118b4828a6SIftekharul Islam                    $scope.dataService = dataService;
128b4828a6SIftekharul Islam                    $scope.toggleSeverityAll = function(){
138b4828a6SIftekharul Islam                        $scope.selectedSeverity.all = !$scope.selectedSeverity.all;
148b4828a6SIftekharul Islam
158b4828a6SIftekharul Islam                        if($scope.selectedSeverity.all){
168b4828a6SIftekharul Islam                            $scope.selectedSeverity.low = false;
178b4828a6SIftekharul Islam                            $scope.selectedSeverity.medium = false;
188b4828a6SIftekharul Islam                            $scope.selectedSeverity.high = false;
198b4828a6SIftekharul Islam                        }
208b4828a6SIftekharul Islam                    }
218b4828a6SIftekharul Islam
228b4828a6SIftekharul Islam                    $scope.toggleSeverity = function(severity){
238b4828a6SIftekharul Islam                        $scope.selectedSeverity[severity] = !$scope.selectedSeverity[severity];
248b4828a6SIftekharul Islam
25df3bd124SMichael Davis                        if(['high', 'medium', 'low'].indexOf(severity) > -1){
2696bbf310SIftekharul Islam                            if($scope.selectedSeverity[severity] == false &&
2796bbf310SIftekharul Islam                               (!$scope.selectedSeverity.low &&
2896bbf310SIftekharul Islam                                !$scope.selectedSeverity.medium &&
2996bbf310SIftekharul Islam                                !$scope.selectedSeverity.high
3096bbf310SIftekharul Islam                               )){
31df3bd124SMichael Davis                                $scope.selectedSeverity.all = true;
32df3bd124SMichael Davis                                return;
33df3bd124SMichael Davis                            }
34df3bd124SMichael Davis                        }
35df3bd124SMichael Davis
368b4828a6SIftekharul Islam                        if($scope.selectedSeverity.low &&
378b4828a6SIftekharul Islam                           $scope.selectedSeverity.medium &&
388b4828a6SIftekharul Islam                           $scope.selectedSeverity.high){
398b4828a6SIftekharul Islam                            $scope.selectedSeverity.all = true;
408b4828a6SIftekharul Islam                            $scope.selectedSeverity.low = false;
418b4828a6SIftekharul Islam                            $scope.selectedSeverity.medium = false;
428b4828a6SIftekharul Islam                            $scope.selectedSeverity.high = false;
438b4828a6SIftekharul Islam                        }else{
448b4828a6SIftekharul Islam                            $scope.selectedSeverity.all = false;
458b4828a6SIftekharul Islam                        }
468b4828a6SIftekharul Islam                    }
478b4828a6SIftekharul Islam                }]
488b4828a6SIftekharul Islam            };
498b4828a6SIftekharul Islam        }]);
508b4828a6SIftekharul Islam})(window.angular);
51