From: Vsevolod Stakhov Date: Wed, 1 Feb 2017 18:32:31 +0000 (+0000) Subject: [WebUI] Fix configuration page partially X-Git-Tag: 1.5.0~197 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bbf2795c8dce18b8c2c64f7107d2a1d1840a6c2;p=thirdparty%2Frspamd.git [WebUI] Fix configuration page partially --- diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 903874d16c..999adce889 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -134,6 +134,17 @@ function($) { }); } + function loadActionsFromForm() { + var values = []; + var inputs = $('#actionsForm :input[type="slider"]'); + // Rspamd order: [spam,probable_spam,greylist] + values[0] = parseFloat(inputs[2].value); + values[1] = parseFloat(inputs[1].value); + values[2] = parseFloat(inputs[0].value); + + return JSON.stringify(values); + } + function getActions(rspamd) { $.ajax({ dataType: 'json', @@ -194,41 +205,35 @@ function($) { return e.html; }).join('') + '
' + - '
'); + '' + + '' + + ''); if (rspamd.read_only) { + $('#saveActionsClusterBtn').attr('disabled', true); + $('#saveActionsBtn').attr('disabled', true); $('#actionsFormField').attr('disabled', true); } - } + + var elts = loadActionsFromForm(); + + $('#saveActionsClusterBtn').on('click', function() { + rspamd.queryNeighbours('saveactions', null, null, "POST", {}, { + data: elts, + dataType: "json", + }); + }); + $('#saveActionsBtn').on('click', function() { + rspamd.queryLocal('saveactions', null, null, "POST", {}, { + data: elts, + dataType: "json", + }); + }); + }, }); } + // @upload edited actions interface.setup = function(rspamd) { - $('#actionsForm').change('submit', function () { - var inputs = $('#actionsForm :input[type="slider"]'); - var url = 'saveactions'; - var values = []; - // Rspamd order: [spam,probable_spam,greylist] - values[0] = parseFloat(inputs[2].value); - values[1] = parseFloat(inputs[1].value); - values[2] = parseFloat(inputs[0].value); - $.ajax({ - data: JSON.stringify(values), - dataType: 'json', - type: 'POST', - url: url, - jsonp: false, - beforeSend: function (xhr) { - xhr.setRequestHeader('Password', rspamd.getPassword()); - }, - success: function () { - alertMessage('alert-success', 'Actions successfully saved'); - }, - error: function (data) { - alertMessage('alert-modal alert-error', data.statusText); - } - }); - return false; - }); // Modal form for maps $(document).on('click', '[data-toggle="modal"]', function () { var source = $(this).data('source');