Compare commits
4 Commits
2b53b40778
...
3757658539
| Author | SHA1 | Date | |
|---|---|---|---|
| 3757658539 | |||
| e097facef7 | |||
| d5a92d187f | |||
| 209a23509b |
@@ -32,7 +32,6 @@ def close_connection(exception):
|
|||||||
def init_db():
|
def init_db():
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db = get_db()
|
db = get_db()
|
||||||
# Users
|
|
||||||
db.execute("""
|
db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -42,7 +41,6 @@ def init_db():
|
|||||||
is_admin INTEGER DEFAULT 0
|
is_admin INTEGER DEFAULT 0
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
# Bookmarks
|
|
||||||
db.execute("""
|
db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS bookmarks (
|
CREATE TABLE IF NOT EXISTS bookmarks (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -53,11 +51,10 @@ def init_db():
|
|||||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
# Notifications
|
|
||||||
db.execute("""
|
db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS notifications (
|
CREATE TABLE IF NOT EXISTS notifications (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
user_id INTEGER, -- NULL = für alle
|
user_id INTEGER,
|
||||||
message TEXT NOT NULL,
|
message TEXT NOT NULL,
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
is_read INTEGER DEFAULT 0
|
is_read INTEGER DEFAULT 0
|
||||||
@@ -71,7 +68,6 @@ def init_db():
|
|||||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
# Time Tracking
|
|
||||||
db.execute("""
|
db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS time_entries (
|
CREATE TABLE IF NOT EXISTS time_entries (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -82,7 +78,6 @@ def init_db():
|
|||||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
# Settings (OPTIONAL, falls du globale User-Einstellungen abspeichern willst)
|
|
||||||
db.execute("""
|
db.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS user_settings (
|
CREATE TABLE IF NOT EXISTS user_settings (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -94,17 +89,6 @@ def init_db():
|
|||||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
);
|
);
|
||||||
""")
|
""")
|
||||||
db.execute("""
|
|
||||||
CREATE TABLE IF NOT EXISTS settings (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
user_id INTEGER NOT NULL,
|
|
||||||
wallpaper TEXT DEFAULT '19.png',
|
|
||||||
city TEXT DEFAULT 'Berlin',
|
|
||||||
show_forecast INTEGER DEFAULT 1,
|
|
||||||
bookmarks TEXT DEFAULT '[]',
|
|
||||||
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
""")
|
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
@@ -204,7 +188,7 @@ def login():
|
|||||||
flash("Benutzername oder Passwort falsch!", "red")
|
flash("Benutzername oder Passwort falsch!", "red")
|
||||||
return render_template('login.html')
|
return render_template('login.html')
|
||||||
|
|
||||||
@app.route('/logout', methods=['POST'])
|
@app.route('/logout', methods=['GET', 'POST'])
|
||||||
def logout():
|
def logout():
|
||||||
session.clear()
|
session.clear()
|
||||||
flash("Erfolgreich abgemeldet!", "green")
|
flash("Erfolgreich abgemeldet!", "green")
|
||||||
@@ -460,40 +444,54 @@ def dashboard():
|
|||||||
user_id = session['user_id']
|
user_id = session['user_id']
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
|
||||||
# User abfragen
|
# User und Settings ermitteln
|
||||||
user = db.execute("SELECT * FROM users WHERE id = ?", (user_id,)).fetchone()
|
user = db.execute("SELECT * FROM users WHERE id = ?", (user_id,)).fetchone()
|
||||||
if not user:
|
if not user:
|
||||||
flash("Benutzer nicht gefunden.", "red")
|
flash("Benutzer nicht gefunden.", "red")
|
||||||
return redirect(url_for('logout'))
|
return redirect(url_for('logout'))
|
||||||
|
|
||||||
# Settings aus user_settings
|
|
||||||
settings = db.execute("SELECT * FROM user_settings WHERE user_id = ?", (user_id,)).fetchone()
|
settings = db.execute("SELECT * FROM user_settings WHERE user_id = ?", (user_id,)).fetchone()
|
||||||
|
|
||||||
# Standardwerte
|
# Standardwerte aus settings
|
||||||
if not settings:
|
if not settings:
|
||||||
wallpaper = '19.png'
|
wallpaper = '19.png'
|
||||||
city = 'Berlin'
|
city = 'Berlin'
|
||||||
show_forecast = True
|
show_forecast = True
|
||||||
bookmarks = []
|
# (Dieses 'bookmarks' ist optional, kannst du weglassen,
|
||||||
|
# wenn du ausschließlich die DB-Tabelle 'bookmarks' nutzt)
|
||||||
|
bookmarks_setting = []
|
||||||
else:
|
else:
|
||||||
wallpaper = settings['wallpaper']
|
wallpaper = settings['wallpaper']
|
||||||
city = settings['city']
|
city = settings['city']
|
||||||
show_forecast = bool(settings['show_forecast'])
|
show_forecast = bool(settings['show_forecast'])
|
||||||
if settings['bookmarks']:
|
if settings['bookmarks']:
|
||||||
bookmarks = settings['bookmarks'].split(",")
|
bookmarks_setting = settings['bookmarks'].split(",") # Nur als Fallback
|
||||||
else:
|
else:
|
||||||
bookmarks = []
|
bookmarks_setting = []
|
||||||
|
|
||||||
# Wetter holen (wenn gewünscht)
|
# DB-Bookmarks für den eingeloggten User
|
||||||
current_temp, weather_icon, forecast = get_weather(city)
|
user_bookmarks = db.execute("""
|
||||||
if current_temp is None:
|
SELECT id, title, url, icon_class
|
||||||
current_temp = "N/A"
|
FROM bookmarks
|
||||||
weather_icon = "fa-question"
|
WHERE user_id=?
|
||||||
forecast = []
|
ORDER BY id DESC
|
||||||
|
""", (user_id,)).fetchall()
|
||||||
|
|
||||||
# Domain, Logo usw.
|
# Notifications für diesen User (user_id) oder globale (user_id IS NULL)
|
||||||
domain = "example.com"
|
notifications = db.execute("""
|
||||||
logo_path = url_for('static', filename='clickcandit.png')
|
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
|
# Beispiel-Apps
|
||||||
user_app_chunks = [
|
user_app_chunks = [
|
||||||
@@ -515,25 +513,83 @@ 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(
|
return render_template(
|
||||||
'dashboard.html',
|
'dashboard.html',
|
||||||
user=user['username'],
|
user=user['username'],
|
||||||
wallpaper=wallpaper,
|
wallpaper=wallpaper,
|
||||||
city=city,
|
city=city,
|
||||||
show_forecast=show_forecast,
|
show_forecast=show_forecast,
|
||||||
bookmarks=bookmarks,
|
bookmarks=bookmarks_setting, # falls noch gebraucht, sonst weglassen
|
||||||
current_temp=current_temp,
|
current_temp=current_temp,
|
||||||
weather_icon=weather_icon,
|
weather_icon=weather_icon,
|
||||||
forecast=forecast,
|
forecast=forecast,
|
||||||
domain=domain,
|
domain=domain,
|
||||||
logo_path=logo_path,
|
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
|
||||||
)
|
)
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# SUPPORT & SETTINGS ROUTEN (Aus V1)
|
# SUPPORT & SETTINGS ROUTEN (Aus V1)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
|
||||||
|
@app.route('/delete_notification/<int:notif_id>', methods=['POST'])
|
||||||
|
def delete_notification(notif_id):
|
||||||
|
if 'user_id' not in session:
|
||||||
|
flash("Bitte melde dich an!", "red")
|
||||||
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
|
user_id = session['user_id']
|
||||||
|
db = get_db()
|
||||||
|
|
||||||
|
# Prüfen, ob die Notification existiert
|
||||||
|
row = db.execute("""
|
||||||
|
SELECT user_id
|
||||||
|
FROM notifications
|
||||||
|
WHERE id=?
|
||||||
|
""", (notif_id,)).fetchone()
|
||||||
|
|
||||||
|
if not row:
|
||||||
|
flash("Benachrichtigung existiert nicht.", "red")
|
||||||
|
return redirect(url_for('dashboard'))
|
||||||
|
|
||||||
|
# Wenn user_id = NULL => globale Notification
|
||||||
|
# Du kannst selbst definieren, ob jeder sie löschen darf oder nur Admin
|
||||||
|
# Hier: Jeder kann globale Notification löschen, wenn er sie sieht.
|
||||||
|
# Oder du sagst: Nur Admin kann globale Notis löschen -> if row['user_id'] is None and not is_admin(): ...
|
||||||
|
if row['user_id'] is None:
|
||||||
|
# Optional: Nur Admin löschen
|
||||||
|
if not is_admin():
|
||||||
|
flash('Nicht erlaubt', 'red')
|
||||||
|
return redirect(url_for('dashboard'))
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# Wenn es eine user-spezifische Notification ist: user_id muss übereinstimmen
|
||||||
|
if row['user_id'] != user_id:
|
||||||
|
flash("Keine Berechtigung, diese Benachrichtigung zu löschen.", "red")
|
||||||
|
return redirect(url_for('dashboard'))
|
||||||
|
|
||||||
|
# Benachrichtigung löschen
|
||||||
|
db.execute("DELETE FROM notifications WHERE id=?", (notif_id,))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
flash("Benachrichtigung gelöscht!", "green")
|
||||||
|
return redirect(url_for('dashboard'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/send_support_message', methods=['POST'])
|
@app.route('/send_support_message', methods=['POST'])
|
||||||
def send_support_message():
|
def send_support_message():
|
||||||
"""
|
"""
|
||||||
@@ -580,12 +636,93 @@ def get_settings():
|
|||||||
else:
|
else:
|
||||||
# Falls noch kein Datensatz existiert
|
# Falls noch kein Datensatz existiert
|
||||||
return jsonify({
|
return jsonify({
|
||||||
"wallpaper": "1.png",
|
"wallpaper": "24.png",
|
||||||
"city": "",
|
"city": "",
|
||||||
"show_forecast": False,
|
"show_forecast": False,
|
||||||
"bookmarks": []
|
"bookmarks": []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@app.context_processor
|
||||||
|
def inject_wallpaper():
|
||||||
|
"""
|
||||||
|
Dieser Context Processor wird bei jedem Template-Aufruf ausgeführt.
|
||||||
|
Ermittelt das Wallpaper des eingeloggten Benutzers (falls eingeloggt)
|
||||||
|
und stellt es allen Templates als Variable 'WALLPAPER_URL' bereit.
|
||||||
|
"""
|
||||||
|
if 'user_id' in session:
|
||||||
|
db = get_db()
|
||||||
|
row = db.execute("SELECT wallpaper FROM user_settings WHERE user_id=?", (session['user_id'],)).fetchone()
|
||||||
|
if row and row['wallpaper']:
|
||||||
|
# Bsp: row['wallpaper'] könnte '19.png' o. ä. sein
|
||||||
|
return {
|
||||||
|
"WALLPAPER_URL": url_for('static', filename=row['wallpaper'])
|
||||||
|
}
|
||||||
|
# Fallback: Wenn User nicht eingeloggt oder kein Wallpaper gesetzt
|
||||||
|
return {
|
||||||
|
"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'))
|
||||||
|
icon = request.form.get('icon_class')
|
||||||
|
|
||||||
|
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'])
|
@app.route('/save_settings', methods=['POST'])
|
||||||
def save_settings():
|
def save_settings():
|
||||||
"""
|
"""
|
||||||
@@ -596,7 +733,7 @@ def save_settings():
|
|||||||
return jsonify({"success": False, "error": "not logged in"}), 403
|
return jsonify({"success": False, "error": "not logged in"}), 403
|
||||||
|
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
wallpaper = data.get('wallpaper', '1.png')
|
wallpaper = data.get('wallpaper', '24.png')
|
||||||
city = data.get('city', '')
|
city = data.get('city', '')
|
||||||
show_forecast = data.get('show_forecast', False)
|
show_forecast = data.get('show_forecast', False)
|
||||||
bookmarks_list = data.get('bookmarks', [])
|
bookmarks_list = data.get('bookmarks', [])
|
||||||
|
|||||||
Binary file not shown.
@@ -1,148 +1,175 @@
|
|||||||
<!-- templates/admin.html -->
|
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% block title %}Admin-Bereich{% endblock %}
|
{% block title %}
|
||||||
|
Admin-Bereich
|
||||||
|
{% endblock title %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container mx-auto p-4 sm:p-6 lg:p-8">
|
<div class="container mx-auto px-4 sm:px-6 lg:px-8 py-10">
|
||||||
<h1 class="text-3xl font-bold mb-6">Admin-Bereich</h1>
|
<h1 class="text-3xl font-bold text-center mb-8">Admin-Bereich</h1>
|
||||||
|
|
||||||
|
<!-- Flash-Messages -->
|
||||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
{% if messages %}
|
{% if messages %}
|
||||||
{% for category, message in messages %}
|
{% for category, message in messages %}
|
||||||
<div class="bg-{{category}}-500 text-white p-2 rounded mb-2">
|
<div class="bg-{{ category }}-500 text-white p-3 rounded mb-4">
|
||||||
{{ message }}
|
{{ message }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
||||||
<!-- Benutzer anlegen -->
|
<!-- Grid Layout für Boxen -->
|
||||||
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
|
<div class="grid gap-8 sm:grid-cols-1 md:grid-cols-2 xl:grid-cols-4">
|
||||||
<h2 class="text-xl font-semibold mb-2">Neuen Benutzer anlegen</h2>
|
<!-- 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">
|
<form method="POST" action="{{ url_for('admin_panel') }}" class="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block mb-1">Benutzername</label>
|
<label class="block mb-1 font-medium">Benutzername:</label>
|
||||||
<input type="text" name="new_username" class="p-2 border rounded w-full" required>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<label class="block mb-1">Passwort</label>
|
<label class="block mb-1 font-medium">Passwort:</label>
|
||||||
<input type="password" name="new_password" class="p-2 border rounded w-full" required>
|
<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>
|
||||||
<div>
|
<div class="flex items-center space-x-2">
|
||||||
<label class="inline-flex items-center">
|
<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" />
|
||||||
<input type="checkbox" name="new_is_admin" class="form-checkbox h-5 w-5 text-blue-600" />
|
<span class="font-medium">Als Admin markieren</span>
|
||||||
<span class="ml-2">Als Admin markieren</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="bg-green-500 text-white py-2 px-4 rounded hover:bg-green-600">
|
<button type="submit" class="bg-green-600 hover:bg-green-700 text-white py-3 px-6 rounded shadow transition duration-200">
|
||||||
Erstellen
|
Erstellen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Benutzerübersicht -->
|
<!-- BENUTZERVERWALTUNG -->
|
||||||
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
|
<div style="background-color: transparent !important;" class="glassmorphism p-6 rounded shadow flex flex-col">
|
||||||
<h2 class="text-xl font-semibold mb-2">Benutzerverwaltung</h2>
|
<h2 class="text-xl font-semibold mb-4">Benutzerverwaltung</h2>
|
||||||
|
<div class="overflow-x-auto">
|
||||||
<table class="w-full table-auto">
|
<table class="w-full table-auto">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="border-b">
|
<tr class="border-b">
|
||||||
<th class="px-2 py-1">ID</th>
|
<th class="p-3 text-left">ID</th>
|
||||||
<th class="px-2 py-1">Username</th>
|
<th class="p-3 text-left">Username</th>
|
||||||
<th class="px-2 py-1">Admin?</th>
|
<th class="p-3 text-left">Admin?</th>
|
||||||
<th class="px-2 py-1"></th>
|
<th class="p-3 text-left">Aktion</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for u in users %}
|
{% for u in users %}
|
||||||
<tr class="border-b">
|
<tr class="border-b">
|
||||||
<td class="px-2 py-1">{{ u.id }}</td>
|
<td class="p-3">{{ u.id }}</td>
|
||||||
<td class="px-2 py-1">{{ u.username }}</td>
|
<td class="p-3">{{ u.username }}</td>
|
||||||
<td class="px-2 py-1">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
<td class="p-3">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
||||||
<td class="px-2 py-1 text-right">
|
<td class="p-3 space-x-2">
|
||||||
{% if u.id != session.user_id %}
|
<a href="{{ url_for('manage_bookmarks', user_id=u.id) }}"
|
||||||
<form method="POST" action="{{ url_for('delete_user', user_id=u.id) }}" onsubmit="return confirm('Benutzer wirklich löschen?')">
|
style="margin: 10px !important;" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded text-sm transition duration-200">
|
||||||
<button class="bg-red-500 text-white px-2 py-1 rounded hover:bg-red-600 text-sm">
|
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
|
Löschen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Benachrichtigung erstellen -->
|
<!-- BENACHRICHTIGUNG ERSTELLEN (MULTI-USER) -->
|
||||||
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
|
<div class="glassmorphism p-6 rounded shadow flex flex-col">
|
||||||
<h2 class="text-xl font-semibold mb-2">Benachrichtigung erstellen</h2>
|
<h2 class="text-xl font-semibold mb-4">Benachrichtigung erstellen</h2>
|
||||||
<form method="POST" action="{{ url_for('add_notification') }}" class="space-y-4">
|
<form method="POST" action="{{ url_for('add_notification_multi') }}" class="space-y-4">
|
||||||
<div>
|
<div>
|
||||||
<label class="block mb-1">Nachricht</label>
|
<label class="block mb-1 font-medium">Nachricht:</label>
|
||||||
<textarea name="message" class="p-2 border rounded w-full" rows="2" required></textarea>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<label class="block mb-1">Für Benutzer</label>
|
<p class="mb-2 font-medium">Für welche Benutzer?</p>
|
||||||
<select name="user_id" class="p-2 border rounded w-full">
|
<div class="flex flex-wrap gap-2">
|
||||||
<option value="all">Alle</option>
|
<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 %}
|
{% for u in users %}
|
||||||
<option value="{{ u.id }}">{{ u.username }}</option>
|
<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 %}
|
{% endfor %}
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="bg-purple-500 text-white py-2 px-4 rounded hover:bg-purple-600">
|
</div>
|
||||||
|
<button type="submit" class="bg-purple-500 hover:bg-purple-600 text-white px-6 py-3 rounded shadow transition duration-200">
|
||||||
Senden
|
Senden
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Falls man Lesezeichen für EINEN User verwaltet -->
|
<!-- LESEZEICHEN-VERWALTUNG (MULTI-USER) -->
|
||||||
{% if single_user is defined and single_user %}
|
<div class="glassmorphism p-6 rounded shadow flex flex-col">
|
||||||
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
|
<h2 class="text-xl font-semibold mb-4">Lesezeichen-Verwaltung</h2>
|
||||||
<h2 class="text-xl font-semibold mb-2">
|
<form method="POST" action="{{ url_for('add_bookmarks_multi') }}" class="space-y-4">
|
||||||
Lesezeichen für {{ single_user.username }}
|
<p class="font-medium">Für welche Benutzer soll das Lesezeichen gelten?</p>
|
||||||
</h2>
|
<div class="flex flex-wrap gap-2">
|
||||||
<form method="POST" class="space-y-4">
|
{% for u in users %}
|
||||||
<div>
|
<label class="inline-flex items-center gap-1 bg-gray-200 dark:bg-gray-800 p-2 rounded cursor-pointer">
|
||||||
<label class="block mb-1">Titel</label>
|
<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" />
|
||||||
<input type="text" name="title" class="p-2 border rounded w-full" required>
|
{{ u.username }}
|
||||||
|
</label>
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label class="block mb-1">URL</label>
|
<label class="block mb-1 font-medium">Titel:</label>
|
||||||
<input type="text" name="url" class="p-2 border rounded w-full" required>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<label class="block mb-1">Icon (FontAwesome CSS-Klasse)</label>
|
<label class="block mb-1 font-medium">URL:</label>
|
||||||
<input type="text" name="icon_class" class="p-2 border rounded w-full" placeholder="z.B. fas fa-user">
|
<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>
|
||||||
<button type="submit" class="bg-green-500 text-white py-2 px-4 rounded hover:bg-green-600">
|
<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
|
Hinzufügen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Tabelle der vorhandenen Bookmarks -->
|
{% if single_user and bookmarks %}
|
||||||
<ul class="mt-4 space-y-2">
|
<p class="mt-6 mb-4 font-semibold">Lesezeichen für {{ single_user.username }}:</p>
|
||||||
|
<ul class="space-y-3">
|
||||||
{% for bm in bookmarks %}
|
{% for bm in bookmarks %}
|
||||||
<li class="bg-gray-100 dark:bg-gray-700 p-2 rounded flex justify-between items-center">
|
<li class="bg-gray-200 dark:bg-gray-800 p-3 rounded flex justify-between items-center">
|
||||||
<div>
|
<div>
|
||||||
<i class="{{ bm.icon_class }} mr-2"></i>
|
<i class="{{ bm.icon_class }} mr-2"></i>
|
||||||
<a href="{{ bm.url }}" target="_blank" class="text-blue-600 hover:underline">{{ bm.title }}</a>
|
<a href="{{ bm.url }}" target="_blank" class="text-blue-500 hover:underline">
|
||||||
|
{{ bm.title }}
|
||||||
|
</a>
|
||||||
</div>
|
</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?')">
|
<form method="POST"
|
||||||
<button class="text-red-500 hover:text-red-700"><i class="fas fa-trash-alt"></i></button>
|
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>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
{% 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 %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
<a href="{{ url_for('dashboard') }}" class="inline-block bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600">
|
</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
|
Zurück zum Dashboard
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
background: rgba(255, 255, 255, 0.1);
|
background: rgba(255, 255, 255, 0.1);
|
||||||
backdrop-filter: blur(10px);
|
backdrop-filter: blur(10px);
|
||||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||||
border-radius: 10px;
|
border-radius: 15px !important;
|
||||||
}
|
}
|
||||||
.dark .glassmorphism {
|
.dark .glassmorphism {
|
||||||
background: rgba(0, 0, 0, 0.2);
|
background: rgba(0, 0, 0, 0.2);
|
||||||
@@ -66,9 +66,9 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="min-h-screen bg-gray-100 dark:bg-gray-900 text-gray-800 dark:text-gray-100 transition-colors duration-300"
|
<body class="min-h-screen bg-gray-100 dark:bg-gray-900 text-gray-800 dark:text-gray-100 transition-colors duration-300"
|
||||||
style="background-image: url('{{ url_for('static', filename='1.png') }}');">
|
style="background-image: url('{{ WALLPAPER_URL }}');">
|
||||||
|
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock content %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Dark Mode init
|
// Dark Mode init
|
||||||
|
|||||||
@@ -24,15 +24,15 @@
|
|||||||
|
|
||||||
<!-- Websuche: ohne Input-BG/Border -->
|
<!-- Websuche: ohne Input-BG/Border -->
|
||||||
<div class="glassmorphism p-4 shadow-lg mb-6 w-full max-w-lg">
|
<div class="glassmorphism p-4 shadow-lg mb-6 w-full max-w-lg">
|
||||||
<form id="searchForm" style="background-color: transparent !important;" class="flex flex-col sm:flex-row items-center justify-center">
|
<form id="searchForm" style="background-color: transparent !important; padding-bottom: 2px;" class="flex flex-col sm:flex-row items-center justify-center">
|
||||||
<input type="text" style="background-color: transparent !important;" id="searchInput" placeholder="Suche..."
|
<input type="text" style="background-color: transparent !important; padding-bottom: 2px !important;" id="searchInput" placeholder="Suche..."
|
||||||
class="flex-grow bg-transparent border-0 outline-none placeholder-gray-500 text-gray-800
|
class="flex-grow bg-transparent border-0 outline-none placeholder-gray-500 text-gray-800
|
||||||
dark:placeholder-gray-300" />
|
dark:placeholder-gray-300" />
|
||||||
<select id="searchEngine" style="background-color: transparent !important;" class="bg-transparent border-0 outline-none text-gray-800 dark:text-white ml-2">
|
<select id="searchEngine" style="background-color: transparent !important; padding-bottom: 2px !important;" class="bg-transparent border-0 outline-none text-gray-800 dark:text-white ml-2">
|
||||||
<option value="qwant">Qwant</option>
|
<option value="qwant">Qwant</option>
|
||||||
<option value="google">Google</option>
|
<option value="google">Google</option>
|
||||||
</select>
|
</select>
|
||||||
<button type="submit" class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 ml-2">
|
<button type="submit" class="bg-green-500 text-white px-2 py-2 rounded hover:bg-green-600 ml-2">
|
||||||
Los
|
Los
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
{% if messages %}
|
{% if messages %}
|
||||||
<div class="mb-4 w-full max-w-lg ">
|
<div class="mb-4 w-full max-w-lg ">
|
||||||
{% for category, message in messages %}
|
{% for category, message in messages %}
|
||||||
<div class="alert flex items-center bg-{{ category }}-500 text-white text-sm font-bold px-4 py-3 mb-2"
|
<div style="border-radius: 15px !important;" class="alert flex items-center bg-{{ category }}-500 text-white text-sm font-bold px-4 py-3 mb-2"
|
||||||
role="alert">
|
role="alert">
|
||||||
<p>{{ message }}</p>
|
<p>{{ message }}</p>
|
||||||
<svg class="fill-current h-6 w-6 text-white ml-auto close-flash" role="button"
|
<svg class="fill-current h-6 w-6 text-white ml-auto close-flash" role="button"
|
||||||
@@ -69,9 +69,18 @@
|
|||||||
{% if notifications %}
|
{% if notifications %}
|
||||||
<ul class="space-y-2 max-h-56 overflow-auto">
|
<ul class="space-y-2 max-h-56 overflow-auto">
|
||||||
{% for note in notifications %}
|
{% for note in notifications %}
|
||||||
<li class="bg-gray-100 dark:bg-gray-700 p-2 rounded">
|
<li class="bg-gray-100 dark:bg-gray-700 p-2 rounded flex justify-between items-center">
|
||||||
|
<div>
|
||||||
{{ note.message }}<br>
|
{{ note.message }}<br>
|
||||||
<span class="text-xs text-gray-500">{{ note.created_at }}</span>
|
<span class="text-xs text-gray-500">{{ note.created_at }}</span>
|
||||||
|
</div>
|
||||||
|
<form method="POST" action="{{ url_for('delete_notification', notif_id=note.id) }}"
|
||||||
|
onsubmit="return confirm('Benachrichtigung wirklich löschen?')"
|
||||||
|
class="inline">
|
||||||
|
<button class="text-red-500 hover:text-red-700 text-sm ml-2" title="Benachrichtigung löschen">
|
||||||
|
<i class="fas fa-times"></i>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -85,7 +94,7 @@
|
|||||||
<h2 class="text-lg font-semibold mb-2">Zeiterfassung</h2>
|
<h2 class="text-lg font-semibold mb-2">Zeiterfassung</h2>
|
||||||
<form action="{{ url_for('time_tracking') }}" method="POST"
|
<form action="{{ url_for('time_tracking') }}" method="POST"
|
||||||
class="mb-4 flex flex-col sm:flex-row items-center">
|
class="mb-4 flex flex-col sm:flex-row items-center">
|
||||||
<input type="text" name="activity" placeholder="Aktivität"
|
<input type="text" name="activity" style="border-bottom: solid rgb(240, 222, 222) !important; border-top: none !important; border-left: none !important; border-right: none !important; background-color: transparent !important;" placeholder="Aktivität"
|
||||||
class="p-2 border rounded mb-2 sm:mb-0 sm:mr-2 flex-1 text-gray-800" />
|
class="p-2 border rounded mb-2 sm:mb-0 sm:mr-2 flex-1 text-gray-800" />
|
||||||
<button type="submit" name="action" value="start"
|
<button type="submit" name="action" value="start"
|
||||||
class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 mr-2">
|
class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 mr-2">
|
||||||
|
|||||||
Reference in New Issue
Block a user