Skip to content

Commit cd96035

Browse files
committed
style: touch up SessionUsageMonitor
1 parent a68c5bf commit cd96035

File tree

1 file changed

+44
-19
lines changed

1 file changed

+44
-19
lines changed

react/src/components/SessionUsageMonitor.tsx

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ import { useResourceSlotsDetails } from '../hooks/backendai';
88
import BAIProgressWithLabel from './BAIProgressWithLabel';
99
import Flex from './Flex';
1010
import { SessionUsageMonitorFragment$key } from './__generated__/SessionUsageMonitorFragment.graphql';
11-
import { ProgressProps, Tooltip, Typography, theme, Row, Col } from 'antd';
11+
import {
12+
ProgressProps,
13+
Tooltip,
14+
Typography,
15+
theme,
16+
Row,
17+
Col,
18+
Progress,
19+
} from 'antd';
1220
import graphql from 'babel-plugin-relay/macro';
1321
import _ from 'lodash';
1422
import { useMemo } from 'react';
@@ -47,17 +55,18 @@ const SessionUtilItem: React.FC<SessionUtilItemProps> = ({
4755
{description && (
4856
<Typography.Text
4957
type="secondary"
50-
style={{ fontSize: token.fontSizeSM }}
58+
// style={{ fontSize: token.fontSizeSM }}
5159
>
5260
{description}
5361
</Typography.Text>
5462
)}
5563
</Flex>
56-
<BAIProgressWithLabel
64+
<Progress
65+
strokeColor={token.colorTextQuaternary}
66+
strokeLinecap="butt"
5767
percent={_.toNumber(percent)}
58-
valueLabel={percentLabel}
59-
strokeColor="#BFBFBF"
60-
progressStyle={{ border: 'none' }}
68+
showInfo={false}
69+
style={{ lineHeight: '8px' }}
6170
/>
6271
</>
6372
);
@@ -151,9 +160,17 @@ const SessionUsageMonitor: React.FC<SessionUsageMonitorProps> = ({
151160
capacity: string,
152161
decimalSize: number = 2,
153162
) => {
154-
return `${convertBinarySizeUnit(current, 'g', decimalSize)?.numberFixed ?? '-'} / ${
155-
convertBinarySizeUnit(capacity, 'g', decimalSize)?.numberFixed ?? '-'
156-
} GiB`;
163+
return (
164+
<>
165+
<Typography.Text>
166+
{convertBinarySizeUnit(current, 'g', decimalSize)?.numberFixed ?? '-'}{' '}
167+
</Typography.Text>{' '}
168+
&nbsp;/&nbsp;
169+
{convertBinarySizeUnit(capacity, 'g', decimalSize)?.numberFixed ??
170+
'-'}{' '}
171+
GiB
172+
</>
173+
);
157174
};
158175

159176
const utilItems = filterEmptyItem([
@@ -163,6 +180,14 @@ const SessionUsageMonitor: React.FC<SessionUsageMonitorProps> = ({
163180
size={size}
164181
title={mergedResourceSlots?.['cpu']?.human_readable_name}
165182
percent={sortedLiveStat?.cpu_util?.pct || 0}
183+
description={
184+
<>
185+
<Typography.Text>
186+
{sortedLiveStat?.cpu_util?.pct || 0}
187+
</Typography.Text>
188+
&nbsp;%
189+
</>
190+
}
166191
/>
167192
),
168193
sortedLiveStat?.mem && (
@@ -206,17 +231,19 @@ const SessionUsageMonitor: React.FC<SessionUsageMonitorProps> = ({
206231
title={
207232
<>
208233
{mergedResourceSlots?.[deviceKey]?.human_readable_name}
209-
<Typography.Text type="secondary">
210-
{_.includes(key, 'util') && ' (util)'}
211-
{_.includes(key, 'mem') && ' (mem)'}
212-
</Typography.Text>
234+
{_.includes(key, 'util') && ' (util)'}
235+
{_.includes(key, 'mem') && ' (mem)'}
213236
</>
214237
}
215238
percent={value.pct || 0}
216239
description={
217-
_.includes(key, 'mem')
218-
? displayMemoryUsage(value?.current, value?.capacity)
219-
: undefined
240+
_.includes(key, 'mem') ? (
241+
displayMemoryUsage(value?.current, value?.capacity)
242+
) : _.includes(key, 'util') ? (
243+
<>
244+
<Typography.Text>{value.pct || 0}</Typography.Text>&nbsp;%
245+
</>
246+
) : undefined
220247
}
221248
tooltipTitle={
222249
<Flex direction="column" align="stretch">
@@ -254,9 +281,7 @@ const SessionUsageMonitor: React.FC<SessionUsageMonitorProps> = ({
254281
{size === 'default' && (
255282
<Col span={24}>
256283
<Flex justify="end">
257-
<Typography.Text>
258-
{`I/O Read: ${convertDecimalSizeUnit(sortedLiveStat?.io_read?.current, 'm')?.numberUnit ?? '-'}B / Write: ${convertDecimalSizeUnit(sortedLiveStat?.io_write?.current, 'm')?.numberUnit ?? '-'}B`}
259-
</Typography.Text>
284+
{`I/O: Read ${convertDecimalSizeUnit(sortedLiveStat?.io_read?.current, 'm')?.numberFixed ?? '-'} MB, Write ${convertDecimalSizeUnit(sortedLiveStat?.io_write?.current, 'm')?.numberFixed ?? '-'} MB`}
260285
</Flex>
261286
</Col>
262287
)}

0 commit comments

Comments
 (0)