Commit e475c840 authored by chenshouchao's avatar chenshouchao

feat: 任务详情结果文件的数据集大小获取接口修改

parent acf7cc2e
...@@ -30,6 +30,15 @@ type IGetDatasetItemsListParams = { ...@@ -30,6 +30,15 @@ type IGetDatasetItemsListParams = {
sort?: string; // 排序 sort?: string; // 排序
} }
type IGetDatasetSizeParams = {
type?: string; // 产品id
projectId: string;
token: string;
filetoken: string;
path: string; // 数据集路径
name: string; // 数据集名称
}
type ISaveDatasetParams = { type ISaveDatasetParams = {
type?: string; type?: string;
projectId: string; projectId: string;
...@@ -244,6 +253,19 @@ class CloudEController { ...@@ -244,6 +253,19 @@ class CloudEController {
} }
} }
// 获取dataset条数
static GetDatasetSize(params: IGetDatasetSizeParams) {
if (ApiUtils.getAuthorizationHeaders(headers)) {
headers["Cache-Control"] = "no-cache";
let url = getUrlThroughParams(params, ['filetoken','path','token'], '?')
return axios.get(
`${APIOPTION()}:5003/size${url}`,
{
headers: headers,
}
);
}
}
// 获取分子列表 // 获取分子列表
static GetDatasetItemsList(params: IGetDatasetItemsListParams) { static GetDatasetItemsList(params: IGetDatasetItemsListParams) {
......
...@@ -28,14 +28,13 @@ import jobFail from "@/assets/project/jobFail.svg"; ...@@ -28,14 +28,13 @@ import jobFail from "@/assets/project/jobFail.svg";
import fileIcon from "@/assets/project/fileIcon.svg"; import fileIcon from "@/assets/project/fileIcon.svg";
import dataSetIcon from "@/assets/project/dataSetIcon.svg"; import dataSetIcon from "@/assets/project/dataSetIcon.svg";
import { useStores } from "@/store"; import { useStores } from "@/store";
import { getDataFind } from "@/api/project_api";
import { ITaskInfo } from "../ProjectSubmitWork/interface"; import { ITaskInfo } from "../ProjectSubmitWork/interface";
import Flow from "../components/Flow"; import Flow from "../components/Flow";
import { cancelWorkflowJob, deleteWorkflowJob } from "@/api/workbench_api"; import { cancelWorkflowJob, deleteWorkflowJob } from "@/api/workbench_api";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import MyPopconfirm from "@/components/mui/MyPopconfirm"; import MyPopconfirm from "@/components/mui/MyPopconfirm";
import SeeDataset from "../ProjectData/SeeDataset"; import SeeDataset from "../ProjectData/SeeDataset";
import { storageUnitFromB } from "@/utils/util"; import { getToken, storageUnitFromB } from "@/utils/util";
import styles from "./index.module.css"; import styles from "./index.module.css";
import usePass from "@/hooks/usePass"; import usePass from "@/hooks/usePass";
...@@ -61,6 +60,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -61,6 +60,7 @@ const ProjectSubmitWork = observer(() => {
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken); const fileToken = toJS(currentProjectStore.currentProjectInfo.filetoken);
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const productId = toJS(currentProjectStore.currentProductInfo.id);
const [workFlowJobInfo, setWorkFlowJobInfo] = useState<ITaskInfo>(); const [workFlowJobInfo, setWorkFlowJobInfo] = useState<ITaskInfo>();
const [patchInfo, setPatchInfo] = useState<any>(); const [patchInfo, setPatchInfo] = useState<any>();
const [activePatchId, setActivePatchId] = useState<string>(""); const [activePatchId, setActivePatchId] = useState<string>("");
...@@ -127,9 +127,32 @@ const ProjectSubmitWork = observer(() => { ...@@ -127,9 +127,32 @@ const ProjectSubmitWork = observer(() => {
// return path; // return path;
// }; // };
// 根据outputs的路径获取数据集的路径
const getDatasetPath = (path: string) => {
let datasetPath = "";
const noProjectPath = path.slice(12);
const fileIndex = noProjectPath.indexOf("/.dataset");
if (fileIndex !== -1) {
datasetPath = noProjectPath.slice(0, fileIndex);
} else {
datasetPath = noProjectPath;
}
return datasetPath ? datasetPath : "/";
};
// 根据outputs的路径获取数据集的名称
const getDatasetName = (path: string) => {
let name = "";
let nameIndex = path.indexOf("/.dataset/") + 10;
const lastIndex = path.lastIndexOf("/");
if (nameIndex !== -1 && lastIndex !== -1) {
name = path.slice(nameIndex, lastIndex);
}
return name;
};
// 下载任务结果 // 下载任务结果
const handleDownLoadOutput = (item: any) => { const handleDownLoadOutput = (item: any) => {
console.log(item);
// 是文件下载 // 是文件下载
if (item.type !== "dataset") { if (item.type !== "dataset") {
CloudEController.JobFileDownload( CloudEController.JobFileDownload(
...@@ -139,27 +162,8 @@ const ProjectSubmitWork = observer(() => { ...@@ -139,27 +162,8 @@ const ProjectSubmitWork = observer(() => {
); );
} else { } else {
// 是数据集 查看数据集 // 是数据集 查看数据集
setSeeDatasetPath(getDatasetPath(item.path));
const noProjectPath = item.path.slice(12); setSeeDatasetName(getDatasetName(item.path));
const fileIndex = noProjectPath.indexOf("/.dataset");
let datasetPath = "";
if (fileIndex !== -1) {
datasetPath = noProjectPath.slice(0, fileIndex);
} else {
datasetPath = noProjectPath;
}
let name = "";
let nameIndex = item.path.indexOf("/.dataset/") + 10;
const lastIndex = item.path.lastIndexOf("/");
if (nameIndex !== -1 && lastIndex !== -1) {
name = item.path.slice(nameIndex, lastIndex);
} else {
name = item.name;
}
setSeeDatasetPath(datasetPath ? datasetPath : "/");
setSeeDatasetName(name);
setShowSeeDataset(true); setShowSeeDataset(true);
} }
}; };
...@@ -207,23 +211,21 @@ const ProjectSubmitWork = observer(() => { ...@@ -207,23 +211,21 @@ const ProjectSubmitWork = observer(() => {
}; };
const getDataSetSize = async (item: any, index: number) => { const getDataSetSize = async (item: any, index: number) => {
let path = item.path.slice(12); CloudEController.GetDatasetSize({
const lastIndex = path.lastIndexOf("/"); type: productId,
if (lastIndex === -1) {
path = "/";
} else {
path = path.slice(0, lastIndex + 1);
}
const res = await getDataFind({
projectId: projectId as string, projectId: projectId as string,
path: path, token: getToken(),
}); filetoken: fileToken as string,
res.data.forEach((item1: any) => { path: getDatasetPath(item.path),
if (item1.name === item.path.slice(item.path.lastIndexOf("/") + 1)) { name: getDatasetName(item.path),
randerOutputs[index].size = `${item1.size}条`; })
?.then((res) => {
randerOutputs[index].size = `${res.data}条`;
setRanderOutputs([...randerOutputs]); setRanderOutputs([...randerOutputs]);
} })
}); ?.catch(() => {
message.error("获取数据集大小失败");
});
}; };
const getFileSize = (item: any, index: number) => { const getFileSize = (item: any, index: number) => {
......
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