Skip to content

Commit

Permalink
feat: add all backend settings to the forms (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidemarcoli authored Dec 10, 2024
1 parent 2072cb9 commit 634e2a0
Show file tree
Hide file tree
Showing 7 changed files with 290 additions and 160 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ vite.config.ts.timestamp-*
.idea
/.vs
/package-lock.json
bun.lockb
.vscode
/config
/config
server-config.json
openapi*.log
11 changes: 11 additions & 0 deletions src/lib/forms/content-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,17 @@
<NumberField {form} name="trakt_popular_count" {formData} stepValue={1} />
</div>
{/if}

<div transition:slide>
<CheckboxField {form} name="trakt_fetch_most_watched" {formData} />
</div>

{#if $formData.trakt_fetch_most_watched}
<div transition:slide>
<NumberField {form} name="trakt_most_watched_count" {formData} stepValue={1} />
<TextField {form} name="trakt_most_watched_period" {formData} />
</div>
{/if}
{/if}

<Separator class="mt-4" />
Expand Down
113 changes: 74 additions & 39 deletions src/lib/forms/general-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@

<form method="POST" action={actionUrl} use:enhance class="my-8 flex flex-col gap-2">
<CheckboxField {form} name="debug" {formData} fieldDescription="Requires restart" />
<CheckboxField {form} name="debug_database" {formData} fieldDescription="Requires restart" />
<CheckboxField {form} name="force_refresh" {formData} fieldDescription="Requires restart" />
<CheckboxField
{form}
name="map_metadata"
{formData}
fieldDescription="Requires restart, inits an empty database based on the symlinked files"
/>
<CheckboxField {form} name="log" {formData} fieldDescription="Requires restart" />
<TextField {form} name="rclone_path" {formData} />
<TextField {form} name="library_path" {formData} />
Expand All @@ -71,6 +79,53 @@
fieldDescription="In seconds"
/>

<ArrayField {form} name="video_extensions" {formData}>
{#each $formData.video_extensions as _, i}
<Form.ElementField {form} name="video_extensions[{i}]">
<Form.Control let:attrs>
<div class="flex items-center gap-2">
<Input
type="text"
spellcheck="false"
autocomplete="false"
{...attrs}
bind:value={$formData.video_extensions[i]}
/>

<div class="flex items-center gap-2">
<Form.Button
type="button"
size="sm"
variant="destructive"
on:click={() => {
removeField('video_extensions', i);
}}
>
<Trash2 class="h-4 w-4" />
</Form.Button>
</div>
</div>
</Form.Control>
</Form.ElementField>
{/each}

<div class="flex w-full items-center justify-between gap-2">
<p class="text-sm text-muted-foreground">Add Video Extension</p>
<Form.Button
type="button"
size="sm"
variant="outline"
on:click={() => {
addField('video_extensions');
}}
>
<Plus class="h-4 w-4" />
</Form.Button>
</div>
</ArrayField>

<TextField {form} name="proxy_url" label="Downloader Proxy URL" {formData} />

<GroupCheckboxField
fieldTitle="Downloaders"
fieldDescription="Enable only one downloader at a time"
Expand All @@ -82,58 +137,44 @@
{formData}
isForGroup={true}
/>
<CheckboxField
{form}
name="alldebrid_enabled"
label="All-Debrid"
{formData}
isForGroup={true}
/>
<CheckboxField {form} name="torbox_enabled" label="Torbox" {formData} isForGroup={true} />
<CheckboxField {form} name="alldebrid_enabled" label="AllDebrid" {formData} isForGroup={true} />
<CheckboxField {form} name="torbox_enabled" label="TorBox" {formData} isForGroup={true} />
</GroupCheckboxField>

{#if $formData.realdebrid_enabled}
<div transition:slide>
<TextField {form} name="realdebrid_api_key" {formData} isProtected={true} />
</div>

<div transition:slide>
<CheckboxField
<TextField
{form}
name="realdebrid_proxy_enabled"
label="Real-Debrid Proxy"
name="realdebrid_api_key"
label="Real-Debrid API Key"
{formData}
fieldDescription="Use proxy for Real-Debrid API"
isProtected={true}
/>
</div>

{#if $formData.realdebrid_proxy_enabled}
<div transition:slide>
<TextField {form} name="realdebrid_proxy_url" {formData} />
</div>
{/if}
{/if}

{#if $formData.alldebrid_enabled}
<div transition:slide>
<TextField {form} name="alldebrid_api_key" {formData} isProtected={true} />
<TextField
{form}
name="alldebrid_api_key"
label="AllDebrid API Key"
{formData}
isProtected={true}
/>
</div>
{/if}

{#if $formData.torbox_enabled}
<div transition:slide>
<CheckboxField
<TextField
{form}
name="alldebrid_proxy_enabled"
label="All-Debrid Proxy"
name="torbox_api_key"
label="TorBox API Key"
{formData}
fieldDescription="Use proxy for All-Debrid API"
isProtected={true}
/>
</div>

{#if $formData.alldebrid_proxy_enabled}
<div transition:slide>
<TextField {form} name="alldebrid_proxy_url" {formData} />
</div>
{/if}
{/if}

<NumberField
Expand Down Expand Up @@ -165,12 +206,6 @@
fieldDescription="In MB, -1 for unlimited"
/>

{#if $formData.torbox_enabled}
<div transition:slide>
<TextField {form} name="torbox_api_key" {formData} />
</div>
{/if}

<CheckboxField {form} name="notifications_enabled" label="Notifications" {formData} />

{#if $formData.notifications_enabled}
Expand Down
Loading

0 comments on commit 634e2a0

Please sign in to comment.