365 lines
17 KiB
HTML
365 lines
17 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Job mit Code starten{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="min-h-screen bg-gradient-to-br from-blue-50 via-indigo-50 to-purple-50 dark:from-slate-900 dark:via-slate-800 dark:to-slate-900">
|
|
|
|
<!-- Header Section -->
|
|
<div class="relative overflow-hidden">
|
|
<div class="absolute inset-0 bg-gradient-to-r from-blue-600/10 to-purple-600/10"></div>
|
|
<div class="relative max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-16 text-center">
|
|
<h1 class="text-4xl lg:text-6xl font-bold text-slate-900 dark:text-white mb-6">
|
|
<span class="bg-gradient-to-r from-blue-600 to-purple-600 bg-clip-text text-transparent">
|
|
Job starten
|
|
</span>
|
|
</h1>
|
|
<p class="text-xl text-slate-600 dark:text-slate-400 max-w-3xl mx-auto leading-relaxed">
|
|
Geben Sie Ihren 6-stelligen Zugangscode ein, um Ihren genehmigten Druckauftrag zu starten.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<div class="max-w-2xl mx-auto px-4 sm:px-6 lg:px-8 -mt-8 relative z-10">
|
|
|
|
<!-- Code-Eingabe Container -->
|
|
<div class="form-container professional-shadow p-8 lg:p-12">
|
|
<div class="text-center mb-10">
|
|
<div class="w-20 h-20 bg-gradient-to-r from-green-500 to-emerald-500 rounded-full flex items-center justify-center mx-auto mb-6">
|
|
<svg class="w-10 h-10 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="text-3xl font-bold text-slate-900 dark:text-white mb-4">
|
|
Zugangscode eingeben
|
|
</h2>
|
|
<p class="text-lg text-slate-600 dark:text-slate-400">
|
|
Ihr persönlicher 6-stelliger Code wurde Ihnen nach der Genehmigung mitgeteilt.
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Erfolgs-Nachricht (versteckt) -->
|
|
<div id="successMessage" class="hidden mb-8 p-6 bg-gradient-to-r from-green-50 to-emerald-50 dark:from-green-900/20 dark:to-emerald-900/20 border border-green-200 dark:border-green-700 rounded-2xl">
|
|
<div class="flex items-center">
|
|
<div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center mr-4">
|
|
<svg class="w-5 h-5 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>
|
|
<h3 class="text-lg font-semibold text-green-800 dark:text-green-200">Job erfolgreich gestartet!</h3>
|
|
<p class="text-green-700 dark:text-green-300" id="successDetails"></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Fehler-Nachricht (versteckt) -->
|
|
<div id="errorMessage" class="hidden mb-8 p-6 bg-gradient-to-r from-red-50 to-rose-50 dark:from-red-900/20 dark:to-rose-900/20 border border-red-200 dark:border-red-700 rounded-2xl">
|
|
<div class="flex items-center">
|
|
<div class="w-8 h-8 bg-red-500 rounded-full flex items-center justify-center mr-4">
|
|
<svg class="w-5 h-5 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>
|
|
<h3 class="text-lg font-semibold text-red-800 dark:text-red-200">Fehler beim Starten</h3>
|
|
<p class="text-red-700 dark:text-red-300" id="errorDetails"></p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<form id="codeForm" class="space-y-8">
|
|
|
|
<!-- Code-Eingabe -->
|
|
<div class="group">
|
|
<label for="accessCode" class="block text-sm font-semibold text-slate-700 dark:text-slate-300 mb-4">
|
|
6-stelliger Zugangscode <span class="text-red-500">*</span>
|
|
</label>
|
|
|
|
<!-- Code-Input mit einzelnen Feldern -->
|
|
<div class="flex justify-center space-x-3 mb-4">
|
|
<input type="text" id="code1" maxlength="1"
|
|
class="code-input w-16 h-16 text-center text-2xl font-bold border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 dark:bg-slate-800 dark:text-white"
|
|
oninput="moveToNext(this, 'code2')" onkeydown="handleBackspace(event, this, null)">
|
|
<input type="text" id="code2" maxlength="1"
|
|
class="code-input w-16 h-16 text-center text-2xl font-bold border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 dark:bg-slate-800 dark:text-white"
|
|
oninput="moveToNext(this, 'code3')" onkeydown="handleBackspace(event, this, 'code1')">
|
|
<input type="text" id="code3" maxlength="1"
|
|
class="code-input w-16 h-16 text-center text-2xl font-bold border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 dark:bg-slate-800 dark:text-white"
|
|
oninput="moveToNext(this, 'code4')" onkeydown="handleBackspace(event, this, 'code2')">
|
|
<input type="text" id="code4" maxlength="1"
|
|
class="code-input w-16 h-16 text-center text-2xl font-bold border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 dark:bg-slate-800 dark:text-white"
|
|
oninput="moveToNext(this, 'code5')" onkeydown="handleBackspace(event, this, 'code3')">
|
|
<input type="text" id="code5" maxlength="1"
|
|
class="code-input w-16 h-16 text-center text-2xl font-bold border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 dark:bg-slate-800 dark:text-white"
|
|
oninput="moveToNext(this, 'code6')" onkeydown="handleBackspace(event, this, 'code4')">
|
|
<input type="text" id="code6" maxlength="1"
|
|
class="code-input w-16 h-16 text-center text-2xl font-bold border border-slate-300 dark:border-slate-600 rounded-xl focus:ring-4 focus:ring-blue-500/25 focus:border-blue-500 dark:bg-slate-800 dark:text-white"
|
|
oninput="moveToNext(this, null)" onkeydown="handleBackspace(event, this, 'code5')">
|
|
</div>
|
|
|
|
<div class="text-center">
|
|
<p class="text-sm text-slate-500 dark:text-slate-400">
|
|
Der Code besteht aus 6 Zeichen (Großbuchstaben und Zahlen)
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Submit Button -->
|
|
<div class="text-center pt-6">
|
|
<button type="submit" id="submitBtn"
|
|
class="w-full sm:w-auto px-12 py-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white font-semibold rounded-2xl hover:from-blue-700 hover:to-indigo-700 focus:outline-none focus:ring-4 focus:ring-blue-500/25 transform transition-all duration-300 hover:scale-105 shadow-lg disabled:opacity-50 disabled:cursor-not-allowed disabled:transform-none">
|
|
<span class="flex items-center justify-center">
|
|
<svg class="w-6 h-6 mr-3" 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
|
|
</span>
|
|
</button>
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<!-- Hilfe-Sektion -->
|
|
<div class="mt-12 pt-8 border-t border-slate-200 dark:border-slate-700">
|
|
<div class="text-center">
|
|
<h3 class="text-lg font-semibold text-slate-900 dark:text-white mb-4">
|
|
Brauchen Sie Hilfe?
|
|
</h3>
|
|
<div class="space-y-3 text-sm text-slate-600 dark:text-slate-400">
|
|
<p>• Ihr Zugangscode wurde Ihnen nach der Genehmigung mitgeteilt</p>
|
|
<p>• Der Code ist nur einmalig verwendbar und hat eine begrenzte Gültigkeit</p>
|
|
<p>• Bei Problemen wenden Sie sich an den Administrator</p>
|
|
</div>
|
|
<div class="mt-6">
|
|
<a href="{{ url_for('guest.guest_request_form') }}"
|
|
class="inline-flex items-center text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300 font-medium">
|
|
<svg class="w-4 h-4 mr-2" 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>
|
|
|
|
<style>
|
|
.form-container {
|
|
background: rgba(255, 255, 255, 0.95);
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
}
|
|
|
|
.dark .form-container {
|
|
background: rgba(30, 41, 59, 0.95);
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
}
|
|
|
|
.professional-shadow {
|
|
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
|
|
}
|
|
|
|
.code-input {
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.code-input:focus {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.code-input.valid {
|
|
border-color: #10b981;
|
|
background-color: #ecfdf5;
|
|
}
|
|
|
|
.dark .code-input.valid {
|
|
border-color: #059669;
|
|
background-color: rgba(16, 185, 129, 0.1);
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
// 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 %} |