11import DataTable from '@gravity-ui/react-data-table' ;
2+ import { DefinitionList } from '@gravity-ui/uikit' ;
23
34import { getLoadSeverityForNode } from '../../store/reducers/nodes/utils' ;
45import type { TPoolStats } from '../../types/api/nodes' ;
@@ -11,15 +12,18 @@ import {
1112} from '../../utils/dataFormatters/dataFormatters' ;
1213import { getSpaceUsageSeverity } from '../../utils/storage' ;
1314import type { Column } from '../../utils/tableUtils/types' ;
15+ import { isNumeric } from '../../utils/utils' ;
1416import { CellWithPopover } from '../CellWithPopover/CellWithPopover' ;
1517import { NodeHostWrapper } from '../NodeHostWrapper/NodeHostWrapper' ;
1618import type { NodeHostData } from '../NodeHostWrapper/NodeHostWrapper' ;
1719import { PoolsGraph } from '../PoolsGraph/PoolsGraph' ;
1820import { ProgressViewer } from '../ProgressViewer/ProgressViewer' ;
1921import { TabletsStatistic } from '../TabletsStatistic' ;
22+ import { formatPool } from '../TooltipsContent' ;
2023import { UsageLabel } from '../UsageLabel/UsageLabel' ;
2124
2225import { NODES_COLUMNS_IDS , NODES_COLUMNS_TITLES } from './constants' ;
26+ import i18n from './i18n' ;
2327import type { GetNodesColumnsParams } from './types' ;
2428
2529export function getNodeIdColumn < T extends { NodeId ?: string | number } > ( ) : Column < T > {
@@ -114,24 +118,52 @@ export function getMemoryColumn<
114118 resizeMinWidth : 170 ,
115119 } ;
116120}
121+
117122export function getRAMColumn < T extends { MemoryUsed ?: string ; MemoryLimit ?: string } > ( ) : Column < T > {
118123 return {
119124 name : NODES_COLUMNS_IDS . RAM ,
120125 header : NODES_COLUMNS_TITLES . RAM ,
121126 sortAccessor : ( { MemoryUsed = 0 } ) => Number ( MemoryUsed ) ,
122127 defaultOrder : DataTable . DESCENDING ,
123- render : ( { row} ) => (
124- < ProgressViewer
125- value = { row . MemoryUsed }
126- capacity = { row . MemoryLimit }
127- formatValues = { ( value , total ) =>
128- formatStorageValues ( value , total , 'gb' , undefined , true )
129- }
130- colorizeProgress
131- vertical
132- hideCapacity
133- />
134- ) ,
128+ render : ( { row} ) => {
129+ const [ memoryUsed , memoryLimit ] =
130+ isNumeric ( row . MemoryUsed ) && isNumeric ( row . MemoryLimit )
131+ ? formatStorageValues (
132+ Number ( row . MemoryUsed ) ,
133+ Number ( row . MemoryLimit ) ,
134+ 'gb' ,
135+ undefined ,
136+ true ,
137+ )
138+ : [ 0 , 0 ] ;
139+ return (
140+ < CellWithPopover
141+ placement = { [ 'top' , 'auto' ] }
142+ fullWidth
143+ content = {
144+ < DefinitionList responsive >
145+ < DefinitionList . Item name = { i18n ( 'field_memory-used' ) } >
146+ { memoryUsed }
147+ </ DefinitionList . Item >
148+ < DefinitionList . Item name = { i18n ( 'field_memory-limit' ) } >
149+ { memoryLimit }
150+ </ DefinitionList . Item >
151+ </ DefinitionList >
152+ }
153+ >
154+ < ProgressViewer
155+ value = { row . MemoryUsed }
156+ capacity = { row . MemoryLimit }
157+ formatValues = { ( value , total ) =>
158+ formatStorageValues ( value , total , 'gb' , undefined , true )
159+ }
160+ colorizeProgress
161+ vertical
162+ hideCapacity
163+ />
164+ </ CellWithPopover >
165+ ) ;
166+ } ,
135167 align : DataTable . LEFT ,
136168 width : 85 ,
137169 resizeMinWidth : 40 ,
@@ -183,13 +215,29 @@ export function getTotalCpuColumn<T extends {PoolStats?: TPoolStats[]}>(): Colum
183215 const totalPoolUsage = row . PoolStats . reduce ( ( acc , pool ) => acc + ( pool . Usage || 0 ) , 0 ) ;
184216
185217 return (
186- < ProgressViewer
187- value = { totalPoolUsage }
188- capacity = { 1 }
189- colorizeProgress
190- percents
191- vertical
192- />
218+ < CellWithPopover
219+ placement = { [ 'top' , 'auto' ] }
220+ fullWidth
221+ content = {
222+ < DefinitionList responsive >
223+ { row . PoolStats . map ( ( pool ) =>
224+ isNumeric ( pool . Usage ) ? (
225+ < DefinitionList . Item key = { pool . Name } name = { pool . Name } >
226+ { formatPool ( 'Usage' , pool . Usage ) . value }
227+ </ DefinitionList . Item >
228+ ) : null ,
229+ ) }
230+ </ DefinitionList >
231+ }
232+ >
233+ < ProgressViewer
234+ value = { totalPoolUsage }
235+ capacity = { 1 }
236+ colorizeProgress
237+ percents
238+ vertical
239+ />
240+ </ CellWithPopover >
193241 ) ;
194242 } ,
195243 align : DataTable . LEFT ,
0 commit comments