Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #114 from SalesforceEng/2.0
Browse files Browse the repository at this point in the history
Merge 2.0 to master
  • Loading branch information
dilipdevaraj-sfdc authored Aug 26, 2016
2 parents 94b75b8 + 6fac2a6 commit 3a9a0f2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 20 deletions.
67 changes: 49 additions & 18 deletions ArgusWeb/app/views/argus_custom_directives/argus-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ controlsModule.directive('agDashboardResource', ['DashboardService','$sce','$com
}
}]);

controlsModule.directive('agDashboard', ['$routeParams', function($routeParams) {
controlsModule.directive('agDashboard', ['$routeParams', '$location', function($routeParams, $location) {

return{
restrict:'E',
Expand All @@ -57,15 +57,19 @@ controlsModule.directive('agDashboard', ['$routeParams', function($routeParams)
template:'<div ng-transclude=""></div>',
controller: function($scope){
$scope.controls = [];
this.updateControl = function(controlName, controlValue, controlType){

this.updateControl = function(controlName, controlValue, controlType, localSubmit){
var controlExists = false;

// check $routeParams to override controlValue
for (var prop in $routeParams) {
if (prop == controlName) {
controlValue = $routeParams[prop];
}
};
// check $routeParams to override controlValue,
// unless the user changes local scope
if (!localSubmit) {
for (var prop in $routeParams) {
if (prop == controlName) {
controlValue = $routeParams[prop];
}
};
}

for(var i in $scope.controls) {
if($scope.controls[i].name === controlName) {
Expand All @@ -83,20 +87,39 @@ controlsModule.directive('agDashboard', ['$routeParams', function($routeParams)
};
$scope.controls.push(control);
}

// add controls to the url
this.addControlsToUrl();
};

this.addControlsToUrl = function() {
var controls = $scope.controls;
var urlStr = '';

// setup url str from all controls values
for (var i=0; i < controls.length; i++) {
urlStr += controls[i].name + '=' + controls[i].value;
if (i < controls.length - 1) {
urlStr += '&';
}
};

// update url with controls params
$location.search(urlStr);
};

this.getAllControls = function(){
return $scope.controls;
};

this.getSubmitBtnEventName = function(){
return 'submitButtonEvent';
};

this.broadcastEvent = function(eventName, data){
console.log(eventName + ' was broadcast');
$scope.$broadcast(eventName, data);
}

};
},
link:function(scope,element,attributes){
if(!attributes.onload || attributes.onload == true) {
Expand Down Expand Up @@ -129,9 +152,9 @@ controlsModule.directive('agText', ['$routeParams', 'CONFIG', function($routePar
require:'^agDashboard',
template:'<B>{{labelName}} : </B> <input type="text" ng-model="ctrlVal">',
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");
dashboardCtrl.updateControl(scope.controlName, scope.ctrlVal, "agText");
scope.$watch('ctrlVal', function(newValue, oldValue){
dashboardCtrl.updateControl(scope.controlName, newValue, "agText", true);
});
}
}
Expand Down Expand Up @@ -229,11 +252,20 @@ controlsModule.directive('agDate', ['$routeParams', 'CONFIG', function($routePar
};
},
require:'^agDashboard',
template:'<B>{{labelName}} : </B><div class="dropdown" style="display: inline;"><a class="dropdown-toggle my-toggle-select" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href=""><input type="text" class="input-medium" style="color:black;" ng-model="ctrlVal"></a> <ul class="dropdown-menu" role="menu" aria-labelledby="dLabel"> <datetimepicker ng-model="data.date" on-set-time="onSetTime(newDate, oldDate)" data-datetimepicker-config="datetimepickerConfig"></datetimepicker> </ul> </div>',
template:
'<strong>{{labelName}} : </strong>' +
'<div class="dropdown" style="display: inline;">' +
'<a class="dropdown-toggle my-toggle-select" id="dLabel" role="button" data-toggle="dropdown" data-target="#" href="">' +
'<input type="text" class="input-medium" style="color:black;" ng-model="ctrlVal">' +
'</a>' +
'<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">' +
'<datetimepicker ng-model="data.date" on-set-time="onSetTime(newDate, oldDate)" data-datetimepicker-config="datetimepickerConfig"></datetimepicker>' +
'</ul>' +
'</div>',
link: function(scope, element, attributes, dashboardCtrl){
dashboardCtrl.updateControl(scope.controlName, scope.controlValue, "agDate");
scope.$watch('controlValue', function(newValue, oldValue){
dashboardCtrl.updateControl(scope.controlName, newValue, "agDate");
dashboardCtrl.updateControl(scope.controlName, scope.ctrlVal, "agDate");
scope.$watch('ctrlVal', function(newValue, oldValue){
dashboardCtrl.updateControl(scope.controlName, newValue, "agDate", true);
});
}
}
Expand All @@ -257,7 +289,6 @@ controlsModule.directive('agSubmit', ['$rootScope','$http',function($rootScope,$
element.on('click', function(){
$http.pendingRequests=[]; //This line should be deleted.
dashboardCtrl.broadcastEvent(dashboardCtrl.getSubmitBtnEventName(), dashboardCtrl.getAllControls());
//console.log('Submit button event emitted.');
});
}
}
Expand Down
3 changes: 2 additions & 1 deletion ArgusWeb/app/views/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ argusMain.config(['$routeProvider', '$httpProvider', 'growlProvider', 'paginatio
templateUrl: 'views/dashboards/dashboard-detail.html',
controller: 'DashboardDetailCtrl',
label: '{{dashboards.dashboardId}}',
activeTab: 'dashboards'
activeTab: 'dashboards',
reloadOnSearch: false
}).
when('/alerts', {
templateUrl: 'views/alerts/alert-list.html',
Expand Down
2 changes: 1 addition & 1 deletion ArgusWebServices/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<url-pattern>/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>59</session-timeout>
<session-timeout>240</session-timeout>
<cookie-config>
<secure>${build.property.secure.cookies}</secure>
</cookie-config>
Expand Down

0 comments on commit 3a9a0f2

Please sign in to comment.