🐛 Aktualisierung der Protokolldateien und Verbesserung der Benutzeroberfläche im Admin-Dashboard. 📈 Hinzufügen von Fallback-Optionen für die Benutzererstellung und Optimierung der Live-Statistiken. 🛠️ Behebung von Problemen mit nicht definierten Attributen in den Protokollen und Verbesserung der Benutzererfahrung durch informative Meldungen. 🌟
This commit is contained in:
@@ -207,6 +207,13 @@ class AdminDashboard {
|
||||
this.showUserModal();
|
||||
});
|
||||
|
||||
// Ersten Benutzer anlegen Button (Fallback)
|
||||
this.addEventListenerSafe('#add-first-user-btn', 'click', (e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.showUserModal();
|
||||
});
|
||||
|
||||
// Event-Delegation für Benutzer-Aktionen
|
||||
document.addEventListener('click', (e) => {
|
||||
if (e.target.closest('.edit-user-btn')) {
|
||||
@@ -388,46 +395,7 @@ class AdminDashboard {
|
||||
}
|
||||
}
|
||||
|
||||
async loadLiveStats() {
|
||||
try {
|
||||
const url = `${this.apiBaseUrl}/api/stats`;
|
||||
const response = await fetch(url);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
this.updateStatsDisplay(data);
|
||||
this.retryCount = 0;
|
||||
|
||||
} catch (error) {
|
||||
console.error('Fehler beim Laden der Live-Statistiken:', error);
|
||||
this.retryCount++;
|
||||
|
||||
if (this.retryCount <= this.maxRetries) {
|
||||
setTimeout(() => this.loadLiveStats(), 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateStatsDisplay(data) {
|
||||
// Sichere Updates mit null-Checks
|
||||
this.updateElement('live-users-count', data.total_users || 0);
|
||||
this.updateElement('live-printers-count', data.total_printers || 0);
|
||||
this.updateElement('live-printers-online', `${data.online_printers || 0} online`);
|
||||
this.updateElement('live-jobs-active', data.active_jobs || 0);
|
||||
this.updateElement('live-jobs-queued', `${data.queued_jobs || 0} in Warteschlange`);
|
||||
this.updateElement('live-success-rate', `${data.success_rate || 0}%`);
|
||||
|
||||
// Progress Bars aktualisieren
|
||||
this.updateProgressBar('users-progress', data.total_users, 20);
|
||||
this.updateProgressBar('printers-progress', data.online_printers, data.total_printers);
|
||||
this.updateProgressBar('jobs-progress', data.active_jobs, 10);
|
||||
this.updateProgressBar('success-progress', data.success_rate, 100);
|
||||
|
||||
console.log('📊 Live-Statistiken aktualisiert');
|
||||
}
|
||||
// Diese Funktion wurde entfernt - verwende die korrekte loadLiveStats Funktion weiter unten
|
||||
|
||||
updateElement(elementId, value) {
|
||||
const element = document.getElementById(elementId);
|
||||
@@ -1942,26 +1910,28 @@ class AdminDashboard {
|
||||
if (!stats) return;
|
||||
|
||||
// Benutzer-Statistiken aktualisieren
|
||||
this.updateElement('total-users-count', stats.total_users || 0);
|
||||
this.updateElement('active-users-count', stats.active_users || 0);
|
||||
this.updateElement('total-users-count', stats.users?.total || 0);
|
||||
this.updateElement('active-users-count', stats.users?.active || 0);
|
||||
this.updateElement('live-users-count', stats.users?.total || 0);
|
||||
|
||||
// Drucker-Statistiken aktualisieren
|
||||
this.updateElement('total-printers-count', stats.total_printers || 0);
|
||||
this.updateElement('online-printers-count', stats.online_printers || 0);
|
||||
this.updateElement('total-printers-count', stats.printers?.total || 0);
|
||||
this.updateElement('online-printers-count', stats.printers?.online || 0);
|
||||
this.updateElement('live-printers-count', stats.printers?.total || 0);
|
||||
this.updateElement('live-printers-online', `${stats.printers?.online || 0} online`);
|
||||
|
||||
// Job-Statistiken aktualisieren
|
||||
this.updateElement('total-jobs-count', stats.total_jobs || 0);
|
||||
this.updateElement('active-jobs-count', stats.active_jobs || 0);
|
||||
this.updateElement('completed-jobs-count', stats.completed_jobs || 0);
|
||||
this.updateElement('total-jobs-count', stats.jobs?.total || 0);
|
||||
this.updateElement('active-jobs-count', stats.jobs?.active || 0);
|
||||
this.updateElement('live-jobs-active', stats.jobs?.active || 0);
|
||||
this.updateElement('live-jobs-queued', `${stats.jobs?.active || 0} in Warteschlange`);
|
||||
|
||||
// Gast-Anfragen aktualisieren
|
||||
this.updateElement('pending-guests-count', stats.pending_guests || 0);
|
||||
// Progress Bars aktualisieren
|
||||
this.updateProgressBar('users-progress', stats.users?.total || 0, 20);
|
||||
this.updateProgressBar('printers-progress', stats.printers?.online || 0, stats.printers?.total || 1);
|
||||
this.updateProgressBar('jobs-progress', stats.jobs?.active || 0, 10);
|
||||
|
||||
// Zeitstempel aktualisieren
|
||||
const timestampEl = document.getElementById('stats-timestamp');
|
||||
if (timestampEl) {
|
||||
timestampEl.textContent = new Date().toLocaleTimeString('de-DE');
|
||||
}
|
||||
console.log('📊 Dashboard-Statistiken aktualisiert');
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user