Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pages/Stream/Views/Manage/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ type ColumnRuleProps = {
};

const getInputComponent = (type: 'text' | 'number' | 'timestamp') => {
return type === 'text' || 'timestamp' ? TextInput : NumberInput;
return type === 'text' || type === 'timestamp' ? TextInput : NumberInput;
};

const ColumnRule = (props: ColumnRuleProps) => {
Expand Down
17 changes: 0 additions & 17 deletions src/utils/convertToReadableScale.ts

This file was deleted.

16 changes: 8 additions & 8 deletions src/utils/formatBytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ export const formatBytes = (a: number, b: number = 1) => {
if (!+a) return '0 Bytes';
const c = b < 0 ? 0 : b,
d = Math.floor(Math.log(a) / Math.log(1024));
return `${parseFloat((a / Math.pow(1024, d)).toFixed(c))} ${
['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'][d]
}`;
return `${parseFloat((a / Math.pow(1024, d)).toFixed(c))} ${['Bytes', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'][d]
}`;
};

export const convertGibToBytes = (value: number) => {
Expand All @@ -13,23 +12,24 @@ export const convertGibToBytes = (value: number) => {
return value * Math.pow(1024, 3);
};

export function HumanizeNumber(val: number) {
export const HumanizeNumber = (val: number) => {
// Thousands, millions, billions etc..
let s = ['', ' K', ' M', ' B', ' T'];
const s = ['', ' K', ' M', ' B', ' T'];

// Dividing the value by 3.
let sNum = Math.floor(('' + val).length / 3);
const sNum = Math.floor(('' + val).length / 3);

// Calculating the precised value.
let sVal = parseFloat((sNum != 0 ? val / Math.pow(1000, sNum) : val).toPrecision(4));
const sVal = parseFloat((sNum != 0 ? val / Math.pow(1000, sNum) : val).toPrecision(4));

if (sVal % 1 != 0) {
return sVal.toFixed(1) + s[sNum];
}

// Appending the letter to precised val.
return sVal + s[sNum];
}
};


export const sanitizeEventsCount = (val: any) => {
return typeof val === 'number' ? HumanizeNumber(val) : '0';
Expand Down
Loading