mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-04-18 11:02:04 +00:00
feat: improve torrent client tables
This commit is contained in:
parent
39db7af384
commit
4cc501feaf
8 changed files with 21 additions and 23 deletions
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
import { keys, layout, type KeyCode, codeMap } from './maps.ts'
|
||||
|
||||
import { SUPPORTS } from '$lib/modules/settings'
|
||||
|
||||
type Bind <T extends Record<string, unknown> = Record<string, unknown>> = T & {
|
||||
fn: (e: MouseEvent | KeyboardEvent) => void
|
||||
id: string
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ export default class Subtitles {
|
|||
// replace all html special tags with normal ones
|
||||
Text = Text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/ /g, '\\h').replace(/\r?\n/g, '\\N')
|
||||
} else {
|
||||
Text = Text.replace('\r', '') // some bad subbers put \n in the text, which breaks the rendering
|
||||
Text = Text.replace(/\r?\n/g, '')
|
||||
}
|
||||
return {
|
||||
Start: subtitle.time,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
id: 'progress',
|
||||
cell: ({ value }) => createRender(ProgressCell, { value })
|
||||
}),
|
||||
table.column({ accessor: 'selections', header: 'Selections', id: 'selections' })
|
||||
table.column({ accessor: 'selections', header: 'Streams', id: 'selections' })
|
||||
])
|
||||
|
||||
const tableModel = table.createViewModel(columns)
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
const { headerRows, pageRows, tableAttrs, tableBodyAttrs } = tableModel
|
||||
</script>
|
||||
|
||||
<div class='rounded-md border max-w-screen-xl h-full overflow-clip contain-strict'>
|
||||
<div class='rounded-md border size-full overflow-clip contain-strict'>
|
||||
<Table.Root {...$tableAttrs} class='max-h-full'>
|
||||
<Table.Header class='px-5'>
|
||||
{#each $headerRows as headerRow, i (i)}
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
<Table.Row {...rowAttrs} class='h-12'>
|
||||
{#each row.cells as cell (cell.id)}
|
||||
<Subscribe attrs={cell.attrs()} let:attrs>
|
||||
<Table.Cell {...attrs} class={cn('px-4 h-14 first:pl-6 last:pr-6 text-nowrap', (cell.id === 'downloaded' || cell.id === 'episode') && 'text-muted-foreground')}>
|
||||
<Table.Cell {...attrs} class={cn('px-4 h-14 first:pl-6 last:pr-6 text-nowrap', cell.id === 'name' && 'text-wrap break-all')}>
|
||||
<Render of={cell.render()} />
|
||||
</Table.Cell>
|
||||
</Subscribe>
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
export let value: string
|
||||
</script>
|
||||
|
||||
<div class='text-xs font-mono'>{value}</div>
|
||||
<div class='text-xs font-mono text-wrap'>{value}</div>
|
||||
|
|
|
|||
|
|
@ -25,12 +25,14 @@
|
|||
accessor: 'mediaID',
|
||||
header: 'Series',
|
||||
id: 'series',
|
||||
plugins: { sort: { getSortValue: e => e ?? 0 } },
|
||||
cell: ({ value }) => value ? createRender(MediaCell, { value }) : '?'
|
||||
}),
|
||||
table.column({
|
||||
accessor: 'episode',
|
||||
header: 'Episode',
|
||||
id: 'episode',
|
||||
plugins: { sort: { getSortValue: e => e ?? 0 } },
|
||||
cell: ({ value }) => value?.toString() ?? '?'
|
||||
}),
|
||||
table.column({ accessor: 'files', header: 'Files', id: 'files' }),
|
||||
|
|
@ -38,24 +40,28 @@
|
|||
accessor: 'size',
|
||||
header: 'Size',
|
||||
id: 'size',
|
||||
plugins: { sort: { getSortValue: e => e ?? 0 } },
|
||||
cell: ({ value }) => value ? fastPrettyBytes(value) : '?'
|
||||
}),
|
||||
table.column({
|
||||
accessor: 'progress',
|
||||
header: 'Status',
|
||||
id: 'completed',
|
||||
plugins: { sort: { getSortValue: e => e ?? 0 } },
|
||||
cell: ({ value }) => value ? createRender(StatusCell, { value: value === 1 }) : '?'
|
||||
}),
|
||||
table.column({
|
||||
accessor: 'date',
|
||||
header: 'Date',
|
||||
id: 'date',
|
||||
plugins: { sort: { getSortValue: e => e ?? 0 } },
|
||||
cell: ({ value }) => value ? new Date(value).toLocaleDateString() : '?'
|
||||
}),
|
||||
table.column({
|
||||
accessor: e => e?.name ?? e.hash,
|
||||
header: 'Torrent Name',
|
||||
id: 'name',
|
||||
plugins: { sort: { getSortValue: e => e ?? '' } },
|
||||
cell: ({ value }) => createRender(NameCell, { value })
|
||||
})
|
||||
])
|
||||
|
|
@ -76,7 +82,7 @@
|
|||
// $: allIDsPromise = client.multiple($lib.map(e => e.mediaID))
|
||||
</script>
|
||||
|
||||
<div class='rounded-md border max-w-screen-xl h-full overflow-clip contain-strict'>
|
||||
<div class='rounded-md border size-full overflow-clip contain-strict'>
|
||||
<Table.Root {...$tableAttrs} class='max-h-full'>
|
||||
<Table.Header class='px-5'>
|
||||
{#each $headerRows as headerRow, i (i)}
|
||||
|
|
@ -88,16 +94,10 @@
|
|||
props={cell.props()}
|
||||
let:attrs
|
||||
let:props>
|
||||
<Table.Head {...attrs} class={cn('px-0 first:pl-2 h-12 last:pr-2', cell.id === 'name' && 'w-full')}>
|
||||
{#if cell.id !== 'flags'}
|
||||
<Columnheader {props}>
|
||||
<Render of={cell.render()} />
|
||||
</Columnheader>
|
||||
{:else}
|
||||
<div class='text-sm px-4'>
|
||||
<Render of={cell.render()} />
|
||||
</div>
|
||||
{/if}
|
||||
<Table.Head {...attrs} class={cn('px-0 first:pl-2 h-12 last:pr-2')}>
|
||||
<Columnheader {props}>
|
||||
<Render of={cell.render()} />
|
||||
</Columnheader>
|
||||
</Table.Head>
|
||||
</Subscribe>
|
||||
{/each}
|
||||
|
|
@ -109,10 +109,10 @@
|
|||
{#if $pageRows.length}
|
||||
{#each $pageRows as row (row.id)}
|
||||
<Subscribe rowAttrs={row.attrs()} let:rowAttrs>
|
||||
<Table.Row {...rowAttrs} class={cn('h-12', (row instanceof DataBodyRow) && row.original.mediaID ? 'cursor-pointer' : 'cursor-not-allowed')} on:click={() => { if (row instanceof DataBodyRow) playEntry(row.original) }}>
|
||||
<Table.Row {...rowAttrs} class={cn('h-14', (row instanceof DataBodyRow) && row.original.mediaID ? 'cursor-pointer' : 'cursor-not-allowed')} on:click={() => { if (row instanceof DataBodyRow) playEntry(row.original) }}>
|
||||
{#each row.cells as cell (cell.id)}
|
||||
<Subscribe attrs={cell.attrs()} let:attrs>
|
||||
<Table.Cell {...attrs} class={cn('px-4 h-14 first:pl-6 last:pr-6 text-nowrap', (cell.id === 'downloaded' || cell.id === 'episode') && 'text-muted-foreground')}>
|
||||
<Table.Cell {...attrs} class={cn('px-4 min-h-14 first:pl-6 last:pr-6 text-nowrap', (cell.id === 'episode') && 'text-muted-foreground', (cell.id === 'series' || cell.id === 'name') && 'min-w-80 text-wrap break-all')}>
|
||||
<Render of={cell.render()} />
|
||||
</Table.Cell>
|
||||
</Subscribe>
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
const forwarding = safeLocalStorage<boolean>('torrent-port-forwarding') ?? false
|
||||
</script>
|
||||
|
||||
<div class='max-w-6xl flex flex-col gap-12'>
|
||||
<div class='max-w-6xl flex flex-col gap-12 min-[2000px]:max-w-full'>
|
||||
<div class='flex items-center gap-4'>
|
||||
<div class='flex-1 w-full'>
|
||||
<h1 class='text-2xl font-bold truncate text-nowrap'>{torrent.name || 'No Name Provided'}</h1>
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@
|
|||
const { headerRows, pageRows, tableAttrs, tableBodyAttrs } = tableModel
|
||||
</script>
|
||||
|
||||
<div class='rounded-md border max-w-screen-xl h-full overflow-clip contain-strict'>
|
||||
<div class='rounded-md border size-full overflow-clip contain-strict'>
|
||||
<Table.Root {...$tableAttrs} class='max-h-full'>
|
||||
<Table.Header class='px-5'>
|
||||
{#each $headerRows as headerRow, i (i)}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export function makeEpisodeList (media: Media, episodesRes?: EpisodesResponse |
|
|||
|
||||
const { image, summary, overview, rating, title, length, airdate, anidbEid } = resolvedEpisode ?? {}
|
||||
const res = {
|
||||
episode, image, summary: summary ?? overview, rating, title, length, airdate, airingAt, filler: !!fillerEpisodes[media.id]?.includes(episode + 1), anidbEid
|
||||
episode, image, summary: summary ?? overview, rating, title, length, airdate, airingAt, filler: !!fillerEpisodes[media.id]?.includes(episode), anidbEid
|
||||
}
|
||||
episodeList.push(res)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue