srv/poe_manager/templates/logs.html aktualisiert

This commit is contained in:
2025-10-08 18:46:26 +02:00
parent 207eed1f00
commit 9c25d532ec

View File

@@ -3,6 +3,11 @@
<h2>Live Log</h2> <h2>Live Log</h2>
<!-- Refresh-Button unter der Überschrift -->
<button id="refresh-btn" class="btn btn-primary mb-3">
🔄 Logs aktualisieren
</button>
<div id="log-container"> <div id="log-container">
<div id="log-box"></div> <div id="log-box"></div>
<div id="refresh-timer"> <div id="refresh-timer">
@@ -11,11 +16,18 @@
</div> </div>
<script> <script>
const intervalMinutes = {{ interval | int }}; document.addEventListener("DOMContentLoaded", () => {
const intervalMilliseconds = intervalMinutes * 60 * 1000; // --- Seitentitel setzen ---
let lastUpdateTime = Date.now(); const baseTitle = document.title.split(" - ")[0];
document.title = baseTitle + " - Live Log";
function fetchLog() { // --- Intervallwerte ---
const intervalMinutes = {{ interval | int }};
const intervalMilliseconds = intervalMinutes * 60 * 1000;
let lastUpdateTime = Date.now();
// --- Log laden ---
function fetchLog() {
fetch("{{ url_for('get_log') }}") fetch("{{ url_for('get_log') }}")
.then(response => response.text()) .then(response => response.text())
.then(data => { .then(data => {
@@ -29,18 +41,24 @@ function fetchLog() {
lastUpdateTime = Date.now(); lastUpdateTime = Date.now();
}) })
.catch(err => console.error("Fehler beim Laden der Logs:", err)); .catch(err => console.error("Fehler beim Laden der Logs:", err));
} }
function updateTimer() { // --- Timer aktualisieren ---
function updateTimer() {
const now = Date.now(); const now = Date.now();
const remainingMs = intervalMilliseconds - (now - lastUpdateTime); const remainingMs = intervalMilliseconds - (now - lastUpdateTime);
const remainingSec = Math.max(Math.ceil(remainingMs / 1000), 0); const remainingSec = Math.max(Math.ceil(remainingMs / 1000), 0);
document.getElementById("timer").innerText = remainingSec; document.getElementById("timer").innerText = remainingSec;
} }
setInterval(updateTimer, 1000); // --- Button klick ---
fetchLog(); document.getElementById("refresh-btn").addEventListener("click", fetchLog);
setInterval(fetchLog, intervalMilliseconds);
// --- Initial starten ---
setInterval(updateTimer, 1000);
fetchLog();
setInterval(fetchLog, intervalMilliseconds);
});
</script> </script>
{% endblock %} {% endblock %}