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
This commit is contained in:
AneoPsy
2026-02-18 02:45:43 -10:00
parent 3a028724a8
commit d9dd15dbff
9 changed files with 28 additions and 13 deletions
+1 -1
View File
@@ -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');
});
});
});
+13 -2
View File
@@ -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) && (
<div className="text-sm text-bambu-gray flex items-center gap-2">
{storageData.used_bytes != null && (
<span>{t('printerFiles.storageUsed')} {formatFileSize(storageData.used_bytes)}</span>
<span>{t('printerFiles.storageUsed')} {formatStorageSize(storageData.used_bytes)}</span>
)}
{storageData.used_bytes != null && storageData.free_bytes != null && (
<span className="text-bambu-dark-tertiary">|</span>
)}
{storageData.free_bytes != null && (
<span>{t('printerFiles.storageFree')} {formatFileSize(storageData.free_bytes)}</span>
<span>{t('printerFiles.storageFree')} {formatStorageSize(storageData.free_bytes)}</span>
)}
</div>
)}
+1 -1
View File
@@ -3437,7 +3437,7 @@ export default {
// Time
time: {
unknown: '-',
waiting:'Wartend',
waiting: 'Wartend',
justNow: 'Gerade eben',
now: 'Jetzt',
minsAgo: 'vor {{count}}m',
+2 -2
View File
@@ -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',
},
};
+1 -1
View File
@@ -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',
+3 -3
View File
@@ -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',
+1 -1
View File
@@ -3273,7 +3273,7 @@ export default {
// Time
time: {
unknown: '-',
waiting:'待機中',
waiting: '待機中',
justNow: 'たった今',
now: '今すぐ',
minsAgo: '{{count}}分前',
+5 -1
View File
@@ -477,7 +477,11 @@ function SortableQueueItem({
{isPending && !item.manual_start && (
<span className="flex items-center gap-1.5">
<Clock className="w-3.5 h-3.5" />
{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'}
</span>
)}
</div>
+1 -1
View File
@@ -484,4 +484,4 @@ export function formatRelativeTime(
// Older than 7 days
return formatDateTime(dateStr, timeFormat);
}
}