Update: Separate uptime UI updates and enhance logging for WebSocket messages

- Add `updateUptimeUI` function for dedicated uptime handling.
- Modify WebSocket message handling to update uptime separately from sensor data.
- Adjust logging to provide better clarity for unknown payload types.
- Fix formatting inconsistency in uptime display (`1d` -> `1days`).

Signed-off-by: YoungSoo Shin <shinys000114@gmail.com>
This commit is contained in:
2025-09-03 15:21:01 +09:00
parent feb16beb0f
commit 630d3c4f58
3 changed files with 27 additions and 16 deletions

View File

@@ -47,14 +47,20 @@ export function updateSensorUI(data) {
dom.powerDisplay.textContent = `${data.VIN.power.toFixed(2)} W`;
}
if (data.uptime_sec !== undefined) {
dom.uptimeDisplay.textContent = formatUptime(data.uptime_sec);
}
// Pass the entire multi-channel data object to the charts
updateCharts(data);
}
/**
* Updates the system uptime display in the UI.
* @param {number} uptimeInSeconds - The system uptime in seconds.
*/
export function updateUptimeUI(uptimeInSeconds) {
if (uptimeInSeconds !== undefined) {
dom.uptimeDisplay.textContent = formatUptime(uptimeInSeconds);
}
}
/**
* Updates the Wi-Fi status indicator in the header.
* @param {Object} data - The Wi-Fi status object from the WebSocket.