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