aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--interface/js/app/config.js38
1 files changed, 27 insertions, 11 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js
index 3346d3936..4346dee45 100644
--- a/interface/js/app/config.js
+++ b/interface/js/app/config.js
@@ -215,19 +215,35 @@ function($) {
$('#actionsFormField').attr('disabled', true);
}
- $('#saveActionsClusterBtn').on('click', function() {
+ function saveActions(callback) {
var elts = loadActionsFromForm();
- rspamd.queryNeighbours('saveactions', null, null, "POST", {}, {
- data: elts,
- dataType: "json",
- });
- });
+ // String to array for comparison
+ var eltsArray = JSON.parse(loadActionsFromForm());
+ if(eltsArray[0]<0){
+ rspamd.alertMessage('alert-modal alert-error', 'Spam can not be negative');
+ }
+ else if(eltsArray[1]<0){
+ rspamd.alertMessage('alert-modal alert-error', 'Probable spam can not be negative');
+ }
+ else if(eltsArray[2]<0){
+ rspamd.alertMessage('alert-modal alert-error', 'Greylist can not be negative');
+ }
+ else if(eltsArray[2]<eltsArray[1] && eltsArray[1]<eltsArray[0]){
+ callback('saveactions', null, null, "POST", {}, {
+ data: elts,
+ dataType: "json",
+ });
+ }
+ else {
+ rspamd.alertMessage('alert-modal alert-error', 'Incorrect order of metric actions threshold');
+ }
+ };
+
$('#saveActionsBtn').on('click', function() {
- var elts = loadActionsFromForm();
- rspamd.queryLocal('saveactions', null, null, "POST", {}, {
- data: elts,
- dataType: "json",
- });
+ saveActions(rspamd.queryLocal);
+ });
+ $('#saveActionsClusterBtn').on('click', function() {
+ saveActions(rspamd.queryNeighbours);
});
},
});