-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
272 additions
and
447 deletions.
There are no files selected for viewing
This file contains 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,6 @@ | ||
.ydb-usage-label { | ||
&_overload { | ||
color: var(--yc-color-text-light-primary); | ||
background-color: var(--yc-color-base-danger-heavy); | ||
} | ||
} |
This file contains 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,18 @@ | ||
import cn from 'bem-cn-lite'; | ||
|
||
import {Label, type LabelProps} from '@gravity-ui/uikit'; | ||
|
||
const b = cn('ydb-usage-label'); | ||
|
||
interface UsageLabelProps extends LabelProps { | ||
value: number | string; | ||
overloadThreshold?: number; | ||
} | ||
|
||
export function UsageLabel({value, overloadThreshold = 90, theme}: UsageLabelProps) { | ||
return ( | ||
<Label theme={theme} className={b({overload: Number(value) >= overloadThreshold})}> | ||
{value || 0}% | ||
</Label> | ||
); | ||
} |
This file contains 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 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
31 changes: 0 additions & 31 deletions
31
src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TenantCpu.scss
This file was deleted.
Oops, something went wrong.
This file contains 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
68 changes: 16 additions & 52 deletions
68
src/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TopNodesByCpu.tsx
This file contains 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 |
---|---|---|
@@ -1,89 +1,53 @@ | ||
import cn from 'bem-cn-lite'; | ||
import {useDispatch} from 'react-redux'; | ||
import {useCallback} from 'react'; | ||
|
||
import DataTable from '@gravity-ui/react-data-table'; | ||
|
||
import { | ||
TENANT_OVERVIEW_TABLES_LIMIT, | ||
TENANT_OVERVIEW_TABLES_SETTINGS, | ||
} from '../../../../../utils/constants'; | ||
import {useAutofetcher, useTypedSelector} from '../../../../../utils/hooks'; | ||
import { | ||
getTopComputeNodesByCpu, | ||
getTopNodesByCpu, | ||
selectTopNodesByCpu, | ||
setDataWasNotLoaded, | ||
} from '../../../../../store/reducers/tenantOverview/topNodesByCpu/topNodesByCpu'; | ||
import type {EPathType} from '../../../../../types/api/schema'; | ||
import type {AdditionalNodesProps} from '../../../../../types/additionalProps'; | ||
import {TableSkeleton} from '../../../../../components/TableSkeleton/TableSkeleton'; | ||
import {ResponseError} from '../../../../../components/Errors/ResponseError'; | ||
import {getTopPoolsColumns} from '../../../../Nodes/getNodesColumns'; | ||
import {isDatabaseEntityType} from '../../../utils/schema'; | ||
import {getTopNodesByCpuColumns} from '../../../../Nodes/getNodesColumns'; | ||
import {TenantOverviewTableLayout} from '../TenantOverviewTableLayout'; | ||
|
||
import i18n from '../i18n'; | ||
import './TenantCpu.scss'; | ||
|
||
const b = cn('tenant-overview-cpu'); | ||
|
||
interface TopNodesByCpuProps { | ||
path?: string; | ||
type?: EPathType; | ||
path: string; | ||
additionalNodesProps?: AdditionalNodesProps; | ||
} | ||
|
||
export function TopNodesByCpu({path, type, additionalNodesProps}: TopNodesByCpuProps) { | ||
export function TopNodesByCpu({path, additionalNodesProps}: TopNodesByCpuProps) { | ||
const dispatch = useDispatch(); | ||
|
||
const {wasLoaded, loading, error} = useTypedSelector((state) => state.topNodesByCpu); | ||
const {autorefresh} = useTypedSelector((state) => state.schema); | ||
const topNodes = useTypedSelector(selectTopNodesByCpu); | ||
const columns = getTopPoolsColumns(additionalNodesProps?.getNodeRef); | ||
const columns = getTopNodesByCpuColumns(additionalNodesProps?.getNodeRef); | ||
|
||
const fetchNodes = useCallback( | ||
(isBackground) => { | ||
if (!isBackground) { | ||
dispatch(setDataWasNotLoaded()); | ||
} | ||
|
||
// For not DB entities we always use /compute endpoint instead of /nodes | ||
// since /nodes can return data only for tenants | ||
if (path && !isDatabaseEntityType(type)) { | ||
dispatch(getTopComputeNodesByCpu({path})); | ||
} else { | ||
dispatch(getTopNodesByCpu({tenant: path})); | ||
} | ||
dispatch(getTopNodesByCpu({tenant: path})); | ||
}, | ||
[dispatch, path, type], | ||
[dispatch, path], | ||
); | ||
|
||
useAutofetcher(fetchNodes, [fetchNodes], autorefresh); | ||
|
||
const renderContent = () => { | ||
if (error) { | ||
return <ResponseError error={error} />; | ||
} | ||
|
||
if (loading && !wasLoaded) { | ||
return <TableSkeleton rows={TENANT_OVERVIEW_TABLES_LIMIT} />; | ||
} | ||
|
||
return ( | ||
<DataTable | ||
theme="yandex-cloud" | ||
data={topNodes || []} | ||
columns={columns} | ||
settings={TENANT_OVERVIEW_TABLES_SETTINGS} | ||
emptyDataMessage={i18n('top-nodes.empty-data')} | ||
/> | ||
); | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className={b('title')}>Top nodes by pools usage</div> | ||
<div className={b('table')}>{renderContent()}</div> | ||
</> | ||
<TenantOverviewTableLayout | ||
data={topNodes || []} | ||
columns={columns} | ||
title="Top nodes by pools usage" | ||
loading={loading} | ||
wasLoaded={wasLoaded} | ||
error={error} | ||
emptyDataMessage={i18n('top-nodes.empty-data')} | ||
/> | ||
); | ||
} |
Oops, something went wrong.