mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-01-30 07:06:39 +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:
@ -7,7 +7,7 @@ import {
|
||||
} from '@/interfaces/request/document';
|
||||
import i18n from '@/locales/config';
|
||||
import chatService from '@/services/chat-service';
|
||||
import kbService from '@/services/knowledge-service';
|
||||
import kbService, { listDocument } from '@/services/knowledge-service';
|
||||
import api, { api_host } from '@/utils/api';
|
||||
import { buildChunkHighlights } from '@/utils/document-util';
|
||||
import { post } from '@/utils/request';
|
||||
@ -73,7 +73,7 @@ export const useFetchNextDocumentList = () => {
|
||||
refetchInterval: 15000,
|
||||
enabled: !!knowledgeId || !!id,
|
||||
queryFn: async () => {
|
||||
const ret = await kbService.get_document_list({
|
||||
const ret = await listDocument({
|
||||
kb_id: knowledgeId || id,
|
||||
keywords: searchString,
|
||||
page_size: pagination.pageSize,
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { useHandleFilterSubmit } from '@/components/list-filter-bar/use-handle-filter-submit';
|
||||
import {
|
||||
IKnowledge,
|
||||
IKnowledgeResult,
|
||||
@ -72,8 +73,8 @@ export const useTestRetrieval = () => {
|
||||
export const useFetchNextKnowledgeListByPage = () => {
|
||||
const { searchString, handleInputChange } = useHandleSearchChange();
|
||||
const { pagination, setPagination } = useGetPaginationWithRouter();
|
||||
const [ownerIds, setOwnerIds] = useState<string[]>([]);
|
||||
const debouncedSearchString = useDebounce(searchString, { wait: 500 });
|
||||
const { filterValue, handleFilterSubmit } = useHandleFilterSubmit();
|
||||
|
||||
const { data, isFetching: loading } = useQuery<IKnowledgeResult>({
|
||||
queryKey: [
|
||||
@ -81,7 +82,7 @@ export const useFetchNextKnowledgeListByPage = () => {
|
||||
{
|
||||
debouncedSearchString,
|
||||
...pagination,
|
||||
ownerIds,
|
||||
filterValue,
|
||||
},
|
||||
],
|
||||
initialData: {
|
||||
@ -97,7 +98,7 @@ export const useFetchNextKnowledgeListByPage = () => {
|
||||
page: pagination.current,
|
||||
},
|
||||
{
|
||||
owner_ids: ownerIds,
|
||||
owner_ids: filterValue.owner,
|
||||
},
|
||||
);
|
||||
|
||||
@ -113,11 +114,6 @@ export const useFetchNextKnowledgeListByPage = () => {
|
||||
[handleInputChange],
|
||||
);
|
||||
|
||||
const handleOwnerIdsChange = useCallback((ids: string[]) => {
|
||||
// setPagination({ page: 1 }); // TODO: 这里导致重复请求
|
||||
setOwnerIds(ids);
|
||||
}, []);
|
||||
|
||||
return {
|
||||
...data,
|
||||
searchString,
|
||||
@ -125,8 +121,8 @@ export const useFetchNextKnowledgeListByPage = () => {
|
||||
pagination: { ...pagination, total: data?.total },
|
||||
setPagination,
|
||||
loading,
|
||||
setOwnerIds: handleOwnerIdsChange,
|
||||
ownerIds,
|
||||
filterValue,
|
||||
handleFilterSubmit,
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user