Skip to content

Commit

Permalink
Merge pull request #60 from rivenmedia/dev
Browse files Browse the repository at this point in the history
feat: ui improvements
  • Loading branch information
AyushSehrawat authored Aug 11, 2024
2 parents 5e8d40b + 9ab525b commit 9e3d470
Show file tree
Hide file tree
Showing 17 changed files with 375 additions and 20 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.idea
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
.idea
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
pnpm-lock.yaml
package-lock.json
yarn.lock
CHANGELOG.md
CHANGELOG.md
.idea
12 changes: 8 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/sh
# Export the ORIGIN and BACKEND_URL environment variables
export ORIGIN=${ORIGIN}
if [ -z "$ORIGIN" ]; then
echo "ORIGIN is not set"
export PROTOCOL_HEADER=x-forwarded-proto
export HOST_HEADER=x-forwarded-host
else
export ORIGIN=${ORIGIN}
fi

export BACKEND_URL=${BACKEND_URL}
export DIALECT=${DIALECT}
export DATABASE_URL=${DATABASE_URL}

# Execute the command provided to the script
exec "$@"
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ export default [
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/', 'src/lib/components/ui/']
ignores: ['build/', '.svelte-kit/', 'dist/', 'src/lib/components/ui/', '.idea/']
}
];
59 changes: 59 additions & 0 deletions src/lib/forms/general-form.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,65 @@
</div>
{/if}

<GroupCheckboxField fieldTitle="Post Processing" fieldDescription="Post processing options">
<CheckboxField
{form}
name="subliminal_enabled"
label="Subtitles Download"
{formData}
isForGroup={true}
/>
</GroupCheckboxField>

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

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

<Separator class="mt-4" />
<div class="flex w-full justify-end">
<Form.Button disabled={$delayed} type="submit" size="sm" class="w-full lg:max-w-max">
Expand Down
20 changes: 17 additions & 3 deletions src/lib/forms/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const generalSettingsToGet: string[] = [
'symlink',
'downloaders',
'database',
'notifications'
'notifications',
'post_processing'
];

