Show uptime in webgui

This commit is contained in:
Thomas Basler 2022-04-28 21:56:11 +02:00
parent e6bbca05bd
commit 2748e2e97d
2 changed files with 21 additions and 0 deletions

View File

@ -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); sprintf(version, "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff);
root[F("firmware_version")] = version; root[F("firmware_version")] = version;
root[F("uptime")] = esp_timer_get_time() / 1000000;
response->setLength(); response->setLength();
request->send(response); request->send(response);
} }

View File

@ -31,6 +31,10 @@
<th>Config save count</th> <th>Config save count</th>
<td>{{ systemDataList.cfgsavecount }}</td> <td>{{ systemDataList.cfgsavecount }}</td>
</tr> </tr>
<tr>
<th>Uptime</th>
<td>{{ timeInHours(systemDataList.uptime) }}</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
@ -48,6 +52,21 @@ export default {
created() { created() {
this.getSystemInfo(); 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: { methods: {
getSystemInfo() { getSystemInfo() {
fetch("/api/system/status") fetch("/api/system/status")