diff --git a/web/src/components/DialogTorrentDetailsContent/index.jsx b/web/src/components/DialogTorrentDetailsContent/index.jsx index 09f5207..b3b8a32 100644 --- a/web/src/components/DialogTorrentDetailsContent/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/index.jsx @@ -7,6 +7,7 @@ import ptt from 'parse-torrent-title' import axios from 'axios' import { playlistTorrHost, streamHost, torrentsHost, viewedHost } from 'utils/Hosts' import { GETTING_INFO, IN_DB } from 'torrentStates' +import CircularProgress from '@material-ui/core/CircularProgress' import { useUpdateCache, useCreateCacheMap, useGetSettings } from './customHooks' import DialogHeader from './DialogHeader' @@ -115,197 +116,201 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) { {...(isDetailedCacheView && { onBack: () => setIsDetailedCacheView(false) })} /> - {isLoading ? ( - 'loading' - ) : isDetailedCacheView ? ( - -
- Data - - - - - - - - - +
+ {isLoading ? ( +
+
- -
- Cache - -
- - ) : ( - - - {poster ? poster : } - + ) : isDetailedCacheView ? ( +
- {name && name !== title ? ( - <> - {shortenText(name, 50)} - {shortenText(title, 160)} - - ) : ( - {shortenText(title, 50)} - )} - + Data + + + +
- +
+ Cache + +
+
+ ) : ( + + + {poster ? poster : } - {!isOnlyOnePlayableFile && !!viewedFileList?.length && ( - <> - Download Playlist - - Latest file played: {latestViewedFileData.title}. - {latestViewedFileData.season && ( - <> - {' '} - Season: {latestViewedFileData.season}. Episode: {latestViewedFileData.episode}. - - )} - +
+ {name && name !== title ? ( + <> + {shortenText(name, 50)} + {shortenText(title, 160)} + + ) : ( + {shortenText(title, 50)} + )} - + + + + + + + + + + {!isOnlyOnePlayableFile && !!viewedFileList?.length && ( + <> + Download Playlist + + Latest file played: {latestViewedFileData.title}. + {latestViewedFileData.season && ( + <> + {' '} + Season: {latestViewedFileData.season}. Episode: {latestViewedFileData.episode}. + + )} + + + + + + + + + + + + + )} + + Torrent State + + + + + + + Info + + + {(isOnlyOnePlayableFile || !viewedFileList?.length) && ( + )} + + + + +
+
- - - - + + + Buffer + {!settings?.PreloadBuffer && ( + Enable "Preload Buffer" in settings to change buffer size + )} + + + + + + + + + Torrent Content + + {!playableFileList?.length ? ( + 'No playable files in this torrent' + ) : ( + <> + + + + + + {fileHasSeasonText && } + {fileHasEpisodeText && } + {fileHasResolutionText && } + + + + + + + {playableFileList.map(({ id, path, length }) => { + const { title, resolution, episode, season } = ptt.parse(path) + const isViewed = viewedFileList?.includes(id) + const link = getFileLink(path, id) + + return ( + + + {fileHasSeasonText && } + {fileHasEpisodeText && } + {fileHasResolutionText && } + + + + ) + })} + +
viewednameseasonepisoderesolutionsizeactions
+ {title}{season}{episode}{resolution}{humanizeSize(length)} + + + + + + + + + +
)} - - Torrent State - - - - - - - Info - - - {(isOnlyOnePlayableFile || !viewedFileList?.length) && ( - - - - )} - - - - -
- - - - - Buffer - {!settings?.PreloadBuffer && ( - Enable "Preload Buffer" in settings to change buffer size - )} - - - - - - - - - Torrent Content - - {!playableFileList?.length ? ( - 'No playable files in this torrent' - ) : ( - <> - - - - - - {fileHasSeasonText && } - {fileHasEpisodeText && } - {fileHasResolutionText && } - - - - - - - {playableFileList.map(({ id, path, length }) => { - const { title, resolution, episode, season } = ptt.parse(path) - const isViewed = viewedFileList?.includes(id) - const link = getFileLink(path, id) - - return ( - - - {fileHasSeasonText && } - {fileHasEpisodeText && } - {fileHasResolutionText && } - - - - ) - })} - -
viewednameseasonepisoderesolutionsizeactions
- {title}{season}{episode}{resolution}{humanizeSize(length)} - - - - - - - - - -
- - )} -
- - )} + + + )} +
) } diff --git a/web/src/components/DialogTorrentDetailsContent/style.js b/web/src/components/DialogTorrentDetailsContent/style.js index fe62ab2..f83b93b 100644 --- a/web/src/components/DialogTorrentDetailsContent/style.js +++ b/web/src/components/DialogTorrentDetailsContent/style.js @@ -92,7 +92,6 @@ export const SectionHeader = styled.div` export const DetailedTorrentCacheViewWrapper = styled.div` overflow: auto; - min-height: 80vh; padding: 40px; > :not(:last-child) { padding-bottom: 50px; diff --git a/web/src/components/TorrentList.jsx b/web/src/components/TorrentList.jsx index 7b33671..35fd993 100644 --- a/web/src/components/TorrentList.jsx +++ b/web/src/components/TorrentList.jsx @@ -4,6 +4,7 @@ import { Typography } from '@material-ui/core' import { torrentsHost } from 'utils/Hosts' import TorrentCard from 'components/TorrentCard' import axios from 'axios' +import CircularProgress from '@material-ui/core/CircularProgress' const TorrentListWrapper = styled.div` display: grid; @@ -20,9 +21,16 @@ const TorrentListWrapper = styled.div` } ` +const CenteredGrid = styled.div` + height: 75vh; + display: grid; + place-items: center; +` + export default function TorrentList() { const [torrents, setTorrents] = useState([]) - const [offline, setOffline] = useState(true) + const [isLoading, setIsLoading] = useState(true) + const [isOffline, setIsOffline] = useState(true) const timerID = useRef(-1) useEffect(() => { @@ -33,27 +41,34 @@ export default function TorrentList() { .then(({ data }) => { // updating torrent list setTorrents(data) - setOffline(false) + setIsOffline(false) }) .catch(() => { // resetting torrent list setTorrents([]) - setOffline(true) + setIsOffline(true) }) + .finally(() => setIsLoading(false)) }, 1000) return () => clearInterval(timerID.current) }, []) - return ( + return isLoading ? ( + + + + ) : isOffline ? ( + + Offline + + ) : !torrents.length ? ( + No torrents added + ) : ( - {offline ? ( - Offline - ) : !torrents.length ? ( - No torrents added - ) : ( - torrents.map(torrent => ) - )} + {torrents.map(torrent => ( + + ))} ) }