mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Feat: Filter document by running status and file type. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,10 +1,11 @@
|
||||
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
|
||||
import { IDocumentInfo } from '@/interfaces/database/document';
|
||||
import {
|
||||
IChangeParserConfigRequestBody,
|
||||
IDocumentMetaRequestBody,
|
||||
} from '@/interfaces/request/document';
|
||||
import i18n from '@/locales/config';
|
||||
import kbService from '@/services/knowledge-service';
|
||||
import kbService, { listDocument } from '@/services/knowledge-service';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { useDebounce } from 'ahooks';
|
||||
import { message } from 'antd';
|
||||
@ -26,6 +27,7 @@ export const enum DocumentApiAction {
|
||||
SaveDocumentName = 'saveDocumentName',
|
||||
SetDocumentParser = 'setDocumentParser',
|
||||
SetDocumentMeta = 'setDocumentMeta',
|
||||
FetchAllDocumentList = 'fetchAllDocumentList',
|
||||
}
|
||||
|
||||
export const useUploadNextDocument = () => {
|
||||
@ -74,6 +76,7 @@ export const useFetchDocumentList = () => {
|
||||
const { pagination, setPagination } = useGetPaginationWithRouter();
|
||||
const { id } = useParams();
|
||||
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
|
||||
const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
|
||||
|
||||
const { data, isFetching: loading } = useQuery<{
|
||||
docs: IDocumentInfo[];
|
||||
@ -83,17 +86,24 @@ export const useFetchDocumentList = () => {
|
||||
DocumentApiAction.FetchDocumentList,
|
||||
debouncedSearchString,
|
||||
pagination,
|
||||
filterValue,
|
||||
],
|
||||
initialData: { docs: [], total: 0 },
|
||||
refetchInterval: 15000,
|
||||
enabled: !!knowledgeId || !!id,
|
||||
queryFn: async () => {
|
||||
const ret = await kbService.get_document_list({
|
||||
kb_id: knowledgeId || id,
|
||||
keywords: debouncedSearchString,
|
||||
page_size: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
});
|
||||
const ret = await listDocument(
|
||||
{
|
||||
kb_id: knowledgeId || id,
|
||||
keywords: debouncedSearchString,
|
||||
page_size: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
},
|
||||
{
|
||||
types: filterValue.type,
|
||||
run_status: filterValue.run,
|
||||
},
|
||||
);
|
||||
if (ret.data.code === 0) {
|
||||
return ret.data.data;
|
||||
}
|
||||
@ -120,9 +130,39 @@ export const useFetchDocumentList = () => {
|
||||
pagination: { ...pagination, total: data?.total },
|
||||
handleInputChange: onInputChange,
|
||||
setPagination,
|
||||
filterValue,
|
||||
handleFilterSubmit,
|
||||
};
|
||||
};
|
||||
|
||||
export function useFetchAllDocumentList() {
|
||||
const { id } = useParams();
|
||||
const { data, isFetching: loading } = useQuery<{
|
||||
docs: IDocumentInfo[];
|
||||
total: number;
|
||||
}>({
|
||||
queryKey: [DocumentApiAction.FetchAllDocumentList],
|
||||
initialData: { docs: [], total: 0 },
|
||||
refetchInterval: 15000,
|
||||
enabled: !!id,
|
||||
queryFn: async () => {
|
||||
const ret = await listDocument({
|
||||
kb_id: id,
|
||||
});
|
||||
if (ret.data.code === 0) {
|
||||
return ret.data.data;
|
||||
}
|
||||
|
||||
return {
|
||||
docs: [],
|
||||
total: 0,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
return { data, loading };
|
||||
}
|
||||
|
||||
export const useSetDocumentStatus = () => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user