mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-02 17:35:57 -05:00
Improved report totals.
This commit is contained in:
parent
eb30d40e25
commit
333d7813b9
@ -5428,12 +5428,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
// Columns
|
// Columns
|
||||||
if (command.groupBy == 1) {
|
if (command.groupBy == 1) {
|
||||||
data.groupFormat = 'user';
|
data.groupFormat = 'user';
|
||||||
data.columns = [{ id: 'time', title: "time", format: 'datetime' }, { id: "nodeid", title: "device", format: "node" }, { id: "protocol", title: "session", format: "protocol", align: "center" }, { id: "length", title: "length", format: "seconds", align: "center" } ];
|
data.columns = [{ id: 'time', title: "time", format: 'datetime' }, { id: 'nodeid', title: "device", format: 'node' }, { id: 'protocol', title: "session", format: 'protocol', align: 'center' }, { id: 'length', title: "length", format: 'seconds', align: 'center', sumBy: 'protocol' } ];
|
||||||
} else if (command.groupBy == 2) {
|
} else if (command.groupBy == 2) {
|
||||||
data.groupFormat = 'node';
|
data.groupFormat = 'node';
|
||||||
data.columns = [{ id: 'time', title: "time", format: 'datetime' }, { id: "userid", title: "user", format: "user" }, { id: "protocol", title: "session", format: "protocol", align: "center" }, { id: "length", title: "length", format: "seconds", align: "center" } ];
|
data.columns = [{ id: 'time', title: "time", format: 'datetime' }, { id: 'userid', title: "user", format: 'user' }, { id: 'protocol', title: "session", format: 'protocol', align: 'center' }, { id: 'length', title: "length", format: 'seconds', align: 'center', sumBy: 'protocol' } ];
|
||||||
} else if (command.groupBy == 3) {
|
} else if (command.groupBy == 3) {
|
||||||
data.columns = [{ id: 'time', title: "time", format: 'time' }, { id: "nodeid", title: "device", format: "node" }, { id: "userid", title: "user", format: "user" }, { id: "protocol", title: "session", format: "protocol", align: "center" }, { id: "length", title: "length", format: "seconds", align:"center" } ];
|
data.columns = [{ id: 'time', title: "time", format: 'time' }, { id: 'nodeid', title: "device", format: 'node' }, { id: 'userid', title: "user", format: 'user' }, { id: 'protocol', title: "session", format: 'protocol', align: 'center' }, { id: 'length', title: "length", format: 'seconds', align: 'center', sumBy: 'protocol' } ];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rows
|
// Rows
|
||||||
|
@ -14965,6 +14965,9 @@
|
|||||||
//console.log('renderReport', r);
|
//console.log('renderReport', r);
|
||||||
var colTranslation = { time: "Time", device: "Device", session: "Session", user: "User", length: "Length" }
|
var colTranslation = { time: "Time", device: "Device", session: "Session", user: "User", length: "Length" }
|
||||||
var x = '<table style=width:100%>';
|
var x = '<table style=width:100%>';
|
||||||
|
var sumByCol = null; // Indicate by what colum we sum by
|
||||||
|
var sumByValues = []; // Indicate by what values we sum by
|
||||||
|
|
||||||
x += '<tr>'
|
x += '<tr>'
|
||||||
for (var i in r.columns) {
|
for (var i in r.columns) {
|
||||||
var coltitle;
|
var coltitle;
|
||||||
@ -14987,9 +14990,16 @@
|
|||||||
var style = '';
|
var style = '';
|
||||||
if (r.columns[k].align) { style = 'text-align:' + EscapeHtml(r.columns[k].align); }
|
if (r.columns[k].align) { style = 'text-align:' + EscapeHtml(r.columns[k].align); }
|
||||||
if (e[r.columns[k].id] != null) { x += '<td style="' + style + '">' + renderReportFormat(e[r.columns[k].id], r.columns[k].format) + '</td>'; } else { x += '<td></td>'; }
|
if (e[r.columns[k].id] != null) { x += '<td style="' + style + '">' + renderReportFormat(e[r.columns[k].id], r.columns[k].format) + '</td>'; } else { x += '<td></td>'; }
|
||||||
if (r.columns[k].format == 'seconds') {
|
if (r.columns[k].sumBy != null) {
|
||||||
var v = e[r.columns[k].id];
|
var v1 = e[r.columns[k].sumBy];
|
||||||
if (v != null) { if (r.columns[k].subtotal == null) { r.columns[k].subtotal = v; r.columns[k].total = v; } else { r.columns[k].subtotal += v; r.columns[k].total += v; } }
|
var v2 = e[r.columns[k].id];
|
||||||
|
sumByCol = r.columns[k].sumBy;
|
||||||
|
if (v2 != null) {
|
||||||
|
if (sumByValues.indexOf(v1) == -1) { sumByValues.push(v1); }
|
||||||
|
if (r.columns[k].subtotals == null) { r.columns[k].subtotals = {}; r.columns[k].totals = {}; }
|
||||||
|
if (r.columns[k].subtotals[v1] == null) { r.columns[k].subtotals[v1] = v2; } else { r.columns[k].subtotals[v1] += v2; }
|
||||||
|
if (r.columns[k].totals[v1] == null) { r.columns[k].totals[v1] = v2; } else { r.columns[k].totals[v1] += v2; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += '</tr>'
|
x += '</tr>'
|
||||||
@ -14997,17 +15007,35 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Display totals
|
// Display totals
|
||||||
x += '<tr>'
|
if (sumByCol != null) {
|
||||||
for (var i in r.columns) {
|
var sumByColNum = -1;
|
||||||
if (r.columns[i].total != null) {
|
for (var i in r.columns) { if (r.columns[i].id == sumByCol) { sumByColNum = i; } }
|
||||||
var style = '';
|
if (sumByColNum >= 0) {
|
||||||
if (r.columns[k].align) { style = 'text-align:' + EscapeHtml(r.columns[k].align); }
|
sumByValues.sort();
|
||||||
x += '<td style="border-top:1pt solid black;color:#777;' + style + '">' + renderReportFormat(r.columns[i].total, r.columns[i].format); + '</td>';
|
var firstRow = true;
|
||||||
} else {
|
x += '<tr style=height:8px></tr>'
|
||||||
x += '<td></td>';
|
for (var j in sumByValues) {
|
||||||
|
x += '<tr>'
|
||||||
|
for (var i in r.columns) {
|
||||||
|
if (i == sumByColNum) {
|
||||||
|
var style = '';
|
||||||
|
if (r.columns[k].align) { style += ';text-align:' + EscapeHtml(r.columns[k].align); }
|
||||||
|
if (firstRow) { style += ';border-top:1pt solid #777'; }
|
||||||
|
x += '<td style="color:#777' + style + '">' + renderReportFormat(sumByValues[j], r.columns[i].format); + '</td>';
|
||||||
|
} else if (r.columns[i].totals != null) {
|
||||||
|
var style = '';
|
||||||
|
if (r.columns[k].align) { style += ';text-align:' + EscapeHtml(r.columns[k].align); }
|
||||||
|
if (firstRow) { style += ';border-top:1pt solid #777'; }
|
||||||
|
x += '<td style="color:#777' + style + '">' + renderReportFormat(r.columns[i].totals[sumByValues[j]], r.columns[i].format); + '</td>';
|
||||||
|
} else {
|
||||||
|
x += '<td></td>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x += '</tr>'
|
||||||
|
firstRow = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
x += '</tr>'
|
|
||||||
|
|
||||||
x += '</table>';
|
x += '</table>';
|
||||||
QH('p60report', x);
|
QH('p60report', x);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user