diff --git a/frontend/src/components/DownloadDialog.tsx b/frontend/src/components/DownloadDialog.tsx index ecdd8f7..888a38d 100644 --- a/frontend/src/components/DownloadDialog.tsx +++ b/frontend/src/components/DownloadDialog.tsx @@ -207,7 +207,7 @@ const DownloadDialog: FC = ({ open, onClose, onDownloadStart }) => { backgroundColor: (theme) => theme.palette.background.default, minHeight: (theme) => `calc(99vh - ${theme.mixins.toolbar.minHeight}px)` }}> - + { - const listView = useRecoilValue(listViewState) + const tableView = useRecoilValue(listViewState) const loadingDownloads = useRecoilValue(loadingDownloadsState) const [isLoading, setIsLoading] = useRecoilState(loadingAtom) @@ -20,15 +20,9 @@ const Downloads: React.FC = () => { setIsLoading(false) }, [loadingDownloads, isLoading]) - if (listView) { - return ( - - ) - } + if (tableView) return - return ( - - ) + return } export default Downloads \ No newline at end of file diff --git a/frontend/src/components/DownloadsCardView.tsx b/frontend/src/components/DownloadsCardView.tsx index e4047d9..222041d 100644 --- a/frontend/src/components/DownloadsCardView.tsx +++ b/frontend/src/components/DownloadsCardView.tsx @@ -16,10 +16,10 @@ const DownloadsCardView: React.FC = () => { const abort = (id: string) => client.kill(id) return ( - + { downloads.map(download => ( - + abort(download.id)} diff --git a/frontend/src/components/DownloadsTableView.tsx b/frontend/src/components/DownloadsTableView.tsx index 73b9813..e414c5c 100644 --- a/frontend/src/components/DownloadsTableView.tsx +++ b/frontend/src/components/DownloadsTableView.tsx @@ -45,89 +45,83 @@ const DownloadsTableView: React.FC = () => { const abort = (id: string) => client.kill(id) return ( - - - - - + )) + } + + + ) } diff --git a/frontend/src/components/LogTerminal.tsx b/frontend/src/components/LogTerminal.tsx index c020098..0fa5e3d 100644 --- a/frontend/src/components/LogTerminal.tsx +++ b/frontend/src/components/LogTerminal.tsx @@ -1,4 +1,3 @@ -import { Box, Container, Paper, Typography } from '@mui/material' import { useEffect, useMemo, useRef, useState } from 'react' import { useRecoilValue } from 'recoil' import { serverURL } from '../atoms/settings' @@ -7,14 +6,15 @@ import { useI18n } from '../hooks/useI18n' const token = localStorage.getItem('token') const LogTerminal: React.FC = () => { + const [logBuffer, setLogBuffer] = useState([]) + const [isConnecting, setIsConnecting] = useState(true) + + const boxRef = useRef(null) + const serverAddr = useRecoilValue(serverURL) const { i18n } = useI18n() - const [logBuffer, setLogBuffer] = useState([]) - - const boxRef = useRef(null) - const eventSource = useMemo( () => new EventSource(`${serverAddr}/log/sse?token=${token}`), [serverAddr] @@ -23,7 +23,7 @@ const LogTerminal: React.FC = () => { useEffect(() => { eventSource.addEventListener('log', event => { const msg: string[] = JSON.parse(event.data) - setLogBuffer(buff => [...buff, ...msg].slice(-100)) + setLogBuffer(buff => [...buff, ...msg].slice(-500)) boxRef.current?.scrollTo(0, boxRef.current.scrollHeight) }) @@ -32,6 +32,10 @@ const LogTerminal: React.FC = () => { return () => eventSource.close() }, [eventSource]) + useEffect(() => { + eventSource.onopen = () => setIsConnecting(false) + }, [eventSource]) + const logEntryStyle = (data: string) => { const sx = {} @@ -46,41 +50,33 @@ const LogTerminal: React.FC = () => { } return ( - - - - {i18n.t('logsTitle')} - - - {logBuffer.length === 0 && {i18n.t('awaitingLogs')}} - {logBuffer.map((log, idx) => ( - - {log} - - ))} - - - + +
+ {isConnecting ?
{'Connecting...'}
:
{'Connected!'}
} + + {logBuffer.length === 0 &&
{i18n.t('awaitingLogs')}
} + + {logBuffer.map((log, idx) => ( +
+ {log} +
+ ))} +
+ ) } diff --git a/frontend/src/views/Archive.tsx b/frontend/src/views/Archive.tsx index 547ab83..194af4f 100644 --- a/frontend/src/views/Archive.tsx +++ b/frontend/src/views/Archive.tsx @@ -182,7 +182,7 @@ export default function Downloaded() { return ( setShowMenu(false)} > diff --git a/frontend/src/views/Home.tsx b/frontend/src/views/Home.tsx index 7f16f68..c8b6a81 100644 --- a/frontend/src/views/Home.tsx +++ b/frontend/src/views/Home.tsx @@ -8,7 +8,7 @@ import Splash from '../components/Splash' export default function Home() { return ( - + diff --git a/frontend/src/views/Settings.tsx b/frontend/src/views/Settings.tsx index b4d4b81..8e9a69a 100644 --- a/frontend/src/views/Settings.tsx +++ b/frontend/src/views/Settings.tsx @@ -134,12 +134,12 @@ export default function Settings() { } return ( - + { + const { i18n } = useI18n() + return ( - + + + + {i18n.t('logsTitle')} + + + + ) } diff --git a/server/server.go b/server/server.go index 78f4bb9..6307b2f 100644 --- a/server/server.go +++ b/server/server.go @@ -105,8 +105,10 @@ func RunBlocking(cfg *RunConfig) { go gracefulShutdown(srv, &mdb) go autoPersist(time.Minute*5, &mdb, logger) - network := "tcp" - address := fmt.Sprintf("%s:%d", cfg.Host, cfg.Port) + var ( + network = "tcp" + address = fmt.Sprintf("%s:%d", cfg.Host, cfg.Port) + ) if strings.HasPrefix(cfg.Host, "/") { network = "unix" @@ -120,6 +122,7 @@ func RunBlocking(cfg *RunConfig) { } logger.Info("yt-dlp-webui started", slog.String("address", address)) + if err := srv.Serve(listener); err != nil { logger.Warn("http server stopped", slog.String("err", err.Error())) } diff --git a/server/utils/file.go b/server/utils/file.go index bf9f9f2..26e67c6 100644 --- a/server/utils/file.go +++ b/server/utils/file.go @@ -1,8 +1,6 @@ package utils import ( - "crypto/sha256" - "encoding/hex" "io/fs" "regexp" "strings" @@ -21,9 +19,3 @@ func IsValidEntry(d fs.DirEntry) bool { !strings.HasSuffix(d.Name(), ".part") && !strings.HasSuffix(d.Name(), ".ytdl") } - -func ShaSumString(path string) string { - h := sha256.New() - h.Write([]byte(path)) - return hex.EncodeToString(h.Sum(nil)) -}