|
@@ -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) {
|
|
function getFileIcon(filename: string, isDirectory: boolean) {
|
|
|
if (isDirectory) return Folder;
|
|
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 && (storageData.used_bytes != null || storageData.free_bytes != null) && (
|
|
|
<div className="text-sm text-bambu-gray flex items-center gap-2">
|
|
<div className="text-sm text-bambu-gray flex items-center gap-2">
|
|
|
{storageData.used_bytes != null && (
|
|
{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 && (
|
|
{storageData.used_bytes != null && storageData.free_bytes != null && (
|
|
|
<span className="text-bambu-dark-tertiary">|</span>
|
|
<span className="text-bambu-dark-tertiary">|</span>
|
|
|
)}
|
|
)}
|
|
|
{storageData.free_bytes != null && (
|
|
{storageData.free_bytes != null && (
|
|
|
- <span>{t('printerFiles.storageFree')} {formatFileSize(storageData.free_bytes)}</span>
|
|
|
|
|
|
|
+ <span>{t('printerFiles.storageFree')} {formatStorageSize(storageData.free_bytes)}</span>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
|
)}
|
|
)}
|