style: flatten menu items

This commit is contained in:
jialin
2025-07-10 09:47:12 +08:00
parent 751ddbb3f3
commit 51450c2b02
23 changed files with 1052 additions and 553 deletions
+133 -117
View File
@@ -4,6 +4,7 @@ import ProgressBar from '@/components/progress-bar';
import InfoColumn from '@/components/simple-table/info-column';
import useTableFetch from '@/hooks/use-table-fetch';
import { convertFileSize } from '@/utils';
import { PageContainer } from '@ant-design/pro-components';
import { useIntl } from '@umijs/max';
import { ConfigProvider, Empty, Table } from 'antd';
import _ from 'lodash';
@@ -69,128 +70,143 @@ const GPUList: React.FC = () => {
return (
<>
<FilterBar
buttonText={intl.formatMessage({ id: 'resources.button.create' })}
handleSearch={handleSearch}
handleInputChange={handleNameChange}
showDeleteButton={false}
showPrimaryButton={false}
width={{ input: 300 }}
></FilterBar>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
tableLayout={dataSource.loadend ? 'auto' : 'fixed'}
dataSource={dataSource.dataList}
loading={dataSource.loading}
rowKey="id"
onChange={handleTableChange}
pagination={{
showSizeChanger: true,
pageSize: queryParams.perPage,
current: queryParams.page,
total: dataSource.total,
hideOnSinglePage: queryParams.perPage === 10,
onChange: handlePageChange
}}
>
<Column
title={intl.formatMessage({ id: 'common.table.name' })}
dataIndex="name"
key="name"
width={240}
render={(text, record) => {
return (
<AutoTooltip ghost maxWidth={240}>
{text}
</AutoTooltip>
);
<PageContainer
ghost
header={{
title: 'GPUs',
style: {
paddingInline: 'var(--layout-content-header-inlinepadding)'
},
breadcrumb: {}
}}
extra={[]}
>
<FilterBar
marginBottom={22}
buttonText={intl.formatMessage({ id: 'resources.button.create' })}
handleSearch={handleSearch}
handleInputChange={handleNameChange}
showDeleteButton={false}
showPrimaryButton={false}
width={{ input: 300 }}
></FilterBar>
<ConfigProvider renderEmpty={renderEmpty}>
<Table
tableLayout={dataSource.loadend ? 'auto' : 'fixed'}
dataSource={dataSource.dataList}
loading={dataSource.loading}
rowKey="id"
onChange={handleTableChange}
pagination={{
showSizeChanger: true,
pageSize: queryParams.perPage,
current: queryParams.page,
total: dataSource.total,
hideOnSinglePage: queryParams.perPage === 10,
onChange: handlePageChange
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.index' })}
dataIndex="index"
key="index"
render={(text, record: GPUDeviceItem) => {
return <span>{record.index}</span>;
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.workername' })}
dataIndex="worker_name"
key="worker_name"
width={200}
render={(text, record: GPUDeviceItem) => {
return (
<span style={{ display: 'flex', width: '100%' }}>
<AutoTooltip ghost maxWidth={340}>
>
<Column
title={intl.formatMessage({ id: 'common.table.name' })}
dataIndex="name"
key="name"
width={240}
render={(text, record) => {
return (
<AutoTooltip ghost maxWidth={240}>
{text}
</AutoTooltip>
</span>
);
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.vender' })}
dataIndex="vendor"
key="vendor"
/>
);
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.index' })}
dataIndex="index"
key="index"
render={(text, record: GPUDeviceItem) => {
return <span>{record.index}</span>;
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.workername' })}
dataIndex="worker_name"
key="worker_name"
width={200}
render={(text, record: GPUDeviceItem) => {
return (
<span style={{ display: 'flex', width: '100%' }}>
<AutoTooltip ghost maxWidth={340}>
{text}
</AutoTooltip>
</span>
);
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.vender' })}
dataIndex="vendor"
key="vendor"
/>
<Column
title={`${intl.formatMessage({ id: 'resources.table.temperature' })} (°C)`}
dataIndex="temperature"
key="Temperature"
render={(text, record: GPUDeviceItem) => {
return <span>{text ? _.round(text, 1) : '-'}</span>;
}}
/>
<Column
title={intl.formatMessage({ id: 'resources.table.gpuutilization' })}
dataIndex="gpuUtil"
key="gpuUtil"
render={(text, record: GPUDeviceItem) => {
return (
<>
{record.core ? (
<ProgressBar
percent={_.round(record.core?.utilization_rate, 2)}
></ProgressBar>
) : (
'-'
)}
</>
);
}}
/>
<Column
title={`${intl.formatMessage({ id: 'resources.table.temperature' })} (°C)`}
dataIndex="temperature"
key="Temperature"
render={(text, record: GPUDeviceItem) => {
return <span>{text ? _.round(text, 1) : '-'}</span>;
}}
/>
<Column
title={intl.formatMessage({
id: 'resources.table.gpuutilization'
})}
dataIndex="gpuUtil"
key="gpuUtil"
render={(text, record: GPUDeviceItem) => {
return (
<>
{record.core ? (
<ProgressBar
percent={_.round(record.core?.utilization_rate, 2)}
></ProgressBar>
) : (
'-'
)}
</>
);
}}
/>
<Column
title={intl.formatMessage({
id: 'resources.table.vramutilization'
})}
dataIndex="VRAM"
key="VRAM"
render={(text, record: GPUDeviceItem) => {
return (
<ProgressBar
percent={
record.memory?.used
? _.round(record.memory?.utilization_rate, 0)
: _.round(
record.memory?.allocated / record.memory?.total,
0
) * 100
}
label={
<InfoColumn
fieldList={fieldList}
data={record.memory}
></InfoColumn>
}
></ProgressBar>
);
}}
/>
</Table>
</ConfigProvider>
<Column
title={intl.formatMessage({
id: 'resources.table.vramutilization'
})}
dataIndex="VRAM"
key="VRAM"
render={(text, record: GPUDeviceItem) => {
return (
<ProgressBar
percent={
record.memory?.used
? _.round(record.memory?.utilization_rate, 0)
: _.round(
record.memory?.allocated / record.memory?.total,
0
) * 100
}
label={
<InfoColumn
fieldList={fieldList}
data={record.memory}
></InfoColumn>
}
></ProgressBar>
);
}}
/>
</Table>
</ConfigProvider>
</PageContainer>
</>
);
};