@@ -8,16 +8,17 @@ import {valueIsDefined} from '../../utils';
8
8
import { cn } from '../../utils/cn' ;
9
9
import { EMPTY_DATA_PLACEHOLDER } from '../../utils/constants' ;
10
10
import {
11
+ formatPercent ,
11
12
formatStorageValues ,
12
13
formatStorageValuesToGb ,
13
14
} from '../../utils/dataFormatters/dataFormatters' ;
14
15
import { getSpaceUsageSeverity } from '../../utils/storage' ;
15
16
import type { Column } from '../../utils/tableUtils/types' ;
16
- import { isNumeric } from '../../utils/utils' ;
17
+ import { bytesToSpeed , isNumeric } from '../../utils/utils' ;
17
18
import { CellWithPopover } from '../CellWithPopover/CellWithPopover' ;
18
19
import { MemoryViewer } from '../MemoryViewer/MemoryViewer' ;
19
20
import { NodeHostWrapper } from '../NodeHostWrapper/NodeHostWrapper' ;
20
- import type { NodeHostData } from '../NodeHostWrapper/NodeHostWrapper' ;
21
+ import type { NodeHostData , StatusForIcon } from '../NodeHostWrapper/NodeHostWrapper' ;
21
22
import { PoolsGraph } from '../PoolsGraph/PoolsGraph' ;
22
23
import { ProgressViewer } from '../ProgressViewer/ProgressViewer' ;
23
24
import { TabletsStatistic } from '../TabletsStatistic' ;
@@ -27,6 +28,7 @@ import {UsageLabel} from '../UsageLabel/UsageLabel';
27
28
import { NODES_COLUMNS_IDS , NODES_COLUMNS_TITLES } from './constants' ;
28
29
import i18n from './i18n' ;
29
30
import type { GetNodesColumnsParams } from './types' ;
31
+ import { prepareClockSkewValue , preparePingTimeValue } from './utils' ;
30
32
31
33
import './NodesColumns.scss' ;
32
34
@@ -41,15 +43,22 @@ export function getNodeIdColumn<T extends {NodeId?: string | number}>(): Column<
41
43
align : DataTable . RIGHT ,
42
44
} ;
43
45
}
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 } : { statusForIcon ?: StatusForIcon } = { } ,
49
+ ) : Column < T > {
48
50
return {
49
51
name : NODES_COLUMNS_IDS . Host ,
50
52
header : NODES_COLUMNS_TITLES . Host ,
51
53
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
+ ) ;
53
62
} ,
54
63
width : 350 ,
55
64
align : DataTable . LEFT ,
@@ -363,3 +372,163 @@ export function getMissingDisksColumn<T extends {Missing?: number}>(): Column<T>
363
372
defaultOrder : DataTable . DESCENDING ,
364
373
} ;
365
374
}
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