diff --git a/web/src/lib/components/library-combobox.svelte b/web/src/lib/components/library-combobox.svelte index 22a65ca..29f5fb9 100644 --- a/web/src/lib/components/library-combobox.svelte +++ b/web/src/lib/components/library-combobox.svelte @@ -97,7 +97,7 @@ role="combobox" aria-expanded={open} > - {selectedLabel || 'Select Library'} + {'Select Library'} {/snippet} diff --git a/web/src/lib/components/ui/switch/index.ts b/web/src/lib/components/ui/switch/index.ts new file mode 100644 index 0000000..129f8f5 --- /dev/null +++ b/web/src/lib/components/ui/switch/index.ts @@ -0,0 +1,7 @@ +import Root from './switch.svelte'; + +export { + Root, + // + Root as Switch +}; diff --git a/web/src/lib/components/ui/switch/switch.svelte b/web/src/lib/components/ui/switch/switch.svelte new file mode 100644 index 0000000..01f9f75 --- /dev/null +++ b/web/src/lib/components/ui/switch/switch.svelte @@ -0,0 +1,27 @@ + + + + + diff --git a/web/src/routes/dashboard/movies/[movieId=uuid]/+page.svelte b/web/src/routes/dashboard/movies/[movieId=uuid]/+page.svelte index b035a91..306efbe 100644 --- a/web/src/routes/dashboard/movies/[movieId=uuid]/+page.svelte +++ b/web/src/routes/dashboard/movies/[movieId=uuid]/+page.svelte @@ -14,6 +14,7 @@ import LibraryCombobox from '$lib/components/library-combobox.svelte'; import { Label } from '$lib/components/ui/label'; import { base } from '$app/paths'; + import { Switch } from '$lib/components/ui/switch/index.js'; let movie: PublicMovie = page.data.movie; let user: () => User = getContext('user'); @@ -57,7 +58,7 @@

{getFullyQualifiedMediaName(movie)}

-
+
{#if movie.id} @@ -75,24 +76,16 @@ {movie.overview}

-
+
{#if user().is_superuser} -
- - -
-
+ -
{/if}
-
diff --git a/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte b/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte index feb4709..10101e5 100644 --- a/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte +++ b/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte @@ -6,7 +6,7 @@ import { goto } from '$app/navigation'; import { ImageOff } from 'lucide-svelte'; import * as Table from '$lib/components/ui/table/index.js'; - import { getContext } from 'svelte'; + import { getContext, onMount } from 'svelte'; import type { PublicShow, RichShowTorrent, User } from '$lib/types.js'; import { getFullyQualifiedMediaName } from '$lib/utils'; import DownloadSeasonDialog from '$lib/components/download-season-dialog.svelte'; @@ -16,6 +16,7 @@ import RequestSeasonDialog from '$lib/components/request-season-dialog.svelte'; import MediaPicture from '$lib/components/media-picture.svelte'; import { Checkbox } from '$lib/components/ui/checkbox/index.js'; + import { Switch } from '$lib/components/ui/switch/index.js'; import { toast } from 'svelte-sonner'; import { Label } from '$lib/components/ui/label'; import LibraryCombobox from '$lib/components/library-combobox.svelte'; @@ -25,13 +26,15 @@ let torrents: RichShowTorrent = page.data.torrentsData; import { base } from '$app/paths'; + let continuousDownloadEnabled = $state(show().continuous_download); + async function toggle_continuous_download() { - const urlString = `${apiUrl}/tv/shows/${show().id}/continuousDownload?continuous_download=${!show().continuous_download}`; + const urlString = `${apiUrl}/tv/shows/${show().id}/continuousDownload?continuous_download=${!continuousDownloadEnabled}`; console.log( 'Toggling continuous download for show', show().name, 'to', - !show().continuous_download + !continuousDownloadEnabled ); const response = await fetch(urlString, { method: 'POST', @@ -41,10 +44,15 @@ const errorText = await response.text(); toast.error('Failed to toggle continuous download: ' + errorText); } else { - show().continuous_download = !show().continuous_download; + continuousDownloadEnabled = !continuousDownloadEnabled; toast.success('Continuous download toggled successfully.'); } } + + /* $effect(()=>{ + continuousDownloadEnabled; + toggle_continuous_download(); + });*/ @@ -85,7 +93,7 @@

{getFullyQualifiedMediaName(show())}

-
+
{#if show().id} @@ -103,30 +111,23 @@ {show().overview}

-
+
{#if user().is_superuser} {#if !show().ended} -
- { - toggle_continuous_download(); - }} +
+ continuousDownloadEnabled, toggle_continuous_download} id="continuous-download-checkbox" /> -
{/if} -
- - -
-
+ -
{/if}