Skip to content

Commit

Permalink
fix: add new settings changes to frontend (#416)
Browse files Browse the repository at this point in the history
* fix: add new settings changes to frontend

* chore: formatted frontend files and added eslint rules to ignore some errors
  • Loading branch information
AyushSehrawat authored Jun 16, 2024
1 parent f2b86e0 commit 38c1b75
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 3 deletions.
9 changes: 9 additions & 0 deletions frontend/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ export default [
parserOptions: {
parser: ts.parser
}
},
rules: {
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^\\$\\$(Props|Events|Slots|Generic)$'
}
]
}
},
{
Expand Down
49 changes: 48 additions & 1 deletion frontend/src/lib/forms/content-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
<div transition:slide>
<NumberField {form} name="overseerr_update_interval" {formData} stepValue={1} />
</div>

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

{#if $formData.mdblist_enabled}
Expand Down Expand Up @@ -138,7 +142,50 @@

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

<div class="flex items-center gap-2">
<Form.Button
type="button"
size="sm"
variant="destructive"
on:click={() => {
removeField('plex_watchlist_rss', 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 Plex Watchlist RSS</p>
<Form.Button
type="button"
size="sm"
variant="outline"
on:click={() => {
addField('plex_watchlist_rss');
}}
>
<Plus class="h-4 w-4" />
</Form.Button>
</div>
</ArrayField>
</div>

<div transition:slide>
Expand Down
35 changes: 35 additions & 0 deletions frontend/src/lib/forms/general-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { generalSettingsSchema, type GeneralSettingsSchema } from '$lib/forms/helpers';
import { toast } from 'svelte-sonner';
import TextField from './components/text-field.svelte';
import NumberField from './components/number-field.svelte';
import CheckboxField from './components/checkbox-field.svelte';
import GroupCheckboxField from './components/group-checkbox-field.svelte';
import { Loader2 } from 'lucide-svelte';
Expand Down Expand Up @@ -38,6 +39,40 @@
<TextField {form} name="rclone_path" {formData} />
<TextField {form} name="library_path" {formData} />

<!-- movie_filesize_min, movie_filesize_max, episode_filesize_min, episode_filesize_max -->
<NumberField
{form}
name="movie_filesize_min"
label="Minimum Movie Filesize"
{formData}
stepValue={0.1}
fieldDescription="Filesize in MB"
/>
<NumberField
{form}
name="movie_filesize_max"
label="Maximum Movie Filesize"
{formData}
stepValue={0.1}
fieldDescription="Filesize in MB. Set to -1 for no limit"
/>
<NumberField
{form}
name="episode_filesize_min"
label="Minimum Episode Filesize"
{formData}
stepValue={0.1}
fieldDescription="Filesize in MB"
/>
<NumberField
{form}
name="episode_filesize_max"
label="Maximum Episode Filesize"
{formData}
stepValue={0.1}
fieldDescription="Filesize in MB. Set to -1 for no limit"
/>

<GroupCheckboxField
fieldTitle="Downloaders"
fieldDescription="Enable only one downloader at a time"
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/lib/forms/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export const generalSettingsSchema = z.object({
log: z.boolean().default(true),
rclone_path: z.string().min(1),
library_path: z.string().min(1),
movie_filesize_min: z.coerce.number().gte(0).int().optional().default(200),
movie_filesize_max: z.coerce.number().gte(-1).int().optional().default(-1),
episode_filesize_min: z.coerce.number().gte(0).int().optional().default(40),
episode_filesize_max: z.coerce.number().gte(-1).int().optional().default(-1),
realdebrid_enabled: z.boolean().default(false),
realdebrid_api_key: z.string().optional().default(''),
torbox_enabled: z.boolean().default(false),
Expand All @@ -61,6 +65,10 @@ export function generalSettingsToPass(data: any) {
log: data.data.log,
rclone_path: data.data.symlink.rclone_path,
library_path: data.data.symlink.library_path,
movie_filesize_min: data.data.movie_filesize_min,
movie_filesize_max: data.data.movie_filesize_max,
episode_filesize_min: data.data.episode_filesize_min,
episode_filesize_max: data.data.episode_filesize_max,
realdebrid_enabled: data.data.downloaders.real_debrid.enabled,
realdebrid_api_key: data.data.downloaders.real_debrid?.api_key || '',
torbox_enabled: data.data.downloaders.torbox.enabled,
Expand Down Expand Up @@ -88,6 +96,10 @@ export function generalSettingsToSet(form: SuperValidated<Infer<GeneralSettingsS
{
key: 'downloaders',
value: {
movie_filesize_min: form.data.movie_filesize_min,
movie_filesize_max: form.data.movie_filesize_max,
episode_filesize_min: form.data.episode_filesize_min,
episode_filesize_max: form.data.episode_filesize_max,
real_debrid: {
enabled: form.data.realdebrid_enabled,
api_key: form.data.realdebrid_api_key
Expand Down Expand Up @@ -276,7 +288,7 @@ export const contentSettingsSchema = z.object({
mdblist_update_interval: z.coerce.number().gte(0).int().optional().default(300),
mdblist_lists: z.string().array().optional().default([]),
plex_watchlist_enabled: z.boolean().default(false),
plex_watchlist_rss: z.string().optional().default(''),
plex_watchlist_rss: z.array(z.string()).optional().default([]),
plex_watchlist_update_interval: z.coerce.number().gte(0).int().optional().default(60),
listrr_enabled: z.boolean().default(false),
listrr_api_key: z.string().optional().default(''),
Expand Down Expand Up @@ -307,7 +319,7 @@ export function contentSettingsToPass(data: any) {
mdblist_update_interval: data.data.content.mdblist?.update_interval || 300,
mdblist_lists: data.data.content.mdblist?.lists || [],
plex_watchlist_enabled: data.data.content.plex_watchlist.enabled,
plex_watchlist_rss: data.data.content.plex_watchlist?.rss || '',
plex_watchlist_rss: data.data.content.plex_watchlist?.rss || [],
plex_watchlist_update_interval: data.data.content.plex_watchlist?.update_interval || 60,
listrr_enabled: data.data.content.listrr.enabled,
listrr_api_key: data.data.content.listrr?.api_key || '',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/routes/settings/content/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const actions: Actions = {

try {
const data = await setSettings(event.fetch, toSet);
console.log(data);
if (!data.data.success) {
return message(form, `Service(s) failed to initialize. Please check your settings.`, {
status: 400
Expand Down

0 comments on commit 38c1b75

Please sign in to comment.