From ca8a1022771f67f4a378902fe9645a5efca78f26 Mon Sep 17 00:00:00 2001
From: maxDorninger <97409287+maxDorninger@users.noreply.github.com>
Date: Sun, 22 Jun 2025 14:48:40 +0200
Subject: [PATCH] add ui to change the continuous download attribute of a show
---
web/package-lock.json | 9 +++--
web/package.json | 2 +-
.../components/ui/checkbox/checkbox.svelte | 35 +++++++++++++++++
web/src/lib/components/ui/checkbox/index.ts | 7 ++++
web/src/lib/types.ts | 3 ++
.../dashboard/tv/[showId=uuid]/+page.svelte | 39 ++++++++++++++++++-
6 files changed, 88 insertions(+), 7 deletions(-)
create mode 100644 web/src/lib/components/ui/checkbox/checkbox.svelte
create mode 100644 web/src/lib/components/ui/checkbox/index.ts
diff --git a/web/package-lock.json b/web/package-lock.json
index cf798fb..b5a48b8 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -22,7 +22,7 @@
"@eslint/compat": "^1.2.5",
"@eslint/js": "^9.18.0",
"@fontsource/fira-mono": "^5.0.0",
- "@lucide/svelte": "^0.503.0",
+ "@lucide/svelte": "^0.482.0",
"@neoconfetti/svelte": "^2.0.0",
"@sveltejs/adapter-static": "^3.0.8",
"@sveltejs/enhanced-img": "^0.6.0",
@@ -1928,10 +1928,11 @@
}
},
"node_modules/@lucide/svelte": {
- "version": "0.503.0",
- "resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-0.503.0.tgz",
- "integrity": "sha512-Y7Q8pHnX2YG8Ef4a/VnYFN9tTAJS33MiS78vQtPiyp5iiWuBlTMoViMiRUxQb7U9Ro46RdJ0kpCADvvha3Z2rA==",
+ "version": "0.482.0",
+ "resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-0.482.0.tgz",
+ "integrity": "sha512-n2ycHU9cNcleRDwwpEHBJ6pYzVhHIaL3a+9dQa8kns9hB2g05bY+v2p2KP8v0pZwtNhYTHk/F2o2uZ1bVtQGhw==",
"dev": true,
+ "license": "ISC",
"peerDependencies": {
"svelte": "^5"
}
diff --git a/web/package.json b/web/package.json
index 0d5d9d3..063b5c2 100644
--- a/web/package.json
+++ b/web/package.json
@@ -17,7 +17,7 @@
"@eslint/compat": "^1.2.5",
"@eslint/js": "^9.18.0",
"@fontsource/fira-mono": "^5.0.0",
- "@lucide/svelte": "^0.503.0",
+ "@lucide/svelte": "^0.482.0",
"@neoconfetti/svelte": "^2.0.0",
"@sveltejs/adapter-static": "^3.0.8",
"@sveltejs/enhanced-img": "^0.6.0",
diff --git a/web/src/lib/components/ui/checkbox/checkbox.svelte b/web/src/lib/components/ui/checkbox/checkbox.svelte
new file mode 100644
index 0000000..de5338d
--- /dev/null
+++ b/web/src/lib/components/ui/checkbox/checkbox.svelte
@@ -0,0 +1,35 @@
+
+
+
+ {#snippet children({checked, indeterminate})}
+
+ {#if indeterminate}
+
+ {:else}
+
+ {/if}
+
+ {/snippet}
+
diff --git a/web/src/lib/components/ui/checkbox/index.ts b/web/src/lib/components/ui/checkbox/index.ts
new file mode 100644
index 0000000..e8b5080
--- /dev/null
+++ b/web/src/lib/components/ui/checkbox/index.ts
@@ -0,0 +1,7 @@
+import Root from "./checkbox.svelte";
+
+export {
+ Root,
+ //
+ Root as Checkbox,
+};
diff --git a/web/src/lib/types.ts b/web/src/lib/types.ts
index 0e6012f..a6b85e0 100644
--- a/web/src/lib/types.ts
+++ b/web/src/lib/types.ts
@@ -103,6 +103,7 @@ export interface Show {
metadata_provider: string;
seasons: Season[]; // items: { $ref: #/components/schemas/Season }, type: array
id: string; // type: string, format: uuid
+ continuous_download: boolean;
}
export interface PublicShow {
@@ -113,6 +114,8 @@ export interface PublicShow {
metadata_provider: string;
seasons: PublicSeason[]; // items: { $ref: #/components/schemas/Season }, type: array
id: string; // type: string, format: uuid
+ continuous_download: boolean;
+
}
export interface Torrent {
diff --git a/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte b/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte
index fe265c2..cc1ff1f 100644
--- a/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte
+++ b/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte
@@ -16,11 +16,32 @@
import RequestSeasonDialog from '$lib/components/request-season-dialog.svelte';
import {browser} from "$app/environment";
import ShowPicture from "$lib/components/show-picture.svelte";
+ import {Checkbox} from "$lib/components/ui/checkbox/index.js";
+ import {toast} from 'svelte-sonner';
+ import {Label} from "$lib/components/ui/label";
const apiUrl = env.PUBLIC_API_URL
- let show: Show = getContext('show');
- let user: User = getContext('user');
+ let show: () => Show = getContext('show');
+ let user: () => User = getContext('user');
let torrents: RichShowTorrent = page.data.torrentsData;
+
+ async function toggle_continuous_download() {
+ let url = new URL(apiUrl + "/tv/shows/" + show().id + "/continuousDownload");
+ url.searchParams.append('continuous_download', !show().continuous_download);
+ console.log("Toggling continuous download for show", show().name, "to", !show().continuous_download);
+ const response = await fetch(url, {
+ method: 'POST',
+ credentials: 'include'
+ });
+ if (!response.ok) {
+ const errorText = await response.text();
+ toast.error("Failed to toggle continuous download: " + errorText);
+ } else {
+ show().continuous_download = !show().continuous_download;
+ toast.success("Continuous download toggled successfully.");
+ }
+ }
+