diff --git a/src/components/AppShelf/AppShelf.tsx b/src/components/AppShelf/AppShelf.tsx index 62be7994c..974729dac 100644 --- a/src/components/AppShelf/AppShelf.tsx +++ b/src/components/AppShelf/AppShelf.tsx @@ -126,7 +126,7 @@ const AppShelf = (props: any) => { const noCategory = config.services.filter( (e) => e.category === undefined || e.category === null ); - const downloadEnabled = config.modules?.[DownloadsModule.id]?.enabled ?? false; + const downloadEnabled = config.modules?.[TorrentsModule.id]?.enabled ?? false; // Create an item with 0: true, 1: true, 2: true... For each category return ( // TODO: Style accordion so that the bar is transparent to the user settings @@ -150,7 +150,7 @@ const AppShelf = (props: any) => { {/* Return the item for all services without category */} {noCategory && noCategory.length > 0 ? ( - Other + {t('accordions.others.text')} {getItems()} ) : null} diff --git a/src/modules/torrents/TotalDownloadsModule.tsx b/src/modules/torrents/TotalDownloadsModule.tsx index e0e7f05af..1dbb44d66 100644 --- a/src/modules/torrents/TotalDownloadsModule.tsx +++ b/src/modules/torrents/TotalDownloadsModule.tsx @@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'; import axios from 'axios'; import { NormalizedTorrent } from '@ctrl/shared-torrent'; import { linearGradientDef } from '@nivo/core'; +import { useTranslation } from 'next-i18next'; import { Datum, ResponsiveLine } from '@nivo/line'; import { useListState } from '@mantine/hooks'; import { showNotification } from '@mantine/notifications'; @@ -14,10 +15,10 @@ import { IModule } from '../ModuleTypes'; import { useSetSafeInterval } from '../../tools/hooks/useSetSafeInterval'; export const TotalDownloadsModule: IModule = { - id: 'totalDownload', title: 'Download Speed', icon: Download, component: TotalDownloadsComponent, + id: 'dlspeed', }; interface torrentHistory { @@ -36,6 +37,7 @@ export default function TotalDownloadsComponent() { service.type === 'Transmission' || service.type === 'Deluge' ) ?? []; + const { t } = useTranslation(`modules/${TotalDownloadsModule.id}`); const [torrentHistory, torrentHistoryHandlers] = useListState([]); const [torrents, setTorrents] = useState([]); @@ -69,6 +71,30 @@ export default function TotalDownloadsComponent() { }, 1000); }, [config.services]); + useEffect(() => { + torrentHistoryHandlers.append({ + x: Date.now(), + down: totalDownloadSpeed, + up: totalUploadSpeed, + }); + }, [totalDownloadSpeed, totalUploadSpeed]); + + if (downloadServices.length === 0) { + return ( + + {t('card.errors.noDownloadClients.title')} + + + {t('card.errors.noDownloadClients.text')} + + + ); + } + const theme = useMantineTheme(); // Load the last 10 values from the history const history = torrentHistory.slice(-10); @@ -81,41 +107,21 @@ export default function TotalDownloadsComponent() { y: load.down, })) as Datum[]; - useEffect(() => { - torrentHistoryHandlers.append({ - x: Date.now(), - down: totalDownloadSpeed, - up: totalUploadSpeed, - }); - }, [totalDownloadSpeed, totalUploadSpeed]); - - if (downloadServices.length === 0) { - return ( - - No supported download clients found! - - - Add a download service to view your current downloads - - - ); - } - return ( - Current download speed + {t('card.lineChart.title')} - Download: {humanFileSize(totalDownloadSpeed)}/s + + {t('card.lineChart.totalDownload', { download: humanFileSize(totalDownloadSpeed) })} + - Upload: {humanFileSize(totalUploadSpeed)}/s + + {t('card.lineChart.totalUpload', { upload: humanFileSize(totalUploadSpeed) })} + - {roundedSeconds} seconds ago + {t('card.lineChart.timeSpan', { seconds: roundedSeconds })} - Download: {humanFileSize(Download)} + + {t('card.lineChart.download', { download: humanFileSize(Download) })} + - Upload: {humanFileSize(Upload)} + + {t('card.lineChart.upload', { upload: humanFileSize(Upload) })} +