display TB in disk usage charts if value >= 1 TB

This commit is contained in:
Henry Dollman
2024-09-23 13:34:40 -04:00
parent a286bed54c
commit 4ee169fea5
2 changed files with 20 additions and 2 deletions

View File

@@ -290,3 +290,17 @@ export async function updateUserSettings() {
console.log('create settings', e)
}
}
/**
* Get the unit of size (TB or GB) for a given size in gigabytes
* @param n size in gigabytes
* @returns unit of size (TB or GB)
*/
export const getSizeUnit = (n: number) => (n >= 1_000 ? ' TB' : ' GB')
/**
* Get the value of number in gigabytes if less than 1000, otherwise in terabytes
* @param n size in gigabytes
* @returns value in GB if less than 1000, otherwise value in TB
*/
export const getSizeVal = (n: number) => (n >= 1_000 ? n / 1_000 : n)