Browse Source

fix: 修复复制实验面包屑不正确

pull/152/head
cp3hnu 1 year ago
parent
commit
bef1fd6f5b
5 changed files with 29 additions and 33 deletions
  1. +5
    -0
      react-ui/config/routes.ts
  2. +22
    -26
      react-ui/src/pages/AutoML/Create/index.tsx
  3. +1
    -4
      react-ui/src/pages/AutoML/List/index.tsx
  4. +1
    -1
      react-ui/src/pages/ModelDeployment/CreateVersion/index.tsx
  5. +0
    -2
      react-ui/src/utils/sessionStorage.ts

+ 5
- 0
react-ui/config/routes.ts View File

@@ -169,6 +169,11 @@ export default [
path: 'edit/:id', path: 'edit/:id',
component: './AutoML/Create/index', component: './AutoML/Create/index',
}, },
{
name: '复制实验',
path: 'copy/:id',
component: './AutoML/Create/index',
},
{ {
name: '实验实例详情', name: '实验实例详情',
path: 'instance/:autoMLId/:id', path: 'instance/:autoMLId/:id',


+ 22
- 26
react-ui/src/pages/AutoML/Create/index.tsx View File

@@ -9,8 +9,7 @@ import { addAutoMLReq, getAutoMLInfoReq, updateAutoMLReq } from '@/services/auto
import { convertEmptyStringToUndefined, parseJsonText, trimCharacter } from '@/utils'; import { convertEmptyStringToUndefined, parseJsonText, trimCharacter } from '@/utils';
import { safeInvoke } from '@/utils/functional'; import { safeInvoke } from '@/utils/functional';
import { to } from '@/utils/promise'; import { to } from '@/utils/promise';
import SessionStorage from '@/utils/sessionStorage';
import { useNavigate, useParams } from '@umijs/max';
import { useLocation, useNavigate, useParams } from '@umijs/max';
import { App, Button, Form } from 'antd'; import { App, Button, Form } from 'antd';
import { omit } from 'lodash'; import { omit } from 'lodash';
import { useEffect } from 'react'; import { useEffect } from 'react';
@@ -27,27 +26,18 @@ function CreateAutoML() {
const { message } = App.useApp(); const { message } = App.useApp();
const params = useParams(); const params = useParams();
const id = safeInvoke(Number)(params.id); const id = safeInvoke(Number)(params.id);
const { pathname } = useLocation();
const isCopy = pathname.includes('copy');


useEffect(() => { useEffect(() => {
// 复制和新建
const recordId = SessionStorage.getItem(SessionStorage.autoMLRecordIDKey);
if (recordId && !Number.isNaN(Number(recordId))) {
getAutoMLInfo(Number(recordId), true);
}
return () => {
SessionStorage.removeItem(SessionStorage.autoMLRecordIDKey);
};
}, []);

useEffect(() => {
// 编辑
// 编辑,复制
if (id && !Number.isNaN(id)) { if (id && !Number.isNaN(id)) {
getAutoMLInfo(id, false);
getAutoMLInfo(id);
} }
}, [id]); }, [id]);


// 获取服务详情 // 获取服务详情
const getAutoMLInfo = async (id: number, isCopy = false) => {
const getAutoMLInfo = async (id: number) => {
const [res] = await to(getAutoMLInfoReq({ id })); const [res] = await to(getAutoMLInfoReq({ id }));
if (res && res.data) { if (res && res.data) {
const autoMLInfo: AutoMLData = res.data; const autoMLInfo: AutoMLData = res.data;
@@ -127,14 +117,15 @@ function CreateAutoML() {
target_columns, target_columns,
}; };


const params = id
? {
id: id,
...object,
}
: object;
const params =
id && !isCopy
? {
id: id,
...object,
}
: object;


const request = id ? updateAutoMLReq : addAutoMLReq;
const request = id && !isCopy ? updateAutoMLReq : addAutoMLReq;
const [res] = await to(request(params)); const [res] = await to(request(params));
if (res) { if (res) {
message.success('操作成功'); message.success('操作成功');
@@ -153,10 +144,15 @@ function CreateAutoML() {
}; };


let buttonText = '新建'; let buttonText = '新建';
let title = '新实验';
let title = '新实验';
if (id) { if (id) {
title = '编辑实验';
buttonText = '更新';
if (isCopy) {
title = '复制实验';
buttonText = '确定';
} else {
title = '编辑实验';
buttonText = '更新';
}
} }


return ( return (


+ 1
- 4
react-ui/src/pages/AutoML/List/index.tsx View File

@@ -17,7 +17,6 @@ import {
import themes from '@/styles/theme.less'; import themes from '@/styles/theme.less';
import { type ExperimentInstance as ExperimentInstanceData } from '@/types'; import { type ExperimentInstance as ExperimentInstanceData } from '@/types';
import { to } from '@/utils/promise'; import { to } from '@/utils/promise';
import SessionStorage from '@/utils/sessionStorage';
import tableCellRender, { TableCellValueType } from '@/utils/table'; import tableCellRender, { TableCellValueType } from '@/utils/table';
import { modalConfirm } from '@/utils/ui'; import { modalConfirm } from '@/utils/ui';
import { useNavigate } from '@umijs/max'; import { useNavigate } from '@umijs/max';
@@ -118,13 +117,11 @@ function AutoMLList() {


if (record) { if (record) {
if (isCopy) { if (isCopy) {
SessionStorage.setItem(SessionStorage.autoMLRecordIDKey, record.id, false);
navigate(`/pipeline/autoML/create`);
navigate(`/pipeline/autoML/copy/${record.id}`);
} else { } else {
navigate(`/pipeline/autoML/edit/${record.id}`); navigate(`/pipeline/autoML/edit/${record.id}`);
} }
} else { } else {
SessionStorage.setItem(SessionStorage.autoMLRecordIDKey, '', false);
navigate(`/pipeline/autoML/create`); navigate(`/pipeline/autoML/create`);
} }
}; };


+ 1
- 1
react-ui/src/pages/ModelDeployment/CreateVersion/index.tsx View File

@@ -169,7 +169,7 @@ function CreateServiceVersion() {
if (lastPage === CreateServiceVersionFrom.ServiceInfo) { if (lastPage === CreateServiceVersionFrom.ServiceInfo) {
navigate(-1); navigate(-1);
} else { } else {
navigate(`serviceInfo/${serviceId}`, { replace: true });
navigate(`/modelDeployment/serviceInfo/${serviceId}`, { replace: true });
} }
} }
}; };


+ 0
- 2
react-ui/src/utils/sessionStorage.ts View File

@@ -9,8 +9,6 @@ export default class SessionStorage {
static readonly editorUrlKey = 'editor-url'; static readonly editorUrlKey = 'editor-url';
// 客户端信息 // 客户端信息
static readonly clientInfoKey = 'client-info'; static readonly clientInfoKey = 'client-info';
// 自动机器学习记录ID
static readonly autoMLRecordIDKey = 'auto-ml-record-id';


static getItem(key: string, isObject: boolean = false) { static getItem(key: string, isObject: boolean = false) {
const jsonStr = sessionStorage.getItem(key); const jsonStr = sessionStorage.getItem(key);


Loading…
Cancel
Save