🐛 Backend Update: Refactored admin_unified module for improved code maintainability and performance. 🌱🔧
This commit is contained in:
Binary file not shown.
@ -94,7 +94,7 @@ def admin_required(f):
|
||||
@admin_blueprint.route("/")
|
||||
@admin_required
|
||||
def admin_dashboard():
|
||||
"""Admin-Dashboard-Hauptseite mit Systemstatistiken"""
|
||||
"""Admin-Dashboard-Hauptseite mit Systemstatistiken und Benutzerdaten"""
|
||||
try:
|
||||
with get_cached_session() as db_session:
|
||||
# Grundlegende Statistiken sammeln
|
||||
@ -107,6 +107,9 @@ def admin_dashboard():
|
||||
Job.status.in_(['pending', 'printing', 'paused'])
|
||||
).count()
|
||||
|
||||
# Alle Benutzer für die Benutzerverwaltung laden
|
||||
users = db_session.query(User).order_by(User.created_at.desc()).all()
|
||||
|
||||
stats = {
|
||||
'total_users': total_users,
|
||||
'total_printers': total_printers,
|
||||
@ -114,13 +117,13 @@ def admin_dashboard():
|
||||
'active_jobs': active_jobs
|
||||
}
|
||||
|
||||
admin_logger.info(f"Admin-Dashboard geladen von {current_user.username}")
|
||||
return render_template('admin.html', stats=stats, active_tab=None)
|
||||
admin_logger.info(f"Admin-Dashboard geladen von {current_user.username} mit {len(users)} Benutzern")
|
||||
return render_template('admin.html', stats=stats, users=users, active_tab=None)
|
||||
|
||||
except Exception as e:
|
||||
admin_logger.error(f"Fehler beim Laden des Admin-Dashboards: {str(e)}")
|
||||
flash("Fehler beim Laden der Dashboard-Daten", "error")
|
||||
return render_template('admin.html', stats={}, active_tab=None)
|
||||
return render_template('admin.html', stats={}, users=[], active_tab=None)
|
||||
|
||||
@admin_blueprint.route("/plug-schedules")
|
||||
@admin_required
|
||||
|
Reference in New Issue
Block a user