revert srv/poe_manager/templates/index.html aktualisiert
This commit is contained in:
2025-10-08 20:28:46 +02:00
parent 122a4bd4a4
commit 831da1479e

View File

@@ -46,7 +46,7 @@ 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 = Math.max(intervalMilliseconds - elapsed, 0); const remainingMs = intervalMilliseconds - (elapsed % intervalMilliseconds);
const remainingSec = Math.ceil(remainingMs / 1000); const remainingSec = Math.ceil(remainingMs / 1000);
document.getElementById("dashboard-timer").innerText = document.getElementById("dashboard-timer").innerText =
`Nächste Prüfung in ${remainingSec} Sekunden`; `Nächste Prüfung in ${remainingSec} Sekunden`;
@@ -56,14 +56,19 @@ document.addEventListener("DOMContentLoaded", () => {
fetch("{{ url_for('get_log') }}") fetch("{{ url_for('get_log') }}")
.then(response => response.text()) .then(response => response.text())
.then(data => { .then(data => {
const lines = data.split("\n").map(l => l.trim()).filter(Boolean); const lines = data.split("\n").filter(line => !line.includes("ist erreichbar!"));
if (lines.length > 0) { let lastSepIndex = -1;
const lastLine = lines[lines.length - 1]; for (let i = lines.length - 1; i >= 0; i--) {
const match = lastLine.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/); if (lines[i].startsWith("--------------------------------------------------------------------")) {
if (match) { lastSepIndex = i;
lastUpdateTime = parseLogTimestamp(match[1]); break;
} }
} }
if (lastSepIndex >= 0 && lastSepIndex + 1 < lines.length) {
const firstLine = lines[lastSepIndex + 1];
const match = firstLine.match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/);
if (match) lastUpdateTime = parseLogTimestamp(match[1]);
}
}) })
.catch(err => console.error("Fehler beim Laden der Logs:", err)); .catch(err => console.error("Fehler beim Laden der Logs:", err));
} }