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