Files
dev-manufaktur/Dashboard_V2/templates/admin.html
Jason Hirsch 2b53b40778 Dashboard V2
2025-02-19 17:27:01 +01:00

150 lines
6.1 KiB
HTML

<!-- templates/admin.html -->
{% extends "base.html" %}
{% block title %}Admin-Bereich{% endblock %}
{% block content %}
<div class="container mx-auto p-4 sm:p-6 lg:p-8">
<h1 class="text-3xl font-bold mb-6">Admin-Bereich</h1>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="bg-{{category}}-500 text-white p-2 rounded mb-2">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% endwith %}
<!-- Benutzer anlegen -->
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
<h2 class="text-xl font-semibold mb-2">Neuen Benutzer anlegen</h2>
<form method="POST" action="{{ url_for('admin_panel') }}" class="space-y-4">
<div>
<label class="block mb-1">Benutzername</label>
<input type="text" name="new_username" class="p-2 border rounded w-full" required>
</div>
<div>
<label class="block mb-1">Passwort</label>
<input type="password" name="new_password" class="p-2 border rounded w-full" required>
</div>
<div>
<label class="inline-flex items-center">
<input type="checkbox" name="new_is_admin" class="form-checkbox h-5 w-5 text-blue-600" />
<span class="ml-2">Als Admin markieren</span>
</label>
</div>
<button type="submit" class="bg-green-500 text-white py-2 px-4 rounded hover:bg-green-600">
Erstellen
</button>
</form>
</div>
<!-- Benutzerübersicht -->
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
<h2 class="text-xl font-semibold mb-2">Benutzerverwaltung</h2>
<table class="w-full table-auto">
<thead>
<tr class="border-b">
<th class="px-2 py-1">ID</th>
<th class="px-2 py-1">Username</th>
<th class="px-2 py-1">Admin?</th>
<th class="px-2 py-1"></th>
</tr>
</thead>
<tbody>
{% for u in users %}
<tr class="border-b">
<td class="px-2 py-1">{{ u.id }}</td>
<td class="px-2 py-1">{{ u.username }}</td>
<td class="px-2 py-1">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
<td class="px-2 py-1 text-right">
{% if u.id != session.user_id %}
<form method="POST" action="{{ url_for('delete_user', user_id=u.id) }}" onsubmit="return confirm('Benutzer wirklich löschen?')">
<button class="bg-red-500 text-white px-2 py-1 rounded hover:bg-red-600 text-sm">
Löschen
</button>
</form>
{% else %}
<span class="text-xs text-gray-400">[Eigener Account]</span>
{% endif %}
<a href="{{ url_for('manage_bookmarks', user_id=u.id) }}" class="ml-3 bg-blue-500 text-white px-2 py-1 rounded hover:bg-blue-600 text-sm">
Lesezeichen
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<!-- Benachrichtigung erstellen -->
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
<h2 class="text-xl font-semibold mb-2">Benachrichtigung erstellen</h2>
<form method="POST" action="{{ url_for('add_notification') }}" class="space-y-4">
<div>
<label class="block mb-1">Nachricht</label>
<textarea name="message" class="p-2 border rounded w-full" rows="2" required></textarea>
</div>
<div>
<label class="block mb-1">Für Benutzer</label>
<select name="user_id" class="p-2 border rounded w-full">
<option value="all">Alle</option>
{% for u in users %}
<option value="{{ u.id }}">{{ u.username }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="bg-purple-500 text-white py-2 px-4 rounded hover:bg-purple-600">
Senden
</button>
</form>
</div>
<!-- Falls man Lesezeichen für EINEN User verwaltet -->
{% if single_user is defined and single_user %}
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
<h2 class="text-xl font-semibold mb-2">
Lesezeichen für {{ single_user.username }}
</h2>
<form method="POST" class="space-y-4">
<div>
<label class="block mb-1">Titel</label>
<input type="text" name="title" class="p-2 border rounded w-full" required>
</div>
<div>
<label class="block mb-1">URL</label>
<input type="text" name="url" class="p-2 border rounded w-full" required>
</div>
<div>
<label class="block mb-1">Icon (FontAwesome CSS-Klasse)</label>
<input type="text" name="icon_class" class="p-2 border rounded w-full" placeholder="z.B. fas fa-user">
</div>
<button type="submit" class="bg-green-500 text-white py-2 px-4 rounded hover:bg-green-600">
Hinzufügen
</button>
</form>
<!-- Tabelle der vorhandenen Bookmarks -->
<ul class="mt-4 space-y-2">
{% for bm in bookmarks %}
<li class="bg-gray-100 dark:bg-gray-700 p-2 rounded flex justify-between items-center">
<div>
<i class="{{ bm.icon_class }} mr-2"></i>
<a href="{{ bm.url }}" target="_blank" class="text-blue-600 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"><i class="fas fa-trash-alt"></i></button>
</form>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<a href="{{ url_for('dashboard') }}" class="inline-block bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
Zurück zum Dashboard
</a>
</div>
{% endblock content %}