Commit 9bbf7fae authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20220608-projectdata' into 'release'

Feat 20220608 projectdata

See merge request sunyihao/bkunyun!43
parents b053f4c5 3cb7850c
......@@ -21,12 +21,14 @@ const RESTAPI = {
API_DATA_FIND: `${BACKEND_API_URI_PREFIX}/cpp/data/find`, //查询某路径下数据集
API_DATA_SEARCH: `${BACKEND_API_URI_PREFIX}/cpp/data/search`, //搜索项目中某路径下的数据集
API_DATA_MOVE: `${BACKEND_API_URI_PREFIX}/cpp/data/move`, //移动到
API_DATA_MOVE_PACKAGE: `${BACKEND_API_URI_PREFIX}/cpp/data/move/package`, //移动文件夹中的数据集
API_DATA_DEL: `${BACKEND_API_URI_PREFIX}/cpp/data/del`, //删除项目中的数据集
API_DATA_DEL_PACKAGE: `${BACKEND_API_URI_PREFIX}/cpp/data/del/package`, //删除文件夹中的数据集
API_USER_PERMISSION_LIST: `${BACKEND_API_URI_PREFIX}/uaa/routes/privilege/list`, //获取用户包含的权限列表
API_WORKBENCH_TEMPLATE_LIST: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowspec`,//查询项目下工作流模板列表
API_WORKBENCH_DELETE_TEMPLATE: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowspec`,//项目管理员-删除工作流模板
API_WORKBENCH_ADD_TEMPLATE_LIST: `${BACKEND_API_URI_PREFIX}/cpp/workbench/product/workflowspec`,//项目管理员-添加工作流模板-模板列表
API_WORKBENCH_ADD_TEMPLATE: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowspec`,//项目管理员-添加工作流模板-提交
}
API_WORKBENCH_TEMPLATE_LIST: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowspec`, //查询项目下工作流模板列表
API_WORKBENCH_DELETE_TEMPLATE: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowspec`, //项目管理员-删除工作流模板
API_WORKBENCH_ADD_TEMPLATE_LIST: `${BACKEND_API_URI_PREFIX}/cpp/workbench/product/workflowspec`, //项目管理员-添加工作流模板-模板列表
API_WORKBENCH_ADD_TEMPLATE: `${BACKEND_API_URI_PREFIX}/cpp/workbench/project/workflowspec`, //项目管理员-添加工作流模板-提交
};
export default RESTAPI;
export const a = () => {
return "a";
};
......@@ -135,7 +135,6 @@ type getDataFileMoveParams = {
dpath?: string; // 目标路径
};
// Content-Type application/x-www-form-urlencoded
// 移动到
const getDataFileMove = (params: getDataFileMoveParams) => {
return request({
......@@ -148,13 +147,31 @@ const getDataFileMove = (params: getDataFileMoveParams) => {
});
};
type getDataFileMovePackageParams = {
projectId: string;
names: string; // 包名
spath?: string; // 原路径
dpath?: string; // 目标路径
};
// 移动文件夹中的数据集
const getDataFileMovePackage = (params: getDataFileMovePackageParams) => {
return request({
url: Api.API_DATA_MOVE_PACKAGE,
method: "put",
data: params,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
};
type getDataFileDelParams = {
projectId: string;
names: string;
path?: string;
};
// Content-Type application/x-www-form-urlencoded
// 删除项目中的数据集
const getDataFileDel = (params: getDataFileDelParams) => {
return request({
......@@ -167,6 +184,24 @@ const getDataFileDel = (params: getDataFileDelParams) => {
});
};
type getDataFileDelPackageParams = {
projectId: string;
names: string;
path?: string;
};
// 删除项目中的数据集
const getDataFileDelPackage = (params: getDataFileDelPackageParams) => {
return request({
url: Api.API_DATA_DEL_PACKAGE,
method: "delete",
params,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
});
};
export {
current,
menu,
......@@ -180,5 +215,7 @@ export {
getDataFind,
getDataFileSearch,
getDataFileMove,
getDataFileMovePackage,
getDataFileDel,
getDataFileDelPackage,
};
......@@ -33,14 +33,14 @@ export const uuid = () => {
* params: item: 毫秒的时间戳
*/
export const formatTime = (time: number) => {
const newTime = Math.floor( time / 1000) ;
const newTime = Math.floor(time / 1000);
const hours = Math.floor(newTime / 3600);
const minutes = Math.floor((newTime % 3600) / 60);
const seconds = newTime % 60;
const hoursString = hours ? `${hours}小时` : '';
const minutesString = minutes ? `${minutes}分钟` : '';
const secondsString = seconds ? `${seconds}秒` : '';
const hoursString = hours ? `${hours}小时` : "";
const minutesString = minutes ? `${minutes}分钟` : "";
const secondsString = seconds ? `${seconds}秒` : "";
return `${hoursString}${minutesString}${secondsString}`;
};
......
import React, { useState, useImperativeHandle, useMemo } from "react";
import MyDialog from "@/components/mui/MyDialog";
import { useMessage } from "@/components/MySnackbar";
import CloudEController from "@/api/fileserver/CloudEController";
import { getDataFileDel, getDataFileDelPackage } from "@/api/project_api";
import useMyRequest from "@/hooks/useMyRequest";
const DeleteDialog = (props: any) => {
const {
path,
projectId,
fileToken,
currentOperateFile,
selectIds,
refresh,
showList,
} = props;
const Message = useMessage();
let deleteFileDialogRef: any = React.createRef();
const showDialog = () => {
deleteFileDialogRef.current.handleClickOpen();
};
useImperativeHandle(props.onRef, () => {
return {
showDialog: showDialog,
};
});
const { run: getDataFileDelRun } = useMyRequest(getDataFileDel, {
onSuccess: (res: any) => {
successDelete();
},
});
const { run: getDataFileDelPackageRun } = useMyRequest(
getDataFileDelPackage,
{
onSuccess: (res: any) => {
successDelete();
},
}
);
const successDelete = () => {
Message.success("删除成功!");
deleteFileDialogRef?.current?.handleClose();
refresh();
};
const deletePathProvidedToDataSet = useMemo(() => {
return path === "/" ? "/" : `${path}/`;
}, [path]);
const deletePathProvidedFileServer = useMemo(() => {
return path === "/" ? `${path}` : `${path}/`;
}, [path]);
// 删除
const handleSubmit = () => {
if (!currentOperateFile) {
// 批量删除
// 要删除的数据集
const datSetDeleteList = showList.filter((item: any) => {
return selectIds.indexOf(item.name) !== -1 && item.type === "dataSet";
});
// 要删除的文件夹
const folderDeleteList = showList.filter((item: any) => {
return selectIds.indexOf(item.name) !== -1 && item.type === "directory";
});
// 要删除的文件
const fileDeleteList = showList.filter((item: any) => {
return (
selectIds.indexOf(item.name) !== -1 &&
item.type !== "dataSet" &&
item.type !== "directory"
);
});
if (datSetDeleteList.length > 0) {
dataSetsDelete(datSetDeleteList);
}
if (folderDeleteList.length > 0) {
foldersDelete(folderDeleteList);
}
if (fileDeleteList.length > 0) {
filesDelete(fileDeleteList);
}
} else {
if (currentOperateFile.type === "dataSet") {
dataSetDelete();
} else if (currentOperateFile.type === "directory") {
folerDelete();
} else {
fileDelete();
}
}
};
// 删除单个数据集
const dataSetDelete = () => {
getDataFileDelRun({
projectId: projectId as string,
names: currentOperateFile.name,
path: deletePathProvidedToDataSet,
});
};
// 删除单个文件夹
const folerDelete = () => {
fileDelete();
const names = currentOperateFile.name;
dataSetInFolerDelete(names);
};
// 删除文件夹中的数据集
const dataSetInFolerDelete = (names: string) => {
getDataFileDelPackageRun({
projectId: projectId as string,
names,
path: deletePathProvidedToDataSet,
});
};
// 删除单个文件
const fileDelete = () => {
CloudEController.JobOutFileDel(
`${deletePathProvidedFileServer}${currentOperateFile.name}`,
fileToken as string,
projectId as string
)?.then((res) => {
successDelete();
});
};
// 删除多个数据集
const dataSetsDelete = (datSetDeleteList: Array<any>) => {
getDataFileDelRun({
projectId: projectId as string,
names: datSetDeleteList.map((item: any) => item.name).join(","),
path: deletePathProvidedToDataSet,
});
};
// 删除多个文件夹
const foldersDelete = (folderDeleteList: Array<any>) => {
filesDelete(folderDeleteList);
const names = folderDeleteList.map((item: any) => item.name).join(",");
dataSetInFolerDelete(names);
};
// 删除多个文件
const filesDelete = (fileDeleteList: Array<any>) => {
const deletePath = fileDeleteList
.map((item: any) => {
return `${deletePathProvidedFileServer}${item.name}`;
})
.join(" ");
CloudEController.JobOutFileDel(
deletePath,
fileToken as string,
projectId as string
)?.then((res) => {
successDelete();
});
};
const submitloading = false;
return (
<MyDialog
handleSubmit={handleSubmit}
onRef={deleteFileDialogRef}
title="提示"
submitloading={submitloading}
>
{currentOperateFile
? "确认删除该数据吗?"
: `确认删除这${selectIds.length}条数据吗?`}
</MyDialog>
);
};
export default DeleteDialog;
import React, { useState, useImperativeHandle, useCallback } from "react";
import React, {
useState,
useImperativeHandle,
useCallback,
useMemo,
} from "react";
import style from "./index.module.css";
import MyDialog from "@/components/mui/MyDialog";
......@@ -7,7 +12,7 @@ import bigFolderIcon from "@/assets/project/bigFolderIcon.svg";
import { useMessage } from "@/components/MySnackbar";
import MyTreeView from "@/components/mui/MyTreeView";
import CloudEController from "@/api/fileserver/CloudEController";
import { getDataFileMove } from "@/api/project_api";
import { getDataFileMove, getDataFileMovePackage } from "@/api/project_api";
import useMyRequest from "@/hooks/useMyRequest";
import classNames from "classnames";
......@@ -19,17 +24,24 @@ const MoveFile = (props: any) => {
currentOperateFile,
selectIds,
refresh,
activeTab,
showList,
} = props;
const Message = useMessage();
const { run: getDataFileMoveRun } = useMyRequest(getDataFileMove, {
onSuccess: (res: any) => {
Message.success("移动成功!");
moveFileDialogRef.current.handleClose();
refresh();
successMove();
},
});
const { run: getDataFileMovePackageRun } = useMyRequest(
getDataFileMovePackage,
{
onSuccess: (res: any) => {
successMove();
},
}
);
const [newPath, setNewPath] = useState("/");
const [rootActive, setRootActive] = useState(true);
......@@ -65,97 +77,155 @@ const MoveFile = (props: any) => {
};
});
// 提供给fileserver相关接口的newpath 直接用newPath就可以了
// const newPathProvidedToFileServer = useMemo(() => {
// return newPath
// }, [newPath])
// 提供给数据集相关接口的newpath
const newPathProvidedToDataSet = useMemo(() => {
return newPath === "/" ? "/" : `${newPath}/`;
}, [newPath]);
// 提供给fileserver相关接口的oldpath
const oldPathProvidedToFileServer = useMemo(() => {
return `${path}${path === "/" ? "" : "/"}`;
}, [path]);
// 提供给数据集相关接口的oldpath
const oldPathProvidedToDataSet = useMemo(() => {
return path === "/" ? "/" : `${path}/`;
}, [path]);
// 移动成功后的操作
const successMove = () => {
Message.success("移动成功!");
moveFileDialogRef?.current?.handleClose();
refresh();
};
// 移动
const handleMoveFileSubmit = () => {
if (newPath) {
if (!newPath) {
Message.error("请选择移动到哪个目录");
} else if (newPath === path) {
Message.error("指定的目标路径为数据原路径,无需移动。");
} else {
if (!currentOperateFile) {
// 批量移动
if (activeTab === 1) {
const oldPaths = selectIds.map((name: any) => {
return `${path}${path === "/" ? "" : "/"}${name}`;
});
CloudEController.JobFileBatchMove(
newPath,
oldPaths,
"",
fileToken,
projectId
)?.then((res) => {
Message.success("移动成功!");
moveFileDialogRef.current.handleClose();
refresh();
});
} else {
const datSetMoveList = showList.filter((item: any) => {
return (
selectIds.indexOf(item.name) !== -1 && item.type === "dataSet"
);
});
const otherMoveList = showList.filter((item: any) => {
return (
selectIds.indexOf(item.name) !== -1 && item.type !== "dataSet"
);
});
if (datSetMoveList.length > 0) {
const oldPaths = `${path}${path === "/" ? "" : "/"}`;
getDataFileMoveRun({
projectId: projectId as string,
names: datSetMoveList.map((item: any) => item.name).join(","),
spath: oldPaths,
dpath: newPath === "/" ? "/" : `${newPath}/`,
});
}
if (otherMoveList.length > 0) {
const oldPaths = otherMoveList.map((item: any) => {
return `${path}${path === "/" ? "" : "/"}${item.name}`;
});
CloudEController.JobFileBatchMove(
newPath,
oldPaths,
"",
fileToken,
projectId
)?.then((res) => {
Message.success("移动成功!");
moveFileDialogRef.current.handleClose();
refresh();
});
}
// 要移动的数据集
const datSetMoveList = showList.filter((item: any) => {
return selectIds.indexOf(item.name) !== -1 && item.type === "dataSet";
});
// 要移动的文件夹
const folderMoveList = showList.filter((item: any) => {
return (
selectIds.indexOf(item.name) !== -1 && item.type === "directory"
);
});
// 要移动的文件
const fileMoveList = showList.filter((item: any) => {
return (
selectIds.indexOf(item.name) !== -1 &&
item.type !== "dataSet" &&
item.type !== "directory"
);
});
if (datSetMoveList.length > 0) {
dataSetsMove(datSetMoveList);
}
if (folderMoveList.length > 0) {
foldersMove(folderMoveList);
}
if (fileMoveList.length > 0) {
filesMove(fileMoveList);
}
} else {
if (currentOperateFile.type === "dataSet") {
const oldPaths = `${path}${path === "/" ? "" : "/"}`;
getDataFileMoveRun({
projectId: projectId as string,
names: currentOperateFile.name,
spath: oldPaths,
dpath: newPath === "/" ? "/" : `${newPath}/`,
});
dataSetMove();
} else if (currentOperateFile.type === "directory") {
folerMove();
} else {
const oldPath = `${path}${path === "/" ? "" : "/"}${
currentOperateFile.name
}`;
if (oldPath === newPath) {
Message.info("指定的目标路径为数据原路径,无需移动。");
return;
}
CloudEController.JobFileMove(
newPath,
oldPath,
"",
fileToken,
projectId
)?.then((res) => {
Message.success("移动成功!");
moveFileDialogRef.current.handleClose();
refresh();
});
fileMove();
}
}
} else {
Message.error("请选择移动到哪个目录");
}
};
// 单文件移动
const fileMove = () => {
const oldPathToFileServer = `${oldPathProvidedToFileServer}${currentOperateFile.name}`;
CloudEController.JobFileMove(
newPath,
oldPathToFileServer,
"",
fileToken,
projectId
)?.then((res) => {
successMove();
});
};
// 多文件移动
const filesMove = (fileMoveList: Array<any>) => {
const oldPaths = fileMoveList.map((item: any) => {
return `${oldPathProvidedToFileServer}${item.name}`;
});
CloudEController.JobFileBatchMove(
newPath,
oldPaths,
"",
fileToken,
projectId
)?.then((res) => {
successMove();
});
};
// 单文件夹移动
const folerMove = () => {
fileMove();
const names = currentOperateFile.name;
dataSetInFolerMove(names);
};
// 移动文件夹中的数据集
const dataSetInFolerMove = (names: string) => {
getDataFileMovePackageRun({
projectId: projectId as string,
names,
spath: oldPathProvidedToDataSet,
dpath: newPathProvidedToDataSet,
});
};
// 多文件夹移动
const foldersMove = (folderMoveList: Array<any>) => {
filesMove(folderMoveList);
const names = folderMoveList.map((item: any) => item.name).join(",");
dataSetInFolerMove(names);
};
// 单数据集移动
const dataSetMove = () => {
getDataFileMoveRun({
projectId: projectId as string,
names: currentOperateFile.name,
spath: oldPathProvidedToDataSet,
dpath: newPathProvidedToDataSet,
});
};
// 多数据集移动
const dataSetsMove = (datSetMoveList: Array<any>) => {
getDataFileMoveRun({
projectId: projectId as string,
names: datSetMoveList.map((item: any) => item.name).join(","),
spath: oldPathProvidedToFileServer,
dpath: newPath === "/" ? "/" : `${newPath}/`,
});
};
const renderLabel = (labelNmae: string) => {
return (
<span className={style.treeLabel}>
......@@ -170,6 +240,11 @@ const MoveFile = (props: any) => {
setRootActive(false);
};
// 给路径去掉第一个'/'然后结尾加上文件名 方便后面直接使用
const idFunc = (item: any) => {
return `${item.dir.substr(1)}${item.name}`;
};
const handleRoot = () => {
setNewPath("/");
setRootActive(true);
......@@ -177,10 +252,6 @@ const MoveFile = (props: any) => {
const moveFileSubmitloading = false;
const idFunc = (item: any) => {
return `${item.dir.substr(1)}${item.name}`;
};
return (
<MyDialog
handleSubmit={handleMoveFileSubmit}
......
......@@ -67,7 +67,6 @@ const UpLoaderFile = observer((props: any) => {
};
const repeatAndUploaderFileList =
getRepeatFileAndGetUploderFileList(acceptedFiles);
console.log(repeatAndUploaderFileList);
if (repeatAndUploaderFileList.repeatFileList.length > 0) {
message.error(
`“${repeatAndUploaderFileList.repeatFileList
......@@ -78,6 +77,12 @@ const UpLoaderFile = observer((props: any) => {
// 插入新的文件列表
const popLength = 10 - fileList.length;
if (
fileList.length + repeatAndUploaderFileList.uploderFileList.length >
10
) {
message.error("最大支持同时上传10个文件");
}
let newFileList = [
...repeatAndUploaderFileList.uploderFileList.slice(0, popLength),
...fileList,
......
This diff is collapsed.
......@@ -212,6 +212,7 @@ const BaseInfo = observer(() => {
// 显示删除弹窗
const handleClickDelete = () => {
DialogRef.current.handleClickOpen();
setDeleteProjectName("");
};
const deleteProjectNameChange = (e: any) => {
......
......@@ -61,7 +61,6 @@ const AddMember = observer((props: IProps) => {
const defaultValue = selectOptions.filter(
(every) => every.value === item
);
console.log(selectOptions, defaultValue, "111");
return (
<MySelect
input={<OutlinedInput />}
......@@ -122,13 +121,16 @@ const AddMember = observer((props: IProps) => {
});
}, [currentProjectStore?.currentProjectInfo, http, addMemberDialog]);
const onClose = () => {
const onClose = (event: any = {}, reason: any = "other") => {
// 点击弹窗外不关闭弹窗
if (reason === "backdropClick") {
return;
}
setAddMemberDialog(false);
};
const onConfirm = () => {
const projectInfo = toJS(currentProjectStore?.currentProjectInfo);
console.log(tableData, 1111);
const params = tableData.filter((item: any) => {
return checkData.includes(item?.username);
});
......
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