diff options
author | firedranzer <rupeshharode@gmail.com> | 2018-03-07 02:13:09 +0530 |
---|---|---|
committer | firedranzer <rupeshharode@gmail.com> | 2018-03-07 02:13:09 +0530 |
commit | 46334417c2915535c802727abf0abc12b1dda705 (patch) | |
tree | 60d0996d26f417b8c18262ca066487f00c1d1fd6 /interface | |
parent | ba9d6870d71b5d869e649b430b741f090195e4c8 (diff) | |
download | rspamd-46334417c2915535c802727abf0abc12b1dda705.tar.gz rspamd-46334417c2915535c802727abf0abc12b1dda705.zip |
Refactores code and added order of actions
Diffstat (limited to 'interface')
-rw-r--r-- | interface/js/app/config.js | 54 |
1 files changed, 19 insertions, 35 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 3af4005d0..ec36dce48 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -215,51 +215,35 @@ function($) { $('#actionsFormField').attr('disabled', true); } - $('#saveActionsClusterBtn').on('click', function() { + function saveActions(callback) { var elts = loadActionsFromForm(); // String to array for comparison var eltsArray = JSON.parse(loadActionsFromForm()); - if(eltsArray[0]>=0 && eltsArray[1]>=0 && eltsArray[2]>=0){ - rspamd.queryNeighbours('saveactions', null, null, "POST", {}, { - data: elts, - dataType: "json", - }); + if(eltsArray[0]<0){ + rspamd.alertMessage('alert-modal alert-error', 'Spam can not be negative'); } - else{ - 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[1]<0){ + rspamd.alertMessage('alert-modal alert-error', 'Probable spam can not be negative'); } - }); - $('#saveActionsBtn').on('click', function() { - var elts = loadActionsFromForm(); - // String to array for comparison - var eltsArray = JSON.parse(loadActionsFromForm()); - if(eltsArray[0]>=0 && eltsArray[1]>=0 && eltsArray[2]>=0){ - rspamd.queryLocal('saveactions', null, null, "POST", {}, { + else if(eltsArray[2]<0){ + rspamd.alertMessage('alert-modal alert-error', 'Greylist can not be negative'); + } + else if(eltsArray[2]<eltsArray[1]<eltsArray[0]){ + callback('saveactions', null, null, "POST", {}, { data: elts, dataType: "json", }); } - else{ - 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 { + rspamd.alertMessage('alert-modal alert-error', 'Incorrect order of metric actions threshold'); } + }; + + $('#saveActionsBtn').on('click', function() { + saveActions(rspamd.queryLocal); + }); + $('#saveActionsClusterBtn').on('click', function() { + saveActions(rspamd.queryNeighbours); }); }, }); |