Migrate paths dashboard widget to react and add storage metrics
This commit is contained in:
@@ -28,3 +28,11 @@ export function readFileAsText(file: File): Promise<string> {
|
||||
reader.readAsText(file);
|
||||
});
|
||||
}
|
||||
|
||||
/** Gets a human readable string representing a file size in bytes */
|
||||
export function getReadableSize(value: number, precision = 1) {
|
||||
let d = Math.log(value) / Math.log(1024) | 0;
|
||||
|
||||
return (value / Math.pow(1024, d)).toFixed(precision)
|
||||
+ ' ' + (d ? 'KMGTPEZY'[--d] + 'iB' : 'Bytes');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user