styles geändert
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
@@ -1,76 +1,140 @@
|
|||||||
<!-- templates/admin.html -->
|
<!-- templates/admin.html -->
|
||||||
{% extends "base.html" %}
|
<!DOCTYPE html>
|
||||||
{% block title %}Admin-Bereich{% endblock %}
|
<html lang="de">
|
||||||
|
<head>
|
||||||
{% block content %}
|
<meta charset="UTF-8">
|
||||||
<div class="container mx-auto p-4 sm:p-6 lg:p-8">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<h1 class="text-3xl font-bold mb-6">Admin-Bereich</h1>
|
<title>Admin-Bereich</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
background-color: black !important;
|
||||||
|
color: white !important;
|
||||||
|
font-family: Arial, sans-serif !important;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
width: 100%;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #222 !important;
|
||||||
|
border-radius: 10px !important;
|
||||||
|
}
|
||||||
|
.title {
|
||||||
|
text-align: center;
|
||||||
|
font-size: 24px !important;
|
||||||
|
}
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
}
|
||||||
|
input, select, button {
|
||||||
|
width: 100% !important;
|
||||||
|
padding: 8px !important;
|
||||||
|
border-radius: 5px !important;
|
||||||
|
margin-top: 5px !important;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
background-color: green !important;
|
||||||
|
color: white !important;
|
||||||
|
border: none !important;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
background-color: darkgreen !important;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100% !important;
|
||||||
|
border-collapse: collapse !important;
|
||||||
|
margin-top: 10px !important;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
padding: 10px !important;
|
||||||
|
border-bottom: 1px solid gray !important;
|
||||||
|
text-align: left !important;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background-color: #333 !important;
|
||||||
|
}
|
||||||
|
.danger-button {
|
||||||
|
background-color: red !important;
|
||||||
|
}
|
||||||
|
.danger-button:hover {
|
||||||
|
background-color: darkred !important;
|
||||||
|
}
|
||||||
|
.link-button {
|
||||||
|
display: 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;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="title">Admin-Bereich</h1>
|
||||||
|
|
||||||
{% 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 style="background-color: {{category}} !important; color: white !important; padding: 10px !important; border-radius: 5px !important; margin-bottom: 10px !important;">
|
||||||
{{ message }}
|
{{ message }}
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% 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>
|
<div>
|
||||||
<label class="block mb-1">Benutzername</label>
|
<h2>Neuen Benutzer anlegen</h2>
|
||||||
<input type="text" name="new_username" class="p-2 border rounded w-full" required>
|
<form method="POST" action="{{ url_for('admin_panel') }}">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Benutzername:</label>
|
||||||
|
<input type="text" name="new_username" required>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="form-group">
|
||||||
<label class="block mb-1">Passwort</label>
|
<label>Passwort:</label>
|
||||||
<input type="password" name="new_password" class="p-2 border rounded w-full" required>
|
<input type="password" name="new_password" required>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class="form-group">
|
||||||
<label class="inline-flex items-center">
|
<label>
|
||||||
<input type="checkbox" name="new_is_admin" class="form-checkbox h-5 w-5 text-blue-600" />
|
<input type="checkbox" name="new_is_admin"> Als Admin markieren
|
||||||
<span class="ml-2">Als Admin markieren</span>
|
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="bg-green-500 text-white py-2 px-4 rounded hover:bg-green-600">
|
<button type="submit">Erstellen</button>
|
||||||
Erstellen
|
|
||||||
</button>
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Benutzerübersicht -->
|
<div>
|
||||||
<div class="glassmorphism p-4 rounded shadow-lg mb-8">
|
<h2>Benutzerverwaltung</h2>
|
||||||
<h2 class="text-xl font-semibold mb-2">Benutzerverwaltung</h2>
|
<table>
|
||||||
<table class="w-full table-auto">
|
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="border-b">
|
<tr>
|
||||||
<th class="px-2 py-1">ID</th>
|
<th>ID</th>
|
||||||
<th class="px-2 py-1">Username</th>
|
<th>Username</th>
|
||||||
<th class="px-2 py-1">Admin?</th>
|
<th>Admin?</th>
|
||||||
<th class="px-2 py-1"></th>
|
<th>Aktion</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for u in users %}
|
{% for u in users %}
|
||||||
<tr class="border-b">
|
<tr>
|
||||||
<td class="px-2 py-1">{{ u.id }}</td>
|
<td>{{ u.id }}</td>
|
||||||
<td class="px-2 py-1">{{ u.username }}</td>
|
<td>{{ u.username }}</td>
|
||||||
<td class="px-2 py-1">{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
<td>{{ 'Ja' if u.is_admin else 'Nein' }}</td>
|
||||||
<td class="px-2 py-1 text-right">
|
<td>
|
||||||
{% if u.id != session.user_id %}
|
{% 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?')">
|
<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">
|
<button class="danger-button">Löschen</button>
|
||||||
Löschen
|
|
||||||
</button>
|
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="text-xs text-gray-400">[Eigener Account]</span>
|
<span style="color: gray !important;">[Eigener Account]</span>
|
||||||
{% endif %}
|
{% 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 %}
|
||||||
@@ -78,72 +142,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Benachrichtigung erstellen -->
|
<a href="{{ url_for('dashboard') }}" class="link-button">Zurück zum Dashboard</a>
|
||||||
<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>
|
||||||
<div>
|
</body>
|
||||||
<label class="block mb-1">Für Benutzer</label>
|
</html>
|
||||||
<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 %}
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
@@ -41,9 +41,9 @@
|
|||||||
<!-- Flash-Messages -->
|
<!-- Flash-Messages -->
|
||||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
{% 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"
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user