Commit aafef480 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20220801' into 'staging'

Feat 20220801

See merge request !50
parents 84a93e67 a3af50d4
......@@ -229,6 +229,21 @@ class CloudEController {
}
}
// 获取文件文本内容(字符串)
static JobFileDownloadText(url: any, filetoken: string, projectId: string) {
if (ApiUtils.getAuthorizationHeaders(headers)) {
url = url + urlToken(filetoken, projectId);
headers["Cache-Control"] = "no-cache";
headers["Content-Type"] = "multipart/form-data";
return axios.get(
APIOPTION() + "/download" + url + "&showhidden=false",
{
headers: headers,
}
);
}
}
// 获取分子列表
static GetDatasetItemsList(params: IGetDatasetItemsListParams) {
......
......@@ -54,54 +54,6 @@ const OperatorList = (props: IProps) => {
};
});
setIsLastPage(res?.data?.last);
// todo 去掉parameters添加
// arr.forEach((item: any, index: number) => {
// item.edges = [];
// item.parameters.push({
// choices: [],
// classType: "STRING",
// classTypeName: "String",
// defaultValue: null,
// description: "",
// domType: "dataset",
// hidden: false,
// isnull: false,
// level: null,
// linked: false,
// many: false,
// name: `in${index + 1}`,
// order: 0,
// parameterGroup: "in",
// promoted: false,
// promotedName: null,
// required: false,
// title: null,
// validators: [],
// });
// });
// arr.forEach((item: any, index: number) => {
// item.parameters.push({
// choices: [],
// classType: "STRING",
// classTypeName: "String",
// defaultValue: null,
// description: "",
// domType: "dataset",
// hidden: false,
// isnull: false,
// level: null,
// linked: false,
// many: false,
// name: `out${index + 1}`,
// order: 0,
// parameterGroup: "out",
// promoted: false,
// promotedName: null,
// required: false,
// title: null,
// validators: [],
// });
// });
setList([...list, ...arr]);
},
});
......@@ -113,9 +65,8 @@ const OperatorList = (props: IProps) => {
productId: productId as string,
keyword,
page,
size: 5,
size: 20,
});
// size: 20 todo
},
[productId, getOperatorListRun]
);
......
import { saveUserSpec } from "@/api/workbench_api";
import MyDialog from "@/components/mui/MyDialog";
import MyInput from "@/components/mui/MyInput";
import { checkIsNumberLetterChinese } from "@/utils/util";
......@@ -8,7 +7,6 @@ import useMyRequest from "@/hooks/useMyRequest";
import { saveBatchActor } from "@/api/project_api";
import { useStores } from "@/store";
// import styles from "./index.module.css";
import { useMessage } from "@/components/MySnackbar";
import { toJS } from "mobx";
import { ITask } from "@/views/Project/ProjectSubmitWork/interface";
......@@ -16,9 +14,15 @@ interface IProps {
saveFormDialog: boolean;
setSaveFormDialog: (val: boolean) => void;
operatorList: ITask[];
setShowCustomOperator: any;
}
const SaveOperator = (props: IProps) => {
const { saveFormDialog, setSaveFormDialog, operatorList } = props;
const {
saveFormDialog,
setSaveFormDialog,
operatorList,
setShowCustomOperator,
} = props;
const { currentProjectStore } = useStores();
const Message = useMessage();
const productId = toJS(currentProjectStore.currentProductInfo.id);
......@@ -27,12 +31,12 @@ const SaveOperator = (props: IProps) => {
const [description, setDescription] = useState("");
// 保存批算子
const { run: saveBatchActorRun } = useMyRequest(saveBatchActor, {
const { run: saveBatchActorRun, loading } = useMyRequest(saveBatchActor, {
onSuccess: (res) => {
Message.success("保存算子成功");
setSaveFormDialog(false);
sessionStorage.setItem("operatorList", "[]");
console.log("res", res);
setSaveFormDialog(false);
setShowCustomOperator();
},
});
......@@ -146,7 +150,6 @@ const SaveOperator = (props: IProps) => {
// 表单弹窗确定,新建算子
const handleOncofirm = () => {
console.log(operatorList);
if (checkTitle(title) && checkVersion(version)) {
saveBatchActorRun({
query: {
......@@ -156,576 +159,7 @@ const SaveOperator = (props: IProps) => {
description: description,
},
body: positionTransform(),
// body: [
// {
// id: "62c7965c9bf7ba39f2dcefc0",
// title: "RecordFileReader",
// description: "这是一段RecordFileReader算子的描述",
// type: "FLOW",
// productId: "cadd",
// creator: "root",
// parameters: [
// {
// name: "raw",
// classType: "BOOLEAN",
// classTypeName: "Boolean",
// required: false,
// defaultValue: "false",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "RADIO",
// validators: [],
// choices: [
// {
// value: "true",
// },
// {
// value: "false",
// },
// ],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "sep",
// classType: "STRING",
// classTypeName: "String",
// required: false,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "contains_sep",
// classType: "BOOLEAN",
// classTypeName: "Boolean",
// required: false,
// defaultValue: "false",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "RADIO",
// validators: [],
// choices: [
// {
// value: "true",
// },
// {
// value: "false",
// },
// ],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "encoding",
// classType: "STRING",
// classTypeName: "String",
// required: false,
// defaultValue: "UTF-8",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [],
// choices: [],
// parameterGroup: "senior",
// linked: false,
// },
// {
// name: "chunk_size",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1000",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "senior",
// linked: false,
// },
// {
// name: "compression",
// classType: "STRING",
// classTypeName: "String",
// required: false,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [],
// choices: [],
// parameterGroup: "senior",
// linked: false,
// },
// {
// name: "cpus",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// {
// name: "ntasks",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// {
// name: "partition",
// classType: "STRING",
// classTypeName: "String",
// required: false,
// defaultValue: "c-4-1",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// {
// name: "parallelism",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// ],
// edges: [
// {
// id: "d3ffaf04-b3dc-4c1c-a3c0-a897536131ba",
// source: "62c7965c9bf7ba39f2dcefc0",
// target: "62c7965c9bf7ba39f2dcefc1",
// },
// ],
// version: "1.0.0",
// allVersions: ["1.0.0", "2.0.0"],
// scatter: false,
// _class: "com.cloudam.c3.domain.ActorSpec",
// },
// {
// id: "62c7965c9bf7ba39f2dcefc2",
// title: "Docking",
// description: "这是一段Docking算子的描述",
// type: "FLOW",
// productId: "cadd",
// creator: "root",
// parameters: [
// {
// name: "core_num",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "centerX",
// classType: "INT",
// classTypeName: "Int",
// required: true,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "centerY",
// classType: "INT",
// classTypeName: "Int",
// required: true,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "centerZ",
// classType: "INT",
// classTypeName: "Int",
// required: true,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "boxSizeX",
// classType: "INT",
// classTypeName: "Int",
// required: true,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "boxSizeY",
// classType: "INT",
// classTypeName: "Int",
// required: true,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "boxSizeZ",
// classType: "INT",
// classTypeName: "Int",
// required: true,
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "basis",
// linked: false,
// },
// {
// name: "poses_num",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "9",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "senior",
// linked: false,
// },
// {
// name: "verbosity",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "senior",
// linked: false,
// },
// {
// name: "exhaustiveness",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: false,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "senior",
// linked: false,
// },
// {
// name: "cpus",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "1",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// {
// name: "ntasks",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "4",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// {
// name: "partition",
// classType: "STRING",
// classTypeName: "String",
// required: false,
// defaultValue: "c-4-1",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// {
// name: "parallelism",
// classType: "INT",
// classTypeName: "Int",
// required: false,
// defaultValue: "6",
// description: "",
// hidden: true,
// many: false,
// isnull: false,
// promoted: false,
// order: 0,
// domType: "INPUT",
// validators: [
// {
// regex: "^[1-9]\\d*$",
// },
// ],
// choices: [],
// parameterGroup: "hardware",
// linked: false,
// },
// ],
// edges: [
// {
// id: "33f82dd3-47ed-4aae-85bc-0a9e763e0981",
// source: "62c7965c9bf7ba39f2dcefc2",
// target: "62c7965c9bf7ba39f2dcefc3",
// },
// ],
// version: "1.0.0",
// allVersions: ["1.0.0", "2.0.0"],
// scatter: false,
// _class: "com.cloudam.c3.domain.ActorSpec",
// },
// ],
});
// operatorList
// if (id) {
// saveUserSpecRun({
// title,
// version,
// description,
// tasks: templateConfigInfo,
// productId,
// id,
// creator,
// });
// } else {
// saveUserSpecRun({
// title,
// version,
// description,
// tasks: templateConfigInfo,
// productId,
// });
// }
}
};
......@@ -735,6 +169,7 @@ const SaveOperator = (props: IProps) => {
title="保存算子"
onClose={handleCloseDialog}
onConfirm={handleOncofirm}
loading={loading}
>
<div style={{ width: "388px" }}>
<MyInput
......
......@@ -168,6 +168,7 @@ const CustomOperator = observer((props: IProps) => {
saveFormDialog={saveFormDialog}
setSaveFormDialog={setSaveFormDialog}
operatorList={operatorList}
setShowCustomOperator={setShowCustomOperator}
></SaveOperator>
</div>
<div className={styles.coContent} id="customOperatorFlow">
......
......@@ -90,7 +90,6 @@ const BatchOperatorFlow = (props: IProps) => {
/** 删除流节点或者线 */
const deleteSelectFlowNode = useCallback(
(e: any) => {
console.log(tasks);
if (e.keyCode === 8 && ListenState) {
/** 删除流节点逻辑 */
if (inSideFlowNodeId) {
......@@ -100,6 +99,12 @@ const BatchOperatorFlow = (props: IProps) => {
return item.id !== inSideFlowNodeId;
})) ||
[];
// 删除节点时同时删除相关的线
newVal?.forEach((task) => {
task.edges = task.edges.filter(
(edge) => edge.target !== inSideFlowNodeId
);
});
setTasks && setTasks(newVal);
}
if (selectedEdge) {
......@@ -174,7 +179,7 @@ const BatchOperatorFlow = (props: IProps) => {
});
});
return val;
}, [tasks, inSideFlowNodeId, flowNodeDraggable]);
}, [tasks, inSideFlowNodeId, flowNodeDraggable, showVersion]);
/** 生成初始化的连线节点 */
const initialEdges = useMemo(() => {
......@@ -210,7 +215,6 @@ const BatchOperatorFlow = (props: IProps) => {
const onNodeClick = (e: any, node: Node) => {
tasks?.forEach((item) => {
if (item.id === node.id) {
console.log("setInSideFlowNodeId", node.id);
setInSideFlowNodeId(node.id);
}
});
......@@ -356,8 +360,6 @@ const BatchOperatorFlow = (props: IProps) => {
/** 点击连线 */
const onEdgeClick = useCallback((e: any, val: Edge) => {
console.log(e);
console.log(val);
setSelectedEdge(val);
/** 点击连线清除选中的node ID */
setInSideFlowNodeId("");
......
......@@ -68,6 +68,7 @@ const FlowNode = (props: any) => {
[]
);
}, [parameters]);
return (
<div
style={flowNodeStyle}
......@@ -76,14 +77,14 @@ const FlowNode = (props: any) => {
[styles.selectedFlowBox]: selectedStatus,
})}
>
{dotStatus?.isInput ? (
{/* {dotStatus?.isInput ? (
<Handle
className={styles.handleBox}
style={inStyle}
type="target"
position={Position.Top}
/>
) : null}
) : null} */}
{inParamsArr?.length
? inParamsArr.map((item: any, index: number) => {
return (
......@@ -94,8 +95,8 @@ const FlowNode = (props: any) => {
style={{
background: "#fff ",
border: "1px solid #D1D6DE",
left: index * 24 + 20,
...inStyle,
left: index * 24 + 16,
}}
type="target"
position={Position.Top}
......@@ -120,14 +121,14 @@ const FlowNode = (props: any) => {
/>
)}
</div>
{dotStatus?.isOutput ? (
{/* {dotStatus?.isOutput ? (
<Handle
className={styles.handleBox}
style={outStyle}
type="source"
position={Position.Bottom}
/>
) : null}
) : null} */}
{outParamsArr?.length
? outParamsArr.map((item: any, index: number) => {
return (
......@@ -138,8 +139,8 @@ const FlowNode = (props: any) => {
style={{
background: "#fff ",
border: "1px solid #D1D6DE",
left: index * 24 + 20,
...outStyle,
left: index * 24 + 16,
}}
type="source"
position={Position.Bottom}
......
......@@ -143,6 +143,15 @@ const Flow = (props: IProps) => {
);
})) ||
[];
// 删除节点时同时删除相关的线
newVal?.forEach((task) => {
task.edges =
(task?.edges?.length &&
task.edges.filter(
(edge) => edge.target !== inSideBatchNodeId
)) ||
[];
});
setTasks && setTasks(newVal);
}
if (selectedEdge) {
......@@ -151,7 +160,14 @@ const Flow = (props: IProps) => {
}
}
},
[inSideBatchNodeId, selectedEdge, setTasks, tasks, tasksDeleteLine]
[
inSideBatchNodeId,
selectedEdge,
setTasks,
tasks,
tasksDeleteLine,
ListenState,
]
);
/** 监听鼠标按下事件 */
......@@ -163,25 +179,25 @@ const Flow = (props: IProps) => {
}, [deleteSelectBatchNode]);
/** 获取是否有输入节点或者是否有输出节点 */
const nodesInputAndOutputStatus = useCallback(
(id: string) => {
/** 所有的连线 */
const lineArr: IEdge[] = [];
tasks?.length &&
tasks.forEach((item) => {
item.edges?.length && lineArr.push(...item.edges);
});
/** 所有的输入节点ID */
const isInput = lineArr?.some((item) => item.target === id);
/** 所有的输出节点ID */
const isOutput = lineArr?.some((item) => item.source === id);
return {
isInput,
isOutput,
};
},
[tasks]
);
// const nodesInputAndOutputStatus = useCallback(
// (id: string) => {
// /** 所有的连线 */
// const lineArr: IEdge[] = [];
// tasks?.length &&
// tasks.forEach((item) => {
// item.edges?.length && lineArr.push(...item.edges);
// });
// /** 所有的输入节点ID */
// const isInput = lineArr?.some((item) => item.target === id);
// /** 所有的输出节点ID */
// const isOutput = lineArr?.some((item) => item.source === id);
// return {
// isInput,
// isOutput,
// };
// },
// [tasks]
// );
/** 获取是否有流节点 */
const isFlowNode = useCallback(
......@@ -258,7 +274,7 @@ const Flow = (props: IProps) => {
}
: { selectedStatus: inSideFlowNodeId === item.id }),
/** 输入输出圆点状态 */
dotStatus: nodesInputAndOutputStatus(item.id),
// dotStatus: nodesInputAndOutputStatus(item.id),
/** 样式 */
style: {
......@@ -290,7 +306,7 @@ const Flow = (props: IProps) => {
selectedBatchNodeId,
inSideBatchNodeId,
inSideFlowNodeId,
nodesInputAndOutputStatus,
// nodesInputAndOutputStatus,
getBatchStyle,
]);
......
......@@ -156,7 +156,8 @@ const OperatorItem = (props: IOperatorItemProps) => {
const OperatorList = observer((props: IOperatorListProps) => {
const { currentProjectStore } = useStores();
const productId = toJS(currentProjectStore.currentProductInfo.id);
const { templateConfigInfo, setTemplateConfigInfo } = props;
const { templateConfigInfo, setTemplateConfigInfo, showCustomOperator } =
props;
const [operatorListData, setOperatorListData] = useState<ITask[]>([]);
const [keyword, setKeyword] = useState<string>("");
......@@ -168,22 +169,29 @@ const OperatorList = observer((props: IOperatorListProps) => {
});
useEffect(() => {
if (!showCustomOperator) {
run({
owner: "root",
productId: "cadd" || "",
productId: productId as string,
});
}, [productId, run]);
}
}, [productId, run, showCustomOperator]);
/** 处理回车键 */
const handleEnterCode = (e: React.KeyboardEvent<HTMLInputElement>) => {
if (e.keyCode === 13) {
getOperatorList();
}
};
const getOperatorList = useCallback(() => {
run({
owner: "root",
productId: "cadd" || "",
productId: productId as string,
keyword,
});
}
};
}, [run, keyword, productId]);
return (
<div className={styles.operatorListBox}>
<div className={styles.searchBox}>
......
......@@ -19,4 +19,5 @@ export interface IOperatorItemProps {
export interface IOperatorListProps {
templateConfigInfo: ITask[]
setTemplateConfigInfo: (val: ITask[]) => void
showCustomOperator: boolean
}
\ No newline at end of file
......@@ -218,6 +218,7 @@ const WorkFlowEdit = observer((props: IProps) => {
</div>
{leftContentType === "list" && (
<OperatorList
showCustomOperator={showCustomOperator}
templateConfigInfo={templateConfigInfo}
setTemplateConfigInfo={setTemplateConfigInfo}
/>
......@@ -242,7 +243,7 @@ const WorkFlowEdit = observer((props: IProps) => {
setTasks={setTemplateConfigInfo}
type="edit"
onFlowNodeClick={handleNodeClick}
ListenState={!saveFormDialog}
ListenState={!saveFormDialog && !showCustomOperator}
/>
</div>
</div>
......
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