You've already forked DataMate
Merge pull request #19 from chenghh-9609/main
Merge pull request #1 from ModelEngine-Group/main
This commit is contained in:
@@ -28,6 +28,7 @@ export default function EditDataset({
|
|||||||
tags: [],
|
tags: [],
|
||||||
});
|
});
|
||||||
const fetchDataset = async () => {
|
const fetchDataset = async () => {
|
||||||
|
if (!open) return;
|
||||||
// 如果有id,说明是编辑模式
|
// 如果有id,说明是编辑模式
|
||||||
if (data && data.id) {
|
if (data && data.id) {
|
||||||
const { data: newData } = await queryDatasetByIdUsingGet(data.id);
|
const { data: newData } = await queryDatasetByIdUsingGet(data.id);
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ export default function DatasetDetail() {
|
|||||||
data={dataset}
|
data={dataset}
|
||||||
open={showUploadDialog}
|
open={showUploadDialog}
|
||||||
onClose={() => setShowUploadDialog(false)}
|
onClose={() => setShowUploadDialog(false)}
|
||||||
onRefresh={handleRefresh}
|
updateEvent="update:dataset"
|
||||||
/>
|
/>
|
||||||
<EditDataset
|
<EditDataset
|
||||||
data={dataset}
|
data={dataset}
|
||||||
|
|||||||
@@ -1,13 +1,4 @@
|
|||||||
import {
|
import { Select, Input, Form, Radio, Modal, Button, UploadFile } from "antd";
|
||||||
Select,
|
|
||||||
Input,
|
|
||||||
Form,
|
|
||||||
Radio,
|
|
||||||
Modal,
|
|
||||||
Button,
|
|
||||||
App,
|
|
||||||
UploadFile,
|
|
||||||
} from "antd";
|
|
||||||
import { InboxOutlined } from "@ant-design/icons";
|
import { InboxOutlined } from "@ant-design/icons";
|
||||||
import { dataSourceOptions } from "../../dataset.const";
|
import { dataSourceOptions } from "../../dataset.const";
|
||||||
import { Dataset, DataSource } from "../../dataset.model";
|
import { Dataset, DataSource } from "../../dataset.model";
|
||||||
@@ -21,14 +12,13 @@ export default function ImportConfiguration({
|
|||||||
data,
|
data,
|
||||||
open,
|
open,
|
||||||
onClose,
|
onClose,
|
||||||
onRefresh,
|
updateEvent = "update:dataset",
|
||||||
}: {
|
}: {
|
||||||
data?: Dataset;
|
data: Dataset | null;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onRefresh?: (showMessage?: boolean) => void;
|
updateEvent?: string;
|
||||||
}) {
|
}) {
|
||||||
const { message } = App.useApp();
|
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const [collectionOptions, setCollectionOptions] = useState([]);
|
const [collectionOptions, setCollectionOptions] = useState([]);
|
||||||
const [importConfig, setImportConfig] = useState<any>({
|
const [importConfig, setImportConfig] = useState<any>({
|
||||||
@@ -57,7 +47,11 @@ export default function ImportConfiguration({
|
|||||||
});
|
});
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new CustomEvent("upload:dataset", {
|
new CustomEvent("upload:dataset", {
|
||||||
detail: { dataset, files: fileSliceList },
|
detail: {
|
||||||
|
dataset,
|
||||||
|
files: fileSliceList,
|
||||||
|
updateEvent,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
resetFiles();
|
resetFiles();
|
||||||
@@ -73,6 +67,7 @@ export default function ImportConfiguration({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const fetchCollectionTasks = async () => {
|
const fetchCollectionTasks = async () => {
|
||||||
|
if (importConfig.source !== DataSource.COLLECTION) return;
|
||||||
try {
|
try {
|
||||||
const res = await queryTasksUsingGet({ page: 0, size: 100 });
|
const res = await queryTasksUsingGet({ page: 0, size: 100 });
|
||||||
const options = res.data.content.map((task: any) => ({
|
const options = res.data.content.map((task: any) => ({
|
||||||
@@ -93,15 +88,14 @@ export default function ImportConfiguration({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleImportData = async () => {
|
const handleImportData = async () => {
|
||||||
|
if (!data) return;
|
||||||
if (importConfig.source === DataSource.UPLOAD) {
|
if (importConfig.source === DataSource.UPLOAD) {
|
||||||
await handleUpload(data);
|
await handleUpload(data);
|
||||||
} else if (importConfig.source === DataSource.COLLECTION) {
|
} else if (importConfig.source === DataSource.COLLECTION) {
|
||||||
await updateDatasetByIdUsingPut(data?.id!, {
|
await updateDatasetByIdUsingPut(data.id, {
|
||||||
...importConfig,
|
...importConfig,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
message.success("数据已更新");
|
|
||||||
onRefresh?.(false);
|
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,7 +104,7 @@ export default function ImportConfiguration({
|
|||||||
resetState();
|
resetState();
|
||||||
fetchCollectionTasks();
|
fetchCollectionTasks();
|
||||||
}
|
}
|
||||||
}, [open]);
|
}, [open, importConfig.source]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
|
|||||||
@@ -320,6 +320,16 @@ export default function DatasetManagementPage() {
|
|||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const refresh = () => {
|
||||||
|
handleRefresh(true);
|
||||||
|
};
|
||||||
|
window.addEventListener("update:datasets", refresh);
|
||||||
|
return () => {
|
||||||
|
window.removeEventListener("update:datasets", refresh);
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="gap-4 h-full flex flex-col">
|
<div className="gap-4 h-full flex flex-col">
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
@@ -389,7 +399,7 @@ export default function DatasetManagementPage() {
|
|||||||
setCurrentDataset(null);
|
setCurrentDataset(null);
|
||||||
setShowUploadDialog(false);
|
setShowUploadDialog(false);
|
||||||
}}
|
}}
|
||||||
onRefresh={handleRefresh}
|
updateEvent="update:datasets"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -97,4 +97,5 @@ export interface TaskItem {
|
|||||||
isCancel?: boolean;
|
isCancel?: boolean;
|
||||||
controller: AbortController;
|
controller: AbortController;
|
||||||
cancelFn?: () => void;
|
cancelFn?: () => void;
|
||||||
|
updateEvent?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export default function TaskUpload() {
|
|||||||
percent: 0,
|
percent: 0,
|
||||||
reqId: -1,
|
reqId: -1,
|
||||||
controller,
|
controller,
|
||||||
|
updateEvent: detail.updateEvent || "update:dataset",
|
||||||
};
|
};
|
||||||
taskListRef.current = [task, ...taskListRef.current];
|
taskListRef.current = [task, ...taskListRef.current];
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ export default function TaskUpload() {
|
|||||||
if (task.isCancel && task.cancelFn) {
|
if (task.isCancel && task.cancelFn) {
|
||||||
task.cancelFn();
|
task.cancelFn();
|
||||||
}
|
}
|
||||||
window.dispatchEvent(new Event("update:dataset"));
|
window.dispatchEvent(new Event(task.updateEvent || "update:dataset"));
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
new CustomEvent("show:task-popover", { detail: { show: false } })
|
new CustomEvent("show:task-popover", { detail: { show: false } })
|
||||||
);
|
);
|
||||||
@@ -111,7 +112,7 @@ export default function TaskUpload() {
|
|||||||
cancelFn: () => {
|
cancelFn: () => {
|
||||||
task.controller.abort();
|
task.controller.abort();
|
||||||
cancelUploadUsingPut(reqId);
|
cancelUploadUsingPut(reqId);
|
||||||
window.dispatchEvent(new Event("update:dataset"));
|
window.dispatchEvent(new Event(task.updateEvent || "update:dataset"));
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
updateTaskList(newTask);
|
updateTaskList(newTask);
|
||||||
|
|||||||
Reference in New Issue
Block a user