Auto-Status: initial ping on load and 30s interval; README updated

This commit is contained in:
2025-08-21 14:41:47 +02:00
parent 504ca23442
commit 020b535d2f
2 changed files with 21 additions and 3 deletions

View File

@ -106,9 +106,9 @@ Falls weder Kommandozeilenparameter noch Umgebungsvariable gesetzt sind, wird Po
- Das System sendet automatisch ein Wake-on-LAN Paket
### Online-Status prüfen (Ping)
- Klicken Sie auf den Button "Status aktualisieren" in der Tabelle
- Die Online/Offline-Badges werden pro Gerät aktualisiert
- Optional kann ein automatisches Intervall ergänzt werden (siehe Entwicklung)
- Beim Laden der Seite wird automatisch der Status abgefragt
- Alle 30 Sekunden wird der Status automatisch aktualisiert
- Zusätzlich können Sie manuell über den Button "Status aktualisieren" aktualisieren
### PC löschen
- Klicken Sie auf den "Löschen"-Button neben dem gewünschten PC

View File

@ -5,12 +5,15 @@ class PCManager {
this.allPCs = []; // Alle PCs im Speicher
this.filteredPCs = []; // Gefilterte PCs
this.searchTerm = ''; // Aktueller Suchbegriff
this.statusTimer = null; // Intervall für Auto-Status
this.refreshing = false; // Guard gegen parallele Status-Requests
this.init();
}
init() {
this.loadPCs();
this.setupEventListeners();
this.startAutoStatus();
}
setupEventListeners() {
@ -55,6 +58,8 @@ class PCManager {
this.allPCs = data.pcs;
this.filteredPCs = [...this.allPCs];
this.displayPCs();
// Ersten Status direkt nach dem Laden abfragen
this.refreshStatus();
} else {
this.showNotification('Fehler', data.message, 'danger');
}
@ -63,6 +68,15 @@ class PCManager {
}
}
startAutoStatus() {
if (this.statusTimer) {
clearInterval(this.statusTimer);
}
this.statusTimer = setInterval(() => {
this.refreshStatus();
}, 30000); // alle 30 Sekunden
}
searchPCs(searchTerm) {
this.searchTerm = searchTerm.toLowerCase().trim();
@ -304,6 +318,8 @@ class PCManager {
}
async refreshStatus() {
if (this.refreshing) return;
this.refreshing = true;
try {
const response = await fetch('/api/pcs/status');
const data = await response.json();
@ -327,6 +343,8 @@ class PCManager {
}
} catch (error) {
this.showNotification('Fehler', 'Fehler beim Aktualisieren des Online-Status', 'danger');
} finally {
this.refreshing = false;
}
}