You've already forked DataMate
feat: enhance dataset management features with improved tag handling, download functionality, and UI updates
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { Button, Input, Popover, theme, Tag } from "antd";
|
import { Button, Input, Popover, theme, Tag, Empty } from "antd";
|
||||||
import { PlusOutlined } from "@ant-design/icons";
|
import { PlusOutlined } from "@ant-design/icons";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
@@ -70,6 +70,7 @@ export default function AddTagPopover({
|
|||||||
添加标签
|
添加标签
|
||||||
</h4>
|
</h4>
|
||||||
{/* Available Tags */}
|
{/* Available Tags */}
|
||||||
|
{availableTags?.length ? (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<h5 className="text-sm">选择现有标签</h5>
|
<h5 className="text-sm">选择现有标签</h5>
|
||||||
<div className="max-h-32 overflow-y-auto space-y-1">
|
<div className="max-h-32 overflow-y-auto space-y-1">
|
||||||
@@ -88,6 +89,9 @@ export default function AddTagPopover({
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
<Empty description="没有可用标签,请先创建标签。" />
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Create New Tag */}
|
{/* Create New Tag */}
|
||||||
<div className="space-y-2 border-t border-gray-100 pt-3">
|
<div className="space-y-2 border-t border-gray-100 pt-3">
|
||||||
|
|||||||
@@ -103,8 +103,8 @@ function DetailHeader<T>({
|
|||||||
<Dropdown
|
<Dropdown
|
||||||
key={op.key}
|
key={op.key}
|
||||||
menu={{
|
menu={{
|
||||||
items: op.items as ItemType[],
|
items: op?.items as ItemType[],
|
||||||
onClick: op.onMenuClick,
|
onClick: op?.onMenuClick,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tooltip title={op.label}>
|
<Tooltip title={op.label}>
|
||||||
@@ -115,16 +115,7 @@ function DetailHeader<T>({
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<Tooltip key={op.key} title={op.label}>
|
<Tooltip key={op.key} title={op.label}>
|
||||||
<Button
|
<Button {...op} />
|
||||||
key={op.key}
|
|
||||||
onClick={op.onClick}
|
|
||||||
className={
|
|
||||||
op.danger
|
|
||||||
? "text-red-600 border-red-200 bg-transparent"
|
|
||||||
: ""
|
|
||||||
}
|
|
||||||
icon={op.icon}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ export default function TaskList() {
|
|||||||
fetchData();
|
fetchData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const taskOperations = (record) => {
|
const taskOperations = (record: CleansingTask) => {
|
||||||
const isRunning = record.status?.value === TaskStatus.RUNNING;
|
const isRunning = record.status?.value === TaskStatus.RUNNING;
|
||||||
const showStart = [
|
const showStart = [
|
||||||
TaskStatus.PENDING,
|
TaskStatus.PENDING,
|
||||||
@@ -91,7 +91,8 @@ export default function TaskList() {
|
|||||||
{
|
{
|
||||||
key: "delete",
|
key: "delete",
|
||||||
label: "删除",
|
label: "删除",
|
||||||
icon: <DeleteOutlined style={{ color: "#f5222d" }} />,
|
danger: true,
|
||||||
|
icon: <DeleteOutlined />,
|
||||||
onClick: deleteTask, // implement delete logic
|
onClick: deleteTask, // implement delete logic
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -106,6 +107,13 @@ export default function TaskList() {
|
|||||||
width: 150,
|
width: 150,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "任务ID",
|
||||||
|
dataIndex: "id",
|
||||||
|
key: "id",
|
||||||
|
width: 150,
|
||||||
|
ellipsis: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "源数据集",
|
title: "源数据集",
|
||||||
dataIndex: "srcDatasetId",
|
dataIndex: "srcDatasetId",
|
||||||
@@ -231,6 +239,7 @@ export default function TaskList() {
|
|||||||
<Button
|
<Button
|
||||||
type="text"
|
type="text"
|
||||||
icon={op.icon}
|
icon={op.icon}
|
||||||
|
danger={op?.danger}
|
||||||
onClick={() => op.onClick(record)}
|
onClick={() => op.onClick(record)}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ export default function TemplateList() {
|
|||||||
{
|
{
|
||||||
key: "delete",
|
key: "delete",
|
||||||
label: "删除模板",
|
label: "删除模板",
|
||||||
icon: <DeleteOutlined style={{ color: "#f5222d" }} />,
|
danger: true,
|
||||||
|
icon: <DeleteOutlined />,
|
||||||
onClick: (template: CleansingTemplate) => deleteTemplate(template), // 可实现删除逻辑
|
onClick: (template: CleansingTemplate) => deleteTemplate(template), // 可实现删除逻辑
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -27,9 +27,9 @@ export default function DatasetCreate() {
|
|||||||
files: undefined,
|
files: undefined,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
await createDatasetUsingPost(params);
|
const { data } = await createDatasetUsingPost(params);
|
||||||
message.success(`数据集创建成功`);
|
message.success(`数据集创建成功`);
|
||||||
navigate("/data/management");
|
navigate("/data/management/detail/" + data.id);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
message.error("数据集创建失败,请重试");
|
message.error("数据集创建失败,请重试");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
} from "../dataset.api";
|
} from "../dataset.api";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { Dataset, DatasetType } from "../dataset.model";
|
import { Dataset, DatasetType } from "../dataset.model";
|
||||||
import { App, Button, Drawer, Form, Modal } from "antd";
|
import { App, Button, Form, Modal } from "antd";
|
||||||
|
|
||||||
export default function EditDataset({
|
export default function EditDataset({
|
||||||
open,
|
open,
|
||||||
@@ -16,7 +16,7 @@ export default function EditDataset({
|
|||||||
open: boolean;
|
open: boolean;
|
||||||
data: Dataset | null;
|
data: Dataset | null;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onRefresh?: () => void;
|
onRefresh?: (showMessage?: boolean) => void;
|
||||||
}) {
|
}) {
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const { message } = App.useApp();
|
const { message } = App.useApp();
|
||||||
@@ -60,7 +60,7 @@ export default function EditDataset({
|
|||||||
await updateDatasetByIdUsingPut(data?.id, params);
|
await updateDatasetByIdUsingPut(data?.id, params);
|
||||||
onClose();
|
onClose();
|
||||||
message.success("数据集更新成功");
|
message.success("数据集更新成功");
|
||||||
onRefresh?.();
|
onRefresh?.(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
message.error("数据集更新失败,请重试");
|
message.error("数据集更新失败,请重试");
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
DownloadOutlined,
|
DownloadOutlined,
|
||||||
UploadOutlined,
|
UploadOutlined,
|
||||||
EditOutlined,
|
EditOutlined,
|
||||||
|
DeleteOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import DetailHeader from "@/components/DetailHeader";
|
import DetailHeader from "@/components/DetailHeader";
|
||||||
import { mapDataset, datasetTypeMap } from "../dataset.const";
|
import { mapDataset, datasetTypeMap } from "../dataset.const";
|
||||||
@@ -77,8 +78,8 @@ export default function DatasetDetail() {
|
|||||||
if (showMessage) message.success({ content: "数据刷新成功" });
|
if (showMessage) message.success({ content: "数据刷新成功" });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleExportFormat = async ({ type }) => {
|
const handleDownload = async () => {
|
||||||
await downloadFile(dataset.id, type, `${dataset.name}-${type}.zip`);
|
await downloadFile(dataset.id);
|
||||||
message.success("文件下载成功");
|
message.success("文件下载成功");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ export default function DatasetDetail() {
|
|||||||
// { key: "csv", label: "CSV 格式", icon: <FileTextOutlined /> },
|
// { key: "csv", label: "CSV 格式", icon: <FileTextOutlined /> },
|
||||||
// { key: "coco", label: "COCO 格式", icon: <FileImageOutlined /> },
|
// { key: "coco", label: "COCO 格式", icon: <FileImageOutlined /> },
|
||||||
// ],
|
// ],
|
||||||
onMenuClick: handleExportFormat,
|
onClick: () => handleDownload(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "refresh",
|
key: "refresh",
|
||||||
@@ -161,6 +162,15 @@ export default function DatasetDetail() {
|
|||||||
icon: <ReloadOutlined />,
|
icon: <ReloadOutlined />,
|
||||||
onClick: handleRefresh,
|
onClick: handleRefresh,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "delete",
|
||||||
|
label: "删除",
|
||||||
|
danger: true,
|
||||||
|
icon: <DeleteOutlined />,
|
||||||
|
onClick: () => {
|
||||||
|
console.log("delete dataset");
|
||||||
|
},
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
EditOutlined,
|
EditOutlined,
|
||||||
DeleteOutlined,
|
DeleteOutlined,
|
||||||
PlusOutlined,
|
PlusOutlined,
|
||||||
|
UploadOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import TagManager from "@/components/TagManagement";
|
import TagManager from "@/components/TagManagement";
|
||||||
import { Link, useNavigate } from "react-router";
|
import { Link, useNavigate } from "react-router";
|
||||||
@@ -25,6 +26,7 @@ import {
|
|||||||
} from "../dataset.api";
|
} from "../dataset.api";
|
||||||
import { formatBytes } from "@/utils/unit";
|
import { formatBytes } from "@/utils/unit";
|
||||||
import EditDataset from "../Create/EditDataset";
|
import EditDataset from "../Create/EditDataset";
|
||||||
|
import ImportConfiguration from "../Detail/components/ImportConfiguration";
|
||||||
|
|
||||||
export default function DatasetManagementPage() {
|
export default function DatasetManagementPage() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -32,7 +34,7 @@ export default function DatasetManagementPage() {
|
|||||||
const [viewMode, setViewMode] = useState<"card" | "list">("card");
|
const [viewMode, setViewMode] = useState<"card" | "list">("card");
|
||||||
const [editDatasetOpen, setEditDatasetOpen] = useState(false);
|
const [editDatasetOpen, setEditDatasetOpen] = useState(false);
|
||||||
const [currentDataset, setCurrentDataset] = useState<Dataset | null>(null);
|
const [currentDataset, setCurrentDataset] = useState<Dataset | null>(null);
|
||||||
|
const [showUploadDialog, setShowUploadDialog] = useState(false);
|
||||||
const [statisticsData, setStatisticsData] = useState<any>({
|
const [statisticsData, setStatisticsData] = useState<any>({
|
||||||
count: {},
|
count: {},
|
||||||
size: {},
|
size: {},
|
||||||
@@ -131,6 +133,11 @@ export default function DatasetManagementPage() {
|
|||||||
message.success("数据删除成功");
|
message.success("数据删除成功");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleImportData = (dataset: Dataset) => {
|
||||||
|
setCurrentDataset(dataset);
|
||||||
|
setShowUploadDialog(true);
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchStatistics();
|
fetchStatistics();
|
||||||
}, []);
|
}, []);
|
||||||
@@ -141,11 +148,18 @@ export default function DatasetManagementPage() {
|
|||||||
label: "编辑",
|
label: "编辑",
|
||||||
icon: <EditOutlined />,
|
icon: <EditOutlined />,
|
||||||
onClick: (item: Dataset) => {
|
onClick: (item: Dataset) => {
|
||||||
console.log(item);
|
|
||||||
setCurrentDataset(item);
|
setCurrentDataset(item);
|
||||||
setEditDatasetOpen(true);
|
setEditDatasetOpen(true);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: "import",
|
||||||
|
label: "导入",
|
||||||
|
icon: <UploadOutlined />,
|
||||||
|
onClick: (item: Dataset) => {
|
||||||
|
handleImportData(item);
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: "download",
|
key: "download",
|
||||||
label: "下载",
|
label: "下载",
|
||||||
@@ -343,7 +357,19 @@ export default function DatasetManagementPage() {
|
|||||||
<EditDataset
|
<EditDataset
|
||||||
open={editDatasetOpen}
|
open={editDatasetOpen}
|
||||||
data={currentDataset}
|
data={currentDataset}
|
||||||
onClose={() => setEditDatasetOpen(false)}
|
onClose={() => {
|
||||||
|
setCurrentDataset(null);
|
||||||
|
setEditDatasetOpen(false);
|
||||||
|
}}
|
||||||
|
onRefresh={fetchData}
|
||||||
|
/>
|
||||||
|
<ImportConfiguration
|
||||||
|
data={currentDataset}
|
||||||
|
open={showUploadDialog}
|
||||||
|
onClose={() => {
|
||||||
|
setCurrentDataset(null);
|
||||||
|
setShowUploadDialog(false);
|
||||||
|
}}
|
||||||
onRefresh={fetchData}
|
onRefresh={fetchData}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -61,16 +61,8 @@ export function uploadDatasetFileUsingPost(id: string | number, data: any) {
|
|||||||
return post(`/api/data-management/datasets/${id}/files`, data);
|
return post(`/api/data-management/datasets/${id}/files`, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function downloadFile(
|
export function downloadFile(id: string | number) {
|
||||||
id: string | number,
|
return download(`/api/data-management/datasets/${id}/files/download`);
|
||||||
fileId: string | number,
|
|
||||||
filename?: string
|
|
||||||
) {
|
|
||||||
return download(
|
|
||||||
`/api/data-management/datasets/${id}/files/download`,
|
|
||||||
null,
|
|
||||||
filename
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除数据集文件
|
// 删除数据集文件
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ export const datasetStatusMap = {
|
|||||||
|
|
||||||
export const dataSourceMap: Record<string, { label: string; value: string }> = {
|
export const dataSourceMap: Record<string, { label: string; value: string }> = {
|
||||||
[DataSource.UPLOAD]: { label: "本地上传", value: DataSource.UPLOAD },
|
[DataSource.UPLOAD]: { label: "本地上传", value: DataSource.UPLOAD },
|
||||||
[DataSource.COLLECTION]: { label: "本地归集 ", value: DataSource.COLLECTION },
|
// [DataSource.COLLECTION]: { label: "本地归集 ", value: DataSource.COLLECTION },
|
||||||
// [DataSource.DATABASE]: { label: "数据库导入", value: DataSource.DATABASE },
|
// [DataSource.DATABASE]: { label: "数据库导入", value: DataSource.DATABASE },
|
||||||
// [DataSource.NAS]: { label: "NAS导入", value: DataSource.NAS },
|
// [DataSource.NAS]: { label: "NAS导入", value: DataSource.NAS },
|
||||||
// [DataSource.OBS]: { label: "OBS导入", value: DataSource.OBS },
|
// [DataSource.OBS]: { label: "OBS导入", value: DataSource.OBS },
|
||||||
|
|||||||
Reference in New Issue
Block a user