table now has real data

This commit is contained in:
Daniel Shleifman
2021-05-31 13:38:46 +03:00
parent 1f7554489c
commit 695a7c53b6
2 changed files with 55 additions and 124 deletions

View File

@@ -37,8 +37,6 @@ import {
} from './style' } from './style'
import StatisticsField from './StatisticsField' import StatisticsField from './StatisticsField'
ptt.addHandler('part', /Part[. ]([0-9])/i, { type: 'integer' })
const shortenText = (text, count) => text.slice(0, count) + (text.length > count ? '...' : '') const shortenText = (text, count) => text.slice(0, count) + (text.length > count ? '...' : '')
export default function DialogTorrentDetailsContent({ closeDialog, torrent }) { export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
@@ -76,6 +74,10 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
const getFileLink = (path, id) => const getFileLink = (path, id) =>
`${streamHost()}/${encodeURIComponent(path.split('\\').pop().split('/').pop())}?link=${hash}&index=${id}&play` `${streamHost()}/${encodeURIComponent(path.split('\\').pop().split('/').pop())}?link=${hash}&index=${id}&play`
const fileHasEpisodeText = !!playableFileList?.find(({ path }) => ptt.parse(path).episode)
const fileHasSeasonText = !!playableFileList?.find(({ path }) => ptt.parse(path).season)
const fileHasResolutionText = !!playableFileList?.find(({ path }) => ptt.parse(path).resolution)
const { Capacity, PiecesCount, PiecesLength, Filled } = cache const { Capacity, PiecesCount, PiecesLength, Filled } = cache
useEffect(() => { useEffect(() => {
@@ -220,24 +222,6 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
</Button> </Button>
</CopyToClipboard> </CopyToClipboard>
</MainSectionButtonGroup> </MainSectionButtonGroup>
{/* <MainSectionButtonGroup>
<Button variant='contained' color='primary' size='large'>
copy hash
</Button>
<Button variant='contained' color='primary' size='large'>
remove views
</Button>
<Button variant='contained' color='primary' size='large'>
drop torrent
</Button>
<Button variant='contained' color='primary' size='large'>
download full playlist
</Button>
<Button variant='contained' color='primary' size='large'>
download playlist after last view
</Button>
</MainSectionButtonGroup> */}
</div> </div>
</MainSection> </MainSection>
@@ -269,113 +253,61 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
<TorrentFilesSection> <TorrentFilesSection>
<SectionTitle mb={20}>Torrent Content</SectionTitle> <SectionTitle mb={20}>Torrent Content</SectionTitle>
{!playableFileList?.length ? (
'No playable files in this torrent'
) : (
<>
<Table> <Table>
<thead> <thead>
<tr> <tr>
<th style={{ width: '0' }}>viewed</th> <th style={{ width: '0' }}>viewed</th>
<th>name</th> <th>name</th>
<th style={{ width: '0' }}>season</th> {fileHasSeasonText && <th style={{ width: '0' }}>season</th>}
<th style={{ width: '0' }}>episode</th> {fileHasEpisodeText && <th style={{ width: '0' }}>episode</th>}
<th style={{ width: '0' }}>resolution</th> {fileHasResolutionText && <th style={{ width: '0' }}>resolution</th>}
<th style={{ width: '100px' }}>size</th> <th style={{ width: '100px' }}>size</th>
<th style={{ width: '400px' }}>actions</th> <th style={{ width: '400px' }}>actions</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr className='viewed-file-row'> {playableFileList.map(({ id, path, length }) => {
<td className='viewed-file-indicator' /> const { title, resolution, episode, season } = ptt.parse(path)
<td>Jupiters Legacy</td> const isViewed = viewedFileList?.includes(id)
<td>3</td> const link = getFileLink(path, id)
<td>1</td>
<td>1080p</td>
<td>945,41 MB</td>
<td className='button-cell'>
<Button variant='outlined' color='primary' size='small'>
Preload
</Button>
<Button variant='outlined' color='primary' size='small'>
Open link
</Button>
<Button variant='outlined' color='primary' size='small'>
Copy link
</Button>
</td>
</tr>
<tr className='viewed-file-row'>
<td className='viewed-file-indicator' />
<td>Jupiters Legacy</td>
<td>3</td>
<td>2</td>
<td>1080p</td>
<td>712,47 MB</td>
<td className='button-cell'>
<Button variant='outlined' color='primary' size='small'>
Preload
</Button>
<Button variant='outlined' color='primary' size='small'>
Open link
</Button>
<Button variant='outlined' color='primary' size='small'>
Copy link
</Button>
</td>
</tr>
<tr>
<td />
<td>Jupiters Legacy</td>
<td>3</td>
<td>3</td>
<td>1080p</td>
<td>687,44 MB</td>
<td className='button-cell'>
<Button variant='outlined' color='primary' size='small'>
Preload
</Button>
<Button variant='outlined' color='primary' size='small'>
Open link
</Button>
<Button variant='outlined' color='primary' size='small'>
Copy link
</Button>
</td>
</tr>
</tbody>
</Table>
{!playableFileList?.length
? 'No playable files in this torrent'
: playableFileList.map(({ id, path, length }) => {
{
/* console.log(ptt.parse(path)) */
}
{
/* console.log({ title: ptt.parse(path).title })
console.log({ resolution: ptt.parse(path).resolution })
console.log({ episode: ptt.parse(path).episode })
console.log({ season: ptt.parse(path).season }) */
}
return ( return (
<ButtonGroup key={id} disableElevation variant='contained' color='primary'> <tr key={id} className={isViewed ? 'viewed-file-row' : null}>
<Button> <td className={isViewed ? 'viewed-file-indicator' : null} />
<a href={getFileLink(path, id)}> <td>{title}</td>
<Typography> {fileHasSeasonText && <td>{season}</td>}
{path.split('\\').pop().split('/').pop()} | {humanizeSize(length)}{' '} {fileHasEpisodeText && <td>{episode}</td>}
{viewedFileList && viewedFileList?.indexOf(id) !== -1 && '| ✓'} {fileHasResolutionText && <td>{resolution}</td>}
</Typography> <td>{humanizeSize(length)}</td>
</a> <td className='button-cell'>
<Button onClick={() => preloadBuffer(id)} variant='outlined' color='primary' size='small'>
Preload
</Button> </Button>
<Button onClick={() => preloadBuffer(id)}> <a style={{ textDecoration: 'none' }} href={link} target='_blank' rel='noreferrer'>
<CachedIcon /> <Button style={{ width: '100%' }} variant='outlined' color='primary' size='small'>
<Typography>Preload</Typography> Open link
</Button> </Button>
</ButtonGroup> </a>
<CopyToClipboard text={link}>
<Button variant='outlined' color='primary' size='small'>
Copy link
</Button>
</CopyToClipboard>
</td>
</tr>
) )
})} })}
</tbody>
</Table>
</>
)}
</TorrentFilesSection> </TorrentFilesSection>
</DialogContentGrid> </DialogContentGrid>
)} )}

View File

@@ -213,7 +213,6 @@ export const Table = styled.table`
} }
&.viewed-file-row { &.viewed-file-row {
color: lightgray;
background: #f3f3f3; background: #f3f3f3;
} }
} }