Add admin page

This commit is contained in:
Peter Stockings
2025-12-24 09:39:57 +11:00
parent 78e71b3895
commit 9b96e3ad47
3 changed files with 400 additions and 324 deletions

15
app.py
View File

@@ -344,10 +344,9 @@ def collect():
"warnings": warnings,
}
def collect_logs_only():
def collect_admin_data():
"""
Lightweight version that only collects app names and logs.
Much faster than collect() since it skips stats, metrics, and system info.
Collects logs and detailed container info for the admin dashboard.
"""
ps_rows = docker_ps_all()
apps = []
@@ -361,6 +360,7 @@ def collect_logs_only():
"app": app_name,
"container": name,
"logs": get_container_logs(name, lines=50),
"detail": get_container_detail(name)
})
# Sort by app name
@@ -432,16 +432,9 @@ def logout():
@app.get("/admin")
@login_required
def admin():
data = collect_logs_only()
data = collect_admin_data()
return render_template("admin.html", data=data, poll_seconds=POLL_SECONDS)
# Protected container detail page
@app.get("/admin/container/<container_name>")
@login_required
def container_detail(container_name):
detail = get_container_detail(container_name)
return render_template("container_detail.html", container=detail, container_name=container_name)
# API endpoint for container details (used by admin panel)
@app.get("/api/container/<container_name>")
@login_required