mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
feat: normalize size data
This commit is contained in:
1 parent
eab728ad5a
commit
55d34acd31
3 files changed
+7
-2
No files matched your search
@@ -10,3 +10,7 @@ export function abbreviateNumber(num: number, decimals: number = 1): string {
|
||||
return num.toString();
|
||||
}
|
||||
}
|
||||
|
||||
export function toDecimals(num: number, decimals: number = 1): number {
|
||||
return parseFloat(num.toFixed(decimals));
|
||||
}
|
||||
@@ -35,6 +35,6 @@ export function humanFileSize(bytes: number): {
|
||||
|
||||
return {
|
||||
value: value[0],
|
||||
unit: value[1] as Size
|
||||
unit: value[1].toUpperCase() as Size
|
||||
};
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
import { BarChart } from '$lib/charts';
|
||||
import { page } from '$app/stores';
|
||||
import { bytesToSize, humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { toDecimals } from '$lib/helpers/numbers.js';
|
||||
|
||||
export let data;
|
||||
|
||||
@@ -26,7 +27,7 @@
|
||||
return {
|
||||
data: files.map((e) => ({
|
||||
date: new Date(e.date).toLocaleDateString(),
|
||||
value: bytesToSize(e.value, unit)
|
||||
value: toDecimals(bytesToSize(e.value, unit), 2)
|
||||
})),
|
||||
unit
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user