@@ -8,16 +8,17 @@ import {valueIsDefined} from '../../utils';
88import { cn } from '../../utils/cn' ;
99import { EMPTY_DATA_PLACEHOLDER } from '../../utils/constants' ;
1010import {
11+ formatPercent ,
1112 formatStorageValues ,
1213 formatStorageValuesToGb ,
1314} from '../../utils/dataFormatters/dataFormatters' ;
1415import { getSpaceUsageSeverity } from '../../utils/storage' ;
1516import type { Column } from '../../utils/tableUtils/types' ;
16- import { isNumeric } from '../../utils/utils' ;
17+ import { bytesToSpeed , isNumeric } from '../../utils/utils' ;
1718import { CellWithPopover } from '../CellWithPopover/CellWithPopover' ;
1819import { MemoryViewer } from '../MemoryViewer/MemoryViewer' ;
1920import { NodeHostWrapper } from '../NodeHostWrapper/NodeHostWrapper' ;
20- import type { NodeHostData } from '../NodeHostWrapper/NodeHostWrapper' ;
21+ import type { NodeHostData , StatusForIcon } from '../NodeHostWrapper/NodeHostWrapper' ;
2122import { PoolsGraph } from '../PoolsGraph/PoolsGraph' ;
2223import { ProgressViewer } from '../ProgressViewer/ProgressViewer' ;
2324import { TabletsStatistic } from '../TabletsStatistic' ;
@@ -27,6 +28,7 @@ import {UsageLabel} from '../UsageLabel/UsageLabel';
2728import { NODES_COLUMNS_IDS , NODES_COLUMNS_TITLES } from './constants' ;
2829import i18n from './i18n' ;
2930import type { GetNodesColumnsParams } from './types' ;
31+ import { prepareClockSkewValue , preparePingTimeValue } from './utils' ;
3032
3133import './NodesColumns.scss' ;
3234
@@ -41,15 +43,22 @@ export function getNodeIdColumn<T extends {NodeId?: string | number}>(): Column<
4143 align : DataTable . RIGHT ,
4244 } ;
4345}
44- export function getHostColumn < T extends NodeHostData > ( {
45- getNodeRef,
46- database ,
47- } : GetNodesColumnsParams ) : Column < T > {
46+ export function getHostColumn < T extends NodeHostData > (
47+ { getNodeRef, database } : GetNodesColumnsParams ,
48+ { statusForIcon = 'SystemState' } : { statusForIcon ?: StatusForIcon } = { } ,
49+ ) : Column < T > {
4850 return {
4951 name : NODES_COLUMNS_IDS . Host ,
5052 header : NODES_COLUMNS_TITLES . Host ,
5153 render : ( { row} ) => {
52- return < NodeHostWrapper node = { row } getNodeRef = { getNodeRef } database = { database } /> ;
54+ return (
55+ < NodeHostWrapper
56+ node = { row }
57+ getNodeRef = { getNodeRef }
58+ database = { database }
59+ statusForIcon = { statusForIcon }
60+ />
61+ ) ;
5362 } ,
5463 width : 350 ,
5564 align : DataTable . LEFT ,
@@ -363,3 +372,163 @@ export function getMissingDisksColumn<T extends {Missing?: number}>(): Column<T>
363372 defaultOrder : DataTable . DESCENDING ,
364373 } ;
365374}
375+
376+ // Network diagnostics columns
377+ export function getConnectionsColumn < T extends { Connections ?: number } > ( ) : Column < T > {
378+ return {
379+ name : NODES_COLUMNS_IDS . Connections ,
380+ header : NODES_COLUMNS_TITLES . Connections ,
381+ render : ( { row} ) => ( isNumeric ( row . Connections ) ? row . Connections : EMPTY_DATA_PLACEHOLDER ) ,
382+ align : DataTable . RIGHT ,
383+ width : 130 ,
384+ } ;
385+ }
386+ export function getNetworkUtilizationColumn <
387+ T extends {
388+ NetworkUtilization ?: number ;
389+ NetworkUtilizationMin ?: number ;
390+ NetworkUtilizationMax ?: number ;
391+ } ,
392+ > ( ) : Column < T > {
393+ return {
394+ name : NODES_COLUMNS_IDS . NetworkUtilization ,
395+ header : NODES_COLUMNS_TITLES . NetworkUtilization ,
396+ render : ( { row} ) => {
397+ const { NetworkUtilization, NetworkUtilizationMin = 0 , NetworkUtilizationMax = 0 } = row ;
398+
399+ if ( ! isNumeric ( NetworkUtilization ) ) {
400+ return EMPTY_DATA_PLACEHOLDER ;
401+ }
402+
403+ return (
404+ < CellWithPopover
405+ placement = { [ 'top' , 'auto' ] }
406+ fullWidth
407+ content = {
408+ < DefinitionList responsive >
409+ < DefinitionList . Item key = { 'NetworkUtilization' } name = { i18n ( 'sum' ) } >
410+ { formatPercent ( NetworkUtilization ) }
411+ </ DefinitionList . Item >
412+ < DefinitionList . Item key = { 'NetworkUtilizationMin' } name = { i18n ( 'min' ) } >
413+ { formatPercent ( NetworkUtilizationMin ) }
414+ </ DefinitionList . Item >
415+ < DefinitionList . Item key = { 'NetworkUtilizationMax' } name = { i18n ( 'max' ) } >
416+ { formatPercent ( NetworkUtilizationMax ) }
417+ </ DefinitionList . Item >
418+ </ DefinitionList >
419+ }
420+ >
421+ { formatPercent ( NetworkUtilization ) }
422+ </ CellWithPopover >
423+ ) ;
424+ } ,
425+ align : DataTable . RIGHT ,
426+ width : 110 ,
427+ } ;
428+ }
429+ export function getSendThroughputColumn < T extends { SendThroughput ?: string } > ( ) : Column < T > {
430+ return {
431+ name : NODES_COLUMNS_IDS . SendThroughput ,
432+ header : NODES_COLUMNS_TITLES . SendThroughput ,
433+ render : ( { row} ) =>
434+ isNumeric ( row . SendThroughput )
435+ ? bytesToSpeed ( row . SendThroughput )
436+ : EMPTY_DATA_PLACEHOLDER ,
437+ align : DataTable . RIGHT ,
438+ width : 110 ,
439+ } ;
440+ }
441+ export function getReceiveThroughputColumn < T extends { ReceiveThroughput ?: string } > ( ) : Column < T > {
442+ return {
443+ name : NODES_COLUMNS_IDS . ReceiveThroughput ,
444+ header : NODES_COLUMNS_TITLES . ReceiveThroughput ,
445+ render : ( { row} ) =>
446+ isNumeric ( row . ReceiveThroughput )
447+ ? bytesToSpeed ( row . ReceiveThroughput )
448+ : EMPTY_DATA_PLACEHOLDER ,
449+ align : DataTable . RIGHT ,
450+ width : 110 ,
451+ } ;
452+ }
453+ export function getPingTimeColumn <
454+ T extends {
455+ PingTimeUs ?: string ;
456+ PingTimeMinUs ?: string ;
457+ PingTimeMaxUs ?: string ;
458+ } ,
459+ > ( ) : Column < T > {
460+ return {
461+ name : NODES_COLUMNS_IDS . PingTime ,
462+ header : NODES_COLUMNS_TITLES . PingTime ,
463+ render : ( { row} ) => {
464+ const { PingTimeUs, PingTimeMinUs = 0 , PingTimeMaxUs = 0 } = row ;
465+
466+ if ( ! isNumeric ( PingTimeUs ) ) {
467+ return EMPTY_DATA_PLACEHOLDER ;
468+ }
469+
470+ return (
471+ < CellWithPopover
472+ placement = { [ 'top' , 'auto' ] }
473+ fullWidth
474+ content = {
475+ < DefinitionList responsive >
476+ < DefinitionList . Item key = { 'PingTimeUs' } name = { i18n ( 'avg' ) } >
477+ { preparePingTimeValue ( PingTimeUs ) }
478+ </ DefinitionList . Item >
479+ < DefinitionList . Item key = { 'PingTimeMinUs' } name = { i18n ( 'min' ) } >
480+ { preparePingTimeValue ( PingTimeMinUs ) }
481+ </ DefinitionList . Item >
482+ < DefinitionList . Item key = { 'PingTimeMaxUs' } name = { i18n ( 'max' ) } >
483+ { preparePingTimeValue ( PingTimeMaxUs ) }
484+ </ DefinitionList . Item >
485+ </ DefinitionList >
486+ }
487+ >
488+ { preparePingTimeValue ( PingTimeUs ) }
489+ </ CellWithPopover >
490+ ) ;
491+ } ,
492+ align : DataTable . RIGHT ,
493+ width : 110 ,
494+ } ;
495+ }
496+ export function getClockSkewColumn <
497+ T extends { ClockSkewUs ?: string ; ClockSkewMinUs ?: string ; ClockSkewMaxUs ?: string } ,
498+ > ( ) : Column < T > {
499+ return {
500+ name : NODES_COLUMNS_IDS . ClockSkew ,
501+ header : NODES_COLUMNS_TITLES . ClockSkew ,
502+ render : ( { row} ) => {
503+ const { ClockSkewUs, ClockSkewMinUs = 0 , ClockSkewMaxUs = 0 } = row ;
504+
505+ if ( ! isNumeric ( ClockSkewUs ) ) {
506+ return EMPTY_DATA_PLACEHOLDER ;
507+ }
508+
509+ return (
510+ < CellWithPopover
511+ placement = { [ 'top' , 'auto' ] }
512+ fullWidth
513+ content = {
514+ < DefinitionList responsive >
515+ < DefinitionList . Item key = { 'ClockSkewUs' } name = { i18n ( 'avg' ) } >
516+ { prepareClockSkewValue ( ClockSkewUs ) }
517+ </ DefinitionList . Item >
518+ < DefinitionList . Item key = { 'ClockSkewMinUs' } name = { i18n ( 'min' ) } >
519+ { prepareClockSkewValue ( ClockSkewMinUs ) }
520+ </ DefinitionList . Item >
521+ < DefinitionList . Item key = { 'ClockSkewMaxUs' } name = { i18n ( 'max' ) } >
522+ { prepareClockSkewValue ( ClockSkewMaxUs ) }
523+ </ DefinitionList . Item >
524+ </ DefinitionList >
525+ }
526+ >
527+ { prepareClockSkewValue ( ClockSkewUs ) }
528+ </ CellWithPopover >
529+ ) ;
530+ } ,
531+ align : DataTable . RIGHT ,
532+ width : 110 ,
533+ } ;
534+ }
0 commit comments