Commit 21d25080 authored by wuyongsheng's avatar wuyongsheng

feat: 任务结果选中状态不轮询

parent 34250724
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: 吴永生#A02208 yongsheng.wu@wholion.com * @Author: 吴永生#A02208 yongsheng.wu@wholion.com
* @Date: 2022-06-21 20:03:56 * @Date: 2022-06-21 20:03:56
* @LastEditors: 吴永生 15770852798@163.com * @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-12-13 19:15:57 * @LastEditTime: 2022-12-14 10:53:11
* @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx * @FilePath: /bkunyun/src/views/Project/ProjectSubmitWork/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -59,7 +59,6 @@ const statusMap = { ...@@ -59,7 +59,6 @@ const statusMap = {
}; };
type IStatus = "Done" | "Running" | "Failed" | "Pending"; type IStatus = "Done" | "Running" | "Failed" | "Pending";
let renderOutputs: Array<any> = [];
const ProjectSubmitWork = observer(() => { const ProjectSubmitWork = observer(() => {
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
...@@ -99,7 +98,9 @@ const ProjectSubmitWork = observer(() => { ...@@ -99,7 +98,9 @@ const ProjectSubmitWork = observer(() => {
pollingInterval: 1000 * 20, pollingInterval: 1000 * 20,
pollingWhenHidden: false, pollingWhenHidden: false,
onSuccess: (res: IResponse<ITaskInfo>) => { onSuccess: (res: IResponse<ITaskInfo>) => {
getOutputs(res.data.outputs); if(!activeFlowIndex) {
getOutputs(res.data.outputs);
}
getLogs(res.data); getLogs(res.data);
setWorkFlowJobInfo(res.data); setWorkFlowJobInfo(res.data);
const newWorkflowId = locationInfo?.taskId?.replaceAll("-", ""); const newWorkflowId = locationInfo?.taskId?.replaceAll("-", "");
...@@ -228,6 +229,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -228,6 +229,7 @@ const ProjectSubmitWork = observer(() => {
} }
}, [navigate, locationInfo.from, productId]); }, [navigate, locationInfo.from, productId]);
/** 获取输出文件 */
const getOutputs = (outputs: any) => { const getOutputs = (outputs: any) => {
if (outputs) { if (outputs) {
let result = Object.keys(outputs); let result = Object.keys(outputs);
...@@ -246,21 +248,18 @@ const ProjectSubmitWork = observer(() => { ...@@ -246,21 +248,18 @@ const ProjectSubmitWork = observer(() => {
}); });
arr.forEach(async (item, index) => { arr.forEach(async (item, index) => {
if (item.type === "dataset") { if (item.type === "dataset") {
await getDataSetSize(item, index); await getDataSetSize(item, index,arr);
} else { } else {
await getFileSize(item, index); await getFileSize(item, index,arr);
} }
}); });
renderOutputs = arr;
setRenderOutputs(renderOutputs);
} else { } else {
renderOutputs = [];
setRenderOutputs([]); setRenderOutputs([]);
} }
}; };
const getDataSetSize = async (item: any, index: number) => { const getDataSetSize = async (item: any, index: number, arr: any) => {
CloudEController.GetDatasetSize({ CloudEController.GetDatasetSize({
type: productId, type: productId,
projectId: projectId as string, projectId: projectId as string,
...@@ -270,15 +269,15 @@ const ProjectSubmitWork = observer(() => { ...@@ -270,15 +269,15 @@ const ProjectSubmitWork = observer(() => {
name: getDatasetName(item.path), name: getDatasetName(item.path),
}) })
?.then((res) => { ?.then((res) => {
renderOutputs[index].size = `${res.data}条`; arr[index].size = `${res.data}条`;
setRenderOutputs(renderOutputs); setRenderOutputs(arr);
}) })
?.catch(() => { ?.catch(() => {
message.error("获取数据集大小失败"); message.error("获取数据集大小失败");
}); });
}; };
const getFileSize = (item: any, index: number) => { const getFileSize = (item: any, index: number, arr:any) => {
let path = item.path.slice(12); let path = item.path.slice(12);
const lastIndex = path.lastIndexOf("/"); const lastIndex = path.lastIndexOf("/");
if (lastIndex === -1) { if (lastIndex === -1) {
...@@ -295,10 +294,10 @@ const ProjectSubmitWork = observer(() => { ...@@ -295,10 +294,10 @@ const ProjectSubmitWork = observer(() => {
if (Array.isArray(res.data)) { if (Array.isArray(res.data)) {
res.data.forEach((item1) => { res.data.forEach((item1) => {
if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) { if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) {
renderOutputs[index].size = `${ arr[index].size = `${
item1.size ? storageUnitFromB(Number(item1.size)) : "-" item1.size ? storageUnitFromB(Number(item1.size)) : "-"
}`; }`;
setRenderOutputs(renderOutputs); setRenderOutputs(arr);
} }
}); });
} }
...@@ -340,6 +339,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -340,6 +339,7 @@ const ProjectSubmitWork = observer(() => {
} }
}); });
} else { } else {
/** 未选中算子初始化为 整体的任务结果 */
getOutputs(workFlowJobInfo?.outputs) getOutputs(workFlowJobInfo?.outputs)
} }
......
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