mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Updated computer power state timeline export to ISO format, added local browser time.
This commit is contained in:
parent
23ed18441a
commit
8b3f24b5dc
@ -7242,8 +7242,7 @@
|
||||
++count;
|
||||
date = new Date(date.getTime() - (1000 * 60 * 60 * 24)); // Substract one day
|
||||
}
|
||||
|
||||
QH('p10html2', '<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>' + "Day" + '</th><th scope=col style=text-align:center><a onclick=downloadFile("devicepowerevents.ashx?id=' + currentNode._id + (urlargs.key?('&key=' + urlargs.key):'') + '",null,true)><img title="' + "Download power events" + '" src="images/link4.png" /></a>' + "7 Day Power State" + '</th></tr></thead><tbody>' + x + '</tbody></table>');
|
||||
QH('p10html2', '<table cellpadding=2 cellspacing=0><thead><tr style=><th scope=col style=text-align:center;width:150px>' + "Day" + '</th><th scope=col style=text-align:center><a onclick=downloadFile("devicepowerevents.ashx?id=' + currentNode._id + '&tf=' + new Date().getTimezoneOffset() + (urlargs.key?('&key=' + urlargs.key):'') + '",null,true)><img title="' + "Download power events" + '" src="images/link4.png" /></a>' + "7 Day Power State" + '</th></tr></thead><tbody>' + x + '</tbody></table>');
|
||||
}
|
||||
|
||||
// Return a color for the given power state
|
||||
|
13
webserver.js
13
webserver.js
@ -5208,17 +5208,24 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
||||
// Check if we have right to this node
|
||||
if (obj.GetNodeRights(user, node.meshid, node._id) == 0) { res.sendStatus(401); return; }
|
||||
|
||||
// Get local time offset
|
||||
var localTimeOffset = 0;
|
||||
if (req.query.tf != null) { localTimeOffset = parseInt(req.query.tf) }
|
||||
if (isNaN(localTimeOffset)) { localTimeOffset = 0; }
|
||||
|
||||
// Get the list of power events and send them
|
||||
setContentDispositionHeader(res, 'application/octet-stream', 'powerevents.csv', null, 'powerevents.csv');
|
||||
obj.db.getPowerTimeline(node._id, function (err, docs) {
|
||||
var xevents = ['Time, State, Previous State'], prevState = 0;
|
||||
var xevents = ['UTC Time, Local Time, State, Previous State'], prevState = 0;
|
||||
for (var i in docs) {
|
||||
if (docs[i].power != prevState) {
|
||||
prevState = docs[i].power;
|
||||
var localTime = new Date(docs[i].time.getTime() + (localTimeOffset * 60000)).toISOString();
|
||||
localTime = localTime.substring(0, localTime.length - 1);
|
||||
if (docs[i].oldPower != null) {
|
||||
xevents.push(docs[i].time.toString() + ',' + docs[i].power + ',' + docs[i].oldPower);
|
||||
xevents.push(docs[i].time.toISOString() + ',' + localTime + ',' + docs[i].power + ',' + docs[i].oldPower);
|
||||
} else {
|
||||
xevents.push(docs[i].time.toString() + ',' + docs[i].power);
|
||||
xevents.push(docs[i].time.toISOString() + ',' + localTime + ',' + docs[i].power);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user