diff --git a/react/src/components/AgentDetailModal.tsx b/react/src/components/AgentDetailModal.tsx index c0f80a9cf..ce6b89c31 100644 --- a/react/src/components/AgentDetailModal.tsx +++ b/react/src/components/AgentDetailModal.tsx @@ -1,4 +1,4 @@ -import { iSizeToSize } from '../helper'; +import { convertBinarySizeUnit } from '../helper'; import { useResourceSlotsDetails } from '../hooks/backendai'; import BAIModal, { BAIModalProps } from './BAIModal'; import BAIProgressWithLabel from './BAIProgressWithLabel'; @@ -93,16 +93,18 @@ const AgentDetailModal: React.FC = ({ ) : null} @@ -115,8 +117,11 @@ const AgentDetailModal: React.FC = ({ TX: { - iSizeToSize(parsedLiveStat?.node?.net_tx?.current, 'm', 1) - ?.numberUnit + convertBinarySizeUnit( + parsedLiveStat?.node?.net_tx?.current, + 'm', + 1, + )?.numberUnit } iB @@ -125,8 +130,11 @@ const AgentDetailModal: React.FC = ({ RX: { - iSizeToSize(parsedLiveStat?.node?.net_rx?.current, 'm', 1) - ?.numberUnit + convertBinarySizeUnit( + parsedLiveStat?.node?.net_rx?.current, + 'm', + 1, + )?.numberUnit } iB diff --git a/react/src/components/AgentList.tsx b/react/src/components/AgentList.tsx index a87665057..4049b5126 100644 --- a/react/src/components/AgentList.tsx +++ b/react/src/components/AgentList.tsx @@ -1,6 +1,6 @@ import { bytesToGB, - iSizeToSize, + convertBinarySizeUnit, toFixedFloorWithoutTrailingZeros, transformSorterToOrderString, } from '../helper'; @@ -340,11 +340,17 @@ const AgentList: React.FC = ({ - {iSizeToSize(parsedOccupiedSlots.mem, 'g', 0) - ?.numberFixed ?? 0} + {convertBinarySizeUnit( + parsedOccupiedSlots.mem, + 'g', + 0, + )?.numberFixed ?? 0} / - {iSizeToSize(parsedAvailableSlots.mem, 'g', 0) - ?.numberFixed ?? 0} + {convertBinarySizeUnit( + parsedAvailableSlots.mem, + 'g', + 0, + )?.numberFixed ?? 0} = ({ percent={liveStat.mem_util.ratio} width={120} valueLabel={ - iSizeToSize(_.toString(liveStat.mem_util.current), 'g') - ?.numberFixed + + convertBinarySizeUnit( + _.toString(liveStat.mem_util.current), + 'g', + )?.numberFixed + '/' + - iSizeToSize(_.toString(liveStat.mem_util.capacity), 'g') - ?.numberFixed + + convertBinarySizeUnit( + _.toString(liveStat.mem_util.capacity), + 'g', + )?.numberFixed + ' GiB' } /> @@ -568,7 +578,7 @@ const AgentList: React.FC = ({ 100 || 0 } valueLabel={ - iSizeToSize( + convertBinarySizeUnit( _.toString( liveStat[statKey as keyof typeof liveStat] .current, @@ -576,7 +586,7 @@ const AgentList: React.FC = ({ 'g', )?.numberFixed + '/' + - iSizeToSize( + convertBinarySizeUnit( _.toString( liveStat[statKey as keyof typeof liveStat] .capacity, diff --git a/react/src/components/AvailableResourcesCard.tsx b/react/src/components/AvailableResourcesCard.tsx index 69fe66c6c..db214d22f 100644 --- a/react/src/components/AvailableResourcesCard.tsx +++ b/react/src/components/AvailableResourcesCard.tsx @@ -1,4 +1,4 @@ -import { iSizeToSize } from '../helper'; +import { convertBinarySizeUnit } from '../helper'; import { useCurrentProjectValue } from '../hooks/useCurrentProject'; import { useResourceLimitAndRemaining } from '../hooks/useResourceLimitAndRemaining'; import BAIProgressWithLabel from './BAIProgressWithLabel'; @@ -58,12 +58,14 @@ const AvailableResourcesCard = () => { diff --git a/react/src/components/DynamicUnitInputNumber.tsx b/react/src/components/DynamicUnitInputNumber.tsx index 16bbd16b8..36f8ecadf 100644 --- a/react/src/components/DynamicUnitInputNumber.tsx +++ b/react/src/components/DynamicUnitInputNumber.tsx @@ -1,4 +1,4 @@ -import { iSizeToSize, parseUnit } from '../helper'; +import { convertBinarySizeUnit, parseUnit, SizeUnit } from '../helper'; import useControllableState from '../hooks/useControllableState'; import { usePrevious } from 'ahooks'; import { InputNumber, InputNumberProps, Select, Typography } from 'antd'; @@ -99,13 +99,16 @@ const DynamicUnitInputNumber: React.FC = ({ }} //TODO: When min and max have different units, they should be calculated and put in. // 입력의 초소단위 확인 0.4g 가 되는지 확인 - // @ts-ignore - max={maxUnit === unit ? maxNumValue : iSizeToSize(max, unit).number} + max={ + maxUnit === unit + ? maxNumValue + : convertBinarySizeUnit(max, unit as SizeUnit)?.number + } min={ minUnit === unit ? minNumValue : // @ts-ignore - iSizeToSize(min, unit).number + convertBinarySizeUnit(min, unit).number } addonAfter={