📝 Enhanced Printer Details Modal and Scrollable Update Documentation Added 🎉
This commit is contained in:
2
backend/static/css/tailwind.min.css
vendored
2
backend/static/css/tailwind.min.css
vendored
File diff suppressed because one or more lines are too long
@ -36,8 +36,9 @@ class AdminDashboard {
|
||||
|
||||
console.log('🚀 Initialisiere Mercedes-Benz MYP Admin Dashboard');
|
||||
|
||||
// CSRF Token setzen
|
||||
this.csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||
// CSRF Token mit verbesserter Extraktion
|
||||
this.csrfToken = this.extractCSRFToken();
|
||||
console.log('🔒 CSRF Token:', this.csrfToken ? 'verfügbar' : 'FEHLT!');
|
||||
|
||||
// Event-Listener nur einmal registrieren
|
||||
this.attachEventListeners();
|
||||
@ -52,6 +53,39 @@ class AdminDashboard {
|
||||
console.log('✅ Admin Dashboard erfolgreich initialisiert');
|
||||
}
|
||||
|
||||
extractCSRFToken() {
|
||||
// Methode 1: Meta Tag
|
||||
const metaToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||
if (metaToken) {
|
||||
console.log('🔒 CSRF Token aus meta Tag geladen');
|
||||
return metaToken;
|
||||
}
|
||||
|
||||
// Methode 2: Hidden Input
|
||||
const hiddenInput = document.querySelector('input[name="csrf_token"]')?.value;
|
||||
if (hiddenInput) {
|
||||
console.log('🔒 CSRF Token aus hidden input geladen');
|
||||
return hiddenInput;
|
||||
}
|
||||
|
||||
// Methode 3: Cookie (falls verfügbar)
|
||||
const cookieToken = document.cookie.split('; ').find(row => row.startsWith('csrf_token='))?.split('=')[1];
|
||||
if (cookieToken) {
|
||||
console.log('🔒 CSRF Token aus Cookie geladen');
|
||||
return cookieToken;
|
||||
}
|
||||
|
||||
// Methode 4: Flask-WTF Standard
|
||||
const flaskToken = document.querySelector('meta[name="csrf-token"]')?.content;
|
||||
if (flaskToken) {
|
||||
console.log('🔒 CSRF Token aus Flask-WTF Meta geladen');
|
||||
return flaskToken;
|
||||
}
|
||||
|
||||
console.error('❌ CSRF Token konnte nicht gefunden werden!');
|
||||
return null;
|
||||
}
|
||||
|
||||
attachEventListeners() {
|
||||
if (this.eventListenersAttached) {
|
||||
console.log('⚠️ Event-Listener bereits registriert, überspringe...');
|
||||
@ -259,6 +293,12 @@ class AdminDashboard {
|
||||
async loadInitialData() {
|
||||
await this.loadLiveStats();
|
||||
await this.checkSystemHealth();
|
||||
|
||||
// Button-Test ausführen
|
||||
setTimeout(() => {
|
||||
this.testButtons();
|
||||
}, 1000);
|
||||
|
||||
// Logs laden falls wir auf dem Logs-Tab sind
|
||||
if (window.location.search.includes('tab=logs') || document.querySelector('.tabs [href*="logs"]')?.classList.contains('active')) {
|
||||
await this.loadLogs();
|
||||
@ -829,22 +869,55 @@ class AdminDashboard {
|
||||
|
||||
this.showNotification('🔄 Fehler werden automatisch behoben...', 'info');
|
||||
|
||||
// Debug: CSRF Token prüfen
|
||||
if (!this.csrfToken) {
|
||||
console.error('❌ CSRF Token fehlt! Versuche Token neu zu laden...');
|
||||
this.csrfToken = this.extractCSRFToken();
|
||||
|
||||
if (!this.csrfToken) {
|
||||
this.showNotification('❌ Sicherheitsfehler: CSRF Token nicht verfügbar', 'error');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
console.log('🔧 Starte automatische Fehlerkorrektur...');
|
||||
console.log('🔒 CSRF Token für Request:', this.csrfToken.substring(0, 10) + '...');
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/admin/fix-errors', {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: { 'X-CSRFToken': this.csrfToken }
|
||||
});
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': this.csrfToken
|
||||
}
|
||||
};
|
||||
|
||||
console.log('📡 Sende Request an:', '/api/admin/fix-errors');
|
||||
console.log('📝 Request Headers:', requestOptions.headers);
|
||||
|
||||
const response = await fetch('/api/admin/fix-errors', requestOptions);
|
||||
|
||||
console.log('📡 Response Status:', response.status);
|
||||
console.log('📡 Response Headers:', Object.fromEntries(response.headers.entries()));
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error('❌ Response Error:', errorText);
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText} - ${errorText}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('✅ Response Data:', data);
|
||||
|
||||
if (data.success) {
|
||||
this.showNotification('✅ Automatische Reparatur erfolgreich!', 'success');
|
||||
setTimeout(() => this.checkSystemHealth(), 2000);
|
||||
} else {
|
||||
this.showNotification('❌ Automatische Reparatur fehlgeschlagen', 'error');
|
||||
this.showNotification(`❌ Automatische Reparatur fehlgeschlagen: ${data.message || 'Unbekannter Fehler'}`, 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
this.showNotification('❌ Fehler bei der automatischen Reparatur', 'error');
|
||||
console.error('❌ Fehler bei automatischer Reparatur:', error);
|
||||
this.showNotification(`❌ Fehler bei der automatischen Reparatur: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1079,6 +1152,101 @@ class AdminDashboard {
|
||||
this.showNotification('❌ Fehler beim Exportieren der Logs: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// ===== BUTTON-FUNKTIONALITÄT-TEST =====
|
||||
testButtons() {
|
||||
console.log('🧪 Teste Button-Funktionalität...');
|
||||
|
||||
// Teste Fix-Errors Button
|
||||
const fixBtn = document.querySelector('#fix-errors-btn');
|
||||
if (fixBtn) {
|
||||
console.log('✅ Fix-Errors Button gefunden:', fixBtn);
|
||||
console.log('🔗 Event-Listener-Status:', fixBtn.dataset.listenerAttached);
|
||||
|
||||
// Manueller Test-Click
|
||||
fixBtn.addEventListener('click', (e) => {
|
||||
console.log('🖱️ Fix-Errors Button wurde geklickt (manueller Listener)');
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
this.testFixErrors();
|
||||
});
|
||||
} else {
|
||||
console.error('❌ Fix-Errors Button NICHT gefunden!');
|
||||
}
|
||||
|
||||
// Teste View-Details Button
|
||||
const viewBtn = document.querySelector('#view-error-details-btn');
|
||||
if (viewBtn) {
|
||||
console.log('✅ View-Details Button gefunden:', viewBtn);
|
||||
console.log('🔗 Event-Listener-Status:', viewBtn.dataset.listenerAttached);
|
||||
|
||||
// Manueller Test-Click
|
||||
viewBtn.addEventListener('click', (e) => {
|
||||
console.log('🖱️ View-Details Button wurde geklickt (manueller Listener)');
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
console.log('🔄 Weiterleitung zu Logs-Tab...');
|
||||
window.location.href = '/admin-dashboard?tab=logs';
|
||||
});
|
||||
} else {
|
||||
console.error('❌ View-Details Button NICHT gefunden!');
|
||||
}
|
||||
}
|
||||
|
||||
// Test-Version der Fix-Errors Funktion
|
||||
async testFixErrors() {
|
||||
console.log('🧪 TEST: Fix-Errors wird ausgeführt...');
|
||||
|
||||
// Token-Test
|
||||
console.log('🔒 Aktueller CSRF Token:', this.csrfToken);
|
||||
|
||||
if (!this.csrfToken) {
|
||||
console.error('❌ CSRF Token fehlt - versuche neu zu laden...');
|
||||
this.csrfToken = this.extractCSRFToken();
|
||||
console.log('🔒 Neu geladener Token:', this.csrfToken);
|
||||
}
|
||||
|
||||
this.showNotification('🧪 TEST: Starte automatische Fehlerkorrektur...', 'info');
|
||||
|
||||
try {
|
||||
const requestOptions = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': this.csrfToken,
|
||||
'X-Requested-With': 'XMLHttpRequest'
|
||||
}
|
||||
};
|
||||
|
||||
console.log('📡 TEST Request an:', '/api/admin/fix-errors');
|
||||
console.log('📝 TEST Headers:', requestOptions.headers);
|
||||
|
||||
const response = await fetch('/api/admin/fix-errors', requestOptions);
|
||||
|
||||
console.log('📡 TEST Response Status:', response.status);
|
||||
console.log('📡 TEST Response Headers:', Object.fromEntries(response.headers.entries()));
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
console.error('❌ TEST Response Error:', errorText);
|
||||
this.showNotification(`❌ TEST Fehler: ${response.status} - ${errorText}`, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
console.log('✅ TEST Response Data:', data);
|
||||
|
||||
if (data.success) {
|
||||
this.showNotification('✅ TEST: Automatische Reparatur erfolgreich!', 'success');
|
||||
} else {
|
||||
this.showNotification(`❌ TEST: Reparatur fehlgeschlagen - ${data.message}`, 'error');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ TEST Fehler:', error);
|
||||
this.showNotification(`❌ TEST Netzwerk-Fehler: ${error.message}`, 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sichere Initialisierung - nur einmal ausführen
|
||||
|
Reference in New Issue
Block a user