bytes and percentage
This commit is contained in:
1 parent
9caa6c830f
commit
1558b27497
5 files changed
+62
-61
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { CheckDiskInfo, CheckHostInfo } from "@/Types/Check";
|
||||
import type { CheckHostInfo } from "@/Types/Check";
|
||||
|
||||
export const getFrequency = (frequency: number | undefined): string => {
|
||||
if (!frequency) return "N/A";
|
||||
@@ -18,32 +18,6 @@ export const getAvgTemp = (temps: number[]): string => {
|
||||
return `${avgTemp?.toFixed(2)} °C`;
|
||||
};
|
||||
|
||||
export const getGbs = (bytes: number | undefined): string => {
|
||||
if (!bytes) {
|
||||
return "N/A";
|
||||
}
|
||||
if (bytes === 0) {
|
||||
return "0 GB";
|
||||
}
|
||||
|
||||
const GB = bytes / (1024 * 1024 * 1024);
|
||||
const MB = bytes / (1024 * 1024);
|
||||
|
||||
if (GB >= 1) {
|
||||
return GB.toFixed(2) + " GB";
|
||||
} else {
|
||||
return MB.toFixed(2) + " MB";
|
||||
}
|
||||
};
|
||||
|
||||
export const getDiskTotalGbs = (disk?: Partial<CheckDiskInfo>[]): string => {
|
||||
if (!disk) {
|
||||
return getGbs(0);
|
||||
}
|
||||
const totalBytes = disk?.reduce((acc, disk) => acc + (disk.total_bytes || 0), 0) || 0;
|
||||
return getGbs(totalBytes);
|
||||
};
|
||||
|
||||
export const getOsAndPlatform = (hostInfo: CheckHostInfo | undefined): string => {
|
||||
if (!hostInfo) {
|
||||
return "N/A";
|
||||
|
||||
Reference in new issue
Block a user