diff --git a/src/pages/Stream/Views/Manage/Alerts.tsx b/src/pages/Stream/Views/Manage/Alerts.tsx index 54d33106..d65173b7 100644 --- a/src/pages/Stream/Views/Manage/Alerts.tsx +++ b/src/pages/Stream/Views/Manage/Alerts.tsx @@ -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) => { diff --git a/src/utils/convertToReadableScale.ts b/src/utils/convertToReadableScale.ts deleted file mode 100644 index 9c2ca32e..00000000 --- a/src/utils/convertToReadableScale.ts +++ /dev/null @@ -1,17 +0,0 @@ -export const convertToReadableScale = (val: number) => { - // Thousands, millions, billions etc.. - let s = ['', ' K', ' M', ' B', ' T']; - - // Dividing the value by 3. - let sNum = Math.floor(('' + val).length / 3); - - // Calculating the precised value. - let 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]; -}; diff --git a/src/utils/formatBytes.ts b/src/utils/formatBytes.ts index 636acb0b..9feb033d 100644 --- a/src/utils/formatBytes.ts +++ b/src/utils/formatBytes.ts @@ -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) => { @@ -13,15 +12,15 @@ 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]; @@ -29,7 +28,8 @@ export function HumanizeNumber(val: number) { // Appending the letter to precised val. return sVal + s[sNum]; -} +}; + export const sanitizeEventsCount = (val: any) => { return typeof val === 'number' ? HumanizeNumber(val) : '0';