import AutoTooltip from '@/components/auto-tooltip'; import ProgressBar from '@/components/progress-bar'; import InfoColumn from '@/components/simple-table/info-column'; import { tableSorter } from '@/config/settings'; import { convertFileSize } from '@/utils'; import { useIntl } from '@umijs/max'; import { ColumnsType } from 'antd/lib/table'; import _ from 'lodash'; import { useMemo } from 'react'; import { GPUDeviceItem } from '../config/types'; const fieldList = [ { label: 'resources.table.total', key: 'total', locale: true, render: (val: any) => { return convertFileSize(val, 0); } }, { label: 'resources.table.used', key: 'used', locale: true, render: (val: any) => { return convertFileSize(val, 0); } }, { label: 'resources.table.allocated', key: 'allocated', locale: true, render: (val: any) => { return convertFileSize(val, 0); } } ]; const useGPUColumns = (props: { loadend: boolean; firstLoad: boolean; clusterList: Global.BaseOption[]; sortOrder: string[]; }): ColumnsType => { const { clusterList, loadend, firstLoad, sortOrder } = props; const intl = useIntl(); return useMemo(() => { return [ { title: intl.formatMessage({ id: 'common.table.name' }), dataIndex: 'name', width: 240, minWidth: 32, sorter: tableSorter(1), render: (text: string, record: GPUDeviceItem) => ( {text} ) }, { title: intl.formatMessage({ id: 'resources.table.index' }), dataIndex: 'index', sorter: tableSorter(2), render: (text: string, record: GPUDeviceItem) => {text} }, { title: intl.formatMessage({ id: 'clusters.title' }), dataIndex: 'cluster_id', sorter: tableSorter(3), render: (text: number, record: GPUDeviceItem) => ( {clusterList.find((item) => item.value === text)?.label} ) }, { title: intl.formatMessage({ id: 'resources.worker' }), dataIndex: 'worker_name', sorter: tableSorter(4), render: (text: string, record: GPUDeviceItem) => ( {text} ) }, { title: intl.formatMessage({ id: 'resources.table.vendor' }), dataIndex: 'vendor', sorter: tableSorter(5) }, { title: `${intl.formatMessage({ id: 'resources.table.temperature' })} (°C)`, dataIndex: 'temperature', render: (text: number, record: GPUDeviceItem) => ( {text ? _.round(text, 1) : '-'} ) }, { title: `${intl.formatMessage({ id: 'resources.table.utilization' })}`, dataIndex: 'core.utilization_rate', key: 'core.utilization_rate', sorter: tableSorter(6), render: (text: number, record: GPUDeviceItem) => { return ( {record.core ? ( ) : ( '-' )} ); } }, { title: intl.formatMessage({ id: 'resources.table.vramutilization' }), dataIndex: 'memory.utilization_rate', key: 'memory.utilization_rate', sorter: tableSorter(7), render: (text: number, record: GPUDeviceItem, index: number) => { return ( } > ); } } ]; }, [intl, clusterList, loadend, firstLoad]); }; export default useGPUColumns;