mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-11 23:13:21 -05:00
Merge pull request #3310 from nzalev/fix-mysql-powerevents-csv
Fix MariaDB/MySQL power events
This commit is contained in:
commit
2b5348898c
12
webserver.js
12
webserver.js
@ -5413,18 +5413,22 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
|
|||||||
var xevents = ['UTC Time, Local Time, State, Previous State'], prevState = 0;
|
var xevents = ['UTC Time, Local Time, State, Previous State'], prevState = 0;
|
||||||
for (var i in docs) {
|
for (var i in docs) {
|
||||||
if (docs[i].power != prevState) {
|
if (docs[i].power != prevState) {
|
||||||
|
var timedoc = docs[i].time;
|
||||||
|
if (typeof timedoc == 'string') {
|
||||||
|
timedoc = new Date(timedoc);
|
||||||
|
}
|
||||||
prevState = docs[i].power;
|
prevState = docs[i].power;
|
||||||
var localTime = '';
|
var localTime = '';
|
||||||
if (timeConversionSystem == 1) { // Good way
|
if (timeConversionSystem == 1) { // Good way
|
||||||
localTime = new Date(docs[i].time.getTime()).toLocaleString(req.query.l, { timeZone: req.query.tz })
|
localTime = new Date(timedoc.getTime()).toLocaleString(req.query.l, { timeZone: req.query.tz })
|
||||||
} else if (timeConversionSystem == 2) { // Bad way
|
} else if (timeConversionSystem == 2) { // Bad way
|
||||||
localTime = new Date(docs[i].time.getTime() + (localTimeOffset * 60000)).toISOString();
|
localTime = new Date(timedoc.getTime() + (localTimeOffset * 60000)).toISOString();
|
||||||
localTime = localTime.substring(0, localTime.length - 1);
|
localTime = localTime.substring(0, localTime.length - 1);
|
||||||
}
|
}
|
||||||
if (docs[i].oldPower != null) {
|
if (docs[i].oldPower != null) {
|
||||||
xevents.push('\"' + docs[i].time.toISOString() + '\",\"' + localTime + '\",' + docs[i].power + ',' + docs[i].oldPower);
|
xevents.push('\"' + timedoc.toISOString() + '\",\"' + localTime + '\",' + docs[i].power + ',' + docs[i].oldPower);
|
||||||
} else {
|
} else {
|
||||||
xevents.push('\"' + docs[i].time.toISOString() + '\",\"' + localTime + '\",' + docs[i].power);
|
xevents.push('\"' + timedoc.toISOString() + '\",\"' + localTime + '\",' + docs[i].power);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user