1window.angular && (function(angular) { 2 'use strict'; 3 4 angular.module('app.common.directives').directive('logFilter', [ 5 'APIUtils', 6 function(APIUtils) { 7 return { 8 'restrict': 'E', 9 'template': require('./log-filter.html'), 10 'controller': [ 11 '$rootScope', '$scope', 'dataService', '$location', 12 function($rootScope, $scope, dataService, $location) { 13 $scope.dataService = dataService; 14 $scope.supportsDateInput = true; 15 16 $scope.toggleSeverityAll = function() { 17 $scope.selectedSeverity.all = !$scope.selectedSeverity.all; 18 19 if ($scope.selectedSeverity.all) { 20 $scope.selectedSeverity.low = false; 21 $scope.selectedSeverity.medium = false; 22 $scope.selectedSeverity.high = false; 23 } 24 }; 25 26 $scope.toggleSeverity = function(severity) { 27 $scope.selectedSeverity[severity] = 28 !$scope.selectedSeverity[severity]; 29 30 if (['high', 'medium', 'low'].indexOf(severity) > -1) { 31 if ($scope.selectedSeverity[severity] == false && 32 (!$scope.selectedSeverity.low && 33 !$scope.selectedSeverity.medium && 34 !$scope.selectedSeverity.high)) { 35 $scope.selectedSeverity.all = true; 36 return; 37 } 38 } 39 40 if ($scope.selectedSeverity.low && 41 $scope.selectedSeverity.medium && 42 $scope.selectedSeverity.high) { 43 $scope.selectedSeverity.all = true; 44 $scope.selectedSeverity.low = false; 45 $scope.selectedSeverity.medium = false; 46 $scope.selectedSeverity.high = false; 47 } else { 48 $scope.selectedSeverity.all = false; 49 } 50 }; 51 52 /** 53 * Handle browsers that don't support the native date input element 54 * IE 11 and Safari do not support this native date element and 55 * users cannot select a date from a browser generated date picker. 56 * This is a test so that we can indicate to the user the proper 57 * date format based on date input element support. 58 */ 59 const testDateInputSupport = () => { 60 const firstDateInput = document.querySelector('input[type=date]'); 61 62 if (firstDateInput && firstDateInput.type == 'text') { 63 $scope.supportsDateInput = false; 64 } 65 }; 66 67 testDateInputSupport(); 68 } 69 ] 70 }; 71 } 72 ]); 73})(window.angular); 74