Files
Projektarbeit-MYP/backend/app/templates/guest_start_job.html
2025-05-29 16:03:27 +02:00

413 lines
21 KiB
HTML

{% extends "base.html" %}
{% block title %}Job mit Code starten - Mercedes-Benz MYP Platform{% endblock %}
{% block content %}
<div class="bg-professional">
<!-- Dark Mode Override -->
<style>
.dark .bg-professional {
background: #000000 !important;
}
.dark .professional-hero {
background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%) !important;
border-color: #333333 !important;
}
.dark .professional-container {
background: #111111 !important;
border-color: #333333 !important;
}
.dark .mb-glass {
background: rgba(17, 17, 17, 0.95) !important;
border-color: rgba(255, 255, 255, 0.1) !important;
}
.dark .code-input {
background: #1a1a1a !important;
border-color: #333333 !important;
color: #ffffff !important;
}
.dark .code-input:focus {
border-color: #3b82f6 !important;
background: #222222 !important;
}
.dark .code-input.valid {
border-color: #10b981 !important;
background: rgba(16, 185, 129, 0.1) !important;
}
</style>
<!-- Professional Hero Header -->
<div class="professional-hero hero-pattern animate-fade-in" style="margin: 2rem; margin-bottom: 3rem;">
<div class="absolute inset-0 bg-gradient-to-r from-black/10 to-black/20 dark:from-black/40 dark:to-black/60"></div>
<!-- Status Indicator -->
<div class="absolute top-6 right-6 flex items-center space-x-4 z-10">
<div class="mb-glass rounded-full px-6 py-3 animate-scale-in">
<div class="flex items-center space-x-3">
<div class="status-dot status-online"></div>
<span class="text-sm font-semibold text-professional-primary">Live System</span>
</div>
</div>
<div class="mb-glass rounded-full px-6 py-3 animate-scale-in">
<span id="live-time" class="text-sm font-semibold text-professional-primary"></span>
</div>
</div>
<div class="relative max-w-6xl mx-auto px-6 lg:px-8 py-20 z-10">
<div class="text-center animate-slide-up">
<!-- Mercedes-Benz Logo -->
<div class="inline-flex items-center justify-center w-28 h-28 mb-glass rounded-full mb-10 professional-shadow">
<svg class="w-14 h-14 text-professional-primary" viewBox="0 0 80 80" fill="currentColor">
<path d="M58.6,4.5C53,1.6,46.7,0,40,0c-6.7,0-13,1.6-18.6,4.5v0C8.7,11.2,0,24.6,0,40c0,15.4,8.7,28.8,21.5,35.5
C27,78.3,33.3,80,40,80c6.7,0,12.9-1.7,18.5-4.6C71.3,68.8,80,55.4,80,40C80,24.6,71.3,11.2,58.6,4.5z M4,40
c0-13.1,7-24.5,17.5-30.9v0C26.6,6,32.5,4.2,39,4l-4.5,32.7L21.5,46.8v0L8.3,57.1C5.6,52,4,46.2,4,40z M58.6,70.8
C53.1,74.1,46.8,76,40,76c-6.8,0-13.2-1.9-18.6-5.2c-4.9-2.9-8.9-6.9-11.9-11.7l11.9-4.9v0L40,46.6l18.6,7.5v0l12,4.9
C67.6,63.9,63.4,67.9,58.6,70.8z M58.6,46.8L58.6,46.8l-12.9-10L41.1,4c6.3,0.2,12.3,2,17.4,5.1v0C69,15.4,76,26.9,76,40
c0,6.2-1.5,12-4.3,17.1L58.6,46.8z"/>
</svg>
</div>
<h1 class="title-professional text-6xl md:text-7xl font-bold mb-8 tracking-tight">
Job starten
</h1>
<p class="subtitle-professional text-2xl md:text-3xl max-w-5xl mx-auto leading-relaxed mb-12">
Geben Sie Ihren 6-stelligen Zugangscode ein, um Ihren genehmigten Druckauftrag zu starten
</p>
</div>
</div>
</div>
<div class="max-w-3xl mx-auto px-6 lg:px-8 -mt-12 relative z-10" style="margin-bottom: 4rem;">
<!-- Code-Eingabe Container -->
<div class="professional-container animate-slide-up" style="padding: 3rem; border-radius: 2rem; margin-bottom: 2rem;">
<div class="text-center mb-12">
<div class="w-24 h-24 bg-gradient-to-r from-green-500 to-emerald-500 rounded-3xl flex items-center justify-center mx-auto mb-8">
<svg class="w-12 h-12 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-3a1 1 0 011-1h2.586l6.243-6.243A6 6 0 0121 9z"/>
</svg>
</div>
<h2 class="title-professional text-4xl font-bold mb-6">
Zugangscode eingeben
</h2>
<p class="subtitle-professional text-xl">
Ihr persönlicher 6-stelliger Code wurde Ihnen nach der Genehmigung mitgeteilt.
</p>
</div>
<!-- Erfolgs-Nachricht (versteckt) -->
<div id="successMessage" class="hidden mb-8 alert-professional alert-success" style="border-radius: 2rem; padding: 2rem;">
<div class="flex-shrink-0">
<div class="w-12 h-12 bg-gradient-to-br from-green-500 to-emerald-600 rounded-2xl flex items-center justify-center">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
</div>
</div>
<div class="flex-1 ml-6">
<h3 class="text-xl font-bold text-professional-primary mb-3">Job erfolgreich gestartet!</h3>
<p class="text-professional-secondary" id="successDetails"></p>
</div>
</div>
<!-- Fehler-Nachricht (versteckt) -->
<div id="errorMessage" class="hidden mb-8 alert-professional alert-danger" style="border-radius: 2rem; padding: 2rem;">
<div class="flex-shrink-0">
<div class="w-12 h-12 bg-gradient-to-br from-red-500 to-red-600 rounded-2xl flex items-center justify-center">
<svg class="w-6 h-6 text-white" 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>
</div>
</div>
<div class="flex-1 ml-6">
<h3 class="text-xl font-bold text-professional-primary mb-3">Fehler beim Starten</h3>
<p class="text-professional-secondary" id="errorDetails"></p>
</div>
</div>
<form id="codeForm" class="space-y-10">
<!-- Code-Eingabe -->
<div class="group">
<label for="accessCode" class="block text-base font-bold text-professional-primary mb-6 text-center">
6-stelliger Zugangscode <span class="text-red-500 text-lg">*</span>
</label>
<!-- Code-Input mit einzelnen Feldern -->
<div class="flex justify-center space-x-4 mb-8">
<input type="text" id="code1" maxlength="1"
class="code-input w-20 h-20 text-center text-3xl font-bold border border-slate-300 dark:border-slate-600 rounded-2xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 transition-all duration-300"
oninput="moveToNext(this, 'code2')" onkeydown="handleBackspace(event, this, null)">
<input type="text" id="code2" maxlength="1"
class="code-input w-20 h-20 text-center text-3xl font-bold border border-slate-300 dark:border-slate-600 rounded-2xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 transition-all duration-300"
oninput="moveToNext(this, 'code3')" onkeydown="handleBackspace(event, this, 'code1')">
<input type="text" id="code3" maxlength="1"
class="code-input w-20 h-20 text-center text-3xl font-bold border border-slate-300 dark:border-slate-600 rounded-2xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 transition-all duration-300"
oninput="moveToNext(this, 'code4')" onkeydown="handleBackspace(event, this, 'code2')">
<input type="text" id="code4" maxlength="1"
class="code-input w-20 h-20 text-center text-3xl font-bold border border-slate-300 dark:border-slate-600 rounded-2xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 transition-all duration-300"
oninput="moveToNext(this, 'code5')" onkeydown="handleBackspace(event, this, 'code3')">
<input type="text" id="code5" maxlength="1"
class="code-input w-20 h-20 text-center text-3xl font-bold border border-slate-300 dark:border-slate-600 rounded-2xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 transition-all duration-300"
oninput="moveToNext(this, 'code6')" onkeydown="handleBackspace(event, this, 'code4')">
<input type="text" id="code6" maxlength="1"
class="code-input w-20 h-20 text-center text-3xl font-bold border border-slate-300 dark:border-slate-600 rounded-2xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 transition-all duration-300"
oninput="moveToNext(this, null)" onkeydown="handleBackspace(event, this, 'code5')">
</div>
<div class="text-center">
<p class="text-professional-muted text-base">
Der Code besteht aus 6 Zeichen (Großbuchstaben und Zahlen)
</p>
</div>
</div>
<!-- Submit Button -->
<div class="text-center pt-8">
<button type="submit" id="submitBtn"
class="btn-success-professional group px-12 py-5 text-lg disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none">
<svg class="w-6 h-6 mr-4 group-hover:scale-110 transition-transform duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-6 4h.01M12 5v.01M12 19v.01M12 12h.01M12 9a3 3 0 100-6 3 3 0 000 6zm0 0a3 3 0 100 6 3 3 0 000-6z"/>
</svg>
Job jetzt starten
</button>
</div>
</form>
<!-- Hilfe-Sektion -->
<div class="mt-16 pt-8 border-t-2 border-slate-200 dark:border-slate-600">
<div class="text-center">
<h3 class="text-2xl font-bold text-professional-primary mb-8">
Brauchen Sie Hilfe?
</h3>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div class="mb-glass p-6 rounded-2xl">
<div class="w-12 h-12 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-2xl mx-auto mb-4 flex items-center justify-center">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
</div>
<p class="text-professional-secondary">Ihr Zugangscode wurde Ihnen nach der Genehmigung mitgeteilt</p>
</div>
<div class="mb-glass p-6 rounded-2xl">
<div class="w-12 h-12 bg-gradient-to-br from-green-500 to-emerald-600 rounded-2xl mx-auto mb-4 flex items-center justify-center">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
</svg>
</div>
<p class="text-professional-secondary">Der Code ist nur einmalig verwendbar und hat eine begrenzte Gültigkeit</p>
</div>
<div class="mb-glass p-6 rounded-2xl">
<div class="w-12 h-12 bg-gradient-to-br from-purple-500 to-purple-600 rounded-2xl mx-auto mb-4 flex items-center justify-center">
<svg class="w-6 h-6 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 5.636l-3.536 3.536m0 5.656l3.536 3.536M9.172 9.172L5.636 5.636m3.536 9.192L5.636 18.364M12 12h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
<p class="text-professional-secondary">Bei Problemen wenden Sie sich an den Administrator</p>
</div>
</div>
<div class="mt-8">
<a href="{{ url_for('guest.guest_request_form') }}"
class="btn-professional group px-8 py-4">
<svg class="w-6 h-6 mr-3 group-hover:scale-110 transition-transform duration-300" 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>
Neue Anfrage stellen
</a>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Live Time Update
function updateLiveTime() {
const now = new Date();
document.getElementById('live-time').textContent = now.toLocaleTimeString('de-DE');
}
updateLiveTime();
setInterval(updateLiveTime, 1000);
// Code-Eingabe-Logik
function moveToNext(current, nextId) {
const value = current.value.toUpperCase();
// Nur alphanumerische Zeichen erlauben
if (!/^[A-Z0-9]$/.test(value)) {
current.value = '';
return;
}
current.value = value;
current.classList.add('valid');
// Zum nächsten Feld wechseln
if (nextId && value) {
document.getElementById(nextId).focus();
}
// Prüfen ob alle Felder ausgefüllt sind
checkFormComplete();
}
function handleBackspace(event, current, prevId) {
if (event.key === 'Backspace') {
if (current.value === '' && prevId) {
event.preventDefault();
const prevField = document.getElementById(prevId);
prevField.focus();
prevField.value = '';
prevField.classList.remove('valid');
} else if (current.value !== '') {
current.classList.remove('valid');
}
}
}
function checkFormComplete() {
const inputs = ['code1', 'code2', 'code3', 'code4', 'code5', 'code6'];
const allFilled = inputs.every(id => document.getElementById(id).value !== '');
const submitBtn = document.getElementById('submitBtn');
submitBtn.disabled = !allFilled;
if (allFilled) {
submitBtn.classList.add('ring-4', 'ring-green-500/25');
} else {
submitBtn.classList.remove('ring-4', 'ring-green-500/25');
}
}
function getCodeValue() {
const inputs = ['code1', 'code2', 'code3', 'code4', 'code5', 'code6'];
return inputs.map(id => document.getElementById(id).value).join('');
}
function clearCode() {
const inputs = ['code1', 'code2', 'code3', 'code4', 'code5', 'code6'];
inputs.forEach(id => {
const input = document.getElementById(id);
input.value = '';
input.classList.remove('valid');
});
checkFormComplete();
document.getElementById('code1').focus();
}
function showSuccess(message, details) {
document.getElementById('successMessage').classList.remove('hidden');
document.getElementById('successDetails').textContent = details;
document.getElementById('errorMessage').classList.add('hidden');
// Scroll zur Nachricht
document.getElementById('successMessage').scrollIntoView({ behavior: 'smooth', block: 'center' });
}
function showError(message, details) {
document.getElementById('errorMessage').classList.remove('hidden');
document.getElementById('errorDetails').textContent = details;
document.getElementById('successMessage').classList.add('hidden');
// Scroll zur Nachricht
document.getElementById('errorMessage').scrollIntoView({ behavior: 'smooth', block: 'center' });
}
// Form-Submit-Handler
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('codeForm');
const submitBtn = document.getElementById('submitBtn');
// Erstes Feld fokussieren
document.getElementById('code1').focus();
form.addEventListener('submit', async function(e) {
e.preventDefault();
const code = getCodeValue();
if (code.length !== 6) {
showError('Ungültiger Code', 'Bitte geben Sie alle 6 Zeichen ein.');
return;
}
// Button-Animation
submitBtn.disabled = true;
const originalContent = submitBtn.innerHTML;
submitBtn.innerHTML = `
<span class="flex items-center justify-center">
<svg class="animate-spin w-5 h-5 mr-3" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
Wird überprüft...
</span>
`;
try {
const response = await fetch('/api/guest/start-job', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
},
body: JSON.stringify({ code: code })
});
const result = await response.json();
if (result.success) {
showSuccess(
'Job erfolgreich gestartet!',
`Ihr Job "${result.job_name}" wurde gestartet und läuft bis ${result.end_time}.`
);
// Form deaktivieren
form.style.opacity = '0.5';
form.style.pointerEvents = 'none';
// Nach 3 Sekunden zur Job-Status-Seite weiterleiten
setTimeout(() => {
if (result.job_id) {
window.location.href = `/guest/job/${result.job_id}/status`;
}
}, 3000);
} else {
showError('Code ungültig', result.error || 'Der eingegebene Code ist ungültig oder bereits verwendet.');
clearCode();
}
} catch (error) {
showError('Verbindungsfehler', 'Es gab ein Problem bei der Verbindung. Bitte versuchen Sie es erneut.');
clearCode();
} finally {
submitBtn.disabled = false;
submitBtn.innerHTML = originalContent;
checkFormComplete();
}
});
// Paste-Handler für kompletten Code
document.addEventListener('paste', function(e) {
const target = e.target;
if (target.classList.contains('code-input')) {
e.preventDefault();
const paste = (e.clipboardData || window.clipboardData).getData('text').toUpperCase();
if (paste.length === 6 && /^[A-Z0-9]+$/.test(paste)) {
const inputs = ['code1', 'code2', 'code3', 'code4', 'code5', 'code6'];
inputs.forEach((id, index) => {
const input = document.getElementById(id);
input.value = paste[index] || '';
if (input.value) input.classList.add('valid');
});
checkFormComplete();
document.getElementById('code6').focus();
}
}
});
});
</script>
{% endblock %}