From 442d7ca7408bbe7545f6358ff4937028dfbcd701 Mon Sep 17 00:00:00 2001 From: Josh Pinto Date: Thu, 21 Aug 2025 08:31:20 -0400 Subject: [PATCH] :sparkles: Add playlist deletion --- backend/app.py | 5 +- frontend/src/Layout.svelte | 25 +++++++- frontend/src/pages/Playlist.svelte | 95 +++++++++++++++++++++++------- 3 files changed, 99 insertions(+), 26 deletions(-) diff --git a/backend/app.py b/backend/app.py index 4cd1190..55c8bbf 100644 --- a/backend/app.py +++ b/backend/app.py @@ -586,8 +586,6 @@ def start_playlist(playlist_id: int): @app.post('/playlists/stop') def stop_playlist(): - if device_store.status != "online" or not device_store.amp: - raise HTTPException(status_code=400, detail="Device not online") try: device_store.active_playlist_details = { "id": None, @@ -599,7 +597,8 @@ def stop_playlist(): "first_tap_time": None, "second_tap_time": None, } - device_store.amp.set_qa_slots([0, 0]) + if not (device_store.status != "online" or not device_store.amp): + device_store.amp.set_qa_slots([0, 0]) except Exception as e: return {"error": str(e)} return {"ok": True} diff --git a/frontend/src/Layout.svelte b/frontend/src/Layout.svelte index 9571e2c..c9dd4a9 100644 --- a/frontend/src/Layout.svelte +++ b/frontend/src/Layout.svelte @@ -40,7 +40,7 @@ memoryUsage, processorUsage, firmwareVersion, - activePlaylist, + activePlaylist, playlists, playlistsLoading, playlistItems, @@ -139,7 +139,7 @@ processorUsage.set(msg.processor_usage ?? processorUsage); firmwareVersion.set(msg.firmware_version ?? firmwareVersion); allPresets.set(msg.presets ?? allPresets); - activePlaylist.set(msg.active_playlist ?? null); + activePlaylist.set(msg.active_playlist ?? null); if ($allPresets && $allPresets.length > 0) { presetsLoading.set(false); } @@ -229,7 +229,6 @@ $effect(async () => { if ($routerLocation.split('/').includes('playlist')) { - await refreshPlaylistItems(); } }); @@ -277,6 +276,26 @@ if ($routerLocation.split('/').includes('playlist')) { refreshPlaylistItems(); } + } else if ($layoutEvents.type === 'playlist_deleted') { + toaster.success({ + title: 'Playlist Deleted', + description: 'The playlist has been successfully deleted.' + }); + fetchPlaylists(); + + if ($routerLocation.split('/').includes('playlist')) { + window.location.href = '/#/playlists'; + } + } else if ($layoutEvents.type === 'playlist_started') { + toaster.success({ + title: 'Playlist Started', + description: `The playlist has been started successfully.` + }); + } else if ($layoutEvents.type === 'playlist_stopped') { + toaster.success({ + title: 'Playlist Stopped', + description: `The playlist has been stopped successfully.` + }); } layoutEvents.set(null); diff --git a/frontend/src/pages/Playlist.svelte b/frontend/src/pages/Playlist.svelte index 5554a16..6902360 100644 --- a/frontend/src/pages/Playlist.svelte +++ b/frontend/src/pages/Playlist.svelte @@ -1,7 +1,11 @@