diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-03-07 20:47:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-07 20:47:43 +0000 |
commit | 1b74022f78e233c8f832b6aa06cd5375cc798ba5 (patch) | |
tree | ec27b0cdabb8e10012202b8f49647dc441a0a565 | |
parent | 5edbf6e0549d08e51dcb33590900e04e015c64e7 (diff) | |
parent | ba09e88aec9b90638db7876dbcfbfadc2f0b3fbf (diff) | |
download | rspamd-1b74022f78e233c8f832b6aa06cd5375cc798ba5.tar.gz rspamd-1b74022f78e233c8f832b6aa06cd5375cc798ba5.zip |
Merge pull request #2061 from firedranzer/rupesh-greylist
Fixes greylist form vanish
-rw-r--r-- | interface/js/app/config.js | 38 |
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); }); }, }); |