| @@ -13,6 +13,7 @@ import { | |||||
| } from '@/pages/Dataset/config'; | } from '@/pages/Dataset/config'; | ||||
| import GraphLegend from '@/pages/Model/components/GraphLegend'; | import GraphLegend from '@/pages/Model/components/GraphLegend'; | ||||
| import ModelEvolution from '@/pages/Model/components/ModelEvolution'; | import ModelEvolution from '@/pages/Model/components/ModelEvolution'; | ||||
| import { VersionChangedMessage } from '@/utils/constant'; | |||||
| import { openAntdModal } from '@/utils/modal'; | import { openAntdModal } from '@/utils/modal'; | ||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { modalConfirm } from '@/utils/ui'; | import { modalConfirm } from '@/utils/ui'; | ||||
| @@ -124,6 +125,7 @@ const ResourceInfo = ({ resourceType }: ResourceInfoProps) => { | |||||
| onOk: () => { | onOk: () => { | ||||
| getVersionList(true); | getVersionList(true); | ||||
| close(); | close(); | ||||
| window.postMessage({ type: VersionChangedMessage }); | |||||
| }, | }, | ||||
| }); | }); | ||||
| }; | }; | ||||
| @@ -170,6 +172,7 @@ const ResourceInfo = ({ resourceType }: ResourceInfoProps) => { | |||||
| if (res) { | if (res) { | ||||
| message.success('删除成功'); | message.success('删除成功'); | ||||
| getVersionList(true); | getVersionList(true); | ||||
| window.postMessage({ type: VersionChangedMessage }); | |||||
| } | } | ||||
| }; | }; | ||||
| @@ -3,6 +3,7 @@ import TableColTitle from '@/components/TableColTitle'; | |||||
| import { useCheck } from '@/hooks/useCheck'; | import { useCheck } from '@/hooks/useCheck'; | ||||
| import { getModelPageVersionsReq, getModelVersionsMetricsReq } from '@/services/dataset'; | import { getModelPageVersionsReq, getModelVersionsMetricsReq } from '@/services/dataset'; | ||||
| import { tableSorter } from '@/utils'; | import { tableSorter } from '@/utils'; | ||||
| import { VersionChangedMessage } from '@/utils/constant'; | |||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import tableCellRender from '@/utils/table'; | import tableCellRender from '@/utils/table'; | ||||
| import { Checkbox, Flex, Table, type TablePaginationConfig, type TableProps } from 'antd'; | import { Checkbox, Flex, Table, type TablePaginationConfig, type TableProps } from 'antd'; | ||||
| @@ -27,10 +28,10 @@ type ModelMetricsProps = { | |||||
| resourceId: number; | resourceId: number; | ||||
| identifier: string; | identifier: string; | ||||
| owner: string; | owner: string; | ||||
| version: string; | |||||
| version: string; // 当前版本 | |||||
| }; | }; | ||||
| function ModelMetrics({ resourceId, identifier, owner, version }: ModelMetricsProps) { | |||||
| function ModelMetrics({ resourceId, identifier, owner, version, refreshTag }: ModelMetricsProps) { | |||||
| const [pagination, setPagination] = useState<TablePaginationConfig>({ | const [pagination, setPagination] = useState<TablePaginationConfig>({ | ||||
| current: 1, | current: 1, | ||||
| pageSize: 10, | pageSize: 10, | ||||
| @@ -59,6 +60,24 @@ function ModelMetrics({ resourceId, identifier, owner, version }: ModelMetricsPr | |||||
| checkSingleMetrics, | checkSingleMetrics, | ||||
| ] = useCheck(allMetricsNames); | ] = useCheck(allMetricsNames); | ||||
| // 新增,删除版本时,重置分页,然后刷新版本列表 | |||||
| useEffect(() => { | |||||
| const handleMessage = (e: MessageEvent) => { | |||||
| const { type } = e.data; | |||||
| if (type === VersionChangedMessage) { | |||||
| setPagination({ | |||||
| current: 1, | |||||
| pageSize: 10, | |||||
| }); | |||||
| } | |||||
| }; | |||||
| window.addEventListener('message', handleMessage); | |||||
| return () => { | |||||
| window.removeEventListener('message', handleMessage); | |||||
| }; | |||||
| }, []); | |||||
| useEffect(() => { | useEffect(() => { | ||||
| // 获取模型版本列表,带有参数和指标数据 | // 获取模型版本列表,带有参数和指标数据 | ||||
| const getModelPageVersions = async () => { | const getModelPageVersions = async () => { | ||||
| @@ -128,6 +147,7 @@ function ModelMetrics({ resourceId, identifier, owner, version }: ModelMetricsPr | |||||
| } | } | ||||
| }; | }; | ||||
| // 行勾选 | |||||
| const rowSelection: TableProps<TableData>['rowSelection'] = { | const rowSelection: TableProps<TableData>['rowSelection'] = { | ||||
| type: 'checkbox', | type: 'checkbox', | ||||
| fixed: 'left', | fixed: 'left', | ||||
| @@ -140,6 +160,7 @@ function ModelMetrics({ resourceId, identifier, owner, version }: ModelMetricsPr | |||||
| }), | }), | ||||
| }; | }; | ||||
| // 计算的表格数据 | |||||
| const showTableData = useMemo(() => { | const showTableData = useMemo(() => { | ||||
| const index = tableData.findIndex((item) => item.name === version); | const index = tableData.findIndex((item) => item.name === version); | ||||
| if (index !== -1) { | if (index !== -1) { | ||||
| @@ -8,11 +8,11 @@ import PageTitle from '@/components/PageTitle'; | |||||
| import SubAreaTitle from '@/components/SubAreaTitle'; | import SubAreaTitle from '@/components/SubAreaTitle'; | ||||
| import { CommonTabKeys, serviceTypeOptions } from '@/enums'; | import { CommonTabKeys, serviceTypeOptions } from '@/enums'; | ||||
| import { createServiceReq, getServiceInfoReq, updateServiceReq } from '@/services/modelDeployment'; | import { createServiceReq, getServiceInfoReq, updateServiceReq } from '@/services/modelDeployment'; | ||||
| import { ServiceCreatedMessage } from '@/utils/constant'; | |||||
| import { to } from '@/utils/promise'; | import { to } from '@/utils/promise'; | ||||
| import { useNavigate, useParams } from '@umijs/max'; | import { useNavigate, useParams } from '@umijs/max'; | ||||
| import { App, Button, Col, Form, Input, Row, Select } from 'antd'; | import { App, Button, Col, Form, Input, Row, Select } from 'antd'; | ||||
| import { useEffect } from 'react'; | import { useEffect } from 'react'; | ||||
| import { createServiceVersionMessage } from '../types'; | |||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| // 表单数据 | // 表单数据 | ||||
| @@ -63,7 +63,7 @@ function CreateService() { | |||||
| navigate(-1); | navigate(-1); | ||||
| if (!serviceId) { | if (!serviceId) { | ||||
| setTimeout(() => { | setTimeout(() => { | ||||
| window.postMessage({ type: createServiceVersionMessage, payload: res.data.id }); | |||||
| window.postMessage({ type: ServiceCreatedMessage, payload: res.data.id }); | |||||
| }, 500); | }, 500); | ||||
| } | } | ||||
| } | } | ||||
| @@ -31,9 +31,9 @@ import { | |||||
| CreateServiceVersionFrom, | CreateServiceVersionFrom, | ||||
| ServiceData, | ServiceData, | ||||
| ServiceOperationType, | ServiceOperationType, | ||||
| createServiceVersionMessage, | |||||
| } from '../types'; | } from '../types'; | ||||
| import styles from './index.less'; | import styles from './index.less'; | ||||
| import { ServiceCreatedMessage } from '@/utils/constant'; | |||||
| const allServiceTypeOptions = [{ label: '全部', value: '' }, ...serviceTypeOptions]; | const allServiceTypeOptions = [{ label: '全部', value: '' }, ...serviceTypeOptions]; | ||||
| @@ -95,7 +95,7 @@ function ModelDeployment() { | |||||
| useEffect(() => { | useEffect(() => { | ||||
| const handleMessage = (e: MessageEvent) => { | const handleMessage = (e: MessageEvent) => { | ||||
| const { type, payload } = e.data; | const { type, payload } = e.data; | ||||
| if (type === createServiceVersionMessage) { | |||||
| if (type === ServiceCreatedMessage) { | |||||
| modalConfirm({ | modalConfirm({ | ||||
| title: '创建服务成功', | title: '创建服务成功', | ||||
| content: '是否创建服务版本?', | content: '是否创建服务版本?', | ||||
| @@ -63,6 +63,3 @@ export enum CreateServiceVersionFrom { | |||||
| CreateService = 'CreateService', // 来自创建服务 | CreateService = 'CreateService', // 来自创建服务 | ||||
| ServiceInfo = 'ServiceInfo', // 来自服务详情 | ServiceInfo = 'ServiceInfo', // 来自服务详情 | ||||
| } | } | ||||
| // 去创建服务版本消息 | |||||
| export const createServiceVersionMessage = 'createServiceVersion'; | |||||
| @@ -10,4 +10,10 @@ const xllCols = { span: 10 }; | |||||
| /** | /** | ||||
| * 输入控件宽度,xl: 12, xll: 10 | * 输入控件宽度,xl: 12, xll: 10 | ||||
| */ | */ | ||||
| export const formCols = { xl: xlCols, xxl: xllCols }; | |||||
| export const FormCols = { xl: xlCols, xxl: xllCols }; | |||||
| // 数据集、模型新增和删除版本消息 | |||||
| export const VersionChangedMessage = 'versionChanged'; | |||||
| // 创建服务成功消息,去创建服务版本 | |||||
| export const ServiceCreatedMessage = 'serviceCreated'; | |||||