mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-22 00:35:50 +02:00
add retry and delete buttons to torrents table
This commit is contained in:
@@ -6,8 +6,43 @@
|
||||
} from '$lib/utils.js';
|
||||
import CheckmarkX from '$lib/components/checkmark-x.svelte';
|
||||
import * as Table from '$lib/components/ui/table/index.js';
|
||||
import type { components } from '$lib/api/api';
|
||||
import { getContext } from 'svelte';
|
||||
import { Button } from '$lib/components/ui/button/index.js';
|
||||
import client from '$lib/api';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import DeleteTorrentDialog from '$lib/components/delete-torrent-dialog.svelte';
|
||||
|
||||
let { torrents, isShow = true } = $props();
|
||||
let {
|
||||
torrents,
|
||||
isShow = true
|
||||
}: {
|
||||
torrents:
|
||||
| components['schemas']['MovieTorrent'][]
|
||||
| components['schemas']['RichSeasonTorrent'][];
|
||||
isShow: boolean;
|
||||
} = $props();
|
||||
|
||||
let user: () => components['schemas']['UserRead'] = getContext('user');
|
||||
|
||||
async function retryTorrentDownload(
|
||||
torrent: components['schemas']['MovieTorrent'] | components['schemas']['RichSeasonTorrent']
|
||||
) {
|
||||
console.log(`Retrying download for torrent ${torrent.torrent_title}`);
|
||||
const { error } = await client.POST('/api/v1/torrent/{torrent_id}/retry', {
|
||||
params: {
|
||||
path: {
|
||||
torrent_id: torrent.torrent_id!
|
||||
}
|
||||
}
|
||||
});
|
||||
if (error) {
|
||||
toast.error(`Failed on retrying download: ${error}`);
|
||||
} else {
|
||||
console.log(`Successfully retried download for torrent ${torrent.torrent_title}`);
|
||||
toast.success('Trying to download torrent...');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Table.Root>
|
||||
@@ -22,6 +57,9 @@
|
||||
<Table.Head>Quality</Table.Head>
|
||||
<Table.Head>File Path Suffix</Table.Head>
|
||||
<Table.Head>Imported</Table.Head>
|
||||
{#if user().is_superuser}
|
||||
<Table.Head>Actions</Table.Head>
|
||||
{/if}
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
@@ -32,7 +70,9 @@
|
||||
</Table.Cell>
|
||||
{#if isShow}
|
||||
<Table.Cell>
|
||||
{convertTorrentSeasonRangeToIntegerRange(torrent)}
|
||||
{convertTorrentSeasonRangeToIntegerRange(
|
||||
(torrent as components['schemas']['RichSeasonTorrent']).seasons!
|
||||
)}
|
||||
</Table.Cell>
|
||||
{/if}
|
||||
<Table.Cell>
|
||||
@@ -47,6 +87,17 @@
|
||||
<Table.Cell>
|
||||
<CheckmarkX state={torrent.imported} />
|
||||
</Table.Cell>
|
||||
{#if user().is_superuser}
|
||||
<Table.Cell class="justify flex flex-col gap-2 xl:flex-row">
|
||||
{#if 'finished' !== getTorrentStatusString(torrent.status)}
|
||||
<Button variant="secondary" onclick={() => retryTorrentDownload(torrent)}>
|
||||
Retry Download
|
||||
</Button>
|
||||
{/if}
|
||||
<DeleteTorrentDialog torrentName={torrent.torrent_title} torrentId={torrent.torrent_id!}
|
||||
></DeleteTorrentDialog>
|
||||
</Table.Cell>
|
||||
{/if}
|
||||
</Table.Row>
|
||||
{/each}
|
||||
</Table.Body>
|
||||
|
||||
Reference in New Issue
Block a user