srv/poe_manager/templates/index.html aktualisiert
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<h2>Dashboard</h2>
|
<h2 class="d-flex justify-content-between align-items-center">
|
||||||
|
Dashboard
|
||||||
|
<span id="dashboard-timer" class="badge bg-success">-- s</span>
|
||||||
|
</h2>
|
||||||
<div class="row row-cols-1 row-cols-md-6 g-3">
|
<div class="row row-cols-1 row-cols-md-6 g-3">
|
||||||
{% for d in devices %}
|
{% for d in devices %}
|
||||||
<div class="col">
|
<div class="col">
|
||||||
@@ -24,5 +27,27 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
const intervalMinutes = {{ interval | int }};
|
||||||
|
const intervalMilliseconds = intervalMinutes * 60 * 1000;
|
||||||
|
let lastUpdateTime = Date.now(); // optional: vom letzten Refresh / Log-Eintrag
|
||||||
|
|
||||||
|
function updateDashboardTimer() {
|
||||||
|
const now = Date.now();
|
||||||
|
const elapsed = now - lastUpdateTime;
|
||||||
|
const remainingMs = intervalMilliseconds - (elapsed % intervalMilliseconds);
|
||||||
|
const remainingSec = Math.ceil(remainingMs / 1000);
|
||||||
|
document.getElementById("dashboard-timer").innerText = remainingSec + " s";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional: reset timer beim manuellen Refresh
|
||||||
|
// lastUpdateTime = Date.now();
|
||||||
|
|
||||||
|
setInterval(updateDashboardTimer, 1000);
|
||||||
|
updateDashboardTimer(); // direkt beim Laden
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user