182 lines
8.4 KiB
HTML
182 lines
8.4 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}
|
|
Admin-Bereich
|
|
{% endblock title %}
|
|
|
|
{% block content %}
|
|
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-10">
|
|
<h1 class="text-3xl font-bold text-center mb-8">Admin-Bereich</h1>
|
|
|
|
<!-- Flash-Messages -->
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="bg-{{ category }}-500 text-white p-3 rounded mb-4">
|
|
{{ message }}
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<!-- Grid Layout für Boxen -->
|
|
<div class="grid gap-8 sm:grid-cols-1 md:grid-cols-2 xl:grid-cols-4">
|
|
<!-- NEUEN BENUTZER ANLEGEN -->
|
|
<div class="glassmorphism p-6 rounded shadow flex flex-col">
|
|
<h2 class="text-xl font-semibold mb-4">Neuen Benutzer anlegen</h2>
|
|
<form method="POST" action="{{ url_for('admin_panel') }}" class="space-y-4">
|
|
<div>
|
|
<label class="block mb-1 font-medium">Benutzername:</label>
|
|
<input type="text" name="new_username" required class="w-full p-3 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
</div>
|
|
<div>
|
|
<label class="block mb-1 font-medium">Passwort:</label>
|
|
<input type="password" name="new_password" required class="w-full p-3 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
</div>
|
|
<div class="flex items-center space-x-2">
|
|
<input type="checkbox" name="new_is_admin" class="h-5 w-5 rounded border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
<span class="font-medium">Als Admin markieren</span>
|
|
</div>
|
|
<button type="submit" class="bg-green-600 hover:bg-green-700 text-white py-3 px-6 rounded shadow transition duration-200">
|
|
Erstellen
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- BENUTZERVERWALTUNG -->
|
|
<div style="background-color: transparent !important;" class="glassmorphism p-6 rounded shadow flex flex-col">
|
|
<h2 class="text-xl font-semibold mb-4">Benutzerverwaltung</h2>
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full table-auto">
|
|
<thead>
|
|
<tr class="border-b">
|
|
<th class="p-3 text-left">ID</th>
|
|
<th class="p-3 text-left">Username</th>
|
|
<th class="p-3 text-left">Admin?</th>
|
|
<th class="p-3 text-left">Aktion</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for u in users %}
|
|
<tr class="border-b">
|
|
<td class="p-3">{{ u.id }}</td>
|
|
<td class="p-3">{{ u.username }}</td>
|
|
<td class="p-3">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
|
<td class="p-3 space-x-2">
|
|
<a href="{{ url_for('manage_bookmarks', user_id=u.id) }}"
|
|
style="margin: 10px !important;" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded text-sm transition duration-200">
|
|
Lesezeichen
|
|
</a>
|
|
<form method="POST" action="{{ url_for('delete_user', user_id=u.id) }}" class="inline"
|
|
onsubmit="return confirm('Benutzer wirklich löschen?')">
|
|
<button style="margin: 10px !important;" class="bg-red-500 text-white px-4 py-2 rounded text-sm transition duration-200">
|
|
Löschen
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- BENACHRICHTIGUNG ERSTELLEN (MULTI-USER) -->
|
|
<div class="glassmorphism p-6 rounded shadow flex flex-col">
|
|
<h2 class="text-xl font-semibold mb-4">Benachrichtigung erstellen</h2>
|
|
<form method="POST" action="{{ url_for('add_notification_multi') }}" class="space-y-4">
|
|
<div>
|
|
<label class="block mb-1 font-medium">Nachricht:</label>
|
|
<textarea name="message" rows="3" required class="w-full p-3 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400"></textarea>
|
|
</div>
|
|
<div>
|
|
<p class="mb-2 font-medium">Für welche Benutzer?</p>
|
|
<div class="flex flex-wrap gap-2">
|
|
<label class="inline-flex items-center gap-1 bg-gray-200 dark:bg-gray-800 p-2 rounded cursor-pointer"
|
|
for="notify_all">
|
|
<input type="checkbox" id="notify_all" name="target_users" value="all" class="h-5 w-5 rounded border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
Alle
|
|
</label>
|
|
{% for u in users %}
|
|
<label class="inline-flex items-center gap-1 bg-gray-200 dark:bg-gray-800 p-2 rounded cursor-pointer">
|
|
<input type="checkbox" name="target_users" value="{{ u.id }}" class="h-5 w-5 rounded border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
{{ u.username }}
|
|
</label>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
<button type="submit" class="bg-purple-500 hover:bg-purple-600 text-white px-6 py-3 rounded shadow transition duration-200">
|
|
Senden
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- LESEZEICHEN-VERWALTUNG (MULTI-USER) -->
|
|
<div class="glassmorphism p-6 rounded shadow flex flex-col">
|
|
<h2 class="text-xl font-semibold mb-4">Lesezeichen-Verwaltung</h2>
|
|
<form method="POST" action="{{ url_for('add_bookmarks_multi') }}" class="space-y-4">
|
|
<p class="font-medium">Für welche Benutzer soll das Lesezeichen gelten?</p>
|
|
<div class="flex flex-wrap gap-2">
|
|
{% for u in users %}
|
|
<label class="inline-flex items-center gap-1 bg-gray-200 dark:bg-gray-800 p-2 rounded cursor-pointer">
|
|
<input type="checkbox" name="target_users" value="{{ u.id }}" class="h-5 w-5 rounded border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
{{ u.username }}
|
|
</label>
|
|
{% endfor %}
|
|
</div>
|
|
<div>
|
|
<label class="block mb-1 font-medium">Titel:</label>
|
|
<input type="text" name="title" required class="w-full p-3 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
</div>
|
|
<div>
|
|
<label class="block mb-1 font-medium">URL:</label>
|
|
<input type="text" name="url" required class="w-full p-3 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
</div>
|
|
<div>
|
|
<label class="block mb-1 font-medium">Icon (FontAwesome CSS-Klasse):</label>
|
|
<input type="text" name="icon_class" placeholder="z.B. fas fa-user" class="w-full p-3 rounded border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-400" />
|
|
</div>
|
|
<button type="submit" class="bg-green-600 hover:bg-green-700 text-white px-6 py-3 rounded shadow transition duration-200">
|
|
Hinzufügen
|
|
</button>
|
|
</form>
|
|
|
|
{% if single_user and bookmarks %}
|
|
<p class="mt-6 mb-4 font-semibold">Lesezeichen für {{ single_user.username }}:</p>
|
|
<ul class="space-y-3">
|
|
{% for bm in bookmarks %}
|
|
<li class="bg-gray-200 dark:bg-gray-800 p-3 rounded flex justify-between items-center">
|
|
<div>
|
|
<i class="{{ bm.icon_class }} mr-2"></i>
|
|
<a href="{{ bm.url }}" target="_blank" class="text-blue-500 hover:underline">
|
|
{{ bm.title }}
|
|
</a>
|
|
</div>
|
|
<form method="POST"
|
|
action="{{ url_for('delete_bookmark', bookmark_id=bm.id, user_id=single_user.id) }}"
|
|
onsubmit="return confirm('Lesezeichen wirklich löschen?')">
|
|
<button class="text-red-500 hover:text-red-700 transition duration-200">
|
|
<i class="fas fa-trash-alt"></i>
|
|
</button>
|
|
</form>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
<p class="text-sm text-gray-400 mt-6">Wähle oben in der Benutzerverwaltung „Lesezeichen“ für einen Nutzer aus, um konkrete Einträge zu sehen.</p>
|
|
{% endif %}
|
|
</div>
|
|
<a href="{{ url_for('admin_time_tracking') }}"
|
|
class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded text-sm">
|
|
Zeiterfassung einsehen
|
|
</a>
|
|
|
|
|
|
</div> <!-- Grid Ende -->
|
|
|
|
<a href="{{ url_for('dashboard') }}"
|
|
class="inline-block bg-blue-500 hover:bg-blue-600 text-white px-6 py-3 rounded shadow transition duration-200 mt-8">
|
|
Zurück zum Dashboard
|
|
</a>
|
|
</div>
|
|
{% endblock content %}
|