"id-length": ["error", { "min": 1 }],
// "max-len": ["error", { "code": 120 }],
"max-params": ["warn", 9],
- "max-statements": ["warn", 27],
+ "max-statements": ["warn", 28],
"max-statements-per-line": ["error", { "max": 2 }],
"multiline-comment-style": "off",
"multiline-ternary": ["error", "always-multiline"],
});
};
- function drawErrorsTable(tables, data) {
- var items = [];
- $.each(data, function (i, item) {
- items.push(
- item.ts = unix_time_format(item.ts)
- );
+ 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) {
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: data,
paging: {
enabled: true,
limit: 5,
},
sorting: {
enabled: true
+ },
+ on: {
+ "ready.ft.table": function () {
+ updateErrorsTable(tables, data);
+ }
}
});
}
if (rspamd.read_only) return;
rspamd.query("errors", {
- success: function (req_data) {
- var neighbours_data = req_data
- .filter(function (d) {
- return d.status;
- }) // filter out unavailable neighbours
- .map(function (d) {
- return d.data;
- });
- drawErrorsTable(tables, [].concat.apply([], neighbours_data));
+ success: function (data) {
+ if (Object.prototype.hasOwnProperty.call(tables, "errors")) {
+ updateErrorsTable(tables, data);
+ } else {
+ initErrorsTable(tables, data);
+ }
}
});