From: Alexander Moisseev Date: Fri, 27 Jul 2018 10:18:21 +0000 (+0300) Subject: [Minor] Use query function to get actions, X-Git-Tag: 1.7.9~31^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6414e55b02989de0ee7e1a7b5eb5c608933f9d3c;p=rspamd.git [Minor] Use query function to get actions, get actions from "local" if "All SERVERS" option is selected, sort conditional operators by action index --- diff --git a/interface/js/app/config.js b/interface/js/app/config.js index ab0aa9371..b0ba4fcc8 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -135,29 +135,21 @@ define(["jquery"], return JSON.stringify(values); } - function getActions(rspamd) { - $.ajax({ - dataType: "json", - type: "GET", - url: "actions", - jsonp: false, - beforeSend: function (xhr) { - xhr.setRequestHeader("Password", rspamd.getPassword()); - }, - success: function (data) { - // Order of sliders greylist -> probable spam -> rewrite subject -> spam + ui.getActions = function getActions(rspamd, checked_server) { + rspamd.query("actions", + function (data) { $("#actionsBody").empty(); $("#actionsForm").empty(); var items = []; - $.each(data, function (i, item) { + $.each(data[0].data, function (i, item) { var idx = -1; var label; - if (item.action === "add header") { - label = "Probably Spam"; - idx = 1; - } else if (item.action === "greylist") { + if (item.action === "greylist") { label = "Greylist"; idx = 0; + } else if (item.action === "add header") { + label = "Probably Spam"; + idx = 1; } else if (item.action === "rewrite subject") { label = "Rewrite subject"; idx = 2; @@ -230,8 +222,9 @@ define(["jquery"], saveActions("All SERVERS"); }); }, - }); - } + null, "GET", {}, {}, {}, (checked_server === "All SERVERS") ? "local" : checked_server + ); + }; // @upload edited actions ui.setup = function (rspamd) { @@ -278,7 +271,6 @@ define(["jquery"], }); }; - ui.getActions = getActions; ui.getMaps = getMaps; return ui; diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 162717288..909e34900 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -119,7 +119,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, }); break; case "#configuration_nav": - tab_config.getActions(ui); + tab_config.getActions(ui, checked_server); tab_config.getMaps(ui); break; case "#symbols_nav":