diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-05 13:07:59 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-05 13:07:59 +0300 |
commit | 218f1f57c7ece0e8418641f5cbbd7fc8d17b831b (patch) | |
tree | c7f487d8bc8290864c9cf0324003d2337eff3f41 | |
parent | e7e2963f96a13feb7e1e0a4bf562cc78bba0cc0e (diff) | |
download | rspamd-218f1f57c7ece0e8418641f5cbbd7fc8d17b831b.tar.gz rspamd-218f1f57c7ece0e8418641f5cbbd7fc8d17b831b.zip |
[Minor] Use query function to get maps
-rw-r--r-- | interface/js/app/config.js | 75 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 2 |
2 files changed, 34 insertions, 43 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js index b98aed4c3..19bc234ec 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -57,35 +57,6 @@ define(["jquery"], }); } - // @get map by id - function getMapById(rspamd, item) { - return $.ajax({ - dataType: "text", - url: "getmap", - jsonp: false, - beforeSend: function (xhr) { - xhr.setRequestHeader("Password", rspamd.getPassword()); - xhr.setRequestHeader("Map", item.map); - }, - error: function () { - rspamd.alertMessage("alert-error", "Cannot receive maps data"); - }, - success: function (text) { - var disabled = ""; - if ((item.editable === false || rspamd.read_only)) { - disabled = "disabled=\"disabled\""; - } - - $("#" + item.map).remove(); - $("<form class=\"form-horizontal form-map\" method=\"post\" action=\"savemap\" data-type=\"map\" id=\"" + - item.map + "\" style=\"display:none\">" + - "<textarea class=\"list-textarea\"" + disabled + ">" + text + - "</textarea>" + - "</form").appendTo("#modalBody"); - } - }); - } - function loadActionsFromForm() { var values = []; var inputs = $("#actionsForm :input[data-id=\"action\"]"); @@ -225,22 +196,42 @@ define(["jquery"], }; // @upload edited actions - ui.setup = function (rspamd) { + ui.setup = function (rspamd, checked_server) { // Modal form for maps $(document).on("click", "[data-toggle=\"modal\"]", function () { var item = $(this).data("item"); - getMapById(rspamd, item).done(function () { - $("#modalTitle").html(item.uri); - $("#" + item.map).first().show(); - $("#modalDialog .progress").hide(); - $("#modalDialog").modal({backdrop: true, keyboard: "show", show: true}); - if (item.editable === false) { - $("#modalSave").hide(); - $("#modalSaveAll").hide(); - } else { - $("#modalSave").show(); - $("#modalSaveAll").show(); - } + rspamd.query("getmap", { + headers: { + Map: item.map + }, + success: function (data) { + var disabled = ""; + var text = data[0].data; + if ((item.editable === false || rspamd.read_only)) { + disabled = "disabled=\"disabled\""; + } + + $("#" + item.map).remove(); + $("<form id=\"" + item.map + "\" class=\"form-horizontal form-map\" style=\"display:none\"" + + " data-type=\"map\" action=\"savemap\" method=\"post\">" + + "<textarea class=\"list-textarea\"" + disabled + ">" + text + + "</textarea>" + + "</form>").appendTo("#modalBody"); + + $("#modalTitle").html(item.uri); + $("#" + item.map).first().show(); + $("#modalDialog .progress").hide(); + $("#modalDialog").modal({backdrop: true, keyboard: "show", show: true}); + if (item.editable === false) { + $("#modalSave").hide(); + $("#modalSaveAll").hide(); + } else { + $("#modalSave").show(); + $("#modalSaveAll").show(); + } + }, + errorMessage: "Cannot receive maps data", + server: (checked_server === "All SERVERS") ? "local" : checked_server }); return false; }); diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 70f6fbfd5..e983e4074 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -286,7 +286,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, tabClick("#status_nav"); } }); - tab_config.setup(ui); + tab_config.setup(ui, checked_server); tab_symbols.setup(ui); tab_upload.setup(ui); selData = tab_graph.setup(); |