Bläddra i källkod

[WebUI] Fix tables destroying

It seems there is a bug in Footable.
FooTable doesn't remove the table body if the table was initialized without contents.
tags/1.8.0
Alexander Moisseev 5 år sedan
förälder
incheckning
c0195310bb
2 ändrade filer med 34 tillägg och 50 borttagningar
  1. 19
    27
      interface/js/app/graph.js
  2. 15
    23
      interface/js/app/history.js

+ 19
- 27
interface/js/app/graph.js Visa fil

@@ -138,26 +138,7 @@ define(["jquery", "d3evolution", "footable"],
}, []);
}

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
@@ -170,19 +151,30 @@ define(["jquery", "d3evolution", "footable"],
{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);
}
}


+ 15
- 23
interface/js/app/history.js Visa fil

@@ -705,22 +705,7 @@ define(["jquery", "footable", "humanize"],
});
};

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}},
@@ -730,6 +715,7 @@ define(["jquery", "footable", "humanize"],
{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,
@@ -742,11 +728,6 @@ define(["jquery", "footable", "humanize"],
},
sorting: {
enabled: true
},
on: {
"ready.ft.table": function () {
updateErrorsTable(tables, data);
}
}
});
}
@@ -756,10 +737,21 @@ define(["jquery", "footable", "humanize"],

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);
}
}
});

Laddar…
Avbryt
Spara