- Live-Log-Bug behoben: _latest_log_file() sortierte nach Datei-ctime statt
nach Dateiname — auf manchen Dateisystemen (u.a. unter WSL2 auf einem
gemounteten Windows-Laufwerk) unzuverlässig und lieferte nicht immer das
tatsächlich neueste Logfile. Sortiert jetzt wie der Rest des Codes über
den chronologisch sortierbaren Dateinamen (rpi-YYYYMMDDHHMMSS.log).
- Navbar umstrukturiert in aufklappbare Gruppen mit Unterpunkten:
- "Geräte": Clients (bisherige Devices-Seite), Switche, Zugangsdaten
- "Einstellungen": Benutzer, Gruppen, Systemeinstellungen (Prüfintervall),
Im-/Export
- "Logs": Live, Änderungen (vormals Live-Log/Änderungslog)
Sichtbarkeit gilt jetzt auch pro Unterpunkt: eine Gruppe erscheint nur,
wenn mindestens ein Unterpunkt für den Benutzer sichtbar ist, und zeigt
dann auch nur die sichtbaren Unterpunkte.
- Im-/Export als eigene Unterseite mit Export/Import nebeneinander
(.settings-grid).
- Neue Seite "Mein Konto" (/account, erreichbar über ein Zahnrad-Symbol
neben dem eigenen Namen in der Sidebar) ersetzt das bisherige Profil-Modal:
Profil/Passwort/Profilbild als volle Seite, dazu für Admins die
Navbar-Reihenfolge (aus den Systemeinstellungen hierher verschoben).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
92 lines
3.4 KiB
HTML
92 lines
3.4 KiB
HTML
{% extends "base.html" %}
|
|
{% set active_page = "logs" %}
|
|
{% block page_title %}Live{% endblock %}
|
|
{% block page_sub %}<div class="topbar-sub">{{ log_name or "kein Logfile" }}</div>{% endblock %}
|
|
{% block topbar_right %}
|
|
<span class="timer-pill"><span class="dot"></span>Update in <span id="timer">--</span>s</span>
|
|
<button id="refresh-btn" class="btn btn-secondary">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 11-3.2-6.9M21 4v5h-5"/></svg>
|
|
Aktualisieren
|
|
</button>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="log-shell">
|
|
<div class="log-toolbar">
|
|
<div class="log-dots"><span></span><span></span><span></span></div>
|
|
<span class="text-faint mono" style="font-size:11.5px;">{{ log_name or "" }}</span>
|
|
</div>
|
|
<div id="log-box">{{ log_content or "Keine Logfiles gefunden." }}</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
function parseLogTimestamp(ts) {
|
|
const parts = ts.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
|
if (!parts) return Date.now();
|
|
const [, year, month, day, hour, minute, second] = parts.map(Number);
|
|
return new Date(year, month - 1, day, hour, minute, second).getTime();
|
|
}
|
|
|
|
function colorizeLine(line) {
|
|
let cls = "";
|
|
if (line.includes(" ist erreichbar!")) cls = "online";
|
|
else if (line.includes(" ist nicht erreichbar!")) cls = "offline";
|
|
else if (line.startsWith("----")) cls = "sep";
|
|
else if (line.toLowerCase().includes("manuell")) cls = "manual";
|
|
const span = document.createElement("span");
|
|
span.className = "log-line" + (cls ? " " + cls : "");
|
|
span.textContent = line;
|
|
return span;
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
const intervalMinutes = {{ interval | int }};
|
|
const intervalMilliseconds = intervalMinutes * 60 * 1000;
|
|
let lastUpdateTime = Date.now();
|
|
|
|
function renderLog(data) {
|
|
const box = document.getElementById("log-box");
|
|
box.innerHTML = "";
|
|
const lines = data.split("\n");
|
|
lines.forEach((line, i) => {
|
|
box.appendChild(colorizeLine(line));
|
|
if (i < lines.length - 1) box.appendChild(document.createElement("br"));
|
|
});
|
|
box.scrollTop = box.scrollHeight;
|
|
|
|
let lastSep = -1;
|
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
if (lines[i].startsWith("----")) { lastSep = i; break; }
|
|
}
|
|
if (lastSep >= 0 && lastSep + 1 < lines.length) {
|
|
const match = lines[lastSep + 1].match(/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})/);
|
|
lastUpdateTime = match ? parseLogTimestamp(match[1]) : Date.now();
|
|
} else {
|
|
lastUpdateTime = Date.now();
|
|
}
|
|
}
|
|
|
|
function fetchLog() {
|
|
fetch("{{ url_for('get_log') }}")
|
|
.then(r => r.text())
|
|
.then(renderLog)
|
|
.catch(err => console.error(err));
|
|
}
|
|
|
|
function updateTimer() {
|
|
const now = Date.now();
|
|
const elapsed = now - lastUpdateTime;
|
|
const remainingMs = intervalMilliseconds - (elapsed % intervalMilliseconds);
|
|
document.getElementById("timer").innerText = Math.ceil(remainingMs / 1000);
|
|
}
|
|
|
|
document.getElementById("refresh-btn").addEventListener("click", fetchLog);
|
|
fetchLog();
|
|
setInterval(fetchLog, intervalMilliseconds);
|
|
setInterval(updateTimer, 1000);
|
|
});
|
|
</script>
|
|
{% endblock %}
|