dashboard fix
This commit is contained in:
@@ -1,178 +1,180 @@
|
||||
<!-- Standalone admin.html without base.html, now with flexible layout, multi-user bookmark creation, and the ability for the own user to manage bookmarks -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Admin-Bereich</title>
|
||||
</head>
|
||||
<body style="margin:0 !important; padding:0 !important; background-color:black !important; color:white !important; font-family:Arial,sans-serif !important;">
|
||||
<div style="max-width:1200px !important; width:100% !important; margin:auto !important; padding:20px !important;">
|
||||
<h1 style="text-align:center !important; font-size:24px !important; margin-bottom:20px !important;">Admin-Bereich</h1>
|
||||
<!-- templates/admin.html -->
|
||||
{% extends "base.html" %}
|
||||
{% block title %}
|
||||
Admin-Bereich
|
||||
{% endblock title %}
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div style="background-color:{{category}} !important; color:white !important; padding:10px !important; border-radius:5px !important; margin-bottom:10px !important;">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% block content %}
|
||||
<div class="container mx-auto py-8 px-4">
|
||||
<h1 class="text-3xl font-bold text-center mb-6">Admin-Bereich</h1>
|
||||
|
||||
<!-- Main grid container for flexibility -->
|
||||
<div style="display:flex !important; flex-wrap:wrap !important; gap:20px !important; justify-content:center !important; align-items:start !important;">
|
||||
<!-- 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-2 rounded mb-2">
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<!-- Neuen Benutzer anlegen -->
|
||||
<div style="flex:1 1 400px !important; min-width:300px !important; max-width:500px !important; background-color:#222 !important; border-radius:10px !important; padding:15px !important;">
|
||||
<h2 style="font-size:18px !important; margin-bottom:10px !important;">Neuen Benutzer anlegen</h2>
|
||||
<form method="POST" action="{{ url_for('admin_panel') }}">
|
||||
<label style="display:block !important; margin-bottom:5px !important;">Benutzername:</label>
|
||||
<input type="text" name="new_username" required
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important;" />
|
||||
|
||||
<label style="display:block !important; margin-bottom:5px !important;">Passwort:</label>
|
||||
<input type="password" name="new_password" required
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important;" />
|
||||
|
||||
<label style="display:inline-flex !important; align-items:center !important; margin-bottom:10px !important;">
|
||||
<input type="checkbox" name="new_is_admin" style="margin-right:5px !important;" /> Als Admin markieren
|
||||
</label>
|
||||
|
||||
<button type="submit"
|
||||
style="background-color:green !important; color:white !important; padding:10px !important; border-radius:5px !important; width:100% !important; border:none !important; cursor:pointer !important; margin-top:10px !important;">
|
||||
Erstellen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Benutzerverwaltung -->
|
||||
<div style="flex:1 1 400px !important; min-width:300px !important; max-width:500px !important; background-color:#222 !important; border-radius:10px !important; padding:15px !important;">
|
||||
<h2 style="font-size:18px !important; margin-bottom:10px !important;">Benutzerverwaltung</h2>
|
||||
<table style="width:100% !important; border-collapse:collapse !important;">
|
||||
<thead>
|
||||
<tr style="border-bottom:1px solid gray !important;">
|
||||
<th style="padding:10px !important; text-align:left !important;">ID</th>
|
||||
<th style="padding:10px !important; text-align:left !important;">Username</th>
|
||||
<th style="padding:10px !important; text-align:left !important;">Admin?</th>
|
||||
<th style="padding:10px !important; text-align:left !important;">Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in users %}
|
||||
<tr style="border-bottom:1px solid #444 !important;">
|
||||
<td style="padding:10px !important;">{{ u.id }}</td>
|
||||
<td style="padding:10px !important;">{{ u.username }}</td>
|
||||
<td style="padding:10px !important;">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
||||
<td style="padding:10px !important;">
|
||||
<!-- Link zum Lesezeichen-Management (auch für eigenen Account) -->
|
||||
<a href="{{ url_for('manage_bookmarks', user_id=u.id) }}"
|
||||
style="background-color:blue !important; color:white !important; padding:5px 10px !important; border-radius:5px !important; text-decoration:none !important; margin-right:10px !important;">
|
||||
Lesezeichen
|
||||
</a>
|
||||
|
||||
<form method="POST" action="{{ url_for('delete_user', user_id=u.id) }}"
|
||||
style="display:inline;"
|
||||
onsubmit="return confirm('Benutzer wirklich löschen?')">
|
||||
<button style="background-color:red !important; color:white !important; padding:5px 10px !important; border-radius:5px !important; border:none !important; cursor:pointer !important;">
|
||||
Löschen
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Benachrichtigung erstellen -->
|
||||
<div style="flex:1 1 400px !important; min-width:300px !important; max-width:500px !important; background-color:#222 !important; border-radius:10px !important; padding:15px !important;">
|
||||
<h2 style="font-size:18px !important; margin-bottom:10px !important;">Benachrichtigung erstellen</h2>
|
||||
<form method="POST" action="{{ url_for('add_notification') }}">
|
||||
<label style="display:block !important; margin-bottom:5px !important;">Nachricht:</label>
|
||||
<textarea name="message" rows="2" required
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important; border:none !important;"></textarea>
|
||||
|
||||
<label style="display:block !important; margin-bottom:5px !important;">Für Benutzer:</label>
|
||||
<select name="user_id"
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important;">
|
||||
<option value="all">Alle</option>
|
||||
{% for u in users %}
|
||||
<option value="{{ u.id }}">{{ u.username }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<button type="submit"
|
||||
style="background-color:purple !important; color:white !important; padding:10px !important; border-radius:5px !important; width:100% !important; border:none !important; cursor:pointer !important;">
|
||||
Senden
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Lesezeichen-Verwaltung -->
|
||||
<div style="flex:1 1 400px !important; min-width:300px !important; max-width:500px !important; background-color:#222 !important; border-radius:10px !important; padding:15px !important;">
|
||||
<h2 style="font-size:18px !important; margin-bottom:10px !important;">Lesezeichen-Verwaltung</h2>
|
||||
|
||||
<!-- Formular: selektierbare Benutzer (Checkboxen) und Lesezeichen-Infos -->
|
||||
<form method="POST" style="margin-bottom:20px !important;">
|
||||
<p style="margin-bottom:10px !important;">Für welche Benutzer soll dieses Lesezeichen gelten?</p>
|
||||
<div style="display:flex !important; flex-wrap:wrap !important; gap:10px !important; margin-bottom:10px !important;">
|
||||
{% for u in users %}
|
||||
<label style="display:inline-flex !important; align-items:center !important; background-color:#333 !important; padding:5px 10px !important; border-radius:5px !important;">
|
||||
<input type="checkbox" name="target_users" value="{{ u.id }}" style="margin-right:5px !important;" />
|
||||
{{ u.username }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<label style="display:block !important; margin-bottom:5px !important;">Titel:</label>
|
||||
<input type="text" name="title" required
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important;" />
|
||||
|
||||
<label style="display:block !important; margin-bottom:5px !important;">URL:</label>
|
||||
<input type="text" name="url" required
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important;" />
|
||||
|
||||
<label style="display:block !important; margin-bottom:5px !important;">Icon (FontAwesome CSS-Klasse):</label>
|
||||
<input type="text" name="icon_class" placeholder="z.B. fas fa-user"
|
||||
style="width:100% !important; padding:8px !important; border-radius:5px !important; margin-bottom:10px !important;" />
|
||||
|
||||
<button type="submit"
|
||||
style="background-color:green !important; color:white !important; padding:10px !important; border-radius:5px !important; width:100% !important; border:none !important; cursor:pointer !important;">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- Liste der Lesezeichen, wenn single_user und bookmarks verfügbar sind -->
|
||||
{% if single_user and bookmarks %}
|
||||
<p style="margin-bottom:10px !important;">Lesezeichen für {{ single_user.username }}:</p>
|
||||
<ul style="list-style-type:none !important; padding:0 !important;">
|
||||
{% for bm in bookmarks %}
|
||||
<li style="background-color:#333 !important; border-radius:5px !important; margin-bottom:10px !important; display:flex !important; justify-content:space-between !important; align-items:center !important; padding:10px !important;">
|
||||
<div>
|
||||
<i class="{{ bm.icon_class }}" style="margin-right:8px !important;"></i>
|
||||
<a href="{{ bm.url }}" target="_blank"
|
||||
style="color:#4AB3F4 !important; text-decoration:none !important;">{{ 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 style="background-color:red !important; color:white !important; padding:5px 10px !important; border-radius:5px !important; border:none !important; cursor:pointer !important;">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p style="color:#888 !important;">Wähle oben in der Benutzerverwaltung „Lesezeichen“ für den gewünschten Nutzer, um bestehende Einträge zu sehen.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div> <!-- Ende Grid -->
|
||||
|
||||
<a href="{{ url_for('dashboard') }}"
|
||||
style="display:inline-block !important; background-color:blue !important; color:white !important; text-align:center !important; padding:10px !important; border-radius:5px !important; margin-top:20px !important; text-decoration:none !important;">
|
||||
Zurück zum Dashboard
|
||||
</a>
|
||||
<!-- Grid Layout für 4 Spalten / Boxen -->
|
||||
<div class="grid gap-6 md:grid-cols-2 xl:grid-cols-4">
|
||||
<!-- NEUEN BENUTZER ANLEGEN -->
|
||||
<div class="glassmorphism p-4 rounded shadow flex flex-col">
|
||||
<h2 class="text-xl font-semibold mb-3">Neuen Benutzer anlegen</h2>
|
||||
<form method="POST" action="{{ url_for('admin_panel') }}" class="space-y-3">
|
||||
<div>
|
||||
<label class="block">Benutzername:</label>
|
||||
<input type="text" name="new_username" required class="w-full p-2 rounded" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block">Passwort:</label>
|
||||
<input type="password" name="new_password" required class="w-full p-2 rounded" />
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<input type="checkbox" name="new_is_admin" class="h-4 w-4" />
|
||||
<span>Als Admin markieren</span>
|
||||
</div>
|
||||
<button type="submit" class="bg-green-600 text-white py-2 px-4 rounded shadow hover:bg-green-700">
|
||||
Erstellen
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<!-- BENUTZERVERWALTUNG -->
|
||||
<div class="glassmorphism p-4 rounded shadow flex flex-col">
|
||||
<h2 class="text-xl font-semibold mb-3">Benutzerverwaltung</h2>
|
||||
<table class="w-full table-auto">
|
||||
<thead>
|
||||
<tr class="border-b">
|
||||
<th class="p-2">ID</th>
|
||||
<th class="p-2">Username</th>
|
||||
<th class="p-2">Admin?</th>
|
||||
<th class="p-2">Aktion</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for u in users %}
|
||||
<tr class="border-b">
|
||||
<td class="p-2">{{ u.id }}</td>
|
||||
<td class="p-2">{{ u.username }}</td>
|
||||
<td class="p-2">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
||||
<td class="p-2 space-x-2">
|
||||
<!-- Lesezeichen-Verwaltung. Auch für eigenen Account. -->
|
||||
<a href="{{ url_for('manage_bookmarks', user_id=u.id) }}"
|
||||
class="bg-blue-500 hover:bg-blue-600 text-white px-3 py-1 rounded text-sm">
|
||||
Lesezeichen
|
||||
</a>
|
||||
<!-- User löschen -->
|
||||
<form method="POST" action="{{ url_for('delete_user', user_id=u.id) }}" class="inline"
|
||||
onsubmit="return confirm('Benutzer wirklich löschen?')">
|
||||
<button class="bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded text-sm">
|
||||
Löschen
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- BENACHRICHTIGUNG ERSTELLEN (MULTI-USER) -->
|
||||
<div class="glassmorphism p-4 rounded shadow flex flex-col">
|
||||
<h2 class="text-xl font-semibold mb-3">Benachrichtigung erstellen</h2>
|
||||
<form method="POST" action="{{ url_for('add_notification_multi') }}" class="space-y-3">
|
||||
<div>
|
||||
<label class="block mb-1">Nachricht:</label>
|
||||
<textarea name="message" rows="2" required class="w-full p-2 rounded"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<p class="mb-1">Für welche Benutzer?</p>
|
||||
<!-- Checkboxen oder Multi-Select -->
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label class="inline-flex items-center gap-1 bg-gray-200 dark:bg-gray-800 p-1 rounded"
|
||||
for="notify_all">
|
||||
<input type="checkbox" id="notify_all" name="target_users" value="all" />
|
||||
Alle
|
||||
</label>
|
||||
{% for u in users %}
|
||||
<label class="inline-flex items-center gap-1 bg-gray-200 dark:bg-gray-800 p-1 rounded">
|
||||
<input type="checkbox" name="target_users" value="{{ u.id }}" />
|
||||
{{ u.username }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="bg-purple-500 hover:bg-purple-600 text-white px-4 py-2 rounded">
|
||||
Senden
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- LESEZEICHEN-VERWALTUNG (MULTI-USER) -->
|
||||
<div class="glassmorphism p-4 rounded shadow flex flex-col">
|
||||
<h2 class="text-xl font-semibold mb-3">Lesezeichen-Verwaltung</h2>
|
||||
<form method="POST" action="{{ url_for('add_bookmarks_multi') }}" class="space-y-3">
|
||||
<p>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-1 rounded">
|
||||
<input type="checkbox" name="target_users" value="{{ u.id }}" />
|
||||
{{ u.username }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block mb-1">Titel:</label>
|
||||
<input type="text" name="title" required class="w-full p-2 rounded" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block mb-1">URL:</label>
|
||||
<input type="text" name="url" required class="w-full p-2 rounded" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block mb-1">Icon (FontAwesome CSS-Klasse):</label>
|
||||
<input type="text" name="icon_class" placeholder="z.B. fas fa-user" class="w-full p-2 rounded" />
|
||||
</div>
|
||||
<button type="submit" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded">
|
||||
Hinzufügen
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- Wenn single_user und bookmarks gesetzt, einzelne Liste zeigen -->
|
||||
{% if single_user and bookmarks %}
|
||||
<p class="mt-4 mb-2 font-semibold">Lesezeichen für {{ single_user.username }}:</p>
|
||||
<ul class="space-y-2">
|
||||
{% for bm in bookmarks %}
|
||||
<li class="bg-gray-200 dark:bg-gray-800 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-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">
|
||||
<i class="fas fa-trash-alt"></i>
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p class="text-sm text-gray-400 mt-4">Wähle oben in der Benutzerverwaltung „Lesezeichen“ für einen Nutzer aus, um konkrete Einträge zu sehen.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</div> <!-- Grid Ende -->
|
||||
|
||||
<a href="{{ url_for('dashboard') }}"
|
||||
class="inline-block bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded mt-6">
|
||||
Zurück zum Dashboard
|
||||
</a>
|
||||
</div>
|
||||
{% endblock content %}
|
||||
|
||||
Reference in New Issue
Block a user