231 lines
12 KiB
HTML
231 lines
12 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Anfrage-Status - Mercedes-Benz MYP Platform{% endblock %}
|
|
|
|
{% block head %}
|
|
{{ super() }}
|
|
<meta name="csrf-token" content="{{ csrf_token() }}">
|
|
<meta http-equiv="refresh" content="30">
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50 dark:from-slate-900 dark:via-slate-800 dark:to-slate-900">
|
|
<div class="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
|
|
|
|
<!-- Header -->
|
|
<div class="mb-8 text-center">
|
|
<h1 class="text-4xl font-bold text-slate-900 dark:text-white mb-4">Anfrage-Status</h1>
|
|
<p class="text-slate-600 dark:text-slate-400 text-lg">
|
|
Status Ihrer Gastanfrage für 3D-Druck
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Status Card -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-2xl shadow-xl p-8 mb-6">
|
|
|
|
<!-- Status Badge -->
|
|
<div class="flex justify-center mb-6">
|
|
{% if request.status == 'pending' %}
|
|
<div class="inline-flex items-center px-6 py-3 rounded-full bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200">
|
|
<svg class="w-5 h-5 mr-2 animate-spin" 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"></path>
|
|
</svg>
|
|
Wird geprüft
|
|
</div>
|
|
{% elif request.status == 'approved' %}
|
|
<div class="inline-flex items-center px-6 py-3 rounded-full bg-green-100 dark:bg-green-900/30 text-green-800 dark:text-green-200">
|
|
<svg class="w-5 h-5 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
|
|
</svg>
|
|
Genehmigt
|
|
</div>
|
|
{% elif request.status == 'denied' %}
|
|
<div class="inline-flex items-center px-6 py-3 rounded-full bg-red-100 dark:bg-red-900/30 text-red-800 dark:text-red-200">
|
|
<svg class="w-5 h-5 mr-2" 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"></path>
|
|
</svg>
|
|
Abgelehnt
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Anfrage-Details -->
|
|
<div class="space-y-4 mb-6">
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<h3 class="text-sm font-medium text-slate-500 dark:text-slate-400">Anfrage-ID</h3>
|
|
<p class="text-lg font-semibold text-slate-900 dark:text-white">#{{ request.id }}</p>
|
|
</div>
|
|
<div>
|
|
<h3 class="text-sm font-medium text-slate-500 dark:text-slate-400">Erstellt am</h3>
|
|
<p class="text-lg font-semibold text-slate-900 dark:text-white">{{ request.created_at|format_datetime }}</p>
|
|
</div>
|
|
<div>
|
|
<h3 class="text-sm font-medium text-slate-500 dark:text-slate-400">Name</h3>
|
|
<p class="text-lg font-semibold text-slate-900 dark:text-white">{{ request.name }}</p>
|
|
</div>
|
|
<div>
|
|
<h3 class="text-sm font-medium text-slate-500 dark:text-slate-400">Gewünschte Dauer</h3>
|
|
<p class="text-lg font-semibold text-slate-900 dark:text-white">{{ request.duration_min }} Minuten</p>
|
|
</div>
|
|
</div>
|
|
|
|
{% if request.reason %}
|
|
<div>
|
|
<h3 class="text-sm font-medium text-slate-500 dark:text-slate-400">Begründung</h3>
|
|
<p class="text-slate-900 dark:text-white mt-1">{{ request.reason }}</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if request.printer %}
|
|
<div>
|
|
<h3 class="text-sm font-medium text-slate-500 dark:text-slate-400">Drucker</h3>
|
|
<p class="text-slate-900 dark:text-white mt-1">{{ request.printer.name }} {% if request.printer.location %}({{ request.printer.location }}){% endif %}</p>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Status-spezifische Inhalte -->
|
|
{% if request.status == 'pending' %}
|
|
<div class="bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-700 rounded-xl p-4">
|
|
<div class="flex">
|
|
<div class="flex-shrink-0">
|
|
<svg class="h-5 w-5 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"></path>
|
|
</svg>
|
|
</div>
|
|
<div class="ml-3">
|
|
<h3 class="text-sm font-medium text-yellow-800 dark:text-yellow-200">Ihre Anfrage wird geprüft</h3>
|
|
<p class="text-sm text-yellow-700 dark:text-yellow-300 mt-1">
|
|
Unser Team prüft Ihre Anfrage. Sie erhalten eine Benachrichtigung, sobald eine Entscheidung getroffen wurde.
|
|
Diese Seite aktualisiert sich automatisch alle 30 Sekunden.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% elif request.status == 'approved' %}
|
|
<!-- OTP-Code anzeigen -->
|
|
{% if otp_code %}
|
|
<div class="bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-700 rounded-xl p-6 mb-4">
|
|
<div class="text-center">
|
|
<h3 class="text-lg font-medium text-green-800 dark:text-green-200 mb-4">Ihr Zugangscode</h3>
|
|
<div class="bg-white dark:bg-slate-700 rounded-lg border-2 border-green-300 dark:border-green-600 p-4 mb-4">
|
|
<code class="text-3xl font-mono font-bold text-green-800 dark:text-green-200 tracking-widest">{{ otp_code }}</code>
|
|
</div>
|
|
<p class="text-sm text-green-700 dark:text-green-300">
|
|
<strong>Wichtig:</strong> Dieser Code ist nur einmalig verwendbar und wird nach der Nutzung gelöscht.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Job-Informationen -->
|
|
{% if job %}
|
|
<div class="bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-700 rounded-xl p-4 mb-4">
|
|
<h3 class="text-sm font-medium text-blue-800 dark:text-blue-200 mb-2">Ihr Druckjob</h3>
|
|
<div class="space-y-2 text-sm text-blue-700 dark:text-blue-300">
|
|
<div class="flex justify-between">
|
|
<span>Job-ID:</span>
|
|
<span class="font-medium">#{{ job.id }}</span>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<span>Geplanter Start:</span>
|
|
<span class="font-medium">{{ job.start_at|format_datetime }}</span>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<span>Geplantes Ende:</span>
|
|
<span class="font-medium">{{ job.end_at|format_datetime }}</span>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<span>Status:</span>
|
|
<span class="font-medium capitalize">
|
|
{% if job.status == 'scheduled' %}Geplant{% elif job.status == 'running' %}Läuft{% elif job.status == 'finished' %}Abgeschlossen{% else %}{{ job.status }}{% endif %}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Job starten (nur wenn OTP verfügbar und Job noch nicht gestartet) -->
|
|
{% if otp_code and job.status == 'scheduled' %}
|
|
<div class="text-center">
|
|
<button onclick="startJob()" id="startJobBtn"
|
|
class="px-8 py-4 bg-gradient-to-r from-green-500 to-green-600 text-white text-lg font-medium rounded-xl hover:from-green-600 hover:to-green-700 transition-all duration-300 shadow-lg disabled:opacity-50 disabled:cursor-not-allowed">
|
|
3D-Druck jetzt starten
|
|
</button>
|
|
<p class="text-xs text-slate-500 dark:text-slate-400 mt-2">
|
|
Sie haben bis {{ (job.start_at|as_datetime + timedelta(minutes=5))|format_datetime }} Zeit, den Druck zu starten
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% elif request.status == 'denied' %}
|
|
<div class="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-700 rounded-xl p-4">
|
|
<div class="flex">
|
|
<div class="flex-shrink-0">
|
|
<svg class="h-5 w-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
|
|
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd"></path>
|
|
</svg>
|
|
</div>
|
|
<div class="ml-3">
|
|
<h3 class="text-sm font-medium text-red-800 dark:text-red-200">Anfrage abgelehnt</h3>
|
|
<p class="text-sm text-red-700 dark:text-red-300 mt-1">
|
|
Ihre Anfrage wurde leider abgelehnt. Bei Fragen wenden Sie sich bitte an unser Team.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
|
|
<!-- Aktionen -->
|
|
<div class="flex items-center justify-center space-x-4">
|
|
<a href="{{ url_for('guest.guest_request_form') }}"
|
|
class="px-6 py-3 border border-slate-300 dark:border-slate-600 text-slate-700 dark:text-slate-300 rounded-xl hover:bg-slate-50 dark:hover:bg-slate-700 transition-all duration-300">
|
|
Neue Anfrage stellen
|
|
</a>
|
|
<button onclick="location.reload()"
|
|
class="px-6 py-3 bg-blue-500 text-white rounded-xl hover:bg-blue-600 transition-all duration-300">
|
|
Aktualisieren
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% if request.status == 'approved' and otp_code and job %}
|
|
<script>
|
|
async function startJob() {
|
|
const btn = document.getElementById('startJobBtn');
|
|
const originalText = btn.textContent;
|
|
|
|
btn.disabled = true;
|
|
btn.textContent = 'Wird gestartet...';
|
|
|
|
try {
|
|
const response = await fetch(`/api/jobs/start/{{ otp_code }}`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
}
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (result.success) {
|
|
alert('3D-Druck erfolgreich gestartet!');
|
|
location.reload();
|
|
} else {
|
|
alert('Fehler beim Starten: ' + (result.error || 'Unbekannter Fehler'));
|
|
}
|
|
} catch (error) {
|
|
console.error('Fehler beim Starten des Jobs:', error);
|
|
alert('Fehler beim Starten des 3D-Drucks. Bitte versuchen Sie es später erneut.');
|
|
} finally {
|
|
btn.disabled = false;
|
|
btn.textContent = originalText;
|
|
}
|
|
}
|
|
</script>
|
|
{% endif %}
|
|
{% endblock %} |