"feat: Update WARTESCHLANGEN System Documentation and related files"
This commit is contained in:
@@ -215,87 +215,34 @@ window.isAdmin = {% if current_user.is_admin %}true{% else %}false{% endif %};
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// File upload preview
|
||||
const fileInput = document.getElementById('stl_file');
|
||||
const fileNameDisplay = document.getElementById('file-name');
|
||||
console.log('🔄 Jobs-Seite initialisiert');
|
||||
|
||||
if (fileInput) {
|
||||
fileInput.addEventListener('change', function() {
|
||||
if (this.files && this.files.length > 0) {
|
||||
fileNameDisplay.textContent = 'Ausgewählte Datei: ' + this.files[0].name;
|
||||
fileNameDisplay.classList.remove('hidden');
|
||||
} else {
|
||||
fileNameDisplay.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
// Zuerst Formular-Defaults initialisieren
|
||||
initFormDefaults();
|
||||
|
||||
// Zeige die aktuelle Zeit als Standardwert für Startzeit
|
||||
const startTimeInput = document.getElementById('start_time');
|
||||
if (startTimeInput) {
|
||||
const now = new Date();
|
||||
now.setMinutes(now.getMinutes() + 30); // Default: 30 Minuten in der Zukunft
|
||||
startTimeInput.value = formatDateTimeForInput(now);
|
||||
}
|
||||
// Erst aktuell warten Jobs prüfen
|
||||
checkWaitingJobs();
|
||||
|
||||
// Drucker-Liste laden und Formular initialisieren
|
||||
// Dann alles laden
|
||||
loadPrinters();
|
||||
loadActiveJobs();
|
||||
|
||||
// Event-Listener für Drucker-Auswahl (Status-Anzeige)
|
||||
const printerSelect = document.getElementById('printer_id');
|
||||
const statusWarning = document.getElementById('printer-status-warning');
|
||||
const statusInfo = document.getElementById('printer-status-info');
|
||||
|
||||
if (printerSelect && statusWarning && statusInfo) {
|
||||
printerSelect.addEventListener('change', function() {
|
||||
const selectedOption = this.options[this.selectedIndex];
|
||||
|
||||
if (!selectedOption || selectedOption.value === "") {
|
||||
// Keine Auswahl
|
||||
statusWarning.classList.add('hidden');
|
||||
statusInfo.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// Status des ausgewählten Druckers bestimmen
|
||||
const isOffline = selectedOption.getAttribute('data-offline') === 'true';
|
||||
const printerName = selectedOption.textContent.split('(')[0].trim().replace(/🟢|🔴/g, '').trim();
|
||||
|
||||
if (isOffline) {
|
||||
// Offline-Drucker: Deutliche Warnung anzeigen
|
||||
statusWarning.classList.remove('hidden');
|
||||
statusInfo.innerHTML = `
|
||||
<div class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 border border-red-200">
|
||||
<span class="w-2 h-2 mr-1 bg-red-500 rounded-full"></span>
|
||||
${printerName} ist OFFLINE
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
// Online-Drucker: Positive Statusmeldung
|
||||
statusWarning.classList.add('hidden');
|
||||
statusInfo.innerHTML = `
|
||||
<div class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 border border-green-200">
|
||||
<span class="w-2 h-2 mr-1 bg-green-500 rounded-full animate-pulse"></span>
|
||||
${printerName} ist ONLINE und bereit
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
});
|
||||
|
||||
// Initial auslösen, um den Status der Vorauswahl anzuzeigen
|
||||
printerSelect.dispatchEvent(new Event('change'));
|
||||
}
|
||||
loadQueueStatus(); // Neu: Queue-Status laden
|
||||
|
||||
// Formulare initialisieren
|
||||
initNewJobForm();
|
||||
initExtendJobForm();
|
||||
|
||||
// Timer für automatische Aktualisierung der Jobs (alle 60 Sekunden)
|
||||
setInterval(loadActiveJobs, 60000);
|
||||
// Statuswarnung für Drucker-Auswahl konfigurieren
|
||||
setupPrinterStatusWarning();
|
||||
|
||||
// Timer für Überprüfung wartender Jobs (alle 30 Sekunden)
|
||||
setInterval(checkWaitingJobs, 30000);
|
||||
// Automatic Updates aktivieren
|
||||
setInterval(() => {
|
||||
loadActiveJobs();
|
||||
checkWaitingJobs();
|
||||
loadQueueStatus(); // Neu: Queue-Status regelmäßig aktualisieren
|
||||
}, 30000); // 30 Sekunden
|
||||
|
||||
console.log('✅ Jobs-Seite vollständig initialisiert');
|
||||
});
|
||||
|
||||
// Hilfsfunktion zum Formatieren des Datums für Datetime-Input
|
||||
@@ -1391,5 +1338,78 @@ function loadPrintersBasic() {
|
||||
showNotification('Fehler beim Laden der Drucker', 'error');
|
||||
});
|
||||
}
|
||||
|
||||
// Setup für Drucker-Status-Warnung
|
||||
function setupPrinterStatusWarning() {
|
||||
const printerSelect = document.getElementById('printer_id');
|
||||
const statusWarning = document.getElementById('printer-status-warning');
|
||||
const statusInfo = document.getElementById('printer-status-info');
|
||||
|
||||
if (printerSelect && statusWarning && statusInfo) {
|
||||
printerSelect.addEventListener('change', function() {
|
||||
const selectedOption = this.options[this.selectedIndex];
|
||||
|
||||
if (!selectedOption || selectedOption.value === "") {
|
||||
// Keine Auswahl
|
||||
statusWarning.classList.add('hidden');
|
||||
statusInfo.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// Status des ausgewählten Druckers bestimmen
|
||||
const isOffline = selectedOption.getAttribute('data-offline') === 'true';
|
||||
const printerName = selectedOption.textContent.split('(')[0].trim().replace(/🟢|🔴/g, '').trim();
|
||||
|
||||
if (isOffline) {
|
||||
// Offline-Drucker: Deutliche Warnung anzeigen
|
||||
statusWarning.classList.remove('hidden');
|
||||
statusInfo.innerHTML = `
|
||||
<div class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 border border-red-200">
|
||||
<span class="w-2 h-2 mr-1 bg-red-500 rounded-full"></span>
|
||||
${printerName} ist OFFLINE
|
||||
</div>
|
||||
`;
|
||||
} else {
|
||||
// Online-Drucker: Positive Statusmeldung
|
||||
statusWarning.classList.add('hidden');
|
||||
statusInfo.innerHTML = `
|
||||
<div class="inline-flex items-center px-2.5 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800 border border-green-200">
|
||||
<span class="w-2 h-2 mr-1 bg-green-500 rounded-full animate-pulse"></span>
|
||||
${printerName} ist ONLINE und bereit
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
});
|
||||
|
||||
// Initial auslösen, um den Status der Vorauswahl anzuzeigen
|
||||
printerSelect.dispatchEvent(new Event('change'));
|
||||
}
|
||||
}
|
||||
|
||||
// Formular-Initialisierungen
|
||||
function initFormDefaults() {
|
||||
// File upload preview
|
||||
const fileInput = document.getElementById('stl_file');
|
||||
const fileNameDisplay = document.getElementById('file-name');
|
||||
|
||||
if (fileInput) {
|
||||
fileInput.addEventListener('change', function() {
|
||||
if (this.files && this.files.length > 0) {
|
||||
fileNameDisplay.textContent = 'Ausgewählte Datei: ' + this.files[0].name;
|
||||
fileNameDisplay.classList.remove('hidden');
|
||||
} else {
|
||||
fileNameDisplay.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Zeige die aktuelle Zeit als Standardwert für Startzeit
|
||||
const startTimeInput = document.getElementById('start_time');
|
||||
if (startTimeInput) {
|
||||
const now = new Date();
|
||||
now.setMinutes(now.getMinutes() + 30); // Default: 30 Minuten in der Zukunft
|
||||
startTimeInput.value = formatDateTimeForInput(now);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user