chore: model list render time
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ export default [
|
|||||||
name: 'dashboard',
|
name: 'dashboard',
|
||||||
path: '/dashboard',
|
path: '/dashboard',
|
||||||
key: 'dashboard',
|
key: 'dashboard',
|
||||||
icon: 'home',
|
icon: 'AppstoreOutlined',
|
||||||
access: 'canSeeAdmin',
|
access: 'canSeeAdmin',
|
||||||
component: './dashboard'
|
component: './dashboard'
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { MoreOutlined } from '@ant-design/icons';
|
import { MoreOutlined } from '@ant-design/icons';
|
||||||
import { Button, Dropdown, Tooltip, type MenuProps } from 'antd';
|
import { Button, Dropdown, Tooltip, type MenuProps } from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
import { memo, useCallback } from 'react';
|
||||||
|
|
||||||
interface DropdownButtonsProps {
|
interface DropdownButtonsProps {
|
||||||
items: MenuProps['items'];
|
items: MenuProps['items'];
|
||||||
@@ -13,16 +14,16 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
|
|||||||
size = 'small',
|
size = 'small',
|
||||||
onSelect
|
onSelect
|
||||||
}) => {
|
}) => {
|
||||||
const handleMenuClick = (item: any) => {
|
const handleMenuClick = useCallback((item: any) => {
|
||||||
console.log('menu click', item.key);
|
console.log('menu click', item.key);
|
||||||
const selectItem = _.find(items, { key: item.key });
|
const selectItem = _.find(items, { key: item.key });
|
||||||
onSelect(item.key, selectItem);
|
onSelect(item.key, selectItem);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const handleButtonClick = (e: any) => {
|
const handleButtonClick = useCallback((e: any) => {
|
||||||
const headItem = _.head(items);
|
const headItem = _.head(items);
|
||||||
onSelect(headItem.key, headItem);
|
onSelect(headItem.key, headItem);
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
if (!items?.length) {
|
if (!items?.length) {
|
||||||
return <span></span>;
|
return <span></span>;
|
||||||
@@ -61,4 +62,4 @@ const DropdownButtons: React.FC<DropdownButtonsProps> = ({
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default DropdownButtons;
|
export default memo(DropdownButtons);
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Col, Row } from 'antd';
|
||||||
|
import React from 'react';
|
||||||
|
import { SealColumnProps } from '../types';
|
||||||
|
import TableHeader from './table-header';
|
||||||
|
|
||||||
|
interface HeaderProps {
|
||||||
|
children: React.ReactNode[];
|
||||||
|
onSort?: (dataIndex: string, order: any) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Header: React.FC<HeaderProps> = (props) => {
|
||||||
|
const { onSort } = props;
|
||||||
|
return (
|
||||||
|
<Row className="row">
|
||||||
|
{React.Children.map(props.children, (child, i) => {
|
||||||
|
const { props: columnProps } = child as any;
|
||||||
|
const {
|
||||||
|
title,
|
||||||
|
dataIndex,
|
||||||
|
align,
|
||||||
|
span,
|
||||||
|
headerStyle,
|
||||||
|
sortOrder,
|
||||||
|
sorter,
|
||||||
|
defaultSortOrder
|
||||||
|
} = columnProps as SealColumnProps;
|
||||||
|
if (React.isValidElement(child)) {
|
||||||
|
return (
|
||||||
|
<Col span={span} key={i}>
|
||||||
|
<TableHeader
|
||||||
|
onSort={onSort}
|
||||||
|
sorter={sorter}
|
||||||
|
dataIndex={dataIndex}
|
||||||
|
sortOrder={sortOrder}
|
||||||
|
defaultSortOrder={defaultSortOrder}
|
||||||
|
title={title}
|
||||||
|
style={headerStyle}
|
||||||
|
firstCell={i === 0}
|
||||||
|
align={align}
|
||||||
|
lastCell={i === props.children.length - 1}
|
||||||
|
></TableHeader>
|
||||||
|
</Col>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})}
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Header;
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import { Pagination, type PaginationProps } from 'antd';
|
||||||
|
import { memo } from 'react';
|
||||||
|
|
||||||
|
const PaginationComponent: React.FC<PaginationProps> = (props) => {
|
||||||
|
return <Pagination {...props} />;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default memo(PaginationComponent);
|
||||||
@@ -14,8 +14,7 @@ const TableHeader: React.FC<TableHeaderProps> = (props) => {
|
|||||||
sortOrder,
|
sortOrder,
|
||||||
onSort,
|
onSort,
|
||||||
sorter,
|
sorter,
|
||||||
dataIndex,
|
dataIndex
|
||||||
defaultSortOrder
|
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const handleOnSort = () => {
|
const handleOnSort = () => {
|
||||||
|
|||||||
@@ -2,19 +2,17 @@ import { RightOutlined } from '@ant-design/icons';
|
|||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Col,
|
|
||||||
Empty,
|
Empty,
|
||||||
Pagination,
|
Pagination,
|
||||||
Row,
|
|
||||||
Spin,
|
Spin,
|
||||||
type PaginationProps
|
type PaginationProps
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import TableHeader from './components/table-header';
|
import Header from './components/header';
|
||||||
import TableRow from './components/table-row';
|
import TableRow from './components/table-row';
|
||||||
import './styles/index.less';
|
import './styles/index.less';
|
||||||
import { SealColumnProps, SealTableProps } from './types';
|
import { SealTableProps } from './types';
|
||||||
|
|
||||||
const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
|
const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
|
||||||
props
|
props
|
||||||
@@ -111,48 +109,6 @@ const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
|
|||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderHeader = () => {
|
|
||||||
return (
|
|
||||||
<div className="header-row-wrapper">
|
|
||||||
{renderHeaderPrefix()}
|
|
||||||
<Row className="row">
|
|
||||||
{React.Children.map(props.children, (child, i) => {
|
|
||||||
const { props: columnProps } = child as any;
|
|
||||||
const {
|
|
||||||
title,
|
|
||||||
dataIndex,
|
|
||||||
align,
|
|
||||||
span,
|
|
||||||
headerStyle,
|
|
||||||
sortOrder,
|
|
||||||
sorter,
|
|
||||||
defaultSortOrder
|
|
||||||
} = columnProps as SealColumnProps;
|
|
||||||
if (React.isValidElement(child)) {
|
|
||||||
return (
|
|
||||||
<Col span={span} key={i}>
|
|
||||||
<TableHeader
|
|
||||||
onSort={onSort}
|
|
||||||
sorter={sorter}
|
|
||||||
dataIndex={dataIndex}
|
|
||||||
sortOrder={sortOrder}
|
|
||||||
defaultSortOrder={defaultSortOrder}
|
|
||||||
title={title}
|
|
||||||
style={headerStyle}
|
|
||||||
firstCell={i === 0}
|
|
||||||
align={align}
|
|
||||||
lastCell={i === props.children.length - 1}
|
|
||||||
></TableHeader>
|
|
||||||
</Col>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
})}
|
|
||||||
</Row>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const renderContent = useCallback(() => {
|
const renderContent = useCallback(() => {
|
||||||
if (!props.dataSource.length) {
|
if (!props.dataSource.length) {
|
||||||
return (
|
return (
|
||||||
@@ -190,14 +146,12 @@ const SealTable: React.FC<SealTableProps & { pagination: PaginationProps }> = (
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="seal-table-container">
|
<div className="seal-table-container">
|
||||||
{renderHeader()}
|
{
|
||||||
{/* {loading ? (
|
<div className="header-row-wrapper">
|
||||||
<div className="spin">
|
{renderHeaderPrefix()}
|
||||||
<Spin></Spin>
|
<Header onSort={onSort}>{children}</Header>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
}
|
||||||
renderContent()
|
|
||||||
)} */}
|
|
||||||
|
|
||||||
<Spin spinning={loading}>{renderContent()}</Spin>
|
<Spin spinning={loading}>{renderContent()}</Spin>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { useIntl } from '@umijs/max';
|
|||||||
import { Col, Row, Space, Tooltip } from 'antd';
|
import { Col, Row, Space, Tooltip } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { InstanceStatusMap, InstanceStatusMapValue, status } from '../config';
|
import { InstanceStatusMap, InstanceStatusMapValue, status } from '../config';
|
||||||
import { ModelInstanceListItem } from '../config/types';
|
import { ModelInstanceListItem } from '../config/types';
|
||||||
|
|
||||||
@@ -49,14 +49,14 @@ const InstanceItem: React.FC<InstanceItemProps> = ({
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const setChildActionList = (item: ModelInstanceListItem) => {
|
const setChildActionList = useCallback((item: ModelInstanceListItem) => {
|
||||||
return _.filter(childActionList, (action: any) => {
|
return _.filter(childActionList, (action: any) => {
|
||||||
if (action.key === 'viewlog') {
|
if (action.key === 'viewlog') {
|
||||||
return action.status.includes(item.state);
|
return action.status.includes(item.state);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const renderWorkerInfo = (item: ModelInstanceListItem) => {
|
const renderWorkerInfo = (item: ModelInstanceListItem) => {
|
||||||
let workerIp = '-';
|
let workerIp = '-';
|
||||||
|
|||||||
@@ -39,10 +39,8 @@ import ViewLogsModal from './view-logs-modal';
|
|||||||
interface ModelsProps {
|
interface ModelsProps {
|
||||||
handleSearch: (e: any) => void;
|
handleSearch: (e: any) => void;
|
||||||
handleNameChange: (e: any) => void;
|
handleNameChange: (e: any) => void;
|
||||||
fetchData: () => Promise<any>;
|
|
||||||
handleShowSizeChange?: (page: number, size: number) => void;
|
handleShowSizeChange?: (page: number, size: number) => void;
|
||||||
handlePageChange: (page: number, pageSize: number | undefined) => void;
|
handlePageChange: (page: number, pageSize: number | undefined) => void;
|
||||||
createModelsChunkRequest: () => void;
|
|
||||||
queryParams: {
|
queryParams: {
|
||||||
page: number;
|
page: number;
|
||||||
perPage: number;
|
perPage: number;
|
||||||
@@ -101,14 +99,14 @@ const Models: React.FC<ModelsProps> = ({
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const setActionList = (record: ListItem) => {
|
const setActionList = useCallback((record: ListItem) => {
|
||||||
return _.filter(ActionList, (action: any) => {
|
return _.filter(ActionList, (action: any) => {
|
||||||
if (action.key === 'chat') {
|
if (action.key === 'chat') {
|
||||||
return record.ready_replicas > 0;
|
return record.ready_replicas > 0;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
};
|
}, []);
|
||||||
|
|
||||||
const handleOnSort = (dataIndex: string, order: any) => {
|
const handleOnSort = (dataIndex: string, order: any) => {
|
||||||
console.log('handleTableChange=======', dataIndex, order);
|
console.log('handleTableChange=======', dataIndex, order);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ const Models: React.FC = () => {
|
|||||||
const [firstLoad, setFirstLoad] = useState(true);
|
const [firstLoad, setFirstLoad] = useState(true);
|
||||||
const chunkRequedtRef = useRef<any>();
|
const chunkRequedtRef = useRef<any>();
|
||||||
const chunkInstanceRequedtRef = useRef<any>();
|
const chunkInstanceRequedtRef = useRef<any>();
|
||||||
const dataSourceRef = useRef<any>();
|
|
||||||
let axiosToken = createAxiosToken();
|
let axiosToken = createAxiosToken();
|
||||||
const [queryParams, setQueryParams] = useState({
|
const [queryParams, setQueryParams] = useState({
|
||||||
page: 1,
|
page: 1,
|
||||||
@@ -30,8 +29,6 @@ const Models: React.FC = () => {
|
|||||||
search: ''
|
search: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
// dataSourceRef.current = dataSource;
|
|
||||||
|
|
||||||
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
const { updateChunkedList, cacheDataListRef } = useUpdateChunkedList({
|
||||||
dataList: dataSource,
|
dataList: dataSource,
|
||||||
setDataList: setDataSource
|
setDataList: setDataSource
|
||||||
@@ -51,7 +48,6 @@ const Models: React.FC = () => {
|
|||||||
if (!firstLoad) {
|
if (!firstLoad) {
|
||||||
setDataSource(res.items);
|
setDataSource(res.items);
|
||||||
}
|
}
|
||||||
// setDataSource(res.items);
|
|
||||||
setTotal(res.pagination.total);
|
setTotal(res.pagination.total);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setDataSource([]);
|
setDataSource([]);
|
||||||
@@ -154,11 +150,9 @@ const Models: React.FC = () => {
|
|||||||
handleNameChange={handleNameChange}
|
handleNameChange={handleNameChange}
|
||||||
handleSearch={handleSearch}
|
handleSearch={handleSearch}
|
||||||
handlePageChange={handlePageChange}
|
handlePageChange={handlePageChange}
|
||||||
createModelsChunkRequest={createModelsChunkRequest}
|
|
||||||
queryParams={queryParams}
|
queryParams={queryParams}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
total={total}
|
total={total}
|
||||||
fetchData={fetchData}
|
|
||||||
></TableList>
|
></TableList>
|
||||||
</TableContext.Provider>
|
</TableContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -44,9 +44,8 @@ const ReferenceParams = (props: ReferenceParamsProps) => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span className="usage">
|
||||||
<Tooltip
|
<Tooltip
|
||||||
trigger={['click']}
|
|
||||||
title={
|
title={
|
||||||
<Space>
|
<Space>
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
@@ -172,9 +172,13 @@ const GPUList: React.FC = () => {
|
|||||||
label={
|
label={
|
||||||
<span className="flex-column">
|
<span className="flex-column">
|
||||||
<span>
|
<span>
|
||||||
Total: {convertFileSize(record.memory?.total, 0)}
|
{intl.formatMessage({ id: 'resources.table.total' })}:{' '}
|
||||||
|
{convertFileSize(record.memory?.total, 0)}
|
||||||
|
</span>
|
||||||
|
<span>
|
||||||
|
{intl.formatMessage({ id: 'resources.table.used' })}:{' '}
|
||||||
|
{convertFileSize(record.memory?.used, 0)}
|
||||||
</span>
|
</span>
|
||||||
<span>Used: {convertFileSize(record.memory?.used, 0)}</span>
|
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
></ProgressBar>
|
></ProgressBar>
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ const Resources: React.FC = () => {
|
|||||||
className="m-r-5"
|
className="m-r-5"
|
||||||
style={{ display: 'flex', width: 25 }}
|
style={{ display: 'flex', width: 25 }}
|
||||||
>
|
>
|
||||||
[{index}]
|
[{item.index}]
|
||||||
</span>
|
</span>
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
key={index}
|
key={index}
|
||||||
|
|||||||
Reference in New Issue
Block a user