import {Flex} from '@gravity-ui/uikit'; import type {PreparedNode} from '../../store/reducers/node/types'; import {cn} from '../../utils/cn'; import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants'; import {formatStorageValues} from '../../utils/dataFormatters/dataFormatters'; import {useNodeDeveloperUIHref} from '../../utils/hooks/useNodeDeveloperUIHref'; import {getNodeMemory} from '../../utils/memory'; import {LinkWithIcon} from '../LinkWithIcon/LinkWithIcon'; import {PoolUsage} from '../PoolUsage/PoolUsage'; import {ProgressViewer} from '../ProgressViewer/ProgressViewer'; import {NodeUptime} from '../UptimeViewer/UptimeViewer'; import type {YDBDefinitionListItem} from '../YDBDefinitionList/YDBDefinitionList'; import {YDBDefinitionList} from '../YDBDefinitionList/YDBDefinitionList'; import i18n from './i18n'; import './FullNodeViewer.scss'; const b = cn('full-node-viewer'); interface FullNodeViewerProps { node?: PreparedNode; className?: string; } const getLoadAverageIntervalTitle = (index: number) => { return [i18n('la-interval-1m'), i18n('la-interval-5m'), i18n('la-interval-15m')][index]; }; const formatMemoryValues = (value?: number, total?: number) => formatStorageValues(value, total, 'gb', undefined, true); // eslint-disable-next-line complexity export const FullNodeViewer = ({node, className}: FullNodeViewerProps) => { const developerUIHref = useNodeDeveloperUIHref(node); const commonInfo: YDBDefinitionListItem[] = []; if (node?.Tenants?.length) { commonInfo.push({ name: i18n('database'), content: node.Tenants[0] || EMPTY_DATA_PLACEHOLDER, }); } commonInfo.push( {name: i18n('version'), content: node?.Version || EMPTY_DATA_PLACEHOLDER}, { name: i18n('uptime'), content: ( ), }, { name: i18n('dc'), content: node?.DataCenterDescription || node?.DC || EMPTY_DATA_PLACEHOLDER, }, ); if (node?.Rack) { commonInfo.push({name: i18n('rack'), content: node.Rack}); } if (developerUIHref) { commonInfo.push({ name: i18n('links'), content: , }); } const endpointsInfo = node?.Endpoints?.map(({Name, Address}) => ({ name: Name || EMPTY_DATA_PLACEHOLDER, content: Address || EMPTY_DATA_PLACEHOLDER, })); const averageInfo = node?.LoadAveragePercents?.map((load, loadIndex) => ({ name: getLoadAverageIntervalTitle(loadIndex), content: ( ), })) ?? []; if (!node) { return
{i18n('no-data')}
; } const {memoryUsed, memoryLimit} = getNodeMemory(node); const renderMemory = () => { if (memoryUsed === undefined) { return EMPTY_DATA_PLACEHOLDER; } if (memoryLimit === undefined) { return formatMemoryValues(memoryUsed)[0]; } return ( ); }; return (
{i18n('title.common-info')}
{endpointsInfo && endpointsInfo.length ? (
{i18n('title.endpoints')}
) : null}
{i18n('title.pools')}
{node?.PoolStats?.map((pool, poolIndex) => ( ))}
{i18n('title.load-average')}
{i18n('title_ram')}
{renderMemory()}
{node.Roles && node.Roles.length ? (
{i18n('title.roles')}
{node?.Roles?.map((role) => (
{role}
))}
) : null}
); };