}, []);
}
- function updateSummaryTable(tables, data) {
- var total_messages = 0;
- var rows = data.map(function (curr, i) {
- total_messages += curr.value;
- return {
- options: {
- style: {
- color: graph_options.legend.entries[i].color
- }
- },
- value: curr
- };
- }, []);
-
- document.getElementById("rrd-total-value").innerHTML = total_messages;
-
- tables.rrd_summary.rows.load(rows);
- }
-
- function initSummaryTable(tables, data, unit) {
+ function initSummaryTable(tables, rows, unit) {
tables.rrd_summary = FooTable.init("#rrd-table", {
sorting: {
enabled: true
{name: "max", title: "Maximum, <span class=\"unit\">" + unit + "</span>", defaultContent: ""},
{name: "last", title: "Last, " + unit},
],
- on: {
- "ready.ft.table": function () {
- updateSummaryTable(tables, data);
- }
- }
+ rows: rows
});
}
function drawRrdTable(tables, data, unit) {
+ var total_messages = 0;
+ var rows = data.map(function (curr, i) {
+ total_messages += curr.value;
+ return {
+ options: {
+ style: {
+ color: graph_options.legend.entries[i].color
+ }
+ },
+ value: curr
+ };
+ }, []);
+
+ document.getElementById("rrd-total-value").innerHTML = total_messages;
+
if (Object.prototype.hasOwnProperty.call(tables, "rrd_summary")) {
- updateSummaryTable(tables, data);
+ tables.rrd_summary.rows.load(rows);
} else {
- initSummaryTable(tables, data, unit);
+ initSummaryTable(tables, rows, unit);
}
}
});
};
- function updateErrorsTable(tables, data) {
- var neighbours_data = data
- .filter(function (d) {
- return d.status;
- }) // filter out unavailable neighbours
- .map(function (d) {
- return d.data;
- });
- var flattened_data = [].concat.apply([], neighbours_data);
- $.each(flattened_data, function (i, item) {
- item.ts = unix_time_format(item.ts);
- });
- tables.errors.rows.load(flattened_data);
- }
-
- function initErrorsTable(tables, data) {
+ function initErrorsTable(tables, rows) {
tables.errors = FooTable.init("#errorsLog", {
columns: [
{sorted: true, direction: "DESC", name:"ts", title:"Time", style:{"font-size":"11px", "width":300, "maxWidth":300}},
{name:"id", title:"Internal ID", style:{"font-size":"11px"}},
{name:"message", title:"Message", breakpoints:"xs sm", style:{"font-size":"11px"}},
],
+ rows: rows,
paging: {
enabled: true,
limit: 5,
},
sorting: {
enabled: true
- },
- on: {
- "ready.ft.table": function () {
- updateErrorsTable(tables, data);
- }
}
});
}
rspamd.query("errors", {
success: function (data) {
+ var neighbours_data = data
+ .filter(function (d) {
+ return d.status;
+ }) // filter out unavailable neighbours
+ .map(function (d) {
+ return d.data;
+ });
+ var rows = [].concat.apply([], neighbours_data);
+ $.each(rows, function (i, item) {
+ item.ts = unix_time_format(item.ts);
+ });
if (Object.prototype.hasOwnProperty.call(tables, "errors")) {
- updateErrorsTable(tables, data);
+ tables.errors.rows.load(rows);
} else {
- initErrorsTable(tables, data);
+ initErrorsTable(tables, rows);
}
}
});