Skip to content

Commit 56d932d

Browse files
refactor(PoolUsage): migrate to ts (#411)
1 parent e330919 commit 56d932d

File tree

5 files changed

+53
-57
lines changed

5 files changed

+53
-57
lines changed

src/components/FullNodeViewer/FullNodeViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
44

55
import InfoViewer from '../InfoViewer/InfoViewer';
66
import ProgressViewer from '../ProgressViewer/ProgressViewer';
7-
import PoolUsage from '../PoolUsage/PoolUsage';
7+
import {PoolUsage} from '../PoolUsage/PoolUsage';
88

99
import {LOAD_AVERAGE_TIME_INTERVALS} from '../../utils/constants';
1010
import {calcUptime} from '../../utils';

src/components/PoolUsage/PoolUsage.js

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/components/PoolUsage/PoolUsage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.pool-usage {
1+
.ydb-pool-usage {
22
font-size: var(--yc-text-body-2-font-size);
33
line-height: var(--yc-text-body-2-line-height);
44
&__info {
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import block from 'bem-cn-lite';
2+
3+
import type {TPoolStats} from '../../types/api/nodes';
4+
5+
import './PoolUsage.scss';
6+
7+
const b = block('ydb-pool-usage');
8+
9+
const getLineType = (fillWidth: number) => {
10+
let fillColor = 'green';
11+
if (fillWidth > 60 && fillWidth <= 80) {
12+
fillColor = 'yellow';
13+
} else if (fillWidth > 80) {
14+
fillColor = 'red';
15+
}
16+
17+
return fillColor;
18+
};
19+
20+
interface PoolUsageProps {
21+
data?: TPoolStats;
22+
}
23+
24+
export const PoolUsage = ({data: pool = {}}: PoolUsageProps) => {
25+
const {Threads, Name = 'Unknown', Usage = 0} = pool;
26+
const dataExist = Usage && Threads;
27+
28+
const value = Math.floor(Usage * 100);
29+
const fillWidth = value > 100 ? 100 : value;
30+
31+
return (
32+
<div className={b()}>
33+
<div className={b('info')}>
34+
<div className={b('pool-name')}>{Name}</div>
35+
{dataExist && (
36+
<div className={b('value')}>
37+
<div className={b('percents')}>{value < 1 ? '<1' : value}%</div>
38+
<div className={b('threads')}>{Threads})</div>
39+
</div>
40+
)}
41+
</div>
42+
<div className={b('visual')}>
43+
<div
44+
className={b('usage-line', {type: getLineType(fillWidth)})}
45+
style={{width: `${fillWidth}%`}}
46+
/>
47+
</div>
48+
</div>
49+
);
50+
};

src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Loader} from '@gravity-ui/uikit';
66

77
import EntityStatus from '../../../../components/EntityStatus/EntityStatus';
88
import InfoViewer from '../../../../components/InfoViewer/InfoViewer';
9-
import PoolUsage from '../../../../components/PoolUsage/PoolUsage';
9+
import {PoolUsage} from '../../../../components/PoolUsage/PoolUsage';
1010
import {Tablet} from '../../../../components/Tablet';
1111

1212
import {getTenantInfo} from '../../../../store/reducers/tenant/tenant';

0 commit comments

Comments
 (0)