Commit 21d25080 authored by wuyongsheng's avatar wuyongsheng

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

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