mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-20 00:53:30 +02:00
feat: implement season requests management with CRUD operations and enhance UI components
This commit is contained in:
@@ -80,7 +80,7 @@
|
||||
if (response.ok) {
|
||||
console.log('Registration successful!');
|
||||
console.log('Received User Data: ', response);
|
||||
goto('/dashboard');
|
||||
tabValue = "login"; // Switch to login tab after successful registration
|
||||
errorMessage = 'Registration successful! Redirecting...';
|
||||
} else {
|
||||
let errorText = await response.text();
|
||||
|
||||
@@ -17,23 +17,9 @@
|
||||
import {base} from '$app/paths';
|
||||
import {env} from "$env/dynamic/public";
|
||||
import {goto} from '$app/navigation';
|
||||
|
||||
import {handleLogout} from '$lib/utils.ts';
|
||||
const user: () => User = getContext('user');
|
||||
const sidebar = useSidebar();
|
||||
const apiUrl = env.PUBLIC_API_URL;
|
||||
|
||||
async function handleLogout() {
|
||||
const response = await fetch(apiUrl + '/auth/cookie/logout', {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
if (response.ok) {
|
||||
console.log('Logout successful!');
|
||||
await goto(base + '/login');
|
||||
} else {
|
||||
console.error('Logout failed:', response.status);
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
62
web/src/lib/components/season-requests-table.svelte
Normal file
62
web/src/lib/components/season-requests-table.svelte
Normal file
@@ -0,0 +1,62 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
convertTorrentSeasonRangeToIntegerRange, getFullyQualifiedShowName,
|
||||
getTorrentQualityString,
|
||||
getTorrentStatusString
|
||||
} from "$lib/utils.js";
|
||||
import type {SeasonRequest} from "$lib/types.js";
|
||||
import CheckmarkX from "$lib/components/checkmark-x.svelte";
|
||||
import * as Table from "$lib/components/ui/table/index.js";
|
||||
|
||||
let {
|
||||
requests, filter = () => {
|
||||
return true
|
||||
}
|
||||
}: { requests: SeasonRequest[], filter: (SeasonRequest) => boolean } = $props();
|
||||
|
||||
</script>
|
||||
|
||||
<Table.Root>
|
||||
<Table.Caption>A list of all requests.</Table.Caption>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.Head>Show</Table.Head>
|
||||
<Table.Head>Season</Table.Head>
|
||||
<Table.Head>Minimum Quality</Table.Head>
|
||||
<Table.Head>Wanted Quality</Table.Head>
|
||||
<Table.Head>Requested by</Table.Head>
|
||||
<Table.Head>Approved</Table.Head>
|
||||
<Table.Head>Approved by</Table.Head>
|
||||
<Table.Head>Actions</Table.Head>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
{#each requests as request (request.id)}
|
||||
{#if filter(request)}
|
||||
<Table.Row>
|
||||
<Table.Cell class="font-medium">
|
||||
{getFullyQualifiedShowName(request.show)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{request.season.number}
|
||||
</Table.Cell>
|
||||
<Table.Cell class="font-medium">
|
||||
{getTorrentQualityString(request.min_quality)}
|
||||
</Table.Cell>
|
||||
<Table.Cell class="font-medium">
|
||||
{getTorrentQualityString(request.wanted_quality)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{request.requested_by?.email}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<CheckmarkX state={request.authorized}/>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{request.authorized_by?.email}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
{/if}
|
||||
{/each}
|
||||
</Table.Body>
|
||||
</Table.Root>
|
||||
@@ -94,11 +94,6 @@ export interface PublicSeason {
|
||||
episodes: Episode[]; // items: { $ref: #/components/schemas/Episode }, type: array
|
||||
id?: string; // type: string, format: uuid
|
||||
}
|
||||
export interface SeasonRequest {
|
||||
season_id: string; // type: string, format: uuid
|
||||
min_quality: Quality; // $ref: #/components/schemas/Quality
|
||||
wanted_quality: Quality; // $ref: #/components/schemas/Quality
|
||||
}
|
||||
|
||||
export interface Show {
|
||||
name: string;
|
||||
@@ -172,3 +167,25 @@ export interface RichShowTorrent {
|
||||
metadata_provider: string;
|
||||
torrents: RichSeasonTorrent[];
|
||||
}
|
||||
|
||||
interface SeasonRequestBase {
|
||||
min_quality: Quality;
|
||||
wanted_quality: Quality;
|
||||
}
|
||||
|
||||
export interface CreateSeasonRequest extends SeasonRequestBase {
|
||||
season_id: string;
|
||||
}
|
||||
|
||||
export interface UpdateSeasonRequest extends SeasonRequestBase {
|
||||
id: string;
|
||||
}
|
||||
|
||||
export interface SeasonRequest extends SeasonRequestBase {
|
||||
id: string;
|
||||
season: Season;
|
||||
requested_by?: User;
|
||||
authorized: boolean;
|
||||
authorized_by?: User;
|
||||
show: Show;
|
||||
}
|
||||
@@ -1,5 +1,10 @@
|
||||
import {type ClassValue, clsx} from 'clsx';
|
||||
import {twMerge} from 'tailwind-merge';
|
||||
import {env} from "$env/dynamic/public";
|
||||
import {goto} from '$app/navigation';
|
||||
import {base} from '$app/paths';
|
||||
|
||||
const apiUrl = env.PUBLIC_API_URL;
|
||||
|
||||
export const qualityMap: { [key: number]: string } = {
|
||||
1: 'high',
|
||||
@@ -42,4 +47,17 @@ export function convertTorrentSeasonRangeToIntegerRange(torrent: any): string {
|
||||
return "Error parsing season range: " + torrent.seasons;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export async function handleLogout(): null {
|
||||
const response = await fetch(apiUrl + '/auth/cookie/logout', {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
if (response.ok) {
|
||||
console.log('Logout successful!');
|
||||
await goto(base + '/login');
|
||||
} else {
|
||||
console.error('Logout failed:', response.status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user