Files
Projektarbeit-MYP/backend/app/templates/jobs.html

290 lines
16 KiB
HTML

{% extends "base.html" %}
{% block title %}Druckaufträge - Mercedes-Benz MYP Platform{% endblock %}
{% block content %}
<div class="space-y-8">
<!-- Page Header -->
<div class="dashboard-card p-6">
<div class="flex flex-col md:flex-row md:items-center md:justify-between gap-6">
<div class="flex items-center gap-4">
<div class="w-12 h-12 flex-shrink-0">
<svg class="w-full h-full text-slate-900 dark:text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-3 7h3m-3 4h3m-6-4h.01M9 16h.01"/>
</svg>
</div>
<div>
<h1 class="text-3xl font-bold text-slate-900 dark:text-white tracking-tight">Druckaufträge</h1>
<p class="text-slate-500 dark:text-slate-400 mt-1">Verwalten Sie Ihre 3D-Druckjobs mit höchster Präzision</p>
</div>
</div>
<div class="flex flex-wrap gap-3">
<button onclick="refreshJobs()"
class="btn-secondary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
<span>Aktualisieren</span>
</button>
</div>
</div>
</div>
<!-- Neue Reservierung anlegen -->
<div class="dashboard-card p-6">
<div class="mb-6">
<h2 class="text-xl font-bold text-slate-900 dark:text-white mb-2">
Neue Reservierung anlegen
</h2>
<p class="text-slate-500 dark:text-slate-400">
Erstellen Sie einen neuen Druckauftrag mit professionellen Einstellungen
</p>
</div>
<!-- Queue-Status-Anzeige -->
<div id="queue-status-info" class="mb-6"></div>
<form id="newJobForm" class="space-y-6">
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- Drucker auswählen -->
<div>
<label for="printer_id" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Drucker auswählen <span class="text-red-500">*</span>
</label>
<select id="printer_id" name="printer_id" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
<option value="">Drucker auswählen...</option>
<!-- Wird durch JavaScript gefüllt -->
</select>
<div id="printer-status-info" class="mt-2 text-center">
<!-- Status-Info wird dynamisch gefüllt -->
</div>
<div id="printer-status-warning" class="mt-4 hidden">
<div class="bg-orange-50 dark:bg-orange-900/30 border border-orange-200 dark:border-orange-800 rounded-lg p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-orange-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-orange-800 dark:text-orange-400 mb-2">
Warteschlangen-Modus: Offline-Drucker ausgewählt
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-2 text-sm text-orange-700 dark:text-orange-300">
<div class="flex items-center gap-2">
<div class="w-2 h-2 bg-red-500 rounded-full"></div>
<span>Drucker ist derzeit OFFLINE</span>
</div>
<div class="flex items-center gap-2">
<div class="w-2 h-2 bg-yellow-500 rounded-full"></div>
<span>Job wird in WARTESCHLANGE eingereiht</span>
</div>
<div class="flex items-center gap-2">
<div class="w-2 h-2 bg-blue-500 rounded-full"></div>
<span>System überwacht alle 2 Minuten</span>
</div>
<div class="flex items-center gap-2">
<div class="w-2 h-2 bg-green-500 rounded-full"></div>
<span>Start AUTOMATISCH bei Verfügbarkeit</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Gewünschte Startzeit -->
<div>
<label for="start_time" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Gewünschte Startzeit <span class="text-red-500">*</span>
</label>
<input type="datetime-local" id="start_time" name="start_time" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
</div>
<!-- Geschätzte Druckdauer -->
<div>
<label for="duration" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Geschätzte Druckdauer (Minuten) <span class="text-red-500">*</span>
</label>
<input type="number" id="duration" name="duration" required min="1" max="7200"
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="60">
</div>
</div>
<div class="grid grid-cols-1 gap-6">
<!-- Job-Titel -->
<div>
<label for="job_title" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Job-Titel <span class="text-red-500">*</span>
</label>
<input type="text" id="job_title" name="job_title" required
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="Geben Sie einen beschreibenden Titel ein">
</div>
<!-- STL-Datei hochladen -->
<div>
<label for="stl_file" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
STL-Datei hochladen (optional)
</label>
<div class="flex items-center justify-center w-full">
<label for="stl_file" class="flex flex-col items-center justify-center w-full h-32 border-2 border-gray-300 dark:border-slate-600 border-dashed rounded-lg cursor-pointer bg-gray-50 dark:bg-slate-700/30 hover:bg-gray-100 dark:hover:bg-slate-700/50 transition-colors">
<div class="flex flex-col items-center justify-center pt-5 pb-6">
<svg class="w-8 h-8 mb-3 text-gray-400 dark:text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/>
</svg>
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Klicken Sie zum Hochladen</span> oder ziehen Sie die Datei hierher</p>
<p class="text-xs text-gray-500 dark:text-gray-400">STL-Dateien bis zu 50MB</p>
</div>
<input id="stl_file" name="stl_file" type="file" accept=".stl" class="hidden" />
</label>
</div>
<div id="file-name" class="mt-2 text-sm text-slate-500 dark:text-slate-400 hidden"></div>
</div>
</div>
<!-- Submit Button -->
<div class="flex items-center justify-end pt-6 border-t border-gray-200 dark:border-slate-600">
<button type="submit" class="btn-primary flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6"/>
</svg>
<span>Reservierung erstellen</span>
</button>
</div>
</form>
</div>
<!-- Aktive und geplante Jobs -->
<div class="dashboard-card p-6">
<div class="mb-6">
<h2 class="text-xl font-bold text-slate-900 dark:text-white mb-2">
Aktive und geplante Jobs
</h2>
<p class="text-slate-500 dark:text-slate-400">
Übersicht Ihrer laufenden und geplanten Druckaufträge mit Echtzeit-Status
</p>
</div>
<div id="active-jobs-container" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Jobs werden dynamisch mit JavaScript geladen -->
<div class="col-span-full py-12 text-center" id="no-jobs-message">
<div class="max-w-sm mx-auto">
<div class="text-slate-400 dark:text-slate-500 mb-4">
<svg class="w-12 h-12 mx-auto" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1" d="M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"/>
</svg>
</div>
<h3 class="text-lg font-semibold text-slate-900 dark:text-white mb-2">Keine aktiven Jobs</h3>
<p class="text-slate-500 dark:text-slate-400">Sie haben derzeit keine aktiven oder geplanten Druckjobs.</p>
</div>
</div>
</div>
</div>
</div>
<!-- Job Details Modal -->
<div id="jobDetailsModal" class="fixed inset-0 bg-black/60 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="dashboard-card max-w-2xl w-full p-8 transform transition-all duration-300 scale-95 opacity-0" id="jobModalContent">
<div class="flex justify-between items-center mb-6">
<div>
<h3 class="text-xl font-bold text-slate-900 dark:text-white mb-2">Job Details</h3>
<p class="text-slate-500 dark:text-slate-400">Detaillierte Informationen zu Ihrem Druckauftrag</p>
</div>
<button onclick="closeJobModal()" class="p-2 hover:bg-gray-100 dark:hover:bg-slate-700 rounded-lg transition-colors">
<svg class="w-6 h-6 text-slate-500 dark:text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<div id="jobDetailsContent">
<!-- Inhalt wird dynamisch geladen -->
</div>
</div>
</div>
</div>
<!-- Job verlängern Modal -->
<div id="extendJobModal" class="fixed inset-0 bg-black/60 backdrop-blur-sm hidden z-50">
<div class="flex items-center justify-center min-h-screen p-4">
<div class="dashboard-card max-w-md w-full p-8 transform transition-all duration-300 scale-95 opacity-0" id="extendModalContent">
<div class="flex justify-between items-center mb-6">
<div>
<h3 class="text-xl font-bold text-slate-900 dark:text-white mb-2">Druckzeit verlängern</h3>
<p class="text-slate-500 dark:text-slate-400">Geben Sie die zusätzlichen Minuten an</p>
</div>
<button onclick="closeExtendModal()" class="p-2 hover:bg-gray-100 dark:hover:bg-slate-700 rounded-lg transition-colors">
<svg class="w-6 h-6 text-slate-500 dark:text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
</div>
<form id="extendJobForm" class="space-y-6">
<input type="hidden" id="extend_job_id" name="job_id">
<div>
<label for="extra_minutes" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
Zusätzliche Minuten
</label>
<input type="number" id="extra_minutes" name="extra_minutes" required min="1" max="720" value="30"
class="block w-full px-3 py-2 border border-gray-300 dark:border-slate-600 rounded-lg bg-white dark:bg-slate-800 text-slate-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
placeholder="30">
</div>
<div class="flex items-center justify-end gap-3 pt-6 border-t border-gray-200 dark:border-slate-600">
<button type="button" onclick="closeExtendModal()" class="btn-secondary">
Abbrechen
</button>
<button type="submit" class="btn-primary">
Verlängern
</button>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
// Globale Variable für Admin-Status
window.isAdmin = {% if current_user.is_admin %}true{% else %}false{% endif %};
// Modal Animations
function showModal(modalId) {
const modal = document.getElementById(modalId);
const content = modal.querySelector('.dashboard-card');
modal.classList.remove('hidden');
setTimeout(() => {
content.classList.remove('scale-95', 'opacity-0');
content.classList.add('scale-100', 'opacity-100');
}, 10);
}
function hideModal(modalId) {
const modal = document.getElementById(modalId);
const content = modal.querySelector('.dashboard-card');
content.classList.remove('scale-100', 'opacity-100');
content.classList.add('scale-95', 'opacity-0');
setTimeout(() => {
modal.classList.add('hidden');
}, 200);
}
function closeJobModal() {
hideModal('jobDetailsModal');
}
function closeExtendModal() {
hideModal('extendJobModal');
}
</script>
{% endblock %}