diff --git a/app/blueprints/main.py b/app/blueprints/main.py index d4fc239..322c377 100644 --- a/app/blueprints/main.py +++ b/app/blueprints/main.py @@ -34,14 +34,44 @@ def dashboard(): storage_mb = round(storage_mb / (1024 * 1024), 2) # Convert to MB server_logs = get_recent_logs(20) - + + # Per-playlist overview for the dashboard: which playlist holds what, and + # which players consume it. This answers "where should I add media / which + # playlist needs editing?" without opening each playlist. + # + # Players are fetched in a single query and grouped in Python rather than + # relying on Playlist.players per row, to avoid one query per playlist. + playlists = Playlist.query.order_by(Playlist.name).all() + players_by_playlist = {} + for player in Player.query.order_by(Player.name).all(): + if player.playlist_id is not None: + players_by_playlist.setdefault(player.playlist_id, []).append(player) + + playlist_overview = [] + for playlist in playlists: + assigned = players_by_playlist.get(playlist.id, []) + playlist_overview.append({ + 'playlist': playlist, + 'content_count': playlist.contents.count(), + 'total_duration': playlist.total_duration, + 'players': assigned, + 'player_count': len(assigned), + 'online_count': sum(1 for p in assigned if p.is_online), + }) + + # Players with no playlist produce no content on screen, so surface them. + unassigned_players = Player.query.filter(Player.playlist_id.is_(None))\ + .order_by(Player.name).all() + return render_template( 'dashboard.html', total_players=total_players, total_playlists=total_playlists, total_content=total_content, storage_mb=storage_mb, - recent_logs=server_logs + recent_logs=server_logs, + playlist_overview=playlist_overview, + unassigned_players=unassigned_players ) diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html index 29be11b..e4840e7 100644 --- a/app/templates/dashboard.html +++ b/app/templates/dashboard.html @@ -43,73 +43,313 @@ -
+ Pick a playlist to add media to or edit. Players listed here are the devices + that will show it. +
-+ No players assigned — content here is not shown on any screen yet. + Assign a player → +
+ {% endif %} ++ No playlists yet. + Create your first playlist → +
+ {% endif %} + + {% if unassigned_players %} +✅ All systems operational
-� Playlist-centric architecture active
+📋 Playlist-centric architecture active
🔄 Groups removed - Streamlined workflow
⚡ DigiServer v2.0