diff --git a/__pycache__/app.cpython-313.pyc b/__pycache__/app.cpython-313.pyc index 39c4220..be634cf 100644 Binary files a/__pycache__/app.cpython-313.pyc and b/__pycache__/app.cpython-313.pyc differ diff --git a/app.py b/app.py index f4c2aa6..5fa799f 100644 --- a/app.py +++ b/app.py @@ -487,32 +487,94 @@ def settings(): if request.method == 'POST': action = request.form.get('action') + # Bestimme, ob es eine AJAX-Anfrage ist + is_ajax = request.headers.get('X-Requested-With') == 'XMLHttpRequest' or request.content_type and 'multipart/form-data' in request.content_type + if action == 'update_profile': - current_user.bio = request.form.get('bio') - - # Update avatar if provided - avatar_url = request.form.get('avatar_url') - if avatar_url: - current_user.avatar = avatar_url + try: + current_user.bio = request.form.get('bio', '') + current_user.location = request.form.get('location', '') + current_user.website = request.form.get('website', '') - db.session.commit() - flash('Profil erfolgreich aktualisiert!', 'success') + # Update avatar if provided + avatar_url = request.form.get('avatar_url') + if avatar_url: + current_user.avatar = avatar_url + + db.session.commit() + + if is_ajax: + return jsonify({ + 'success': True, + 'message': 'Profil erfolgreich aktualisiert!' + }) + else: + flash('Profil erfolgreich aktualisiert!', 'success') + except Exception as e: + db.session.rollback() + app.logger.error(f"Fehler beim Aktualisieren des Profils: {str(e)}") + + if is_ajax: + return jsonify({ + 'success': False, + 'message': 'Fehler beim Aktualisieren des Profils' + }), 500 + else: + flash('Fehler beim Aktualisieren des Profils', 'error') elif action == 'update_password': - current_password = request.form.get('current_password') - new_password = request.form.get('new_password') - confirm_password = request.form.get('confirm_password') - - if not current_user.check_password(current_password): - flash('Aktuelles Passwort ist nicht korrekt', 'error') - elif new_password != confirm_password: - flash('Neue Passwörter stimmen nicht überein', 'error') - else: - current_user.set_password(new_password) - db.session.commit() - flash('Passwort erfolgreich aktualisiert!', 'success') + try: + current_password = request.form.get('current_password') + new_password = request.form.get('new_password') + confirm_password = request.form.get('confirm_password') + + if not current_user.check_password(current_password): + if is_ajax: + return jsonify({ + 'success': False, + 'message': 'Aktuelles Passwort ist nicht korrekt' + }), 400 + else: + flash('Aktuelles Passwort ist nicht korrekt', 'error') + elif new_password != confirm_password: + if is_ajax: + return jsonify({ + 'success': False, + 'message': 'Neue Passwörter stimmen nicht überein' + }), 400 + else: + flash('Neue Passwörter stimmen nicht überein', 'error') + else: + current_user.set_password(new_password) + db.session.commit() + + if is_ajax: + return jsonify({ + 'success': True, + 'message': 'Passwort erfolgreich aktualisiert!' + }) + else: + flash('Passwort erfolgreich aktualisiert!', 'success') + except Exception as e: + db.session.rollback() + app.logger.error(f"Fehler beim Aktualisieren des Passworts: {str(e)}") + + if is_ajax: + return jsonify({ + 'success': False, + 'message': 'Fehler beim Aktualisieren des Passworts' + }), 500 + else: + flash('Fehler beim Aktualisieren des Passworts', 'error') - return redirect(url_for('settings')) + if not is_ajax: + return redirect(url_for('settings')) + else: + # Standardantwort für AJAX, falls keine spezifische Antwort zurückgegeben wurde + return jsonify({ + 'success': True, + 'message': 'Einstellungen aktualisiert' + }) return render_template('settings.html') diff --git a/init_db.py b/init_db.py index 59bebab..9538b1e 100644 --- a/init_db.py +++ b/init_db.py @@ -12,7 +12,7 @@ from datetime import datetime # Erstelle eine temporäre Flask-App, um die Datenbank zu initialisieren app = Flask(__name__) -app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///systades.db' +app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database/systades.db' app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db.init_app(app) diff --git a/instance/systades.db b/instance/systades.db deleted file mode 100644 index 6af1e40..0000000 Binary files a/instance/systades.db and /dev/null differ diff --git a/static/css/assistant.css b/static/css/assistant.css index 0d5f490..4a72a27 100644 --- a/static/css/assistant.css +++ b/static/css/assistant.css @@ -2,6 +2,8 @@ #chatgpt-assistant { font-family: 'Inter', sans-serif; bottom: 5.5rem; + z-index: 100; + max-height: 85vh; } #assistant-chat { @@ -11,7 +13,15 @@ border-radius: 0.75rem; overflow: hidden; max-width: calc(100vw - 2rem); - max-height: 75vh !important; + max-height: 80vh !important; +} + +#assistant-history { + max-height: calc(80vh - 150px); + overflow-y: auto; + scrollbar-width: thin; + scrollbar-color: rgba(156, 163, 175, 0.5) transparent; + padding-bottom: 2rem; /* Zusätzlicher Abstand unten */ } #assistant-toggle { @@ -24,11 +34,6 @@ transform: scale(1.1) rotate(10deg); } -#assistant-history { - scrollbar-width: thin; - scrollbar-color: rgba(156, 163, 175, 0.5) transparent; -} - #assistant-history::-webkit-scrollbar { width: 6px; } diff --git a/static/css/base-styles.css b/static/css/base-styles.css index 3cda484..06653f8 100644 --- a/static/css/base-styles.css +++ b/static/css/base-styles.css @@ -474,18 +474,19 @@ body:not(.dark) a:hover { } /* Light Mode Buttons */ +body:not(.dark) button:not(.toggle):not(.plain-btn) { + color: white !important; + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); +} + body:not(.dark) .btn, -body:not(.dark) button:not(.toggle) { - background: linear-gradient(135deg, #6d28d9, #5b21b6); - color: white; - border: none; - box-shadow: 0 2px 4px rgba(91, 33, 182, 0.25); - border-radius: 8px; - padding: 0.625rem 1.25rem; - transition: all 0.2s ease; - font-weight: 600; - letter-spacing: 0.02em; - text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); +body:not(.dark) .btn-primary, +body:not(.dark) .btn-secondary, +body:not(.dark) .btn-success, +body:not(.dark) .btn-danger, +body:not(.dark) .btn-warning, +body:not(.dark) .btn-info { + color: white !important; } body:not(.dark) .btn:hover, @@ -1043,4 +1044,25 @@ body:not(.dark) .chat-message-user { .chat-assistant .chat-messages { max-height: calc(85vh - 180px); /* Angepasst für größeres Fenster */ overflow-y: auto; + padding-bottom: 2rem; /* Zusätzlicher Abstand um Abschneiden zu vermeiden */ +} + +/* Verbesserungen für das Mobilmenü */ +@media (max-width: 768px) { + .mobile-menu-container { + max-height: 85vh; + overflow-y: auto; + } + + #chatgpt-assistant { + bottom: 4.5rem !important; + } + + .chat-assistant { + max-height: 70vh !important; + } + + .chat-assistant .chat-messages { + max-height: calc(70vh - 160px) !important; + } } \ No newline at end of file