fix: Fix the unit transform in prometheus monitor
1. Fix getValueByUnit to get correct value 2. Fix the unit text, it doesn't need i18n Closes-Bug: #1992407 Change-Id: I6add661f739447666f80308e36991e07f0e8b4aa
This commit is contained in:
parent
1506dd9353
commit
3078eacecb
@ -92,7 +92,7 @@ export const getSuitableValue = (
|
||||
return defaultValue;
|
||||
}
|
||||
const unit = getSuitableUnit(value, unitType);
|
||||
const unitText = unit ? ` ${t(unit)}` : '';
|
||||
const unitText = unit || '';
|
||||
const count = getValueByUnit(value, unit || unitType);
|
||||
return `${count}${unitText}`;
|
||||
};
|
||||
@ -116,15 +116,19 @@ export const getValueByUnit = (num, unit) => {
|
||||
if (value < 1) return 0;
|
||||
break;
|
||||
case 'KiB':
|
||||
case 'KiB/s':
|
||||
value /= 1024;
|
||||
break;
|
||||
case 'MiB':
|
||||
case 'MiB/s':
|
||||
value /= 1024 ** 2;
|
||||
break;
|
||||
case 'GiB':
|
||||
case 'GiB/s':
|
||||
value /= 1024 ** 3;
|
||||
break;
|
||||
case 'TiB':
|
||||
case 'TiB/s':
|
||||
value /= 1024 ** 4;
|
||||
break;
|
||||
case 'Bytes':
|
||||
|
Loading…
Reference in New Issue
Block a user