Commit 72b0a30f authored by 吴永生#A02208's avatar 吴永生#A02208

Merge branch 'feat-20220705-customTemplate' of http://120.77.149.83/root/bkunyun…

Merge branch 'feat-20220705-customTemplate' of http://120.77.149.83/root/bkunyun into feat-20220705-customTemplate
parents 3c390bf4 e1393fbc
...@@ -19,6 +19,7 @@ import OutlinedInput from "@mui/material/OutlinedInput"; ...@@ -19,6 +19,7 @@ import OutlinedInput from "@mui/material/OutlinedInput";
import useMyRequest from "@/hooks/useMyRequest"; import useMyRequest from "@/hooks/useMyRequest";
import { storageUnitFromB } from "@/utils/util"; import { storageUnitFromB } from "@/utils/util";
import classnames from "classnames"; import classnames from "classnames";
import { useMessage } from "@/components/MySnackbar";
import _ from "lodash"; import _ from "lodash";
import moment from "moment"; import moment from "moment";
...@@ -32,6 +33,7 @@ type FileSelectProps = { ...@@ -32,6 +33,7 @@ type FileSelectProps = {
const FileSelect = observer((props: FileSelectProps) => { const FileSelect = observer((props: FileSelectProps) => {
const { onConfirm, type = "path" } = props; const { onConfirm, type = "path" } = props;
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const Message = useMessage();
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken); const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken);
const [path, setPath] = useState<String>("/"); const [path, setPath] = useState<String>("/");
...@@ -45,15 +47,50 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -45,15 +47,50 @@ const FileSelect = observer((props: FileSelectProps) => {
const [dataSetList, setDataSetList] = useState<any>([]); const [dataSetList, setDataSetList] = useState<any>([]);
const [keyWord, setKeyWord] = useState(""); const [keyWord, setKeyWord] = useState("");
const fileSelectOnConfirm = () => { // 点击确认时返回的路径
// if (selectItem.type) const resultPath = useMemo(() => {
console.log(path); if (keyWord) {
console.log(selectFileName); if (selectFileName) {
console.log(selectItem); console.log("selectFileName", selectFileName);
// onConfirm(path); console.log("selectItem", selectItem.dir);
// /ProjectData // dataset path: "/test/" path: "/"
// 其他 dir: "//call_logs/stdout/slurm/536f1e38-9357-470b-a0e9-fa5a9fbafe35/call-task_B/execution/"
//
if (type === "dataset") {
return `${selectItem.path}${selectFileName}`;
} else if (type === "file") {
return `${selectItem.dir.slice(1)}${selectFileName}`;
}
}
} else {
if (selectFileName) {
return `${path === "/" ? "" : path}/${selectFileName}`;
} else {
return path;
}
}
}, [path, selectFileName, keyWord, selectItem, type]);
console.log("resultPath", resultPath);
// /ProjectData/cromwell/slurm const fileSelectOnConfirm = () => {
if (type === "file") {
if (!selectFileName) {
Message.error("请选择一个文件");
return;
} else if (selectItem.type === "directory") {
Message.error("现在选择的是文件夹,请重新选择");
return;
}
} else if (type === "dataset") {
if (!selectFileName) {
Message.error("请选择数据集");
return;
} else if (selectItem.type === "directory") {
Message.error("现在选择的是文件夹,请重新选择");
return;
}
}
onConfirm(resultPath);
}; };
// 搜索值改变 // 搜索值改变
...@@ -184,7 +221,7 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -184,7 +221,7 @@ const FileSelect = observer((props: FileSelectProps) => {
[style.folderIconBox]: true, [style.folderIconBox]: true,
[style.folderPointer]: true, [style.folderPointer]: true,
})} })}
onClick={() => handleViewFolders(item)} onClick={() => !keyWord && handleViewFolders(item)}
> >
<img className={style.folderIcon} src={folderIcon} alt="" /> <img className={style.folderIcon} src={folderIcon} alt="" />
{item.name} {item.name}
...@@ -244,6 +281,15 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -244,6 +281,15 @@ const FileSelect = observer((props: FileSelectProps) => {
fileList.push(item); fileList.push(item);
} }
}); });
if (keyWord) {
if (type === "file") {
return fileList;
} else if (type === "dataset") {
return dataSetList;
} else {
return folderList;
}
} else {
if (type === "file") { if (type === "file") {
return [...folderList, ...fileList]; return [...folderList, ...fileList];
} else if (type === "dataset") { } else if (type === "dataset") {
...@@ -251,7 +297,8 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -251,7 +297,8 @@ const FileSelect = observer((props: FileSelectProps) => {
} else { } else {
return [...folderList]; return [...folderList];
} }
}, [list, dataSetList, type]); }
}, [list, dataSetList, type, keyWord]);
// 前端展示的文件路径 // 前端展示的文件路径
const showPath = useMemo(() => { const showPath = useMemo(() => {
...@@ -324,6 +371,8 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -324,6 +371,8 @@ const FileSelect = observer((props: FileSelectProps) => {
const getAllData = useCallback(() => { const getAllData = useCallback(() => {
setDataSetList([]); setDataSetList([]);
setList([]); setList([]);
setSelectFileName("");
setSelectItem({});
if (type === "file" || type === "path") { if (type === "file" || type === "path") {
// 不需要获取数据集 // 不需要获取数据集
if (keyWord) { if (keyWord) {
...@@ -373,6 +422,7 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -373,6 +422,7 @@ const FileSelect = observer((props: FileSelectProps) => {
<div className={style.FSBox}> <div className={style.FSBox}>
<div className={style.FSTop}> <div className={style.FSTop}>
<div className={style.FSPath}>{showPath}</div> <div className={style.FSPath}>{showPath}</div>
{type !== "path" && (
<div className={style.FSKeyWord}> <div className={style.FSKeyWord}>
<OutlinedInput <OutlinedInput
value={keyWord} value={keyWord}
...@@ -384,6 +434,7 @@ const FileSelect = observer((props: FileSelectProps) => { ...@@ -384,6 +434,7 @@ const FileSelect = observer((props: FileSelectProps) => {
// onKeyUp={handleKeyWordChangeKeyUp} // onKeyUp={handleKeyWordChangeKeyUp}
/> />
</div> </div>
)}
</div> </div>
<Table <Table
footer={false} footer={false}
......
...@@ -4,7 +4,7 @@ import MyInput from "@/components/mui/MyInput"; ...@@ -4,7 +4,7 @@ import MyInput from "@/components/mui/MyInput";
import Tooltip from "@mui/material/Tooltip"; import Tooltip from "@mui/material/Tooltip";
import classnames from "classnames"; import classnames from "classnames";
import { useState, useMemo, useImperativeHandle } from "react"; import { useState, useMemo, useImperativeHandle } from "react";
import FileSelect from "@/components/FileSelect"; import FileSelect from "@/components/BusinessComponents/FileSelect";
import moment from "moment"; import moment from "moment";
import MySelect, { optionsTransform } from "../components/MySelect"; import MySelect, { optionsTransform } from "../components/MySelect";
import MyCheckBox from "@/components/mui/MyCheckBox"; import MyCheckBox from "@/components/mui/MyCheckBox";
...@@ -26,6 +26,9 @@ type ConfigFormProps = { ...@@ -26,6 +26,9 @@ type ConfigFormProps = {
const ConfigForm = (props: ConfigFormProps) => { const ConfigForm = (props: ConfigFormProps) => {
const { templateConfigInfo, setParameter, setSelectedBatchNodeId } = props; const { templateConfigInfo, setParameter, setSelectedBatchNodeId } = props;
const [name, setName] = useState<string>(""); // 任务名称 const [name, setName] = useState<string>(""); // 任务名称
const [fileSelectType, setFileSelectType] = useState<
"path" | "dataset" | "file"
>("path");
const [nameHelp, setNameHelp] = useState({ const [nameHelp, setNameHelp] = useState({
error: false, error: false,
...@@ -218,9 +221,10 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -218,9 +221,10 @@ const ConfigForm = (props: ConfigFormProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => onClick={() => {
handleOpenFileSelect(taskId, parameter.name) setFileSelectType("file");
} handleOpenFileSelect(taskId, parameter.name);
}}
src={fileSelectIcon} src={fileSelectIcon}
alt="" alt=""
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -240,9 +244,10 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -240,9 +244,10 @@ const ConfigForm = (props: ConfigFormProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => onClick={() => {
handleOpenFileSelect(taskId, parameter.name) setFileSelectType("path");
} handleOpenFileSelect(taskId, parameter.name);
}}
src={fileSelectIcon} src={fileSelectIcon}
alt="" alt=""
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -262,9 +267,10 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -262,9 +267,10 @@ const ConfigForm = (props: ConfigFormProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => onClick={() => {
handleOpenFileSelect(taskId, parameter.name) setFileSelectType("dataset");
} handleOpenFileSelect(taskId, parameter.name);
}}
src={fileSelectIcon} src={fileSelectIcon}
alt="" alt=""
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -420,7 +426,10 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -420,7 +426,10 @@ const ConfigForm = (props: ConfigFormProps) => {
InputProps={{ InputProps={{
endAdornment: ( endAdornment: (
<img <img
onClick={() => handleOpenFileSelect()} onClick={() => {
setFileSelectType("path");
handleOpenFileSelect();
}}
src={fileSelectIcon} src={fileSelectIcon}
alt="选择输出路径" alt="选择输出路径"
className={styles.fileSelectImg} className={styles.fileSelectImg}
...@@ -496,6 +505,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -496,6 +505,7 @@ const ConfigForm = (props: ConfigFormProps) => {
onClose={handleFileSelectOnClose} onClose={handleFileSelectOnClose}
open={fileSelectOpen} open={fileSelectOpen}
onConfirm={onFileSelectConfirm} onConfirm={onFileSelectConfirm}
type={fileSelectType}
/> />
)} )}
</div> </div>
......
...@@ -290,6 +290,16 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -290,6 +290,16 @@ const WorkFlowEdit = observer((props: IProps) => {
// 表单弹窗确定,新建/编辑自定义模板保存 // 表单弹窗确定,新建/编辑自定义模板保存
const handleOncofirm = () => { const handleOncofirm = () => {
if (checkTitle(title) && checkVersion(version)) { if (checkTitle(title) && checkVersion(version)) {
if (id) {
saveUserSpecRun({
title,
version,
description,
tasks: templateConfigInfo,
productId,
id,
});
} else {
saveUserSpecRun({ saveUserSpecRun({
title, title,
version, version,
...@@ -298,6 +308,7 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -298,6 +308,7 @@ const WorkFlowEdit = observer((props: IProps) => {
productId, productId,
}); });
} }
}
}; };
/** 选中的task 唯一标识符 */ /** 选中的task 唯一标识符 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment