"Refactor template files for improved consistency"
This commit is contained in:
@@ -1,412 +1,280 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Anmeldung - Mercedes-Benz MYP Platform{% endblock %}
|
||||
{% block title %}Anmelden - Mercedes-Benz MYP Platform{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 flex items-center justify-center p-4 transition-all duration-500">
|
||||
<!-- Floating Background Elements -->
|
||||
<div class="absolute inset-0 overflow-hidden pointer-events-none">
|
||||
<!-- Animated Mercedes Stars -->
|
||||
<div class="absolute top-1/4 left-1/4 w-16 h-16 opacity-5 dark:opacity-10 animate-pulse">
|
||||
<svg class="w-full h-full text-gray-600 dark:text-gray-400" fill="currentColor" viewBox="0 0 80 80">
|
||||
<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>
|
||||
<div class="absolute top-3/4 right-1/4 w-12 h-12 opacity-5 dark:opacity-10 animate-pulse" style="animation-delay: 2s;">
|
||||
<svg class="w-full h-full text-gray-600 dark:text-gray-400" fill="currentColor" viewBox="0 0 80 80">
|
||||
<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>
|
||||
<div class="absolute top-1/2 right-1/3 w-8 h-8 opacity-5 dark:opacity-10 animate-pulse" style="animation-delay: 4s;">
|
||||
<svg class="w-full h-full text-gray-600 dark:text-gray-400" fill="currentColor" viewBox="0 0 80 80">
|
||||
<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>
|
||||
|
||||
<!-- Decorative Lines -->
|
||||
<div class="absolute inset-0 opacity-5 dark:opacity-10">
|
||||
<div class="absolute top-1/3 left-0 right-0 h-px bg-gradient-to-r from-transparent via-gray-600 dark:via-gray-400 to-transparent"></div>
|
||||
<div class="absolute top-2/3 left-0 right-0 h-px bg-gradient-to-r from-transparent via-gray-600 dark:via-gray-400 to-transparent"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Login Card -->
|
||||
<div class="w-full max-w-md relative z-10">
|
||||
<div class="bg-white dark:bg-gray-800 backdrop-blur-xl bg-opacity-95 dark:bg-opacity-95 rounded-2xl shadow-2xl border border-gray-200 dark:border-gray-700 p-8 transition-all duration-300 transform hover:shadow-3xl">
|
||||
<!-- Mercedes-Benz Header -->
|
||||
<div class="text-center mb-8">
|
||||
<div class="flex justify-center mb-6">
|
||||
<div class="w-20 h-20 transition-transform duration-500 hover:scale-110 hover:rotate-12">
|
||||
<svg class="w-full h-full text-gray-900 dark:text-white transition-colors duration-300" fill="currentColor" viewBox="0 0 80 80">
|
||||
<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>
|
||||
</div>
|
||||
<h1 class="text-3xl font-bold text-gray-900 dark:text-white mb-1 tracking-tight transition-colors duration-300">Mercedes-Benz</h1>
|
||||
<div class="w-16 h-0.5 bg-gray-300 dark:bg-gray-600 mx-auto my-3"></div>
|
||||
<h2 class="text-xl font-medium text-gray-700 dark:text-gray-300 mb-1 transition-colors duration-300">MYP Platform</h2>
|
||||
<p class="text-gray-600 dark:text-gray-400 text-sm transition-colors duration-300">3D-Druck Management System</p>
|
||||
<div class="min-h-screen flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8">
|
||||
<div class="max-w-md w-full space-y-8">
|
||||
<!-- Header -->
|
||||
<div class="text-center">
|
||||
<!-- Mercedes-Benz Logo -->
|
||||
<div class="inline-flex items-center justify-center w-20 h-20 bg-white/10 backdrop-blur-sm rounded-full mb-6 border border-white/20">
|
||||
<svg class="w-10 h-10 text-slate-900 dark:text-white" 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>
|
||||
|
||||
<h2 class="text-3xl font-bold text-slate-900 dark:text-white mb-2">
|
||||
Bei MYP Platform anmelden
|
||||
</h2>
|
||||
<p class="text-slate-600 dark:text-slate-400">
|
||||
Zugang zu Ihrem professionellen 3D-Druck Dashboard
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Flash Messages -->
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="mb-6 p-4 {% if category == 'error' %}bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800{% else %}bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800{% endif %} rounded-lg transition-all duration-300">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
{% if category == 'error' %}
|
||||
<svg class="h-5 w-5 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<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-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"/>
|
||||
</svg>
|
||||
{% else %}
|
||||
<svg class="h-5 w-5 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium {% if category == 'error' %}text-red-800 dark:text-red-200{% else %}text-blue-800 dark:text-blue-200{% endif %}">{{ category|capitalize }}</h3>
|
||||
<div class="mt-1 text-sm {% if category == 'error' %}text-red-700 dark:text-red-300{% else %}text-blue-700 dark:text-blue-300{% endif %}">
|
||||
{{ message }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<!-- Login Form -->
|
||||
<form id="login-form" action="/auth/login" method="POST" class="space-y-6">
|
||||
<!-- CSRF-Token hinzufügen -->
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<!-- Login Form -->
|
||||
<div class="dashboard-card p-8">
|
||||
<form id="loginForm" method="POST" action="{{ url_for('login') }}" class="space-y-6">
|
||||
{{ form.hidden_tag() if form }}
|
||||
|
||||
<div class="space-y-4">
|
||||
<div>
|
||||
<label for="username" class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 transition-colors duration-300">
|
||||
Benutzername
|
||||
</label>
|
||||
<div class="relative group">
|
||||
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||
<svg class="h-5 w-5 text-gray-400 dark:text-gray-500 group-focus-within:text-blue-500 dark:group-focus-within:text-blue-400 transition-colors duration-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"/>
|
||||
</svg>
|
||||
</div>
|
||||
<input
|
||||
type="text"
|
||||
id="username"
|
||||
name="username"
|
||||
required
|
||||
class="block w-full pl-10 pr-3 py-3 border-2 border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300"
|
||||
placeholder="Benutzername oder E-Mail"
|
||||
autocomplete="username"
|
||||
>
|
||||
<!-- E-Mail Address -->
|
||||
<div>
|
||||
<label for="email" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
|
||||
E-Mail-Adresse
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||
<svg class="h-5 w-5 text-slate-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"/>
|
||||
</svg>
|
||||
</div>
|
||||
{% if form %}
|
||||
{{ form.email(class="block w-full pl-10 pr-3 py-3 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="ihre.email@mercedes-benz.com", autocomplete="email") }}
|
||||
{% else %}
|
||||
<input type="email" id="email" name="email" required
|
||||
class="block w-full pl-10 pr-3 py-3 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="ihre.email@mercedes-benz.com" autocomplete="email">
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-semibold text-gray-700 dark:text-gray-300 mb-2 transition-colors duration-300">
|
||||
Passwort
|
||||
</label>
|
||||
<div class="relative group">
|
||||
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||
<svg class="h-5 w-5 text-gray-400 dark:text-gray-500 group-focus-within:text-blue-500 dark:group-focus-within:text-blue-400 transition-colors duration-300" 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>
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
required
|
||||
class="block w-full pl-10 pr-3 py-3 border-2 border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent transition-all duration-300"
|
||||
placeholder="••••••••"
|
||||
autocomplete="current-password"
|
||||
>
|
||||
{% if form and form.email.errors %}
|
||||
<div class="mt-1 text-sm text-red-600">
|
||||
{% for error in form.email.errors %}
|
||||
<p>{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Password -->
|
||||
<div>
|
||||
<label for="password" class="block text-sm font-medium text-slate-700 dark:text-slate-300 mb-2">
|
||||
Passwort
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
|
||||
<svg class="h-5 w-5 text-slate-400" 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>
|
||||
{% if form %}
|
||||
{{ form.password(class="block w-full pl-10 pr-10 py-3 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="Ihr Passwort", autocomplete="current-password") }}
|
||||
{% else %}
|
||||
<input type="password" id="password" name="password" required
|
||||
class="block w-full pl-10 pr-10 py-3 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="Ihr Passwort" autocomplete="current-password">
|
||||
{% endif %}
|
||||
<button type="button" id="togglePassword" class="absolute inset-y-0 right-0 pr-3 flex items-center">
|
||||
<svg id="eyeOpen" class="h-5 w-5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
|
||||
</svg>
|
||||
<svg id="eyeClosed" class="h-5 w-5 text-slate-400 hover:text-slate-600 dark:hover:text-slate-300 transition-colors hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
{% if form and form.password.errors %}
|
||||
<div class="mt-1 text-sm text-red-600">
|
||||
{% for error in form.password.errors %}
|
||||
<p>{{ error }}</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Remember Me & Forgot Password -->
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center">
|
||||
<input
|
||||
id="remember-me"
|
||||
name="remember-me"
|
||||
type="checkbox"
|
||||
class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 dark:border-gray-600 rounded transition-colors duration-300"
|
||||
>
|
||||
<label for="remember-me" class="ml-2 block text-sm text-gray-700 dark:text-gray-300 transition-colors duration-300">
|
||||
Angemeldet bleiben
|
||||
</label>
|
||||
{% if form and form.remember_me %}
|
||||
{{ form.remember_me(class="w-4 h-4 text-blue-600 bg-white dark:bg-slate-800 border-gray-300 dark:border-slate-600 rounded focus:ring-blue-500 focus:ring-2") }}
|
||||
{{ form.remember_me.label(class="ml-2 text-sm text-slate-700 dark:text-slate-300") }}
|
||||
{% else %}
|
||||
<input type="checkbox" id="remember_me" name="remember_me"
|
||||
class="w-4 h-4 text-blue-600 bg-white dark:bg-slate-800 border-gray-300 dark:border-slate-600 rounded focus:ring-blue-500 focus:ring-2">
|
||||
<label for="remember_me" class="ml-2 text-sm text-slate-700 dark:text-slate-300">
|
||||
Angemeldet bleiben
|
||||
</label>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="text-sm">
|
||||
<a href="#" class="font-medium text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 transition-colors duration-300">
|
||||
<a href="{{ url_for('reset_password_request') if url_for('reset_password_request') else '#' }}"
|
||||
class="text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors">
|
||||
Passwort vergessen?
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="w-full flex justify-center items-center py-3 px-4 bg-blue-600 hover:bg-blue-700 dark:bg-blue-500 dark:hover:bg-blue-600 border border-transparent rounded-lg shadow-md text-sm font-semibold text-white hover:shadow-lg focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-300 transform hover:-translate-y-0.5"
|
||||
id="login-button"
|
||||
>
|
||||
<span id="login-text">Anmelden</span>
|
||||
<svg id="login-spinner" class="hidden animate-spin ml-3 h-5 w-5" 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>
|
||||
</button>
|
||||
<!-- Submit Button -->
|
||||
<div>
|
||||
<button type="submit" id="submitBtn"
|
||||
class="w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg shadow-sm text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 disabled:opacity-50 disabled:cursor-not-allowed transition-all duration-300">
|
||||
<svg id="loadingSpinner" class="hidden animate-spin -ml-1 mr-2 h-4 w-4 text-white" 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>
|
||||
<span id="submitText">Anmelden</span>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Error Display -->
|
||||
<div id="error-message" class="hidden mt-4 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg transition-all duration-300">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<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-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-red-800 dark:text-red-200">Anmeldung fehlgeschlagen</h3>
|
||||
<div class="mt-2 text-sm text-red-700 dark:text-red-300" id="error-text"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Offline Notice -->
|
||||
<div id="offline-notice" class="hidden mt-4 p-4 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg transition-all duration-300">
|
||||
<div class="flex">
|
||||
<div class="flex-shrink-0">
|
||||
<svg class="h-5 w-5 text-yellow-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<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-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="ml-3">
|
||||
<h3 class="text-sm font-medium text-yellow-800 dark:text-yellow-200">Offline-Modus</h3>
|
||||
<div class="mt-2 text-sm text-yellow-700 dark:text-yellow-300">
|
||||
Sie sind derzeit offline. Die Anwendung läuft im eingeschränkten Modus.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="mt-8 pt-6 border-t border-gray-200 dark:border-gray-700 transition-colors duration-300">
|
||||
<div class="text-center">
|
||||
<p class="text-xs text-gray-500 dark:text-gray-400 transition-colors duration-300">
|
||||
© 2024 Mercedes-Benz Group AG
|
||||
</p>
|
||||
<p class="text-xs text-gray-400 dark:text-gray-500 mt-1 transition-colors duration-300">
|
||||
Das Beste oder nichts
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Connection Status Indicator -->
|
||||
<div id="connection-status-login" class="fixed bottom-6 right-6 z-50 bg-white dark:bg-gray-800 backdrop-blur-lg bg-opacity-90 dark:bg-opacity-90 border border-gray-200 dark:border-gray-700 rounded-full px-4 py-2 shadow-lg transition-all duration-300">
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></div>
|
||||
<span class="text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors duration-300">Online</span>
|
||||
<!-- Alternative Actions -->
|
||||
<div class="text-center space-y-4">
|
||||
<div class="relative">
|
||||
<div class="absolute inset-0 flex items-center">
|
||||
<div class="w-full border-t border-gray-300 dark:border-slate-600"></div>
|
||||
</div>
|
||||
<div class="relative flex justify-center text-sm">
|
||||
<span class="px-2 bg-white dark:bg-black text-slate-500 dark:text-slate-400">
|
||||
Oder
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-3">
|
||||
<a href="{{ url_for('guest.guest_request_form') }}"
|
||||
class="w-full flex justify-center items-center py-3 px-4 border border-gray-300 dark:border-slate-600 rounded-lg shadow-sm text-sm font-medium text-slate-700 dark:text-slate-300 bg-white dark:bg-slate-800 hover:bg-gray-50 dark:hover:bg-slate-700 transition-colors">
|
||||
<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="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"/>
|
||||
</svg>
|
||||
Als Gast eine Anfrage stellen
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('index') }}"
|
||||
class="w-full flex justify-center items-center py-3 px-4 border border-transparent rounded-lg text-sm font-medium text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors">
|
||||
<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="M10 19l-7-7m0 0l7-7m-7 7h18"/>
|
||||
</svg>
|
||||
Zurück zur Startseite
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const loginForm = document.getElementById('login-form');
|
||||
const loginButton = document.getElementById('login-button');
|
||||
const loginText = document.getElementById('login-text');
|
||||
const loginSpinner = document.getElementById('login-spinner');
|
||||
const errorMessage = document.getElementById('error-message');
|
||||
const errorText = document.getElementById('error-text');
|
||||
const offlineNotice = document.getElementById('offline-notice');
|
||||
const form = document.getElementById('loginForm');
|
||||
const submitBtn = document.getElementById('submitBtn');
|
||||
const submitText = document.getElementById('submitText');
|
||||
const loadingSpinner = document.getElementById('loadingSpinner');
|
||||
const togglePassword = document.getElementById('togglePassword');
|
||||
const passwordInput = document.getElementById('password');
|
||||
const eyeOpen = document.getElementById('eyeOpen');
|
||||
const eyeClosed = document.getElementById('eyeClosed');
|
||||
|
||||
// Handle form submission
|
||||
loginForm.addEventListener('submit', async function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Show loading state
|
||||
setLoadingState(true);
|
||||
hideError();
|
||||
|
||||
// Offline-Hinweis anzeigen, aber Anmeldung trotzdem erlauben
|
||||
if (!navigator.onLine) {
|
||||
showOfflineNotice();
|
||||
} else {
|
||||
hideOfflineNotice();
|
||||
}
|
||||
|
||||
const formData = new FormData(loginForm);
|
||||
const username = formData.get('username');
|
||||
const password = formData.get('password');
|
||||
const rememberMe = formData.get('remember-me') === 'on';
|
||||
|
||||
try {
|
||||
const response = await fetch('/auth/login', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json',
|
||||
'X-CSRFToken': '{{ csrf_token() }}'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
username: username,
|
||||
password: password,
|
||||
remember_me: rememberMe
|
||||
})
|
||||
});
|
||||
|
||||
// Prüfen, ob die Antwort JSON ist
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (contentType && contentType.includes('application/json')) {
|
||||
const data = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
// Erfolg - zur Zielseite weiterleiten
|
||||
loginText.textContent = 'Erfolgreich angemeldet...';
|
||||
setTimeout(() => {
|
||||
window.location.href = data.redirect_url || '/dashboard';
|
||||
}, 1000);
|
||||
} else {
|
||||
// Fehler - Fehlermeldung anzeigen
|
||||
showError(data.error || 'Anmeldung fehlgeschlagen. Bitte überprüfen Sie Ihre Eingaben.');
|
||||
setLoadingState(false);
|
||||
}
|
||||
} else if (response.redirected) {
|
||||
// Erfolg mit Umleitung - Umleitung folgen
|
||||
window.location.href = response.url;
|
||||
// Password visibility toggle
|
||||
if (togglePassword && passwordInput) {
|
||||
togglePassword.addEventListener('click', function() {
|
||||
if (passwordInput.type === 'password') {
|
||||
passwordInput.type = 'text';
|
||||
eyeOpen.classList.add('hidden');
|
||||
eyeClosed.classList.remove('hidden');
|
||||
} else {
|
||||
// Unerwartete Antwort
|
||||
console.error('Unerwartete Serverantwort:', await response.text());
|
||||
showError('Unerwartete Serverantwort. Bitte versuchen Sie es später erneut.');
|
||||
setLoadingState(false);
|
||||
passwordInput.type = 'password';
|
||||
eyeOpen.classList.remove('hidden');
|
||||
eyeClosed.classList.add('hidden');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Login error:', error);
|
||||
// Im Falle eines Netzwerkfehlers (wahrscheinlich offline)
|
||||
showError('Verbindungsfehler. Stellen Sie sicher, dass der Server läuft und erreichbar ist.');
|
||||
setLoadingState(false);
|
||||
}
|
||||
});
|
||||
|
||||
function setLoadingState(loading) {
|
||||
loginButton.disabled = loading;
|
||||
if (loading) {
|
||||
loginText.textContent = 'Anmeldung läuft...';
|
||||
loginSpinner.classList.remove('hidden');
|
||||
} else {
|
||||
loginText.textContent = 'Anmelden';
|
||||
loginSpinner.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
errorText.textContent = message;
|
||||
errorMessage.classList.remove('hidden');
|
||||
errorMessage.classList.add('animate-pulse');
|
||||
setTimeout(() => {
|
||||
errorMessage.classList.remove('animate-pulse');
|
||||
}, 1000);
|
||||
// Form submission handling
|
||||
if (form) {
|
||||
form.addEventListener('submit', function(e) {
|
||||
// Show loading state
|
||||
submitBtn.disabled = true;
|
||||
loadingSpinner.classList.remove('hidden');
|
||||
submitText.textContent = 'Wird angemeldet...';
|
||||
});
|
||||
}
|
||||
|
||||
function hideError() {
|
||||
errorMessage.classList.add('hidden');
|
||||
// Form validation
|
||||
const emailInput = document.getElementById('email');
|
||||
if (emailInput) {
|
||||
emailInput.addEventListener('blur', function() {
|
||||
validateEmail();
|
||||
});
|
||||
|
||||
emailInput.addEventListener('input', function() {
|
||||
clearError(emailInput);
|
||||
});
|
||||
}
|
||||
|
||||
function showOfflineNotice() {
|
||||
offlineNotice.classList.remove('hidden');
|
||||
offlineNotice.classList.add('animate-pulse');
|
||||
setTimeout(() => {
|
||||
offlineNotice.classList.remove('animate-pulse');
|
||||
}, 1000);
|
||||
if (passwordInput) {
|
||||
passwordInput.addEventListener('input', function() {
|
||||
clearError(passwordInput);
|
||||
});
|
||||
}
|
||||
|
||||
function hideOfflineNotice() {
|
||||
offlineNotice.classList.add('hidden');
|
||||
// Auto-focus first empty field
|
||||
if (emailInput && !emailInput.value) {
|
||||
emailInput.focus();
|
||||
} else if (passwordInput && !passwordInput.value) {
|
||||
passwordInput.focus();
|
||||
}
|
||||
});
|
||||
|
||||
// Connection status monitoring
|
||||
function updateConnectionStatus() {
|
||||
const statusEl = document.getElementById('connection-status-login');
|
||||
if (navigator.onLine) {
|
||||
statusEl.innerHTML = `
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="w-2 h-2 bg-green-500 rounded-full animate-pulse"></div>
|
||||
<span class="text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors duration-300">Online</span>
|
||||
</div>
|
||||
`;
|
||||
statusEl.className = 'fixed bottom-6 right-6 z-50 bg-white dark:bg-gray-800 backdrop-blur-lg bg-opacity-90 dark:bg-opacity-90 border border-gray-200 dark:border-gray-700 rounded-full px-4 py-2 shadow-lg transition-all duration-300';
|
||||
hideOfflineNotice();
|
||||
} else {
|
||||
statusEl.innerHTML = `
|
||||
<div class="flex items-center space-x-2">
|
||||
<div class="w-2 h-2 bg-yellow-500 rounded-full animate-pulse"></div>
|
||||
<span class="text-xs font-medium text-gray-700 dark:text-gray-300 transition-colors duration-300">Offline-Modus</span>
|
||||
</div>
|
||||
`;
|
||||
statusEl.className = 'fixed bottom-6 right-6 z-50 bg-yellow-50 dark:bg-yellow-900 backdrop-blur-lg bg-opacity-90 dark:bg-opacity-90 border border-yellow-200 dark:border-yellow-700 rounded-full px-4 py-2 shadow-lg transition-all duration-300';
|
||||
showOfflineNotice();
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for connection changes
|
||||
window.addEventListener('online', updateConnectionStatus);
|
||||
window.addEventListener('offline', updateConnectionStatus);
|
||||
function validateEmail() {
|
||||
const emailInput = document.getElementById('email');
|
||||
const email = emailInput.value.trim();
|
||||
|
||||
// Initial status
|
||||
updateConnectionStatus();
|
||||
if (email && !isValidEmail(email)) {
|
||||
showError(emailInput, 'Bitte geben Sie eine gültige E-Mail-Adresse ein');
|
||||
return false;
|
||||
}
|
||||
|
||||
clearError(emailInput);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Auto-focus email field
|
||||
document.getElementById('username').focus();
|
||||
function isValidEmail(email) {
|
||||
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
|
||||
// Enhanced form validation with visual feedback
|
||||
const inputs = document.querySelectorAll('input[type="text"], input[type="password"]');
|
||||
inputs.forEach(input => {
|
||||
input.addEventListener('blur', function() {
|
||||
if (this.value && this.checkValidity()) {
|
||||
this.classList.remove('border-red-300', 'dark:border-red-600');
|
||||
this.classList.add('border-green-300', 'dark:border-green-600');
|
||||
} else if (this.value && !this.checkValidity()) {
|
||||
this.classList.remove('border-green-300', 'dark:border-green-600');
|
||||
this.classList.add('border-red-300', 'dark:border-red-600');
|
||||
}
|
||||
});
|
||||
function showError(input, message) {
|
||||
clearError(input);
|
||||
|
||||
input.classList.add('border-red-500', 'focus:border-red-500', 'focus:ring-red-500');
|
||||
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.className = 'mt-1 text-sm text-red-600 error-message';
|
||||
errorDiv.textContent = message;
|
||||
|
||||
input.parentNode.appendChild(errorDiv);
|
||||
}
|
||||
|
||||
input.addEventListener('focus', function() {
|
||||
this.classList.remove('border-red-300', 'dark:border-red-600', 'border-green-300', 'dark:border-green-600');
|
||||
});
|
||||
});
|
||||
function clearError(input) {
|
||||
input.classList.remove('border-red-500', 'focus:border-red-500', 'focus:ring-red-500');
|
||||
|
||||
const errorMessage = input.parentNode.querySelector('.error-message');
|
||||
if (errorMessage) {
|
||||
errorMessage.remove();
|
||||
}
|
||||
}
|
||||
|
||||
// Add subtle entrance animation
|
||||
setTimeout(() => {
|
||||
document.querySelector('.w-full.max-w-md').classList.add('animate-fade-in');
|
||||
}, 100);
|
||||
// Auto-submit form on Enter key in any field
|
||||
document.addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter' && e.target.form === document.getElementById('loginForm')) {
|
||||
e.preventDefault();
|
||||
document.getElementById('loginForm').submit();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user