Dashboard: move Recent Activity under Playlist Overview and split out heartbeats

Moves the Recent Activity card into the main column, directly beneath
Playlist Overview, so the two cards that describe "what the server and
its players are doing" sit together. System Status stays full-width below
the grid.

While moving it, the card was showing almost nothing useful: player
feedback ("Feedback received from ...") is a ~15s heartbeat that makes up
84% of all log rows (423/506) and 18 of the newest 20, so the list was a
wall of repeated one-line status reports that pushed real events off the
screen.

The card is now tabbed:
  - "Activity" (default) - uploads, logins, HTTPS changes, deployments...
  - "Player heartbeats"  - the raw status stream, on demand

get_recent_logs() gains exclude_prefix / include_prefix so the split
happens in SQL. Filtering a single wide window in Python instead gave only
7 useful entries, because the number returned depends on heartbeat volume
and would fall further as more players are added. Both queries now return
25. Prefixes are passed with autoescape=True so a literal '%' or '_' in a
prefix matches itself rather than acting as a LIKE wildcard.

UI: the list is capped at 320px and scrolls, so a long log cannot make
the card dominate the page. Long messages wrap instead of pushing the
timestamp off-screen (previously float:right), and the debug level now
has its own colour instead of rendering as "info" green.

Verified: 25/25 entries per tab, no cross-contamination, no horizontal
overflow at 500-1400px, tabs wrap below the title under ~600px, and dark
mode uses the theme variables.
This commit is contained in:
2026-09-11 15:42:45 +03:00
parent 84b5cd3d48
commit b4c3f65636
3 changed files with 188 additions and 24 deletions
+16 -2
View File
@@ -33,7 +33,20 @@ def dashboard():
storage_mb += os.path.getsize(filepath)
storage_mb = round(storage_mb / (1024 * 1024), 2) # Convert to MB
server_logs = get_recent_logs(20)
# Recent Activity.
#
# Player feedback ("Feedback received from ...") is a ~15s heartbeat: it is
# ~84% of all log rows, and 18 of the newest 20. Showing it unfiltered
# buries the events an operator actually cares about (uploads, logins,
# HTTPS changes, deployments), so the two kinds are queried separately and
# the card defaults to real activity, with heartbeats available on demand.
#
# The split is done in SQL rather than by filtering one wide window in
# Python: with a fleet of players the heartbeat rate is high enough that a
# fixed window would return mostly noise and only a handful of real events.
HEARTBEAT_PREFIX = 'Feedback received from'
activity_logs = get_recent_logs(25, exclude_prefix=HEARTBEAT_PREFIX)
heartbeat_logs = get_recent_logs(25, include_prefix=HEARTBEAT_PREFIX)
# Per-playlist overview for the dashboard: which playlist holds what, and
# which players consume it. This answers "where should I add media / which
@@ -69,7 +82,8 @@ def dashboard():
total_playlists=total_playlists,
total_content=total_content,
storage_mb=storage_mb,
recent_logs=server_logs,
recent_logs=activity_logs,
heartbeat_logs=heartbeat_logs,
playlist_overview=playlist_overview,
unassigned_players=unassigned_players
)