diff --git a/src/WebApi.cpp b/src/WebApi.cpp index 11b8ac6..2211f4a 100644 --- a/src/WebApi.cpp +++ b/src/WebApi.cpp @@ -122,6 +122,8 @@ void WebApiClass::onSystemStatus(AsyncWebServerRequest* request) sprintf(version, "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff); root[F("firmware_version")] = version; + root[F("uptime")] = esp_timer_get_time() / 1000000; + response->setLength(); request->send(response); } diff --git a/webapp/src/components/partials/FirmwareInfo.vue b/webapp/src/components/partials/FirmwareInfo.vue index cde8da1..8661ede 100644 --- a/webapp/src/components/partials/FirmwareInfo.vue +++ b/webapp/src/components/partials/FirmwareInfo.vue @@ -31,6 +31,10 @@ Config save count {{ systemDataList.cfgsavecount }} + + Uptime + {{ timeInHours(systemDataList.uptime) }} + @@ -48,6 +52,21 @@ export default { created() { this.getSystemInfo(); }, + computed: { + timeInHours() { + return (value) => { + let hours = parseInt(Math.floor(value / 3600)); + let minutes = parseInt(Math.floor((value - hours * 3600) / 60)); + let seconds = parseInt((value - (hours * 3600 + minutes * 60)) % 60); + + let dHours = hours > 9 ? hours : "0" + hours; + let dMins = minutes > 9 ? minutes : "0" + minutes; + let dSecs = seconds > 9 ? seconds : "0" + seconds; + + return dHours + ":" + dMins + ":" + dSecs; + }; + }, + }, methods: { getSystemInfo() { fetch("/api/system/status")