mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-21 21:35:13 +02:00
feat: implement season requests management with CRUD operations and enhance UI components
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
<script lang="ts">
|
||||
import {goto} from "$app/navigation";
|
||||
import {base} from "$app/paths";
|
||||
import {onMount} from 'svelte';
|
||||
|
||||
onMount(() => {
|
||||
goto(base + '/dashboard');
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
@@ -8,12 +8,11 @@ export const load: LayoutLoad = async ({params, fetch}) => {
|
||||
return {
|
||||
showData: null,
|
||||
torrentsData: null,
|
||||
error: 'Show ID is missing'
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${env.PUBLIC_API_URL}/tv/shows/${showId}`, {
|
||||
const show = await fetch(`${env.PUBLIC_API_URL}/tv/shows/${showId}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -29,16 +28,15 @@ export const load: LayoutLoad = async ({params, fetch}) => {
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (!response.ok || !torrents.ok) {
|
||||
console.error(`Failed to fetch show ${showId}: ${response.statusText}`);
|
||||
if (!show.ok || !torrents.ok) {
|
||||
console.error(`Failed to fetch show ${showId}: ${show.statusText}`);
|
||||
return {
|
||||
showData: null,
|
||||
torrentsData: null,
|
||||
error: `Failed to load show or/and its torrents: ${response.statusText}`
|
||||
};
|
||||
}
|
||||
|
||||
const showData = await response.json();
|
||||
const showData = await show.json();
|
||||
const torrentsData = await torrents.json();
|
||||
console.log('Fetched show data:', showData);
|
||||
console.log('Fetched torrents data:', torrentsData);
|
||||
@@ -52,7 +50,6 @@ export const load: LayoutLoad = async ({params, fetch}) => {
|
||||
return {
|
||||
showData: null,
|
||||
torrentsData: null,
|
||||
error: 'An error occurred while fetching show data.'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
33
web/src/routes/dashboard/tv/requests/+layout.ts
Normal file
33
web/src/routes/dashboard/tv/requests/+layout.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import {env} from '$env/dynamic/public';
|
||||
import type {LayoutLoad} from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({params, fetch}) => {
|
||||
try {
|
||||
const requests = await fetch(`${env.PUBLIC_API_URL}/tv/seasons/requests`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
credentials: 'include'
|
||||
});
|
||||
|
||||
if (!requests.ok) {
|
||||
console.error(`Failed to fetch season requests ${requests.statusText}`);
|
||||
return {
|
||||
requestsData: null,
|
||||
};
|
||||
}
|
||||
|
||||
const requestsData = await requests.json();
|
||||
console.log('Fetched season requests:', requestsData);
|
||||
|
||||
return {
|
||||
requestsData: requestsData,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error fetching season requests:', error);
|
||||
return {
|
||||
requestsData: null,
|
||||
};
|
||||
}
|
||||
};
|
||||
49
web/src/routes/dashboard/tv/requests/+page.svelte
Normal file
49
web/src/routes/dashboard/tv/requests/+page.svelte
Normal file
@@ -0,0 +1,49 @@
|
||||
<script lang="ts">
|
||||
import {page} from '$app/state';
|
||||
import {Separator} from '$lib/components/ui/separator/index.js';
|
||||
import * as Sidebar from '$lib/components/ui/sidebar/index.js';
|
||||
import * as Breadcrumb from '$lib/components/ui/breadcrumb/index.js';
|
||||
import * as Table from '$lib/components/ui/table/index.js';
|
||||
import {getTorrentQualityString, getTorrentStatusString} from '$lib/utils';
|
||||
import type {SeasonRequest} from '$lib/types';
|
||||
import {getFullyQualifiedShowName} from '$lib/utils';
|
||||
import * as Accordion from '$lib/components/ui/accordion/index.js';
|
||||
import CheckmarkX from '$lib/components/checkmark-x.svelte';
|
||||
import * as Card from "$lib/components/ui/card/index.js";
|
||||
import RequestsTable from "$lib/components/season-requests-table.svelte";
|
||||
|
||||
let requests: SeasonRequest[] = $state(page.data.requestsData);
|
||||
</script>
|
||||
|
||||
<header class="flex h-16 shrink-0 items-center gap-2">
|
||||
<div class="flex items-center gap-2 px-4">
|
||||
<Sidebar.Trigger class="-ml-1"/>
|
||||
<Separator class="mr-2 h-4" orientation="vertical"/>
|
||||
<Breadcrumb.Root>
|
||||
<Breadcrumb.List>
|
||||
<Breadcrumb.Item class="hidden md:block">
|
||||
<Breadcrumb.Link href="/dashboard">MediaManager</Breadcrumb.Link>
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Separator class="hidden md:block"/>
|
||||
<Breadcrumb.Item>
|
||||
<Breadcrumb.Link href="/dashboard">Home</Breadcrumb.Link>
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Separator class="hidden md:block"/>
|
||||
<Breadcrumb.Item>
|
||||
<Breadcrumb.Link href="/dashboard/tv">Shows</Breadcrumb.Link>
|
||||
</Breadcrumb.Item>
|
||||
<Breadcrumb.Separator class="hidden md:block"/>
|
||||
<Breadcrumb.Item>
|
||||
<Breadcrumb.Page>TV Torrents</Breadcrumb.Page>
|
||||
</Breadcrumb.Item>
|
||||
</Breadcrumb.List>
|
||||
</Breadcrumb.Root>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="flex w-full flex-1 flex-col items-center gap-4 p-4 pt-0">
|
||||
<h1 class="scroll-m-20 text-center text-4xl font-extrabold tracking-tight lg:text-5xl">
|
||||
Season Requests
|
||||
</h1>
|
||||
<RequestsTable requests={requests}/>
|
||||
</div>
|
||||
@@ -2,7 +2,7 @@
|
||||
import {UserCheck} from 'lucide-svelte';
|
||||
import {Button} from '$lib/components/ui/button/index.js';
|
||||
import Logo from '$lib/components/logo-side-by-side.svelte';
|
||||
|
||||
import {handleLogout} from '$lib/utils.ts';
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,10 +10,11 @@
|
||||
<div class="absolute top-4 left-4">
|
||||
<Logo/>
|
||||
</div>
|
||||
<div class="absolute top-4 right-4">
|
||||
<Button onclick={()=>handleLogout()} variant="outline">Logout</Button>
|
||||
</div>
|
||||
<div class="mx-auto w-full max-w-md text-center">
|
||||
|
||||
|
||||
<div class="mb-6">
|
||||
<div class="mb-6">
|
||||
<UserCheck class="mx-auto h-16 w-16 text-primary"/>
|
||||
</div>
|
||||
<h1 class="mt-4 text-3xl font-bold tracking-tight text-foreground sm:text-4xl">
|
||||
@@ -30,6 +31,7 @@
|
||||
The above button will only work once your account is verified.
|
||||
</p>
|
||||
<p class="mt-10 text-sm text-muted-foreground end">
|
||||
If you have any questions, please contact an administrator.</p>
|
||||
If you have any questions, please contact an administrator.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user