aboutsummaryrefslogtreecommitdiffstats
path: root/interface
diff options
context:
space:
mode:
Diffstat (limited to 'interface')
-rw-r--r--interface/js/app/graph.js110
-rw-r--r--interface/js/app/stats.js2
2 files changed, 49 insertions, 63 deletions
diff --git a/interface/js/app/graph.js b/interface/js/app/graph.js
index bb6431056..356b006f7 100644
--- a/interface/js/app/graph.js
+++ b/interface/js/app/graph.js
@@ -212,72 +212,58 @@ define(["jquery", "d3evolution", "footable"],
graphs.graph = initGraph();
}
- if (checked_server === "All SERVERS") {
- rspamd.queryNeighbours("graph", function (req_data) {
- var neighbours_data = req_data
- .filter(function (d) { return d.status; }) // filter out unavailable neighbours
- .map(function (d) { return d.data; });
+ (function (callback) {
+ callback("graph",
+ function (req_data) {
+ if (checked_server !== "All SERVERS") {
+ updateWidgets(req_data);
+ return;
+ }
- if (neighbours_data.length > 1) {
- neighbours_data.reduce(function (res, curr) {
- if ((curr[0][0].x !== res[0][0].x) ||
- (curr[0][curr[0].length - 1].x !== res[0][res[0].length - 1].x)) {
- rspamd.alertMessage("alert-error",
- "Neighbours time extents do not match. Check if time is synchronized on all servers.");
- updateWidgets();
- return;
- }
+ var neighbours_data = req_data
+ .filter(function (d) { return d.status; }) // filter out unavailable neighbours
+ .map(function (d) { return d.data; });
- var data = [];
- curr.forEach(function (action, j) {
- data.push(
- 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]);
- }
- },
- function (serv, jqXHR, textStatus, errorThrown) {
- var alert_status = serv.name + "_alerted";
+ if (neighbours_data.length > 1) {
+ neighbours_data.reduce(function (res, curr) {
+ if ((curr[0][0].x !== res[0][0].x) ||
+ (curr[0][curr[0].length - 1].x !== res[0][res[0].length - 1].x)) {
+ rspamd.alertMessage("alert-error",
+ "Neighbours time extents do not match. Check if time is synchronized on all servers.");
+ updateWidgets();
+ return;
+ }
- if (!(alert_status in sessionStorage)) {
- sessionStorage.setItem(alert_status, true);
- rspamd.alertMessage("alert-error", "Cannot receive RRD data from: " +
- serv.name + ", error: " + errorThrown);
- }
- }, "GET", {}, {}, {
- type: type
- });
- return;
- }
+ var data = [];
+ curr.forEach(function (action, j) {
+ data.push(
+ 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]);
+ }
+ },
+ function (serv, jqXHR, textStatus, errorThrown) {
+ var serv_name = (typeof serv === "string") ? serv : serv.name;
+ var alert_status = "alerted_graph_" + serv_name;
- $.ajax({
- dataType: "json",
- type: "GET",
- url: neighbours[checked_server].url + "graph",
- jsonp: false,
- data: {
- type: type
- },
- beforeSend: function (xhr) {
- xhr.setRequestHeader("Password", rspamd.getPassword());
- },
- success: function (data) {
- updateWidgets(data);
- },
- error: function (jqXHR, textStatus, errorThrown) {
- rspamd.alertMessage("alert-error", "Cannot receive throughput data: " +
- textStatus + " " + jqXHR.status + " " + errorThrown);
- }
- });
+ if (!(alert_status in sessionStorage)) {
+ sessionStorage.setItem(alert_status, true);
+ rspamd.alertMessage("alert-error", "Cannot receive throughput data from " +
+ serv_name + ", error: " + errorThrown);
+ }
+ },
+ "GET", {}, {}, {type: type}
+ );
+ }((checked_server === "All SERVERS") ? rspamd.queryNeighbours : rspamd.queryLocal));
};
ui.setup = function () {
diff --git a/interface/js/app/stats.js b/interface/js/app/stats.js
index c41934200..8ef7e25d6 100644
--- a/interface/js/app/stats.js
+++ b/interface/js/app/stats.js
@@ -220,7 +220,7 @@ define(["jquery", "d3pie", "humanize"],
graphs.chart = getChart(rspamd, graphs.chart, checked_server);
},
function (serv, jqXHR, textStatus, errorThrown) {
- var alert_status = serv.name + "_alerted";
+ var alert_status = "alerted_stats_" + serv.name;
if (!(alert_status in sessionStorage)) {
sessionStorage.setItem(alert_status, true);