-
数据总数:{total}个
+
数据总数:{total} 个
-
- {dataList?.map((item) => (
-
- ))}
-
-
+ {dataList && dataList.length > 0 && (
+ <>
+
+ {dataList?.map((item) => (
+
+ ))}
+
+
+ >
+ )}
+ {dataList && dataList.length === 0 && (
+
+ )}
);
}
diff --git a/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx b/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx
index 8199d336..a6a3380d 100644
--- a/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx
+++ b/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx
@@ -1,125 +1,36 @@
import CommonTableCell from '@/components/CommonTableCell';
import DateTableCell from '@/components/DateTableCell';
import KFIcon from '@/components/KFIcon';
-import { useEffectWhen } from '@/hooks';
-import AddVersionModal from '@/pages/Dataset/components/AddVersionModal';
import {
+ ResourceData,
ResourceFileData,
ResourceType,
- ResourceVersionData,
resourceConfig,
} from '@/pages/Dataset/config';
import { downLoadZip } from '@/utils/downloadfile';
-import { openAntdModal } from '@/utils/modal';
-import { to } from '@/utils/promise';
-import { modalConfirm } from '@/utils/ui';
-import { App, Button, Flex, Select, Table } from 'antd';
-import { useState } from 'react';
+import { Button, Flex, Table } from 'antd';
import styles from './index.less';
type ResourceVersionProps = {
resourceType: ResourceType;
- resourceId: number;
- resourceName: string;
- isPublic: boolean;
- versionList: ResourceVersionData[];
- version?: string;
- isActive: boolean;
- getVersionList: () => void;
- onVersionChange: (version: string) => void;
+ info: ResourceData;
};
-function ResourceVersion({
- resourceType,
- resourceId,
- resourceName,
- isPublic,
- versionList,
- version,
- isActive,
- getVersionList,
- onVersionChange,
-}: ResourceVersionProps) {
- const [fileList, setFileList] = useState
([]);
- const { message } = App.useApp();
+function ResourceVersion({ resourceType, info }: ResourceVersionProps) {
const config = resourceConfig[resourceType];
-
- // 获取版本文件列表
- useEffectWhen(
- () => {
- if (version) {
- getFileList(version);
- } else {
- setFileList([]);
- }
- },
- [resourceId, version],
- isActive,
- );
-
- // 获取版本下的文件列表
- const getFileList = async (version: string) => {
- const params = {
- version,
- [config.fileReqParamKey]: resourceId,
- };
- const request = config.getFiles;
- const [res] = await to(request(params));
- if (res) {
- setFileList(res?.data?.content ?? []);
- }
- };
-
- // 删除版本
- const deleteVersion = async () => {
- const request = config.deleteVersion;
- const params = {
- [config.idParamKey]: resourceId,
- version,
- };
- const [res] = await to(request(params));
- if (res) {
- getVersionList();
- message.success('删除成功');
- }
- };
-
- // 新建版本
- const showModal = () => {
- const { close } = openAntdModal(AddVersionModal, {
- resourceType: resourceType,
- resourceId: resourceId,
- initialName: resourceName,
- onOk: () => {
- getVersionList();
- close();
- },
- });
- };
-
- // 处理删除
- const hanldeDelete = () => {
- modalConfirm({
- title: '删除后,该版本将不可恢复',
- content: '是否确认删除?',
- okText: '确认',
- cancelText: '取消',
-
- onOk: () => {
- deleteVersion();
- },
- });
- };
+ const filePropKey = config.filePropKey as keyof ResourceData;
+ const fileList = (info[filePropKey] ?? []) as ResourceFileData[];
+ fileList.forEach((item) => (item.update_time = info.update_time));
// 全部导出
const handleExport = async () => {
const url = config.downloadAllAction;
- downLoadZip(url, { models_id: resourceId, version });
+ downLoadZip(url, { name: info.name, id: info.id, version: info.version });
};
// 单个导出
- const downloadAlone = (record: ResourceFileData) => {
+ const downloadAlone = async (record: ResourceFileData) => {
const url = config.downloadSingleAction;
- downLoadZip(`${url}/${record.id}`);
+ downLoadZip(url, { url: record.url });
};
const columns = [
@@ -142,12 +53,6 @@ function ResourceVersion({
),
},
- {
- title: '版本号',
- dataIndex: 'version',
- key: 'version',
- render: CommonTableCell(),
- },
{
title: '文件大小',
dataIndex: 'file_size',
@@ -163,7 +68,7 @@ function ResourceVersion({
{
title: '操作',
dataIndex: 'option',
- width: '100px',
+ width: 160,
key: 'option',
render: (_: any, record: ResourceFileData) => [
-
-
- {!isPublic && (
- }
- >
- 删除
-
- )}
}
>
@@ -216,12 +98,7 @@ function ResourceVersion({
-
- {fileList.length > 0 && fileList[0].description
- ? '版本描述:' + fileList[0].description
- : null}
-
-
+
);
}
diff --git a/react-ui/src/pages/Dataset/config.tsx b/react-ui/src/pages/Dataset/config.tsx
index 822b7bfe..b1677bc3 100644
--- a/react-ui/src/pages/Dataset/config.tsx
+++ b/react-ui/src/pages/Dataset/config.tsx
@@ -1,20 +1,18 @@
import KFIcon from '@/components/KFIcon';
import { CommonTabKeys } from '@/enums';
import {
- addDatasetVersionDetail,
- addModelsVersionDetail,
+ addDatasetVersion,
+ addModelVersion,
deleteDataset,
deleteDatasetVersion,
deleteModel,
deleteModelVersion,
- getDatasetById,
+ getDatasetInfo,
getDatasetList,
- getDatasetVersionIdList,
- getDatasetVersionsById,
- getModelById,
+ getDatasetVersionList,
+ getModelInfo,
getModelList,
- getModelVersionIdList,
- getModelVersionsById,
+ getModelVersionList,
} from '@/services/dataset/index.js';
import type { TabsProps } from 'antd';
@@ -26,7 +24,6 @@ export enum ResourceType {
type ResourceTypeInfo = {
getList: (params: any) => Promise