aboutsummaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
authorAlexander Moisseev <moiseev@mezonplus.ru>2018-09-21 09:11:54 +0300
committerAlexander Moisseev <moiseev@mezonplus.ru>2018-09-21 09:11:54 +0300
commit85af07192faaf84256a00df8c12c34b917043dc0 (patch)
tree1ac7b4c8f8f84387ff6fc37fd7d805a45ca98678 /interface
parent193ded1291433dc166018ca52fe50b0522a13a9b (diff)
downloadrspamd-85af07192faaf84256a00df8c12c34b917043dc0.tar.gz
rspamd-85af07192faaf84256a00df8c12c34b917043dc0.zip
[WebUI] Fix throughput data consolidation
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/graph.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js
index bdd4da3fb..c148434ca 100644
--- a/interface/js/app/graph.js
+++ b/interface/js/app/graph.js
@@ -120,7 +120,7 @@ define(["jquery", "d3evolution", "footable"],
var timeInterval = xExtents[1] - xExtents[0];
return json.map(function (curr, i) {
- // Time intervals that don't have data are excluded from average calculation as d3.mean()ignores nulls
+ // Time intervals that don't have data are excluded from average calculation as d3.mean()ignores nulls
var avg = d3.mean(curr, function (d) { return d.y; });
// To find an integral on the whole time interval we need to convert nulls to zeroes
var value = d3.mean(curr, function (d) { return Number(d.y); }) * timeInterval / scaleFactor;
@@ -224,36 +224,40 @@ define(["jquery", "d3evolution", "footable"],
rspamd.query("graph", {
success: function (req_data) {
+ var data = null;
var neighbours_data = req_data
.filter(function (d) { return d.status; }) // filter out unavailable neighbours
.map(function (d) { return d.data; });
- if (neighbours_data.length > 1) {
- neighbours_data.reduce(function (res, curr) {
+ if (neighbours_data.length === 1) {
+ data = neighbours_data[0];
+ } else {
+ var time_match = true;
+ neighbours_data.reduce(function (res, curr, _, arr) {
if ((curr[0][0].x !== res[0][0].x) ||
(curr[0][curr[0].length - 1].x !== res[0][res[0].length - 1].x)) {
+ time_match = false;
rspamd.alertMessage("alert-error",
"Neighbours time extents do not match. Check if time is synchronized on all servers.");
- updateWidgets();
- return;
+ arr.splice(1); // Break out of .reduce() by mutating the source array
}
+ return curr;
+ });
- var data = [];
- curr.forEach(function (action, j) {
- data.push(
- action.map(function (d, i) {
+ if (time_match) {
+ data = neighbours_data.reduce(function (res, curr) {
+ return curr.map(function (action, j) {
+ return action.map(function (d, i) {
return {
x: d.x,
y: (res[j][i].y === null) ? d.y : res[j][i].y + d.y
};
- })
- );
+ });
+ });
});
- updateWidgets(data);
- });
- } else {
- updateWidgets(neighbours_data[0]);
+ }
}
+ updateWidgets(data);
},
errorMessage: "Cannot receive throughput data",
errorOnceId: "alerted_graph_",
@@ -262,7 +266,7 @@ define(["jquery", "d3evolution", "footable"],
};
ui.setup = function () {
- // Handling mouse events on overlapping elements
+ // Handling mouse events on overlapping elements
$("#rrd-pie").mouseover(function () {
$("#rrd-pie").css("z-index", "200");
$("#rrd-table_toggle").css("z-index", "300");