Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add all backend settings to the forms #184

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Comment on lines +16 to +17
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Configuration setup is well documented, but example files are missing

The project has clear documentation in README.md about environment variables and configuration through docker-compose.yml, but it would benefit from example configuration files. Consider:

  • Adding an example config directory (e.g., config.example/) with template files
  • Including a server-config.example.json to demonstrate the expected format
🔗 Analysis chain

Verify availability of example configuration files.

Ignoring both /config and server-config.json might make it difficult for new developers to set up the project. Please ensure that:

  1. Example/template configuration files are provided
  2. Setup instructions are documented in README

Let's verify the existence of example configurations:


Let me gather more information about configuration-related files and documentation.


Let me check the complete environment variables documentation in the README to ensure proper setup instructions are available.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for example configuration files and documentation

# Check for example config files
echo "Checking for example configuration files..."
fd -t f -e json -e yaml -e yml -e example "config|server-config" 

# Check for setup documentation in README
echo "Checking README for configuration setup instructions..."
rg -i "config|configuration|setup" "README.md"

Length of output: 571


Script:

#!/bin/bash
# Check for example/template configuration files with different extensions and naming patterns
echo "Checking for example/template configuration files..."
fd -t f "example|sample|template|default" --exec grep -l "config"

# Check docker-compose.yml for configuration details
echo "\nChecking docker-compose.yml..."
cat docker-compose.yml

# Look for configuration setup in documentation files
echo "\nChecking documentation files..."
fd -t f -e md | xargs rg -i "configuration setup|config setup|environment variables"

Length of output: 1175


Script:

#!/bin/bash
# Get the complete environment variables section from README
echo "Checking environment variables documentation..."
rg -A 10 "### Environment variables" README.md

# Check if there's a sample/example config directory that might be ignored
echo "\nChecking for example config directory..."
fd "example.*config|sample.*config|template.*config" -t d

Length of output: 882

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} />
Gaisberg marked this conversation as resolved.
Show resolved Hide resolved
</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"
Gaisberg marked this conversation as resolved.
Show resolved Hide resolved
/>
Comment on lines +55 to +60
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Enhance map_metadata field description

The description could be clearer about the relationship between the database and symlinked files.

Consider updating the description to: "Requires restart. Initializes an empty database and maps metadata from the existing symlinked media 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"
Gaisberg marked this conversation as resolved.
Show resolved Hide resolved
{...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>
Gaisberg marked this conversation as resolved.
Show resolved Hide resolved

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Add URL validation and description for proxy field

The proxy URL field should include format validation and a description of supported proxy protocols.

Consider updating the field to:

-<TextField {form} name="proxy_url" label="Downloader Proxy URL" {formData} />
+<TextField 
+  {form} 
+  name="proxy_url" 
+  label="Downloader Proxy URL" 
+  {formData}
+  pattern="^(http|https|socks4|socks5)://.*$"
+  fieldDescription="Supported formats: http://, https://, socks4://, socks5://"
+/>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<TextField {form} name="proxy_url" label="Downloader Proxy URL" {formData} />
<TextField
{form}
name="proxy_url"
label="Downloader Proxy URL"
{formData}
pattern="^(http|https|socks4|socks5)://.*$"
fieldDescription="Supported formats: http://, https://, socks4://, socks5://"
/>


<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} />
Gaisberg marked this conversation as resolved.
Show resolved Hide resolved
</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
Loading