dashboard fix
This commit is contained in:
@@ -444,40 +444,54 @@ def dashboard():
|
||||
user_id = session['user_id']
|
||||
db = get_db()
|
||||
|
||||
# User abfragen
|
||||
# User und Settings ermitteln
|
||||
user = db.execute("SELECT * FROM users WHERE id = ?", (user_id,)).fetchone()
|
||||
if not user:
|
||||
flash("Benutzer nicht gefunden.", "red")
|
||||
return redirect(url_for('logout'))
|
||||
|
||||
# Settings aus user_settings
|
||||
settings = db.execute("SELECT * FROM user_settings WHERE user_id = ?", (user_id,)).fetchone()
|
||||
|
||||
# Standardwerte
|
||||
# Standardwerte aus settings
|
||||
if not settings:
|
||||
wallpaper = '19.png'
|
||||
city = 'Berlin'
|
||||
show_forecast = True
|
||||
bookmarks = []
|
||||
# (Dieses 'bookmarks' ist optional, kannst du weglassen,
|
||||
# wenn du ausschließlich die DB-Tabelle 'bookmarks' nutzt)
|
||||
bookmarks_setting = []
|
||||
else:
|
||||
wallpaper = settings['wallpaper']
|
||||
city = settings['city']
|
||||
show_forecast = bool(settings['show_forecast'])
|
||||
if settings['bookmarks']:
|
||||
bookmarks = settings['bookmarks'].split(",")
|
||||
bookmarks_setting = settings['bookmarks'].split(",") # Nur als Fallback
|
||||
else:
|
||||
bookmarks = []
|
||||
bookmarks_setting = []
|
||||
|
||||
# Wetter holen (wenn gewünscht)
|
||||
current_temp, weather_icon, forecast = get_weather(city)
|
||||
if current_temp is None:
|
||||
current_temp = "N/A"
|
||||
weather_icon = "fa-question"
|
||||
forecast = []
|
||||
# DB-Bookmarks für den eingeloggten User
|
||||
user_bookmarks = db.execute("""
|
||||
SELECT id, title, url, icon_class
|
||||
FROM bookmarks
|
||||
WHERE user_id=?
|
||||
ORDER BY id DESC
|
||||
""", (user_id,)).fetchall()
|
||||
|
||||
# Domain, Logo usw.
|
||||
domain = "example.com"
|
||||
logo_path = url_for('static', filename='clickcandit.png')
|
||||
# Notifications für diesen User (user_id) oder globale (user_id IS NULL)
|
||||
notifications = db.execute("""
|
||||
SELECT id, user_id, message, created_at
|
||||
FROM notifications
|
||||
WHERE user_id=? OR user_id IS NULL
|
||||
ORDER BY created_at DESC
|
||||
""", (user_id,)).fetchall()
|
||||
|
||||
# Ggf. Time-Entries (falls du sie zeigen willst)
|
||||
time_entries = db.execute("""
|
||||
SELECT *
|
||||
FROM time_entries
|
||||
WHERE user_id=?
|
||||
ORDER BY start_time DESC
|
||||
""", (user_id,)).fetchall()
|
||||
|
||||
# Beispiel-Apps
|
||||
user_app_chunks = [
|
||||
@@ -499,19 +513,33 @@ def dashboard():
|
||||
]
|
||||
]
|
||||
|
||||
# Wetter (Dummy oder API)
|
||||
current_temp, weather_icon, forecast = get_weather(city)
|
||||
if current_temp is None:
|
||||
current_temp = "N/A"
|
||||
weather_icon = "fa-question"
|
||||
forecast = []
|
||||
|
||||
domain = "clickcandit.com/login"
|
||||
logo_path = url_for('static', filename='clickcandit.png')
|
||||
|
||||
return render_template(
|
||||
'dashboard.html',
|
||||
user=user['username'],
|
||||
wallpaper=wallpaper,
|
||||
city=city,
|
||||
show_forecast=show_forecast,
|
||||
bookmarks=bookmarks,
|
||||
bookmarks=bookmarks_setting, # falls noch gebraucht, sonst weglassen
|
||||
current_temp=current_temp,
|
||||
weather_icon=weather_icon,
|
||||
forecast=forecast,
|
||||
domain=domain,
|
||||
logo_path=logo_path,
|
||||
user_app_chunks=user_app_chunks
|
||||
user_app_chunks=user_app_chunks,
|
||||
# Hier die neuen Variablen:
|
||||
user_bookmarks=user_bookmarks,
|
||||
notifications=notifications,
|
||||
time_entries=time_entries
|
||||
)
|
||||
|
||||
# ------------------------------------------------------------
|
||||
@@ -590,6 +618,66 @@ def inject_wallpaper():
|
||||
"WALLPAPER_URL": url_for('static', filename='24.png')
|
||||
}
|
||||
|
||||
@app.route('/admin/notifications/multi', methods=['POST'])
|
||||
def add_notification_multi():
|
||||
if not is_admin():
|
||||
flash("Zugriff verweigert!", "red")
|
||||
return redirect(url_for('dashboard'))
|
||||
|
||||
message = request.form.get('message')
|
||||
target_list = request.form.getlist('target_users') # ['all'] oder ['1','2'] etc.
|
||||
|
||||
if not message:
|
||||
flash("Bitte eine Nachricht eingeben.", "red")
|
||||
return redirect(url_for('admin_panel'))
|
||||
|
||||
db = get_db()
|
||||
|
||||
# Wenn 'all' in der Liste, Notification für alle
|
||||
if 'all' in target_list:
|
||||
db.execute("INSERT INTO notifications (user_id, message) VALUES (NULL, ?)", (message,))
|
||||
else:
|
||||
# Sonst für jede ausgewählte ID
|
||||
for uid in target_list:
|
||||
db.execute("INSERT INTO notifications (user_id, message) VALUES (?, ?)", (uid, message))
|
||||
|
||||
db.commit()
|
||||
flash("Benachrichtigungen erstellt!", "green")
|
||||
return redirect(url_for('admin_panel'))
|
||||
|
||||
|
||||
@app.route('/admin/bookmarks/multi', methods=['POST'])
|
||||
def add_bookmarks_multi():
|
||||
if not is_admin():
|
||||
flash("Zugriff verweigert!", "red")
|
||||
return redirect(url_for('dashboard'))
|
||||
|
||||
# Checkboxen im Template: name='target_users'
|
||||
target_list = request.form.getlist('target_users') # Liste der IDs (Strings)
|
||||
title = request.form.get('title')
|
||||
url_ = request.form.get('url')
|
||||
icon = request.form.get('icon_class', 'fas fa-bookmark')
|
||||
|
||||
# Ggf. Validierung
|
||||
if not title or not url_:
|
||||
flash("Bitte Titel und URL angeben!", "red")
|
||||
return redirect(url_for('admin_panel'))
|
||||
if not target_list:
|
||||
flash("Bitte mindestens einen Benutzer auswählen!", "red")
|
||||
return redirect(url_for('admin_panel'))
|
||||
|
||||
db = get_db()
|
||||
for uid in target_list:
|
||||
db.execute(
|
||||
"INSERT INTO bookmarks (user_id, title, url, icon_class) VALUES (?, ?, ?, ?)",
|
||||
(uid, title, url_, icon)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
flash("Neues Lesezeichen für mehrere Benutzer hinzugefügt!", "green")
|
||||
return redirect(url_for('admin_panel'))
|
||||
|
||||
|
||||
@app.route('/save_settings', methods=['POST'])
|
||||
def save_settings():
|
||||
"""
|
||||
|
||||
@@ -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 %}
|
||||
|
||||
BIN
clickcandit.db
BIN
clickcandit.db
Binary file not shown.
Reference in New Issue
Block a user