feat: add file icon to table of FileManager #345 (#543)

### What problem does this PR solve?

feat: add file icon to table of FileManager #345
fix: modify datasetDescription

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-04-25 19:06:24 +08:00
committed by GitHub
parent 26003b5076
commit 1dcd439c58
19 changed files with 317 additions and 154 deletions

View File

@ -103,14 +103,14 @@ export const useUploadFile = () => {
const dispatch = useDispatch();
const uploadFile = useCallback(
(file: UploadFile, parentId: string, path: string) => {
(fileList: UploadFile[], parentId: string) => {
try {
return dispatch<any>({
type: 'fileManager/uploadFile',
payload: {
file,
file: fileList,
parentId,
path,
path: fileList.map((file) => (file as any).webkitRelativePath),
},
});
} catch (errorInfo) {

View File

@ -127,13 +127,13 @@ export const useFetchKnowledgeBaseConfiguration = () => {
export const useFetchKnowledgeList = (
shouldFilterListWithoutDocument: boolean = false,
): { list: IKnowledge[]; loading: boolean } => {
) => {
const dispatch = useDispatch();
const loading = useOneNamespaceEffectsLoading('knowledgeModel', ['getList']);
const knowledgeModel = useSelector((state: any) => state.knowledgeModel);
const { data = [] } = knowledgeModel;
const list = useMemo(() => {
const list: IKnowledge[] = useMemo(() => {
return shouldFilterListWithoutDocument
? data.filter((x: IKnowledge) => x.chunk_num > 0)
: data;
@ -149,7 +149,7 @@ export const useFetchKnowledgeList = (
fetchList();
}, [fetchList]);
return { list, loading };
return { list, loading, fetchList };
};
export const useSelectFileThumbnails = () => {

View File

@ -1,9 +1,12 @@
import { LanguageTranslationMap } from '@/constants/common';
import { Pagination } from '@/interfaces/common';
import { IKnowledgeFile } from '@/interfaces/database/knowledge';
import { IChangeParserConfigRequestBody } from '@/interfaces/request/document';
import { useCallback, useState } from 'react';
import { PaginationProps } from 'antd';
import { useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useSetModalState } from './commonHooks';
import { useDispatch } from 'umi';
import { useSetModalState, useTranslate } from './commonHooks';
import { useSetDocumentParser } from './documentHooks';
import { useOneNamespaceEffectsLoading } from './storeHooks';
import { useSaveSetting } from './userSettingHook';
@ -62,3 +65,51 @@ export const useChangeLanguage = () => {
return changeLanguage;
};
export const useGetPagination = (
total: number,
page: number,
pageSize: number,
onPageChange: PaginationProps['onChange'],
) => {
const { t } = useTranslate('common');
const pagination: PaginationProps = useMemo(() => {
return {
showQuickJumper: true,
total,
showSizeChanger: true,
current: page,
pageSize: pageSize,
pageSizeOptions: [1, 2, 10, 20, 50, 100],
onChange: onPageChange,
showTotal: (total) => `${t('total')} ${total}`,
};
}, [t, onPageChange, page, pageSize, total]);
return {
pagination,
};
};
export const useSetPagination = (namespace: string) => {
const dispatch = useDispatch();
const setPagination = useCallback(
(pageNumber = 1, pageSize?: number) => {
const pagination: Pagination = {
current: pageNumber,
} as Pagination;
if (pageSize) {
pagination.pageSize = pageSize;
}
dispatch({
type: `${namespace}/setPagination`,
payload: pagination,
});
},
[dispatch, namespace],
);
return setPagination;
};