import PageTools from '@/components/page-tools'; import ProgressBar from '@/components/progress-bar'; import useTableRowSelection from '@/hooks/use-table-row-selection'; import useTableSort from '@/hooks/use-table-sort'; import { convertFileSize } from '@/utils'; import { SyncOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Button, Input, Space, Table } from 'antd'; import _ from 'lodash'; import { useEffect, useState } from 'react'; import { queryGpuDevicesList } from '../apis'; import { GPUDeviceItem } from '../config/types'; const { Column } = Table; const dataSource: GPUDeviceItem[] = [ { id: 1, name: 'bj-web-service-1', address: '183.14.31.136', hostname: 'bj-web-service-1', labels: {}, resources: { capacity: { cpu: 4, gpu: 2, memory: '64 GiB', gram: '24 Gib' }, allocable: { cpu: 2.5, gpu: 1.6, memory: '64', gram: '24 Gib' } }, state: 'ACTIVE' }, { id: 2, name: 'bj-db-service-2', address: '172.24.1.36', hostname: 'bj-db-service-2', labels: {}, resources: { capacity: { cpu: 4, gpu: 2, memory: '64 GiB', gram: '24 Gib' }, allocable: { cpu: 2, gpu: 1.5, memory: '32 GiB', gram: '12 Gib' } }, state: 'ACTIVE' }, { id: 3, name: 'guangzhou-computed-node-2', address: '170.10.2.10', hostname: 'guangzhou-computed-node-2', labels: {}, resources: { capacity: { cpu: 8, gpu: 4, memory: '64 GiB', gram: '24 Gib' }, allocable: { cpu: 2, gpu: 1.5, memory: '32 GiB', gram: '12 Gib' } }, state: 'ACTIVE' }, { id: 4, name: 'hangzhou-cache-node-1', address: '115.2.21.10', hostname: 'hangzhou-cache-node-1', labels: {}, resources: { capacity: { cpu: 8, gpu: 4, memory: '64 GiB', gram: '24 Gib' }, allocable: { cpu: 4, gpu: 2.5, memory: '40 GiB', gram: '16 Gib' } }, state: 'ACTIVE' } ]; const Models: React.FC = () => { const intl = useIntl(); const rowSelection = useTableRowSelection(); const { sortOrder, setSortOrder } = useTableSort({ defaultSortOrder: 'descend' }); const [dataSource, setDataSource] = useState([]); const [total, setTotal] = useState(10); const [loading, setLoading] = useState(false); const [queryParams, setQueryParams] = useState({ page: 1, perPage: 10, query: '' }); const handleShowSizeChange = (current: number, size: number) => { setQueryParams({ ...queryParams, perPage: size }); }; const handlePageChange = (page: number, perPage: number | undefined) => { console.log(page, perPage); setQueryParams({ ...queryParams, page: page }); }; const handleTableChange = (pagination: any, filters: any, sorter: any) => { setSortOrder(sorter.order); }; const fetchData = async () => { setLoading(true); try { const params = { ..._.pickBy(queryParams, (val: any) => !!val) }; const res = await queryGpuDevicesList(params); setDataSource(res.items); setTotal(res.pagination.total); } catch (error) { console.log('error', error); } finally { setLoading(false); } }; const handleSearch = (e: any) => { fetchData(); }; const handleNameChange = (e: any) => { setQueryParams({ ...queryParams, query: e.target.value }); }; useEffect(() => { fetchData(); }, [queryParams]); return ( <> } > { return {record.index}; }} /> { return {_.round(text, 1)}; }} /> { return {record.core?.total}; }} /> { return ( ); }} /> { return ( Total: {convertFileSize(record.memory?.total, 0)} Used: {convertFileSize(record.memory?.used, 0)} } > ); }} />
); }; export default Models;