export const generalSettingsSchema = z.object({
Expand Down Expand Up @@ -38,7 +39,9 @@ export const generalSettingsSchema = z.object({
notifications_enabled: z.boolean().default(false),
notifications_title: z.string().optional().default('Riven completed something'),
notifications_on_item_type: z.string().array().optional().default([]),
notifications_service_urls: z.string().array().optional().default([])
notifications_service_urls: z.string().array().optional().default([]),
subliminal_enabled: z.boolean().default(false),
subliminal_languages: z.string().array().optional().default([])
});
export type GeneralSettingsSchema = typeof generalSettingsSchema;

Expand Down Expand Up @@ -68,7 +71,9 @@ export function generalSettingsToPass(data: any) {
notifications_enabled: data.data.notifications.enabled,
notifications_title: data.data.notifications.title,
notifications_on_item_type: data.data.notifications.on_item_type,
notifications_service_urls: data.data.notifications.service_urls
notifications_service_urls: data.data.notifications.service_urls,
subliminal_enabled: data.data.post_processing.subliminal.enabled,
subliminal_languages: data.data.post_processing.subliminal?.languages
};
}

Expand Down Expand Up @@ -129,6 +134,15 @@ export function generalSettingsToSet(form: SuperValidated<Infer<GeneralSettingsS
on_item_type: form.data.notifications_on_item_type,
service_urls: form.data.notifications_service_urls
}
},
{
key: 'post_processing',
value: {
subliminal: {
enabled: form.data.subliminal_enabled,
languages: form.data.subliminal_languages
}
}
}
];
}
Expand Down
26 changes: 23 additions & 3 deletions src/lib/server/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export interface MediaItem {
active_stream: Json | null;
aired_at: Timestamp | null;
alternative_folder: string | null;
blacklisted_streams: Json | null;
country: string | null;
file: string | null;
folder: string | null;
Expand All @@ -53,6 +52,7 @@ export interface MediaItem {
requested_by: string | null;
scraped_at: Timestamp | null;
scraped_times: number | null;
symlink_path: string | null;
symlinked: boolean | null;
symlinked_at: Timestamp | null;
symlinked_times: number | null;
Expand All @@ -79,15 +79,32 @@ export interface Show {

export interface Stream {
_id: Generated<number>;
blacklisted: boolean;
infohash: string;
lev_ratio: number;
parent_id: number;
parsed_title: string;
rank: number;
raw_title: string;
}

export interface StreamBlacklistRelation {
_id: Generated<number>;
media_item_id: number;
stream_id: number;
}

export interface StreamRelation {
_id: Generated<number>;
child_id: number;
parent_id: number;
}

export interface Subtitle {
_id: Generated<number>;
file: string | null;
language: string;
parent_id: number;
}

export interface DB {
alembic_version: AlembicVersion;
Episode: Episode;
Expand All @@ -96,4 +113,7 @@ export interface DB {
Season: Season;
Show: Show;
Stream: Stream;
StreamBlacklistRelation: StreamBlacklistRelation;
StreamRelation: StreamRelation;
Subtitle: Subtitle;
}
101 changes: 100 additions & 1 deletion src/routes/[type]/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
import type { PageData } from './$types';
import Header from '$lib/components/header.svelte';
import { Badge } from '$lib/components/ui/badge';
import { Star, Trash2, Download, ArrowUpRight, Tag, Wrench } from 'lucide-svelte';
import {
Star,
Trash2,
Download,
ArrowUpRight,
Tag,
Wrench,
RotateCcw,
CirclePower
} from 'lucide-svelte';
import * as Carousel from '$lib/components/ui/carousel/index.js';
import { Button } from '$lib/components/ui/button';
import * as Tooltip from '$lib/components/ui/tooltip';
Expand Down Expand Up @@ -38,6 +47,32 @@
}
}
async function retryItem(_id: number) {
const response = await fetch(`/api/media/${_id}/retry`, {
method: 'POST'
});
if (response.ok) {
toast.success('Media retried successfully');
invalidateAll();
} else {
toast.error('An error occurred while retrying the media');
}
}
async function resetItem(_id: number) {
const response = await fetch(`/api/media/${_id}/reset`, {
method: 'POST'
});
if (response.ok) {
toast.success('Media reset successfully');
invalidateAll();
} else {
toast.error('An error occurred while resetting the media');
}
}
async function requestItem(imdb: number) {
const response = await fetch(`/api/media/${imdb}`, {
method: 'POST'
Expand Down Expand Up @@ -225,6 +260,7 @@
builders={[builder]}
class="flex items-center gap-1"
variant="destructive"
disabled={true}
>
<Trash2 class="size-4" />
<span>Delete</span>
Expand All @@ -250,6 +286,69 @@
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>

<AlertDialog.Root>
<AlertDialog.Trigger asChild let:builder>
<Button
builders={[builder]}
class="flex items-center gap-1"
variant="destructive"
>
<RotateCcw class="size-4" />
<span>Retry</span>
</Button>
</AlertDialog.Trigger>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Description>
This action will remove the item from queue and insert it back
</AlertDialog.Description>
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<AlertDialog.Action
on:click={async () => {
if (data.db) {
await retryItem(data.db._id);
}
}}>Continue</AlertDialog.Action
>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>

<AlertDialog.Root>
<AlertDialog.Trigger asChild let:builder>
<Button
builders={[builder]}
class="flex items-center gap-1"
variant="destructive"
>
<CirclePower class="size-4" />
<span>Reset</span>
</Button>
</AlertDialog.Trigger>
<AlertDialog.Content>
<AlertDialog.Header>
<AlertDialog.Title>Are you absolutely sure?</AlertDialog.Title>
<AlertDialog.Description>
This action will reset the media to its initial state and blacklist the
torrent
</AlertDialog.Description>
</AlertDialog.Header>
<AlertDialog.Footer>
<AlertDialog.Cancel>Cancel</AlertDialog.Cancel>
<AlertDialog.Action
on:click={async () => {
if (data.db) {
await resetItem(data.db._id);
}
}}>Continue</AlertDialog.Action
>
</AlertDialog.Footer>
</AlertDialog.Content>
</AlertDialog.Root>
{/if}
</div>
{#if data.details.belongs_to_collection}
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/media/[id]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const DELETE: RequestHandler = async ({ params, locals }) => {
const id = params.id;

try {
const itemDeleteResponse = await fetch(`${locals.BACKEND_URL}/items/remove?${id}`, {
const itemDeleteResponse = await fetch(`${locals.BACKEND_URL}/items?${id}`, {
method: 'DELETE'
});

Expand Down
Loading

0 comments on commit 9e3d470

Please sign in to comment.