srv/poe_manager/templates/index.html aktualisiert
This commit is contained in:
@@ -32,11 +32,10 @@
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const intervalMinutes = {{ interval | int }}; // Intervall aus DB in Minuten
|
||||
const intervalMinutes = {{ interval | int }};
|
||||
const intervalMilliseconds = intervalMinutes * 60 * 1000;
|
||||
let lastUpdateTime = Date.now();
|
||||
|
||||
let reloadCountdown = null; // Reload-Timer (10s)
|
||||
let reloadCountdown = null;
|
||||
|
||||
function parseLogTimestamp(ts) {
|
||||
const parts = ts.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
||||
@@ -48,19 +47,15 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
function updateTimer() {
|
||||
const now = Date.now();
|
||||
const elapsed = now - lastUpdateTime;
|
||||
const remainingMs = intervalMilliseconds - (elapsed % intervalMilliseconds);
|
||||
let remainingSec = Math.ceil(remainingMs / 1000);
|
||||
|
||||
const timerElem = document.getElementById("dashboard-timer");
|
||||
|
||||
if (remainingSec > 0) {
|
||||
// Haupt-Timer läuft normal
|
||||
if (elapsed < intervalMilliseconds) {
|
||||
// Haupt-Timer läuft
|
||||
const remainingSec = Math.ceil((intervalMilliseconds - elapsed) / 1000);
|
||||
timerElem.innerText = `Nächste Prüfung in ${remainingSec} Sekunden`;
|
||||
} else {
|
||||
// Haupt-Timer abgelaufen → Reload-Timer starten, falls noch nicht gestartet
|
||||
if (reloadCountdown === null) {
|
||||
reloadCountdown = 10; // 10 Sekunden Countdown
|
||||
}
|
||||
// Haupt-Timer abgelaufen → Reload-Timer starten
|
||||
if (reloadCountdown === null) reloadCountdown = 10; // 10 Sekunden Countdown
|
||||
timerElem.innerText = `Aktualisieren der Seite in ${reloadCountdown} Sekunden`;
|
||||
reloadCountdown--;
|
||||
|
||||
@@ -91,10 +86,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
.catch(err => console.error("Fehler beim Laden der Logs:", err));
|
||||
}
|
||||
|
||||
// Timer jede Sekunde aktualisieren
|
||||
setInterval(updateTimer, 1000);
|
||||
|
||||
// einmal beim Laden letzte Log-Zeit setzen
|
||||
fetchLastLog();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user