aboutsummaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
authormoisseev <moiseev@mezonplus.ru>2020-10-02 21:27:22 +0300
committermoisseev <moiseev@mezonplus.ru>2020-10-02 21:27:22 +0300
commit99074e58773cad52d6b1a09e7e64ffa4f9e3f3a4 (patch)
tree77412d4725becce5dc9c20b67cf69efde6d4dffe /interface
parentb0f1a5ca3db83bbc3defc7b8fad25d25c9c6cbc8 (diff)
downloadrspamd-99074e58773cad52d6b1a09e7e64ffa4f9e3f3a4.tar.gz
rspamd-99074e58773cad52d6b1a09e7e64ffa4f9e3f3a4.zip
[WebUI] Fix Status tab display for scanned = 0
Fixes: #3498
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/stats.js50
1 files changed, 43 insertions, 7 deletions
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index d9fda8f6a..582c5017f 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -199,9 +199,42 @@ define(["jquery", "d3pie"],
}
}
- function getChart(rspamd, pie, checked_server) {
+ function getChart(rspamd, graphs, checked_server) {
+ if (graphs.chart) {
+ graphs.chart.destroy();
+ delete graphs.chart;
+ }
+
var creds = JSON.parse(sessionStorage.getItem("Credentials"));
- if (!creds || !creds[checked_server]) return null;
+ // Controller doesn't return the 'actions' object until at least one message is scanned
+ if (!creds || !creds[checked_server] || !creds[checked_server].data.scanned) {
+ // Show grayed out pie as percentage is undefined
+ return rspamd.drawPie(graphs.chart,
+ "chart",
+ [{
+ value: 1,
+ color: "#ffffff",
+ label: "undefined"
+ }],
+ {
+ labels: {
+ mainLabel: {
+ fontSize: 14,
+ },
+ inner: {
+ format: "none",
+ },
+ lines: {
+ color: "#cccccc"
+ }
+ },
+ tooltips: {
+ enabled: true,
+ string: "{label}"
+ },
+ }
+ );
+ }
var data = creds[checked_server].data.actions;
var new_data = [{
@@ -236,7 +269,7 @@ define(["jquery", "d3pie"],
value: data.reject
}];
- return rspamd.drawPie(pie, "chart", new_data);
+ return rspamd.drawPie(graphs.chart, "chart", new_data);
}
// Public API
var ui = {
@@ -271,9 +304,12 @@ define(["jquery", "d3pie"],
function process_node_stat(e) {
var data = neighbours_status[e].data;
- for (var action in neighbours_sum.actions) {
- if ({}.hasOwnProperty.call(neighbours_sum.actions, action)) {
- neighbours_sum.actions[action] += data.actions[action];
+ // Controller doesn't return the 'actions' object until at least one message is scanned
+ if (data.scanned) {
+ for (var action in neighbours_sum.actions) {
+ if ({}.hasOwnProperty.call(neighbours_sum.actions, action)) {
+ neighbours_sum.actions[action] += data.actions[action];
+ }
}
}
["learned", "scanned", "uptime"].forEach(function (p) {
@@ -327,7 +363,7 @@ define(["jquery", "d3pie"],
to_Credentials["All SERVERS"].data = neighbours_sum;
sessionStorage.setItem("Credentials", JSON.stringify(to_Credentials));
displayStatWidgets(checked_server);
- graphs.chart = getChart(rspamd, graphs.chart, checked_server);
+ graphs.chart = getChart(rspamd, graphs, checked_server);
});
}, promises.length ? 100 : 0);
},