summaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
authormoisseev <moiseev@mezonplus.ru>2020-08-08 18:24:30 +0300
committermoisseev <moiseev@mezonplus.ru>2020-08-08 18:24:30 +0300
commitcb776ef73e9043843480db683392cba4636feb51 (patch)
tree130142d40f9dff18788b48b9c4f58d1d8a6a2915 /interface
parent197de4bd384b8c8b554eae400f69a7a0c33d667a (diff)
downloadrspamd-cb776ef73e9043843480db683392cba4636feb51.tar.gz
rspamd-cb776ef73e9043843480db683392cba4636feb51.zip
[Minor] Refactor displayStatWidgets function
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/stats.js13
1 files changed, 5 insertions, 8 deletions
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index 299b02aad..57e16261e 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -56,17 +56,14 @@ define(["jquery", "d3pie"],
}
function displayStatWidgets(checked_server) {
- var widgets = $("#statWidgets");
- $(widgets).empty().hide();
-
var servers = JSON.parse(sessionStorage.getItem("Credentials"));
var data = {};
-
if (servers && servers[checked_server]) {
data = servers[checked_server].data;
}
- var stat_w = [];
+ var stat_w = [];
+ $("#statWidgets").empty().hide();
$.each(data, function (i, item) {
var widgetsOrder = ["scanned", "no action", "greylist", "add header", "rewrite subject", "reject", "learned"];
@@ -89,7 +86,7 @@ define(["jquery", "d3pie"],
}
$('<div class="' + cls + 'float-left px-3"><strong class="d-block mt-2 mb-1 font-weight-bold">' +
val + "</strong>" + i + "</div>")
- .appendTo(widgets);
+ .appendTo("#statWidgets");
} else if (i === "actions") {
$.each(item, function (action, count) {
stat_w[widgetsOrder.indexOf(action)] = widget(action, count);
@@ -99,12 +96,13 @@ define(["jquery", "d3pie"],
}
});
$.each(stat_w, function (i, item) {
- $(item).appendTo(widgets);
+ $(item).appendTo("#statWidgets");
});
$("#statWidgets > div:not(.stat-box)")
.wrapAll('<div class="card stat-box text-center bg-light shadow-sm float-right">' +
'<div class="widget overflow-hidden p-2 text-capitalize"></div></div>');
$("#statWidgets").find("div.float-right").appendTo("#statWidgets");
+ $("#statWidgets").show();
$("#clusterTable tbody").empty();
$("#selSrv").empty();
@@ -144,7 +142,6 @@ define(["jquery", "d3pie"],
$('#selSrv [value="' + key + '"]').prop("disabled", true);
}
});
- $(widgets).show();
}
function getChart(rspamd, pie, checked_server) {