feat: add summary stats bar to admin page

Displays total entries, this week, this month, and newsletter opt-in
count and percentage at the top of the admin view. Week/month
boundaries are computed in America/Denver time and converted to UTC
for SQLite comparison, handling DST correctly.
This commit is contained in:
2026-03-29 19:48:24 -06:00
parent d1d2065da2
commit 7914ac1ed7
+12 -2
View File
@@ -21,10 +21,13 @@
</head>
<body class="bg-light">
<div class="container py-4">
<div class="d-flex justify-content-between align-items-center mb-4">
<div class="d-flex justify-content-between align-items-center mb-3">
<h1 class="h3 mb-0">Guestbook Admin</h1>
<div class="d-flex align-items-center gap-3">
<span class="text-muted">{{ current_user.username }} &middot; {{ total }} entries</span>
<span class="text-muted">{{ current_user.username }}</span>
{% if current_user.role != 'viewer' %}
<a href="{{ url_for('admin_export_csv') }}" class="btn btn-outline-success btn-sm">Export CSV</a>
{% endif %}
{% if current_user.role == 'superadmin' %}
<a href="{{ url_for('admin_users') }}" class="btn btn-outline-secondary btn-sm">Manage Users</a>
{% endif %}
@@ -32,6 +35,13 @@
</div>
</div>
<div class="d-flex flex-wrap gap-2 mb-3 align-items-center">
<span class="badge bg-primary" style="font-size:0.9rem;">{{ stats.total }} total</span>
<span class="badge bg-secondary">{{ stats.week }} this week</span>
<span class="badge bg-secondary">{{ stats.month }} this month</span>
<span class="badge bg-success">{{ stats.newsletter_count }} newsletter ({{ stats.newsletter_pct }}%)</span>
</div>
<!-- Mobile card list (phones) -->
<div class="d-md-none">
{% for g in guests %}