Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #9539: Two generation are started after changing the global policy mode #1341

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 11 additions & 37 deletions rudder-web/src/main/webapp/javascript/rudder/angular/auditMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ var app = angular.module('auditmode', []);
app.factory('configGlobalFactory', function ($http){
//Case : global configuration
this.policyMode = {
url : contextPath+"/secure/api/latest/settings/global_policy_mode"
url : contextPath+"/secure/api/latest/settings"
, getValue : function(){
return $http.get(this.url).then(function successCallback(response) {
return $http.get(this.url+"/global_policy_mode").then(function successCallback(response) {
return response.data.data.settings.global_policy_mode;
}, function errorCallback(response) {
console.error('error - policy mode');
});
}
, save : function(mode){
var data = {'value' : mode};
var data = { 'global_policy_mode' : mode.policyMode
, 'global_policy_mode_overridable' : mode.overrideMode
};
return $http.post(this.url, data).then(function successCallback(response) {
return response.status==200;
}, function errorCallback(response) {
Expand All @@ -30,14 +32,6 @@ app.factory('configGlobalFactory', function ($http){
console.error('error - policy mode');
});
}
, save : function(mode){
var data = {'value' : mode};
return $http.post(this.url, data).then(function successCallback(response) {
return response.status==200;
}, function errorCallback(response) {
return response.status==200;
});
}
};
return this;
});
Expand All @@ -55,7 +49,7 @@ app.factory('configNodeFactory', function ($http){
});
}
, save : function(mode){
var data = {'policyMode' : mode};
var data = {'policyMode' : mode.policyMode};
return $http.post(this.url, data).then(function successCallback(response) {
return response.status==200;
}, function errorCallback(response) {
Expand All @@ -79,10 +73,7 @@ app.controller('auditmodeCtrl', function ($scope, $http, $location, $timeout, co

var nodeId = getNodeId();
// variable used for saving animations
$scope.saving = {
'policyMode' : 0
, 'overrideMode' : 0
};
$scope.saving = 0;
// global configuration
$scope.isGlobalForm;
$scope.globalConfiguration = {};
Expand Down Expand Up @@ -132,36 +123,19 @@ app.controller('auditmodeCtrl', function ($scope, $http, $location, $timeout, co
$scope.saveChanges = function($event) {
if(!$scope.nochange){
//Start loading animation
$scope.saving = {
'policyMode' : 1
, 'overrideMode' : 1
};
$scope.factory.policyMode.save($scope.conf.policyMode).then(function(success){
$scope.saving = 1;
$scope.factory.policyMode.save($scope.conf).then(function(success){
if(success){
//Reinitialize scope
$scope.errorFeedback = false;
$scope.nochange = true;
$scope.currentConf.policyMode = $scope.conf.policyMode;
$scope.saving.policyMode = 2;
$scope.currentConf.overrideMode = $scope.conf.overrideMode;
}else{
$scope.errorFeedback = true;
$scope.saving.policyMode = 2;
}
$scope.saving = 2;
});
if($scope.isGlobalForm){
$scope.factory.overrideMode.save($scope.conf.overrideMode).then(function(success){
if(success){
//Reinitialize scope
$scope.errorFeedback = false;
$scope.nochange = true;
$scope.currentConf.overrideMode = $scope.conf.overrideMode;
$scope.saving.overrideMode = 2;
}else{
$scope.errorFeedback = true;
$scope.saving.overrideMode = 2;
}
});
}
}
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ <h3 id="agentPolicyMode" class="page-title">Agent Policy Mode</h3>
</div>
<div class="col-lg-12 button-group-success">
<span class="button-shape" ng-mouseover="pop=true" ng-mouseout="pop=false" ng-class="{disabled:$parent.nochange}">
<button type="button" class="btn btn-default btn-primary-rudder" ng-class="{loading: ($parent.saving.policyMode==1 || ($parent.saving.overrideMode==1 && $parent.isGlobalForm))}" ng-click="saveChanges()" ng-disabled="$parent.nochange" ng-mouseover="pop=true;">
<button type="button" class="btn btn-default btn-primary-rudder" ng-class="{loading: $parent.saving === 1 }" ng-click="saveChanges()" ng-disabled="$parent.nochange" ng-mouseover="pop=true;">
<i class="fa fa-cog fa-spin" aria-hidden="true"></i>
<span class="sr-only">Saving...</span>
<span>Save changes</span>
</button>
</span>
<span class="first-index">
<span class="button-warning no-modif" ng-if="$parent.nochange && $parent.saving.policyMode==0 && $parent.saving.overrideMode==0" ng-class="{pop:$parent.pop}">
<span class="button-warning no-modif" ng-if="$parent.nochange && $parent.saving === 0" ng-class="{pop:$parent.pop}">
There are no modifications to save.
</span>
<span class="button-success" ng-class="{pop:($parent.saving.policyMode==2 && (($parent.saving.overrideMode==2 && $parent.isGlobalForm)||!$parent.isGlobalForm)), ngHide:$parent.nochange, error:$parent.errorFeedback}">
<span class="button-success" ng-class="{pop: $parent.saving === 2, ngHide:$parent.nochange, error:$parent.errorFeedback}">
<span ng-if="!$parent.errorFeedback">Your changes have been saved</span>
<span ng-if="$parent.errorFeedback">Error during saving changes</span>
<span class="close-message glyphicon glyphicon-remove" ng-click="$parent.saving.policyMode=0;$parent.saving.overrideMode=0;"></span>
<span class="close-message glyphicon glyphicon-remove" ng-click="$parent.saving=0"></span>
</span>
</span>
</div>
Expand Down