1- import { convertBinarySizeUnit } from '../helper' ;
1+ import {
2+ convertBinarySizeUnit ,
3+ SizeUnit ,
4+ sizeUnitToBinarySizeUnit ,
5+ } from '../helper' ;
26import {
37 BaseResourceSlotName ,
48 KnownAcceleratorResourceSlotName ,
@@ -22,6 +26,7 @@ interface ResourceNumberProps {
2226 value : string ;
2327 hideTooltip ?: boolean ;
2428 max ?: string ;
29+ showDetailValue ?: boolean ;
2530}
2631
2732type ResourceTypeInfo < V > = {
@@ -36,6 +41,7 @@ const ResourceNumber: React.FC<ResourceNumberProps> = ({
3641 opts,
3742 hideTooltip = false ,
3843 max,
44+ showDetailValue,
3945} ) => {
4046 const { token } = theme . useToken ( ) ;
4147 const currentGroup = useCurrentResourceGroupValue ( ) ;
@@ -46,13 +52,16 @@ const ResourceNumber: React.FC<ResourceNumberProps> = ({
4652 const formatAmount = ( amount : string ) => {
4753 return mergedResourceSlots ?. [ type ] ?. number_format . binary
4854 ? Number (
49- convertBinarySizeUnit ( amount , 'g' , 3 , true ) ?. numberFixed ,
55+ convertBinarySizeUnit ( amount , 'g' , 2 , true ) ?. numberFixed ,
5056 ) . toString ( )
5157 : ( mergedResourceSlots ?. [ type ] ?. number_format . round_length || 0 ) > 0
5258 ? parseFloat ( amount ) . toFixed ( 2 )
5359 : amount ;
5460 } ;
5561
62+ const convertedAmount = formatAmount ( amount ) ;
63+ const convertedAmountByAuto = convertBinarySizeUnit ( amount , 'auto' , 2 , true ) ;
64+
5665 return (
5766 < Flex direction = "row" gap = "xxs" >
5867 { mergedResourceSlots ?. [ type ] ? (
@@ -62,16 +71,33 @@ const ResourceNumber: React.FC<ResourceNumberProps> = ({
6271 ) }
6372
6473 < Typography . Text >
65- { formatAmount ( amount ) }
74+ { convertedAmount }
6675 { _ . isUndefined ( max )
6776 ? null
6877 : max === 'Infinity'
6978 ? '~∞'
7079 : `~${ formatAmount ( max ) } ` }
7180 </ Typography . Text >
72- < Typography . Text type = "secondary" >
73- { mergedResourceSlots ?. [ type ] ?. display_unit || '' }
74- </ Typography . Text >
81+ < div >
82+ < Typography . Text type = "secondary" >
83+ { mergedResourceSlots ?. [ type ] ?. display_unit || '' }
84+ </ Typography . Text >
85+ { showDetailValue &&
86+ mergedResourceSlots ?. [ type ] ?. number_format . binary &&
87+ convertedAmount === '0' &&
88+ amount !== '0' ? (
89+ < Typography . Text >
90+ ({ Number ( convertedAmountByAuto ?. numberFixed ) . toString ( ) }
91+ < Typography . Text type = "secondary" >
92+ { sizeUnitToBinarySizeUnit (
93+ convertedAmountByAuto ?. unit as SizeUnit ,
94+ ) }
95+ </ Typography . Text >
96+ )
97+ </ Typography . Text >
98+ ) : null }
99+ </ div >
100+
75101 { type === 'mem' && opts ?. shmem && opts ?. shmem > 0 ? (
76102 < Typography . Text
77103 type = "secondary"
0 commit comments