From 43b165ba84f771379f335050897dff74931a331f Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sat, 4 Aug 2018 12:39:31 +0300 Subject: [Minor] Hide colon if status text is empty --- interface/js/app/rspamd.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index 7ca11ae74..c703d9367 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -208,7 +208,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, neighbours_status[ind].checked = true; function errorMessage() { alertMessage("alert-error", neighbours_status[ind].name + " > " + - ((o.errorMessage) ? o.errorMessage : "Request failed") + ": " + errorThrown); + (o.errorMessage ? o.errorMessage : "Request failed") + + (errorThrown ? (": " + errorThrown) : "")); } if (o.error) { o.error(neighbours_status[ind], -- cgit v1.2.3 From 7d053462fcbb5317f528918b9b0e63abf8d5ce5c Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sat, 4 Aug 2018 12:44:41 +0300 Subject: [Minor] Use query function to get maps list --- interface/js/app/config.js | 71 ++++++++++++++++++++-------------------------- 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 = $(""); - - $.each(data, function (i, item) { - var label; - if ((item.editable === false || rspamd.read_only)) { - label = "Read"; - } else { - label = "Read Write"; - } - var $tr = $(""); - $("" + label + "").appendTo($tr); - var $span = $("" + item.uri + "").data("item", item); - $span.wrap("").parent().appendTo($tr); - $("" + item.description + "").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 = $(""); + + $.each(data, function (i, item) { + var label; + if ((item.editable === false || rspamd.read_only)) { + label = "Read"; + } else { + label = "Read Write"; + } + var $tr = $(""); + $("" + label + "").appendTo($tr); + var $span = $("" + item.uri + "").data("item", item); + $span.wrap("").parent().appendTo($tr); + $("" + item.description + "").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); -- cgit v1.2.3 From e7e2963f96a13feb7e1e0a4bf562cc78bba0cc0e Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sun, 5 Aug 2018 13:05:23 +0300 Subject: [Minor] Do not consider request as failed if returned object is empty --- interface/js/app/rspamd.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/js/app/rspamd.js b/interface/js/app/rspamd.js index b83bb5cff..70f6fbfd5 100644 --- a/interface/js/app/rspamd.js +++ b/interface/js/app/rspamd.js @@ -199,10 +199,8 @@ function ($, d3pie, visibility, tab_stat, tab_graph, tab_config, url: neighbours_status[ind].url + req_url, success: function (json) { neighbours_status[ind].checked = true; - if (!jQuery.isEmptyObject(json) || req_url === "neighbours") { - neighbours_status[ind].status = true; - neighbours_status[ind].data = json; - } + neighbours_status[ind].status = true; + neighbours_status[ind].data = json; }, error: function (jqXHR, textStatus, errorThrown) { neighbours_status[ind].checked = true; -- cgit v1.2.3 From 218f1f57c7ece0e8418641f5cbbd7fc8d17b831b Mon Sep 17 00:00:00 2001 From: Alexander Moisseev Date: Sun, 5 Aug 2018 13:07:59 +0300 Subject: [Minor] Use query function to get maps --- interface/js/app/config.js | 75 ++++++++++++++++++++-------------------------- 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(); - $("
" + - "" + - "" + + "" + + "
").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(); -- cgit v1.2.3