wallpaper fix

This commit is contained in:
2025-02-19 21:14:02 +01:00
parent 209a23509b
commit d5a92d187f
5 changed files with 195 additions and 145 deletions

View File

@@ -564,12 +564,32 @@ def get_settings():
else:
# Falls noch kein Datensatz existiert
return jsonify({
"wallpaper": "1.png",
"wallpaper": "24.png",
"city": "",
"show_forecast": False,
"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('/save_settings', methods=['POST'])
def save_settings():
"""
@@ -580,7 +600,7 @@ def save_settings():
return jsonify({"success": False, "error": "not logged in"}), 403
data = request.get_json()
wallpaper = data.get('wallpaper', '1.png')
wallpaper = data.get('wallpaper', '24.png')
city = data.get('city', '')
show_forecast = data.get('show_forecast', False)
bookmarks_list = data.get('bookmarks', [])

View File

@@ -1,148 +1,178 @@
<!-- templates/admin.html -->
<!-- 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">
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<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>
<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>
{% 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 %}
{% 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 %}
<div>
<h2>Neuen Benutzer anlegen</h2>
<form method="POST" action="{{ url_for('admin_panel') }}">
<div class="form-group">
<label>Benutzername:</label>
<input type="text" name="new_username" required>
</div>
<div class="form-group">
<label>Passwort:</label>
<input type="password" name="new_password" required>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="new_is_admin"> Als Admin markieren
<!-- 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;">
<!-- 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>
</div>
<button type="submit">Erstellen</button>
</form>
</div>
<div>
<h2>Benutzerverwaltung</h2>
<table>
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Admin?</th>
<th>Aktion</th>
</tr>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{{ u.id }}</td>
<td>{{ u.username }}</td>
<td>{{ 'Ja' if u.is_admin else 'Nein' }}</td>
<td>
{% if u.id != session.user_id %}
<form method="POST" action="{{ url_for('delete_user', user_id=u.id) }}" onsubmit="return confirm('Benutzer wirklich löschen?')">
<button class="danger-button">Löschen</button>
</form>
{% else %}
<span style="color: gray !important;">[Eigener Account]</span>
{% endif %}
</td>
</tr>
<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 %}
</tbody>
</table>
</div>
<a href="{{ url_for('dashboard') }}" class="link-button">Zurück zum Dashboard</a>
</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>
</div>
</body>
</html>
</html>

View File

@@ -5,12 +5,12 @@
<meta charset="UTF-8">
<title>{% block title %}Meine App{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Tailwind + FontAwesome + GSAP -->
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.9.1/gsap.min.js"></script>
<!-- Dark-Mode-Einstellung -->
<script>
tailwind.config = {
@@ -66,9 +66,9 @@
</style>
</head>
<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>
// Dark Mode init
@@ -79,4 +79,4 @@
</script>
</body>
</html>
</html>

View File

@@ -85,7 +85,7 @@
<h2 class="text-lg font-semibold mb-2">Zeiterfassung</h2>
<form action="{{ url_for('time_tracking') }}" method="POST"
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" />
<button type="submit" name="action" value="start"
class="bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 mr-2">

Binary file not shown.