|
@@ -112,16 +134,32 @@ export default function DownloadComponent() {
|
- {downloadSpeed > 0 ? `${downloadSpeed.toFixed(1)} Mb/s` : '-'}
+ {humanFileSize(size)}
|
+ {width > 576 ? (
+
+ {downloadSpeed > 0 ? `${downloadSpeed.toFixed(1)} Mb/s` : '-'}
+ |
+ ) : (
+ ''
+ )}
+ {width > 576 ? (
+
+ {uploadSpeed > 0 ? `${uploadSpeed.toFixed(1)} Mb/s` : '-'}
+ |
+ ) : (
+ ''
+ )}
- {uploadSpeed > 0 ? `${uploadSpeed.toFixed(1)} Mb/s` : '-'}
+ {torrent.eta <= 0 ? '∞' : calculateETA(torrent.eta)}
|
{(torrent.progress * 100).toFixed(1)}%
diff --git a/src/components/modules/downloads/TotalDownloadsModule.tsx b/src/components/modules/downloads/TotalDownloadsModule.tsx
index 41b5b5413..55f9be34d 100644
--- a/src/components/modules/downloads/TotalDownloadsModule.tsx
+++ b/src/components/modules/downloads/TotalDownloadsModule.tsx
@@ -8,41 +8,10 @@ import { Datum, ResponsiveLine } from '@nivo/line';
import { useListState } from '@mantine/hooks';
import { AddItemShelfButton } from '../../AppShelf/AddAppShelfItem';
import { useConfig } from '../../../tools/state';
+import { humanFileSize } from '../../../tools/humanFileSize';
import { IModule } from '../modules';
import { useSetSafeInterval } from '../../../tools/hooks/useSetSafeInterval';
-/**
- * Format bytes as human-readable text.
- *
- * @param bytes Number of bytes.
- * @param si True to use metric (SI) units, aka powers of 1000. False to use
- * binary (IEC), aka powers of 1024.
- * @param dp Number of decimal places to display.
- *
- * @return Formatted string.
- */
-function humanFileSize(initialBytes: number, si = true, dp = 1) {
- const thresh = si ? 1000 : 1024;
- let bytes = initialBytes;
-
- if (Math.abs(bytes) < thresh) {
- return `${bytes} B`;
- }
-
- const units = si
- ? ['kb', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
- : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
- let u = -1;
- const r = 10 ** dp;
-
- do {
- bytes /= thresh;
- u += 1;
- } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
-
- return `${bytes.toFixed(dp)} ${units[u]}`;
-}
-
export const TotalDownloadsModule: IModule = {
title: 'Download Speed',
description: 'Show the current download speed of supported services',
diff --git a/src/tools/humanFileSize.ts b/src/tools/humanFileSize.ts
new file mode 100644
index 000000000..dfd6c9c1f
--- /dev/null
+++ b/src/tools/humanFileSize.ts
@@ -0,0 +1,31 @@
+/**
+ * Format bytes as human-readable text.
+ *
+ * @param bytes Number of bytes.
+ * @param si True to use metric (SI) units, aka powers of 1000. False to use
+ * binary (IEC), aka powers of 1024.
+ * @param dp Number of decimal places to display.
+ *
+ * @return Formatted string.
+ */
+export function humanFileSize(initialBytes: number, si = true, dp = 1) {
+ const thresh = si ? 1000 : 1024;
+ let bytes = initialBytes;
+
+ if (Math.abs(bytes) < thresh) {
+ return `${bytes} B`;
+ }
+
+ const units = si
+ ? ['kb', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
+ : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
+ let u = -1;
+ const r = 10 ** dp;
+
+ do {
+ bytes /= thresh;
+ u += 1;
+ } while (Math.round(Math.abs(bytes) * r) / r >= thresh && u < units.length - 1);
+
+ return `${bytes.toFixed(dp)} ${units[u]}`;
+}
|