From d9dd15dbff7ccd9b350a348419d1e4905fc41cd9 Mon Sep 17 00:00:00 2001 From: AneoPsy Date: Wed, 18 Feb 2026 02:45:43 -1000 Subject: [PATCH] fix(ui): storage size formatting, overdue queue items, and i18n fixes - Add formatStorageSize helper in FileManagerModal to display storage in GB/MB instead of raw bytes - Show "Overdue" label for queue items whose scheduled time has passed by more than 1 minute - Fix missing "in" prefix for English inDays translation - Fix swapped justNow/now translations in Italian locale - Fix whitespace formatting for waiting key across all locales - Add trailing newline to date.ts and date.test.ts --- frontend/src/__tests__/utils/date.test.ts | 2 +- frontend/src/components/FileManagerModal.tsx | 15 +++++++++++++-- frontend/src/i18n/locales/de.ts | 2 +- frontend/src/i18n/locales/en.ts | 4 ++-- frontend/src/i18n/locales/fr.ts | 2 +- frontend/src/i18n/locales/it.ts | 6 +++--- frontend/src/i18n/locales/ja.ts | 2 +- frontend/src/pages/QueuePage.tsx | 6 +++++- frontend/src/utils/date.ts | 2 +- 9 files changed, 28 insertions(+), 13 deletions(-) diff --git a/frontend/src/__tests__/utils/date.test.ts b/frontend/src/__tests__/utils/date.test.ts index 4934dd8b2..da5bfe4a6 100644 --- a/frontend/src/__tests__/utils/date.test.ts +++ b/frontend/src/__tests__/utils/date.test.ts @@ -434,4 +434,4 @@ describe('formatRelativeTime', () => { expect(formatRelativeTime('2025-06-15T11:55:00Z', 'system', t)).toBe('5 minutes ago'); expect(formatRelativeTime('2025-06-15T12:05:00Z', 'system', t)).toBe('in 5 minutes'); }); -}); \ No newline at end of file +}); diff --git a/frontend/src/components/FileManagerModal.tsx b/frontend/src/components/FileManagerModal.tsx index 8955dbd09..62d24e615 100644 --- a/frontend/src/components/FileManagerModal.tsx +++ b/frontend/src/components/FileManagerModal.tsx @@ -236,6 +236,17 @@ function PrinterFileViewerModal({ printerId, filePath, filename, onClose }: Prin ); } +function formatStorageSize(bytes: number): string { + if (bytes === 0) return '0 GB'; + const gb = bytes / (1024 * 1024 * 1024); + if (gb >= 1) { + return `${gb.toFixed(1)} GB`; + } + const mb = bytes / (1024 * 1024); + return `${mb.toFixed(0)} MB`; +} + + function getFileIcon(filename: string, isDirectory: boolean) { if (isDirectory) return Folder; @@ -427,13 +438,13 @@ export function FileManagerModal({ printerId, printerName, onClose }: FileManage {storageData && (storageData.used_bytes != null || storageData.free_bytes != null) && (
{storageData.used_bytes != null && ( - {t('printerFiles.storageUsed')} {formatFileSize(storageData.used_bytes)} + {t('printerFiles.storageUsed')} {formatStorageSize(storageData.used_bytes)} )} {storageData.used_bytes != null && storageData.free_bytes != null && ( | )} {storageData.free_bytes != null && ( - {t('printerFiles.storageFree')} {formatFileSize(storageData.free_bytes)} + {t('printerFiles.storageFree')} {formatStorageSize(storageData.free_bytes)} )}
)} diff --git a/frontend/src/i18n/locales/de.ts b/frontend/src/i18n/locales/de.ts index 75ebb7d86..a377fdbbc 100644 --- a/frontend/src/i18n/locales/de.ts +++ b/frontend/src/i18n/locales/de.ts @@ -3437,7 +3437,7 @@ export default { // Time time: { unknown: '-', - waiting:'Wartend', + waiting: 'Wartend', justNow: 'Gerade eben', now: 'Jetzt', minsAgo: 'vor {{count}}m', diff --git a/frontend/src/i18n/locales/en.ts b/frontend/src/i18n/locales/en.ts index b6d2842d2..8d84f5874 100644 --- a/frontend/src/i18n/locales/en.ts +++ b/frontend/src/i18n/locales/en.ts @@ -3442,7 +3442,7 @@ export default { // Time time: { unknown: '-', - waiting:'Waiting', + waiting: 'Waiting', justNow: 'Just now', now: 'Now', minsAgo: '{{count}}m ago', @@ -3450,6 +3450,6 @@ export default { hoursAgo: '{{count}}h ago', inHours: 'in {{count}}h', daysAgo: '{{count}}d ago', - inDays: '{{count}}d', + inDays: 'in {{count}}d', }, }; diff --git a/frontend/src/i18n/locales/fr.ts b/frontend/src/i18n/locales/fr.ts index 753c6a6e2..fb796514d 100644 --- a/frontend/src/i18n/locales/fr.ts +++ b/frontend/src/i18n/locales/fr.ts @@ -3430,7 +3430,7 @@ export default { // Time time: { unknown: '-', - waiting:'En attente', + waiting: 'En attente', justNow: 'À l\'instant', now: 'Maintenant', minsAgo: 'il y a {{count}}m', diff --git a/frontend/src/i18n/locales/it.ts b/frontend/src/i18n/locales/it.ts index c1b107748..30684b0f5 100644 --- a/frontend/src/i18n/locales/it.ts +++ b/frontend/src/i18n/locales/it.ts @@ -2818,9 +2818,9 @@ export default { // Time time: { unknown: '-', - waiting:'In attesa', - justNow: 'Adesso', - now: 'Proprio ora', + waiting: 'In attesa', + justNow: 'Proprio ora', + now: 'Ora', minsAgo: '{{count}}m fa', inMins: 'tra {{count}}m', hoursAgo: '{{count}}h fa', diff --git a/frontend/src/i18n/locales/ja.ts b/frontend/src/i18n/locales/ja.ts index b6b5119f5..65da44853 100644 --- a/frontend/src/i18n/locales/ja.ts +++ b/frontend/src/i18n/locales/ja.ts @@ -3273,7 +3273,7 @@ export default { // Time time: { unknown: '-', - waiting:'待機中', + waiting: '待機中', justNow: 'たった今', now: '今すぐ', minsAgo: '{{count}}分前', diff --git a/frontend/src/pages/QueuePage.tsx b/frontend/src/pages/QueuePage.tsx index 3d7b583d9..5b03e070a 100644 --- a/frontend/src/pages/QueuePage.tsx +++ b/frontend/src/pages/QueuePage.tsx @@ -477,7 +477,11 @@ function SortableQueueItem({ {isPending && !item.manual_start && ( - {item.scheduled_time ? formatRelativeTime(item.scheduled_time, timeFormat, t) : t?.('queue.time.asap') ?? 'ASAP'} + {item.scheduled_time + ? (new Date(item.scheduled_time).getTime() - Date.now() < -60000 + ? t?.('queue.time.overdue') ?? 'Overdue' + : formatRelativeTime(item.scheduled_time, timeFormat, t)) + : t?.('queue.time.asap') ?? 'ASAP'} )} diff --git a/frontend/src/utils/date.ts b/frontend/src/utils/date.ts index 3df2e246f..df1008bfb 100644 --- a/frontend/src/utils/date.ts +++ b/frontend/src/utils/date.ts @@ -484,4 +484,4 @@ export function formatRelativeTime( // Older than 7 days return formatDateTime(dateStr, timeFormat); -} \ No newline at end of file +}