-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add network section #2621
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/containers/Tenant/Diagnostics/TenantOverview/TenantNetwork/TenantNetwork.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | ||
| } | ||
| } |
74 changes: 74 additions & 0 deletions
74
src/containers/Tenant/Diagnostics/TenantOverview/TenantNetwork/TenantNetwork.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = () => { | ||
| 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> | ||
| ); | ||
| } | ||
73 changes: 73 additions & 0 deletions
73
src/containers/Tenant/Diagnostics/TenantOverview/TenantNetwork/TopNodesByPing.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
astandrik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| {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> | ||
| ); | ||
| } | ||
73 changes: 73 additions & 0 deletions
73
src/containers/Tenant/Diagnostics/TenantOverview/TenantNetwork/TopNodesBySkew.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | ||
astandrik marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
| {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> | ||
| ); | ||
| } | ||
73 changes: 73 additions & 0 deletions
73
src/containers/Tenant/Diagnostics/TenantOverview/TenantNetwork/columns.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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