diff --git a/frontend/js/views/dashboard.js b/frontend/js/views/dashboard.js index f9dfa64..1194c8c 100644 --- a/frontend/js/views/dashboard.js +++ b/frontend/js/views/dashboard.js @@ -105,17 +105,35 @@ function renderDeviceCard(device) { `; } -function renderGroupSection(group, devices) { +function getGroupPlaylistLabel(devices, playlists) { + const playlistMap = new Map((playlists || []).map(p => [p.id, p])); + const assigned = devices.filter(d => d.playlist_id).map(d => d.playlist_id); + if (assigned.length === 0) return ''; + const unique = [...new Set(assigned)]; + if (unique.length === 1) { + const pl = playlistMap.get(unique[0]); + return pl ? esc(pl.name) : 'Unknown playlist'; + } + return 'Mixed playlists'; +} + +function renderGroupSection(group, devices, playlists) { const onlineCount = devices.filter(d => d.status === 'online').length; + const playlistLabel = getGroupPlaylistLabel(devices, playlists); return `
${esc(group.name)} ${devices.length} device${devices.length !== 1 ? 's' : ''} · ${onlineCount} online + ${playlistLabel ? `Playlist: ${playlistLabel}` : ''}
${devices.length > 0 ? ` + - ${devices.map(d => ``).join('')} + ${devices.map(d => ``).join('')} @@ -42,9 +50,40 @@ export async function render(container) {