change time units to milliseconds
Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
This commit is contained in:
@@ -216,7 +216,7 @@ function updateSingleChart(chart, metric, data, timeLabel) {
|
||||
* @param {Object} data - The new sensor data object from the WebSocket.
|
||||
*/
|
||||
export function updateCharts(data) {
|
||||
const timeLabel = new Date(data.timestamp * 1000).toLocaleTimeString();
|
||||
const timeLabel = new Date(data.timestamp).toLocaleTimeString();
|
||||
|
||||
updateSingleChart(charts.power, 'power', data, timeLabel);
|
||||
updateSingleChart(charts.voltage, 'voltage', data, timeLabel);
|
||||
|
||||
@@ -88,13 +88,13 @@ function onWsMessage(event) {
|
||||
USB: sensorData.usb,
|
||||
MAIN: sensorData.main,
|
||||
VIN: sensorData.vin,
|
||||
timestamp: sensorData.timestamp
|
||||
timestamp: sensorData.timestampMs
|
||||
};
|
||||
updateSensorUI(sensorPayload);
|
||||
|
||||
// Update uptime separately from the sensor data payload
|
||||
if (sensorData.uptimeSec !== undefined) {
|
||||
updateUptimeUI(sensorData.uptimeSec);
|
||||
if (sensorData.uptimeMs !== undefined) {
|
||||
updateUptimeUI(sensorData.uptimeMs / 1000);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,7 @@ export function debounce(func, delay) {
|
||||
* @returns {string} The formatted uptime string.
|
||||
*/
|
||||
export function formatUptime(totalSeconds) {
|
||||
totalSeconds = Math.floor(totalSeconds);
|
||||
const days = Math.floor(totalSeconds / 86400);
|
||||
const hours = Math.floor((totalSeconds % 86400) / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
|
||||
Reference in New Issue
Block a user