increase vTick for time screen, add lost IP event handler and system status to web interface

This commit is contained in:
Djuri 2023-11-03 16:03:34 +01:00
parent 7cc524f75f
commit 5c165633d1
7 changed files with 49 additions and 3 deletions

View file

@ -20,6 +20,7 @@ $form-range-track-bg: #fff;
@import "../node_modules/bootstrap/scss/navbar";
@import "../node_modules/bootstrap/scss/nav";
@import "../node_modules/bootstrap/scss/card";
@import "../node_modules/bootstrap/scss/progress";
@import "../node_modules/bootstrap/scss/helpers";
@import "../node_modules/bootstrap/scss/utilities/api";

View file

@ -57,6 +57,20 @@
</span>
</p>
</div>
<hr>
<div>
<div class="progress" role="progressbar" aria-label="Memory usage" aria-valuenow="{{ memUsage }}" aria-valuemin="0" aria-valuemax="100">
<div class="progress-bar progress-bar-striped" style="width: {{ memUsage }}%">{{ memUsage }}%</div>
</div>
<div class="d-flex justify-content-between">
<div>Memory usage</div>
<div>{{ memFree }} / {{ memTotal }} kB</div>
</div>
</div>
<hr>
<div>
<p>Uptime: {{#if uptime.h }}{{ uptime.h }}h {{/if}}{{ uptime.m }}m {{ uptime.s }}s</p>
</div>
</div>
</div>
</script>

View file

@ -2,6 +2,23 @@ import './helpers.js';
var screens = ["Block Height", "Moscow Time", "Ticker", "Time", "Halving countdown"];
toTime = (secs) => {
var hours = Math.floor(secs / (60 * 60));
var divisor_for_minutes = secs % (60 * 60);
var minutes = Math.floor(divisor_for_minutes / 60);
var divisor_for_seconds = divisor_for_minutes % 60;
var seconds = Math.ceil(divisor_for_seconds);
var obj = {
"h": hours,
"m": minutes,
"s": seconds
};
return obj;
}
getBcStatus = () => {
fetch('/api/status', {
method: 'get'
@ -11,7 +28,7 @@ getBcStatus = () => {
var source = document.getElementById("entry-template").innerHTML;
var template = Handlebars.compile(source);
var context = { timerRunning: jsonData.timerRunning, currentScreen: jsonData.currentScreen, rendered: jsonData.rendered, data: jsonData.data, screens: screens, ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [] };
var context = { timerRunning: jsonData.timerRunning, memUsage: Math.round(jsonData.espFreeHeap / jsonData.espHeapSize * 100), memFree: (jsonData.espFreeHeap / 1000), memTotal: (jsonData.espHeapSize / 1000), uptime: toTime(jsonData.espUptime), currentScreen: jsonData.currentScreen, rendered: jsonData.rendered, data: jsonData.data, screens: screens, ledStatus: jsonData.ledStatus ? jsonData.ledStatus.map((t) => (t).toString(16)) : [] };
document.getElementById('output').innerHTML = template(context);