mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-19 07:33:18 +02:00
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:
@@ -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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user