feat: add NumberFlowSize component and integrate it into DashboardPage for improved size display

This commit is contained in:
JSC
2025-08-12 22:15:04 +02:00
parent ccd5973db9
commit 7ebeac1280
3 changed files with 25 additions and 56 deletions

View File

@@ -1,38 +0,0 @@
/**
* Utility functions for formatting data for display
*/
export function formatDuration(durationMs: number): string {
if (!durationMs) return "0s"
const totalSeconds = Math.floor(durationMs / 1000)
const hours = Math.floor(totalSeconds / 3600)
const minutes = Math.floor((totalSeconds % 3600) / 60)
const seconds = totalSeconds % 60
if (hours > 0) {
return `${hours}h ${minutes}m ${seconds}s`
}
if (minutes > 0) {
return `${minutes}m ${seconds}s`
}
return `${seconds}s`
}
export function formatFileSize(sizeBytes: number): string {
if (!sizeBytes) return "0 B"
const units = ["B", "KB", "MB", "GB", "TB"]
let size = sizeBytes
let unitIndex = 0
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024
unitIndex++
}
if (unitIndex === 0) {
return `${Math.floor(size)} ${units[unitIndex]}`
}
return `${size.toFixed(1)} ${units[unitIndex]}`
}