diff --git a/ArgusWeb/app/views/argus_custom_directives/argus-controls.js b/ArgusWeb/app/views/argus_custom_directives/argus-controls.js index 67aa6dc3a..0844b6cce 100644 --- a/ArgusWeb/app/views/argus_custom_directives/argus-controls.js +++ b/ArgusWeb/app/views/argus_custom_directives/argus-controls.js @@ -46,7 +46,7 @@ controlsModule.directive('agDashboardResource', ['DashboardService','$sce','$com } }]); -controlsModule.directive('agDashboard', ['$rootScope',function($rootScope){ +controlsModule.directive('agDashboard', ['$routeParams', function($routeParams) { return{ restrict:'E', @@ -59,6 +59,14 @@ controlsModule.directive('agDashboard', ['$rootScope',function($rootScope){ $scope.controls = []; this.updateControl = function(controlName, controlValue, controlType){ var controlExists = false; + + // check $routeParams to override controlValue + for (var prop in $routeParams) { + if (prop == controlName) { + controlValue = $routeParams[prop]; + } + }; + for(var i in $scope.controls) { if($scope.controls[i].name === controlName) { $scope.controls[i].value = controlValue; @@ -100,8 +108,7 @@ controlsModule.directive('agDashboard', ['$rootScope',function($rootScope){ }]); -controlsModule.directive('agText', ['CONFIG',function(CONFIG){ - +controlsModule.directive('agText', ['$routeParams', 'CONFIG', function($routeParams, CONFIG) { return{ restrict:'EA', scope:{ @@ -109,10 +116,19 @@ controlsModule.directive('agText', ['CONFIG',function(CONFIG){ labelName:'@label', controlValue:'@default' }, + controller: function($scope) { + $scope.ctrlVal = $scope.controlValue; + + // check $routeParams to override controlValue + for (var prop in $routeParams) { + if (prop == $scope.controlName) { + $scope.ctrlVal = $routeParams[prop]; + } + }; + }, require:'^agDashboard', - //templateUrl: CONFIG.templatePath + 'argus-text-control.html', - template:'{{labelName}} : ', - link: function(scope,element,attributes,dashboardCtrl){ + template:'{{labelName}} : ', + link: function(scope, element, attributes, dashboardCtrl) { dashboardCtrl.updateControl(scope.controlName, scope.controlValue, "agText"); scope.$watch('controlValue', function(newValue, oldValue){ dashboardCtrl.updateControl(scope.controlName, newValue, "agText"); @@ -184,7 +200,7 @@ controlsModule.directive('agDropdown', ['CONFIG', 'Tags', function(CONFIG, Tags) }]); -controlsModule.directive('agDate', ['CONFIG',function(CONFIG){ +controlsModule.directive('agDate', ['$routeParams', 'CONFIG', function($routeParams, CONFIG) { return{ restrict:'E', @@ -194,6 +210,15 @@ controlsModule.directive('agDate', ['CONFIG',function(CONFIG){ controlValue:'@default' }, controller: function($scope, $filter) { + $scope.ctrlVal = $scope.controlValue; + + // check $routeParams to override controlValue + for (var prop in $routeParams) { + if (prop == $scope.controlName) { + $scope.ctrlVal = $routeParams[prop]; + } + }; + $scope.datetimepickerConfig = { dropdownSelector: '.my-toggle-select', minuteStep: 1 @@ -201,10 +226,10 @@ controlsModule.directive('agDate', ['CONFIG',function(CONFIG){ $scope.onSetTime = function(newDate, oldDate) { $scope.controlValue = $filter('date')(newDate, "short"); - } + }; }, require:'^agDashboard', - template:'{{labelName}} : ', + template:'{{labelName}} : ', link: function(scope, element, attributes, dashboardCtrl){ dashboardCtrl.updateControl(scope.controlName, scope.controlValue, "agDate"); scope.$watch('controlValue', function(newValue, oldValue){