diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-04 12:44:41 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-08-04 12:44:41 +0300 |
commit | 7d053462fcbb5317f528918b9b0e63abf8d5ce5c (patch) | |
tree | 1a069c84b0da1ed52bb960a0c557012a5e7b2c44 | |
parent | 43b165ba84f771379f335050897dff74931a331f (diff) | |
download | rspamd-7d053462fcbb5317f528918b9b0e63abf8d5ce5c.tar.gz rspamd-7d053462fcbb5317f528918b9b0e63abf8d5ce5c.zip |
[Minor] Use query function to get maps list
-rw-r--r-- | interface/js/app/config.js | 71 | ||||
-rw-r--r-- | interface/js/app/rspamd.js | 2 |
2 files changed, 32 insertions, 41 deletions
diff --git a/interface/js/app/config.js b/interface/js/app/config.js index 78f27c23d..b98aed4c3 100644 --- a/interface/js/app/config.js +++ b/interface/js/app/config.js @@ -57,44 +57,6 @@ define(["jquery"], }); } - // @get maps id - function getMaps(rspamd) { - var $listmaps = $("#listMaps"); - $listmaps.closest(".widget-box").hide(); - $.ajax({ - dataType: "json", - url: "maps", - jsonp: false, - beforeSend: function (xhr) { - xhr.setRequestHeader("Password", rspamd.getPassword()); - }, - error: function (data) { - rspamd.alertMessage("alert-modal alert-error", data.statusText); - }, - success: function (data) { - $listmaps.empty(); - $("#modalBody").empty(); - var $tbody = $("<tbody>"); - - $.each(data, function (i, item) { - var label; - if ((item.editable === false || rspamd.read_only)) { - label = "<span class=\"label label-default\">Read</span>"; - } else { - label = "<span class=\"label label-default\">Read</span> <span class=\"label label-success\">Write</span>"; - } - var $tr = $("<tr>"); - $("<td class=\"col-md-2 maps-cell\">" + label + "</td>").appendTo($tr); - var $span = $("<span class=\"map-link\" data-toggle=\"modal\" data-target=\"#modalDialog\">" + item.uri + "</span>").data("item", item); - $span.wrap("<td>").parent().appendTo($tr); - $("<td>" + item.description + "</td>").appendTo($tr); - $tr.appendTo($tbody); - }); - $tbody.appendTo($listmaps); - $listmaps.closest(".widget-box").show(); - } - }); - } // @get map by id function getMapById(rspamd, item) { return $.ajax({ @@ -231,6 +193,37 @@ define(["jquery"], }); }; + ui.getMaps = function (rspamd, checked_server) { + var $listmaps = $("#listMaps"); + $listmaps.closest(".widget-box").hide(); + rspamd.query("maps", { + success: function (json) { + var data = json[0].data; + $listmaps.empty(); + $("#modalBody").empty(); + var $tbody = $("<tbody>"); + + $.each(data, function (i, item) { + var label; + if ((item.editable === false || rspamd.read_only)) { + label = "<span class=\"label label-default\">Read</span>"; + } else { + label = "<span class=\"label label-default\">Read</span> <span class=\"label label-success\">Write</span>"; + } + var $tr = $("<tr>"); + $("<td class=\"col-md-2 maps-cell\">" + label + "</td>").appendTo($tr); + var $span = $("<span class=\"map-link\" data-toggle=\"modal\" data-target=\"#modalDialog\">" + item.uri + "</span>").data("item", item); + $span.wrap("<td>").parent().appendTo($tr); + $("<td>" + item.description + "</td>").appendTo($tr); + $tr.appendTo($tbody); + }); + $tbody.appendTo($listmaps); + $listmaps.closest(".widget-box").show(); + }, + server: (checked_server === "All SERVERS") ? "local" : checked_server + }); + }; + // @upload edited actions ui.setup = function (rspamd) { // Modal form for maps @@ -284,7 +277,5 @@ define(["jquery"], }); }; - ui.getMaps = getMaps; - return ui; }); diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index c703d9367..b83bb5cff 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -120,7 +120,7 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, break; case "#configuration_nav": tab_config.getActions(ui, checked_server); - tab_config.getMaps(ui); + tab_config.getMaps(ui, checked_server); break; case "#symbols_nav": tab_symbols.getSymbols(ui, checked_server); |