Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {useSetting, useTypedSelector} from '../../../../../utils/hooks';
import {calculateMetricAggregates} from '../../../../../utils/metrics';
import {
formatCoresLegend,
formatSpeedLegend,
formatStorageLegend,
} from '../../../../../utils/metrics/formatMetricLegend';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
Expand Down Expand Up @@ -57,6 +58,10 @@ export function MetricsTabs({
...queryParams,
[TenantTabsGroups.metricsTab]: TENANT_METRICS_TABS_IDS.memory,
}),
[TENANT_METRICS_TABS_IDS.network]: getTenantPath({
...queryParams,
[TenantTabsGroups.metricsTab]: TENANT_METRICS_TABS_IDS.network,
}),
};

// Use only pools that directly indicate resources available to perform user queries
Expand Down Expand Up @@ -131,19 +136,22 @@ export function MetricsTabs({
</Link>
</div>
{showNetworkUtilization && networkStats && networkMetrics && (
<div className={b('link-container')}>
<div className={b('link')}>
<div
className={b('link-container', {
active: metricsTab === TENANT_METRICS_TABS_IDS.network,
})}
>
<Link to={tabLinks.network} className={b('link')}>
<TabCard
label={i18n('cards.network-label')}
sublabel={i18n('context_network-evaluation')}
sublabel={i18n('context_network-usage')}
value={networkMetrics.totalUsed}
limit={networkMetrics.totalLimit}
legendFormatter={formatStorageLegend}
active={false}
clickable={false}
legendFormatter={formatSpeedLegend}
active={metricsTab === TENANT_METRICS_TABS_IDS.network}
helpText={i18n('context_network-description')}
/>
</div>
</Link>
</div>
)}
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
&__card-container {
padding: var(--g-spacing-4);

cursor: pointer;

border: 0;
border-radius: var(--g-border-radius-s);
}

&__card-container_clickable {
cursor: pointer;

// Smooth hover transition
transition: background-color 0.15s ease;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface TabCardProps {
limit: number;
active?: boolean;
helpText?: string;
clickable?: boolean;
legendFormatter: (params: {value: number; capacity: number}) => string;
}

Expand All @@ -26,7 +25,6 @@ export function TabCard({
limit,
active,
helpText,
clickable = true,
legendFormatter,
}: TabCardProps) {
const {status, percents, legend, fill} = getDiagramValues({
Expand All @@ -38,7 +36,7 @@ export function TabCard({
return (
<div className={b({active})}>
<Card
className={b('card-container', {active, clickable})}
className={b('card-container', {active})}
type="container"
view={active ? 'outlined' : 'raised'}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.tenant-network {
&__tabs-container {
margin-top: var(--g-spacing-3);
}

&__tab-content {
margin-top: var(--g-spacing-3);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import {Flex, Tab, TabList, TabProvider} from '@gravity-ui/uikit';

import {TENANT_NETWORK_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
import {cn} from '../../../../../utils/cn';
import i18n from '../i18n';

import {TopNodesByPing} from './TopNodesByPing';
import {TopNodesBySkew} from './TopNodesBySkew';
import {useTenantNetworkQueryParams} from './useTenantNetworkQueryParams';

import './TenantNetwork.scss';

const b = cn('tenant-network');

const networkTabs = [
{id: TENANT_NETWORK_TABS_IDS.ping, title: i18n('title_nodes-by-ping')},
{id: TENANT_NETWORK_TABS_IDS.skew, title: i18n('title_nodes-by-skew')},
];

interface TenantNetworkProps {
tenantName: string;
additionalNodesProps?: AdditionalNodesProps;
}

export function TenantNetwork({tenantName, additionalNodesProps}: TenantNetworkProps) {
const {networkTab, handleNetworkTabChange} = useTenantNetworkQueryParams();

const renderTabContent = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no data in network tables, but there is data in separate Network tab

Screenshot 2025-07-28 at 11 26 45

switch (networkTab) {
case TENANT_NETWORK_TABS_IDS.ping: {
return (
<TopNodesByPing
tenantName={tenantName}
additionalNodesProps={additionalNodesProps}
/>
);
}
case TENANT_NETWORK_TABS_IDS.skew: {
return (
<TopNodesBySkew
tenantName={tenantName}
additionalNodesProps={additionalNodesProps}
/>
);
}
default: {
return null;
}
}
};

return (
<Flex direction="column" gap={4} className={b()}>
<Flex direction="column" gap={3} className={b('tabs-container')}>
<TabProvider value={networkTab}>
<TabList size="m">
{networkTabs.map(({id, title}) => {
return (
<Tab key={id} value={id} onClick={() => handleNetworkTabChange(id)}>
{title}
</Tab>
);
})}
</TabList>
</TabProvider>

<Flex direction="column" className={b('tab-content')}>
{renderTabContent()}
</Flex>
</Flex>
</Flex>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {ResizeableDataTable} from '../../../../../components/ResizeableDataTable/ResizeableDataTable';
import {NODES_COLUMNS_WIDTH_LS_KEY} from '../../../../../components/nodesColumns/constants';
import {nodesApi} from '../../../../../store/reducers/nodes/nodes';
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../../utils/constants';
import {useAutoRefreshInterval, useSearchQuery} from '../../../../../utils/hooks';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
import {getSectionTitle} from '../getSectionTitle';
import i18n from '../i18n';

import {getTopNodesByPingColumns} from './columns';

const TENANT_OVERVIEW_TABLES_SETTINGS = {
stripedRows: false,
sortable: false,
};

interface TopNodesByPingProps {
tenantName: string;
additionalNodesProps?: AdditionalNodesProps;
}

export function TopNodesByPing({tenantName, additionalNodesProps}: TopNodesByPingProps) {
const query = useSearchQuery();
const [autoRefreshInterval] = useAutoRefreshInterval();
const [columns, fieldsRequired] = getTopNodesByPingColumns({
getNodeRef: additionalNodesProps?.getNodeRef,
database: tenantName,
});

const {currentData, isFetching, error} = nodesApi.useGetNodesQuery(
{
tenant: tenantName,
type: 'any',
sort: '-PingTime',
limit: TENANT_OVERVIEW_TABLES_LIMIT,
tablets: false,
fieldsRequired: fieldsRequired as any,
},
{pollingInterval: autoRefreshInterval},
);

const loading = isFetching && currentData === undefined;
const topNodes = currentData?.Nodes || [];

const title = getSectionTitle({
entity: i18n('nodes'),
postfix: i18n('by-ping'),
link: getTenantPath({
...query,
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
}),
});

return (
<TenantOverviewTableLayout
title={title}
loading={loading}
error={error}
withData={Boolean(currentData)}
>
<ResizeableDataTable
columnsWidthLSKey={NODES_COLUMNS_WIDTH_LS_KEY}
data={topNodes}
columns={columns}
emptyDataMessage={i18n('top-nodes.empty-data')}
settings={TENANT_OVERVIEW_TABLES_SETTINGS}
/>
</TenantOverviewTableLayout>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {ResizeableDataTable} from '../../../../../components/ResizeableDataTable/ResizeableDataTable';
import {NODES_COLUMNS_WIDTH_LS_KEY} from '../../../../../components/nodesColumns/constants';
import {nodesApi} from '../../../../../store/reducers/nodes/nodes';
import {TENANT_DIAGNOSTICS_TABS_IDS} from '../../../../../store/reducers/tenant/constants';
import type {AdditionalNodesProps} from '../../../../../types/additionalProps';
import {TENANT_OVERVIEW_TABLES_LIMIT} from '../../../../../utils/constants';
import {useAutoRefreshInterval, useSearchQuery} from '../../../../../utils/hooks';
import {TenantTabsGroups, getTenantPath} from '../../../TenantPages';
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout';
import {getSectionTitle} from '../getSectionTitle';
import i18n from '../i18n';

import {getTopNodesBySkewColumns} from './columns';

const TENANT_OVERVIEW_TABLES_SETTINGS = {
stripedRows: false,
sortable: false,
};

interface TopNodesBySkewProps {
tenantName: string;
additionalNodesProps?: AdditionalNodesProps;
}

export function TopNodesBySkew({tenantName, additionalNodesProps}: TopNodesBySkewProps) {
const query = useSearchQuery();
const [autoRefreshInterval] = useAutoRefreshInterval();
const [columns, fieldsRequired] = getTopNodesBySkewColumns({
getNodeRef: additionalNodesProps?.getNodeRef,
database: tenantName,
});

const {currentData, isFetching, error} = nodesApi.useGetNodesQuery(
{
tenant: tenantName,
type: 'any',
sort: '-ClockSkew',
limit: TENANT_OVERVIEW_TABLES_LIMIT,
tablets: false,
fieldsRequired: fieldsRequired as any,
},
{pollingInterval: autoRefreshInterval},
);

const loading = isFetching && currentData === undefined;
const topNodes = currentData?.Nodes || [];

const title = getSectionTitle({
entity: i18n('nodes'),
postfix: i18n('by-skew'),
link: getTenantPath({
...query,
[TenantTabsGroups.diagnosticsTab]: TENANT_DIAGNOSTICS_TABS_IDS.nodes,
}),
});

return (
<TenantOverviewTableLayout
title={title}
loading={loading}
error={error}
withData={Boolean(currentData)}
>
<ResizeableDataTable
columnsWidthLSKey={NODES_COLUMNS_WIDTH_LS_KEY}
data={topNodes}
columns={columns}
emptyDataMessage={i18n('top-nodes.empty-data')}
settings={TENANT_OVERVIEW_TABLES_SETTINGS}
/>
</TenantOverviewTableLayout>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import {
getClockSkewColumn,
getDataCenterColumn,
getNetworkHostColumn,
getNodeIdColumn,
getPingTimeColumn,
getRackColumn,
getUptimeColumn,
} from '../../../../../components/nodesColumns/columns';
import {isSortableNodesColumn} from '../../../../../components/nodesColumns/constants';
import type {GetNodesColumnsParams} from '../../../../../components/nodesColumns/types';
import type {NodesPreparedEntity} from '../../../../../store/reducers/nodes/types';
import type {Column} from '../../../../../utils/tableUtils/types';

export function getTopNodesByPingColumns(params: GetNodesColumnsParams) {
const columns: Column<NodesPreparedEntity>[] = [
getNodeIdColumn(),
getNetworkHostColumn(params),
getDataCenterColumn(),
getRackColumn(),
getUptimeColumn(),
getPingTimeColumn(),
];

const fieldsRequired = [
'NodeId',
'Host',
'DataCenter',
'Rack',
'UptimeSeconds',
'PingTimeUs',
'PingTimeMinUs',
'PingTimeMaxUs',
];

return [
columns.map((column) => ({
...column,
sortable: isSortableNodesColumn(column.name),
})),
fieldsRequired,
] as const;
}

export function getTopNodesBySkewColumns(params: GetNodesColumnsParams) {
const columns: Column<NodesPreparedEntity>[] = [
getNodeIdColumn(),
getNetworkHostColumn(params),
getDataCenterColumn(),
getRackColumn(),
getUptimeColumn(),
getClockSkewColumn(),
];

const fieldsRequired = [
'NodeId',
'Host',
'DataCenter',
'Rack',
'UptimeSeconds',
'ClockSkewUs',
'ClockSkewMinUs',
'ClockSkewMaxUs',
];

return [
columns.map((column) => ({
...column,
sortable: isSortableNodesColumn(column.name),
})),
fieldsRequired,
] as const;
}
Loading
Loading