📚 Improved logging structure & efficiency across backend logs 🚀
This commit is contained in:
@ -205,6 +205,16 @@ class AdminDashboard {
|
||||
const printerId = e.target.closest('button').dataset.printerId;
|
||||
this.showPrinterSettings(printerId);
|
||||
}
|
||||
|
||||
// Smart-Plug Ein/Aus Toggle für Drucker
|
||||
if (e.target.closest('.toggle-printer-power-btn')) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
const button = e.target.closest('button');
|
||||
const printerId = button.dataset.printerId;
|
||||
const printerName = button.dataset.printerName;
|
||||
this.togglePrinterPower(printerId, printerName, button);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -805,6 +815,70 @@ class AdminDashboard {
|
||||
this.showNotification(`Drucker-Einstellungen werden geladen...`, 'info');
|
||||
}
|
||||
|
||||
// Smart-Plug Ein/Aus Toggle für Drucker
|
||||
async togglePrinterPower(printerId, printerName, button) {
|
||||
console.log(`🔌 Smart-Plug Toggle für Drucker ${printerId} (${printerName})`);
|
||||
|
||||
// Bestätigungsdialog
|
||||
const confirmMessage = `Möchten Sie die Steckdose für "${printerName}" umschalten?\n\nDies schaltet den Drucker ein/aus.`;
|
||||
if (!confirm(confirmMessage)) return;
|
||||
|
||||
// Button-Zustand während der Anfrage anzeigen
|
||||
const originalContent = button.innerHTML;
|
||||
button.disabled = true;
|
||||
button.innerHTML = `
|
||||
<div class="animate-spin rounded-full h-4 w-4 border-2 border-white border-t-transparent"></div>
|
||||
<span class="hidden lg:inline">Schaltet...</span>
|
||||
`;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${this.apiBaseUrl}/api/admin/printers/${printerId}/toggle`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRFToken': this.csrfToken
|
||||
},
|
||||
body: JSON.stringify({
|
||||
reason: 'Admin-Panel Smart-Plug Toggle'
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok && data.success) {
|
||||
const action = data.action || 'umgeschaltet';
|
||||
this.showNotification(`✅ Steckdose für "${printerName}" erfolgreich ${action}`, 'success');
|
||||
|
||||
// Button-Visual-Feedback
|
||||
button.classList.remove('from-orange-500', 'to-red-500');
|
||||
button.classList.add('from-green-500', 'to-green-600');
|
||||
|
||||
setTimeout(() => {
|
||||
button.classList.remove('from-green-500', 'to-green-600');
|
||||
button.classList.add('from-orange-500', 'to-red-500');
|
||||
}, 2000);
|
||||
|
||||
// Live-Statistiken nach kurzer Verzögerung aktualisieren
|
||||
setTimeout(() => {
|
||||
this.loadLiveStats();
|
||||
}, 1000);
|
||||
|
||||
} else {
|
||||
const errorMsg = data.error || 'Unbekannter Fehler beim Schalten der Steckdose';
|
||||
this.showNotification(`❌ Fehler: ${errorMsg}`, 'error');
|
||||
console.error('Smart-Plug Toggle Fehler:', data);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Netzwerkfehler beim Smart-Plug Toggle:', error);
|
||||
this.showNotification(`❌ Netzwerkfehler beim Schalten der Steckdose für "${printerName}"`, 'error');
|
||||
} finally {
|
||||
// Button-Zustand zurücksetzen
|
||||
button.disabled = false;
|
||||
button.innerHTML = originalContent;
|
||||
}
|
||||
}
|
||||
|
||||
// Job-Management
|
||||
handleJobAction(action, jobId) {
|
||||
console.log(`📋 Job-Aktion "${action}" für Job ${jobId}`);
|
||||
|
Reference in New Issue
Block a user