From 29c9f3ecac3c8bed4e77ae7866fa2b391dcf83e7 Mon Sep 17 00:00:00 2001 From: Thomas Camlong <49837342+ajnart@users.noreply.github.com> Date: Tue, 7 Jun 2022 08:32:39 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=94=A5=20Remove=20the=20Code=20qualit?= =?UTF-8?q?y=20tickboxes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They were annoying (to me at least) --- .github/pull_request_template.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index a84bac79d22..ad88029a180 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -14,10 +14,3 @@ ### Screenshot _(if applicable)_ > If you've introduced any significant UI changes, please include a screenshot. - -### Code Quality Checklist _(Please complete)_ -- [ ] All changes are backwards compatible -- [ ] There are no (new) build warnings or errors -- [ ] _(If a new config option is added)_ Attribute is outlined in the schema and documented -- [ ] _(If a new dependency is added)_ Package is essential, and has been checked out for security or performance -- [ ] Bumps version, if new feature added From de0c625f88d9f97ea049fcbca127818267722d3c Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 7 Jun 2022 09:50:04 +0200 Subject: [PATCH 2/3] :bug: Fixing Deluge integration Thanks to @scttcper for fixing https://github.com/scttcper/deluge/issues/106 so quickly ! --- package.json | 2 +- src/components/AppShelf/AddAppShelfItem.tsx | 29 +++++++------- .../modules/downloads/DownloadsModule.tsx | 39 +++++++++++++++---- .../downloads/TotalDownloadsModule.tsx | 3 +- src/pages/api/modules/downloads.ts | 24 ++++++------ yarn.lock | 25 ++++++++---- 6 files changed, 77 insertions(+), 45 deletions(-) diff --git a/package.json b/package.json index bbc97e64f70..be925f35036 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "ci": "yarn test && yarn lint --fix && yarn typecheck && yarn prettier:write" }, "dependencies": { - "@ctrl/deluge": "^4.0.0", + "@ctrl/deluge": "^4.1.0", "@ctrl/qbittorrent": "^4.0.0", "@ctrl/shared-torrent": "^4.1.0", "@ctrl/transmission": "^4.1.1", diff --git a/src/components/AppShelf/AddAppShelfItem.tsx b/src/components/AppShelf/AddAppShelfItem.tsx index 0a59965dd06..93bb83c796e 100644 --- a/src/components/AppShelf/AddAppShelfItem.tsx +++ b/src/components/AppShelf/AddAppShelfItem.tsx @@ -300,21 +300,20 @@ export function AddAppShelfItemForm(props: { setOpened: (b: boolean) => void } & /> )} - {form.values.type === 'Deluge' || - (form.values.type === 'Transmission' && ( - <> - { - form.setFieldValue('password', event.currentTarget.value); - }} - error={form.errors.password && 'Invalid password'} - /> - - ))} + {(form.values.type === 'Deluge' || form.values.type === 'Transmission') && ( + <> + { + form.setFieldValue('password', event.currentTarget.value); + }} + error={form.errors.password && 'Invalid password'} + /> + + )} diff --git a/src/components/modules/downloads/DownloadsModule.tsx b/src/components/modules/downloads/DownloadsModule.tsx index d804ebd386c..e8d7b9d1bba 100644 --- a/src/components/modules/downloads/DownloadsModule.tsx +++ b/src/components/modules/downloads/DownloadsModule.tsx @@ -1,4 +1,15 @@ -import { Table, Text, Tooltip, Title, Group, Progress, Skeleton, ScrollArea } from '@mantine/core'; +import { + Table, + Text, + Tooltip, + Title, + Group, + Progress, + Skeleton, + ScrollArea, + Center, + Image, +} from '@mantine/core'; import { IconDownload as Download } from '@tabler/icons'; import { useEffect, useState } from 'react'; import axios from 'axios'; @@ -34,14 +45,18 @@ export default function DownloadComponent() { (config?.modules?.[DownloadsModule.title]?.options?.hidecomplete?.value as boolean) ?? false; const [torrents, setTorrents] = useState([]); const setSafeInterval = useSetSafeInterval(); + const [isLoading, setIsLoading] = useState(true); useEffect(() => { + setIsLoading(true); + if (downloadServices.length === 0) return; setSafeInterval(() => { // Send one request with each download service inside axios.post('/api/modules/downloads', { config }).then((response) => { setTorrents(response.data); + setIsLoading(false); }); }, 1000); - }, [config.modules]); + }, [config.services]); if (downloadServices.length === 0) { return ( @@ -55,7 +70,7 @@ export default function DownloadComponent() { ); } - if (torrents.length === 0) { + if (isLoading) { return ( <> @@ -115,14 +130,24 @@ export default function DownloadComponent() { ); }); + + const easteregg = ( +
+ +
+ ); return ( Your torrents - - {ths} - {rows} -
+ {rows.length > 0 ? ( + + {ths} + {rows} +
+ ) : ( + easteregg + )}
); diff --git a/src/components/modules/downloads/TotalDownloadsModule.tsx b/src/components/modules/downloads/TotalDownloadsModule.tsx index 56d73516f09..41b5b541367 100644 --- a/src/components/modules/downloads/TotalDownloadsModule.tsx +++ b/src/components/modules/downloads/TotalDownloadsModule.tsx @@ -73,12 +73,13 @@ export default function TotalDownloadsComponent() { const totalDownloadSpeed = torrents.reduce((acc, torrent) => acc + torrent.downloadSpeed, 0); const totalUploadSpeed = torrents.reduce((acc, torrent) => acc + torrent.uploadSpeed, 0); useEffect(() => { + if (downloadServices.length === 0) return; setSafeInterval(() => { axios.post('/api/modules/downloads', { config }).then((response) => { setTorrents(response.data); }); }, 1000); - }, []); + }, [config.services]); useEffect(() => { torrentHistoryHandlers.append({ diff --git a/src/pages/api/modules/downloads.ts b/src/pages/api/modules/downloads.ts index 80d6364752a..be923335386 100644 --- a/src/pages/api/modules/downloads.ts +++ b/src/pages/api/modules/downloads.ts @@ -24,36 +24,34 @@ async function Post(req: NextApiRequest, res: NextApiResponse) { } if (qBittorrentService) { torrents.push( - ...( + ...(( await new QBittorrent({ baseUrl: qBittorrentService.url, username: qBittorrentService.username, password: qBittorrentService.password, }).getAllData() - ).torrents + ).torrents) ); } if (delugeService) { - const delugeTorrents = ( - await new Deluge({ - baseUrl: delugeService.url, - username: delugeService.username, - password: delugeService.password, - }).getAllData() - ).torrents; - delugeTorrents.forEach((delugeTorrent) => - torrents.push({ ...delugeTorrent, progress: delugeTorrent.progress / 100 }) + torrents.push( + ...(( + await new Deluge({ + baseUrl: delugeService.url, + password: delugeService.password, + }).getAllData() + ).torrents) ); } if (transmissionService) { torrents.push( - ...( + ...(( await new Transmission({ baseUrl: transmissionService.url, username: transmissionService.username, password: transmissionService.password, }).getAllData() - ).torrents + ).torrents) ); } res.status(200).json(torrents); diff --git a/yarn.lock b/yarn.lock index 55e7f46afaf..044a138eb41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1583,17 +1583,17 @@ __metadata: languageName: node linkType: hard -"@ctrl/deluge@npm:^4.0.0": - version: 4.0.0 - resolution: "@ctrl/deluge@npm:4.0.0" +"@ctrl/deluge@npm:^4.1.0": + version: 4.1.0 + resolution: "@ctrl/deluge@npm:4.1.0" dependencies: - "@ctrl/magnet-link": ^3.1.0 - "@ctrl/shared-torrent": ^4.1.0 + "@ctrl/magnet-link": ^3.1.1 + "@ctrl/shared-torrent": ^4.1.1 "@ctrl/url-join": ^2.0.0 formdata-node: ^4.3.2 - got: ^12.0.1 + got: ^12.1.0 tough-cookie: ^4.0.0 - checksum: d4b828fb580a3e4c589169044b78e74d2d1c6ea3ff24f24c9aba59a5fc88320c494eebe814aa0f048e772d698ddd5979f8cd92d4144b0550227bc502342c82ed + checksum: a17f974e1b98a9086e1036604a86d3e14b5cf9c8d0fd997357dd4522dc296f0ef92e2697231f97f7211c0224e35256af966f722b6b316a363533328908cd8d5e languageName: node linkType: hard @@ -1606,6 +1606,15 @@ __metadata: languageName: node linkType: hard +"@ctrl/magnet-link@npm:^3.1.1": + version: 3.1.1 + resolution: "@ctrl/magnet-link@npm:3.1.1" + dependencies: + "@ctrl/ts-base32": ^2.1.1 + checksum: 82533b50e2a60b2cfbad19879b0b16dbdbf2cfb633cda519d9cac7ab4039d52f98bc10185a5f6ffd29cfe415d709b8748ebe7cf763e522e0c4dcee8dde6506fe + languageName: node + linkType: hard + "@ctrl/qbittorrent@npm:^4.0.0": version: 4.0.0 resolution: "@ctrl/qbittorrent@npm:4.0.0" @@ -9416,7 +9425,7 @@ __metadata: resolution: "homarr@workspace:." dependencies: "@babel/core": ^7.17.8 - "@ctrl/deluge": ^4.0.0 + "@ctrl/deluge": ^4.1.0 "@ctrl/qbittorrent": ^4.0.0 "@ctrl/shared-torrent": ^4.1.0 "@ctrl/transmission": ^4.1.1 From b72afc227016772f64db9be00ced2068b78ddc39 Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 7 Jun 2022 10:36:47 +0200 Subject: [PATCH 3/3] =?UTF-8?q?:package:=20=F0=9F=92=84=20Upgrade=20packag?= =?UTF-8?q?es=20and=20style?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 18 ++-- src/components/AppShelf/AppShelf.tsx | 2 - src/components/layout/Header.tsx | 7 +- src/components/layout/Layout.tsx | 6 +- src/pages/_app.tsx | 1 - src/pages/api/modules/downloads.ts | 12 +-- yarn.lock | 130 +++++++++++++-------------- 7 files changed, 82 insertions(+), 94 deletions(-) diff --git a/package.json b/package.json index be925f35036..0eb7931ac92 100644 --- a/package.json +++ b/package.json @@ -31,20 +31,20 @@ "@dnd-kit/core": "^6.0.1", "@dnd-kit/sortable": "^7.0.0", "@dnd-kit/utilities": "^3.2.0", - "@mantine/core": "^4.2.6", - "@mantine/dates": "^4.2.6", - "@mantine/dropzone": "^4.2.6", - "@mantine/form": "^4.2.6", - "@mantine/hooks": "^4.2.6", - "@mantine/next": "^4.2.6", - "@mantine/notifications": "^4.2.6", - "@mantine/prism": "^4.2.6", + "@mantine/core": "^4.2.8", + "@mantine/dates": "^4.2.8", + "@mantine/dropzone": "^4.2.8", + "@mantine/form": "^4.2.8", + "@mantine/hooks": "^4.2.8", + "@mantine/next": "^4.2.8", + "@mantine/notifications": "^4.2.8", + "@mantine/prism": "^4.2.8", "@nivo/core": "^0.79.0", "@nivo/line": "^0.79.1", "@tabler/icons": "^1.68.0", "axios": "^0.27.2", "cookies-next": "^2.0.4", - "dayjs": "^1.11.2", + "dayjs": "^1.11.3", "framer-motion": "^6.3.1", "js-file-download": "^0.4.12", "next": "12.1.6", diff --git a/src/components/AppShelf/AppShelf.tsx b/src/components/AppShelf/AppShelf.tsx index 4730f0b3914..422435052a7 100644 --- a/src/components/AppShelf/AppShelf.tsx +++ b/src/components/AppShelf/AppShelf.tsx @@ -19,7 +19,6 @@ import { ModuleWrapper } from '../modules/moduleWrapper'; import { DownloadsModule } from '../modules'; const useStyles = createStyles((theme, _params) => ({ - item: { borderBottom: 0, overflow: 'hidden', @@ -31,7 +30,6 @@ const useStyles = createStyles((theme, _params) => ({ itemOpened: { borderColor: theme.colorScheme === 'dark' ? theme.colors.dark[5] : theme.colors.gray[3], }, - })); const AppShelf = (props: any) => { diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 6b1faca07db..1cfb218a5a2 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -17,12 +17,7 @@ import SearchBar from '../modules/search/SearchModule'; import { AddItemShelfButton } from '../AppShelf/AddAppShelfItem'; import { SettingsMenuButton } from '../Settings/SettingsMenu'; import { ModuleWrapper } from '../modules/moduleWrapper'; -import { - CalendarModule, - TotalDownloadsModule, - WeatherModule, - DateModule, -} from '../modules'; +import { CalendarModule, TotalDownloadsModule, WeatherModule, DateModule } from '../modules'; const HEADER_HEIGHT = 60; diff --git a/src/components/layout/Layout.tsx b/src/components/layout/Layout.tsx index 8b82b4a748d..ac2c3c74296 100644 --- a/src/components/layout/Layout.tsx +++ b/src/components/layout/Layout.tsx @@ -10,11 +10,7 @@ const useStyles = createStyles((theme) => ({ export default function Layout({ children, style }: any) { const { classes, cx } = useStyles(); return ( - } - header={
} - footer={