mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: save the selected parser to the backend on the upload file page and upload document (#54)
* feat: add pagination to document table * feat: fetch document list by page * feat: poll the document list * feat: upload document * feat: save the selected parser to the backend on the upload file page
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
import { useSearchParams } from 'umi';
|
||||
import showDeleteConfirm from '@/components/deleting-confirm';
|
||||
import { IKnowledge } from '@/interfaces/database/knowledge';
|
||||
import { useDispatch, useSearchParams, useSelector } from 'umi';
|
||||
|
||||
export const useKnowledgeBaseId = (): string => {
|
||||
const [searchParams] = useSearchParams();
|
||||
@ -6,3 +8,41 @@ export const useKnowledgeBaseId = (): string => {
|
||||
|
||||
return knowledgeBaseId || '';
|
||||
};
|
||||
|
||||
export const useDeleteDocumentById = (): {
|
||||
removeDocument: (documentId: string) => Promise<number>;
|
||||
} => {
|
||||
const dispatch = useDispatch();
|
||||
const knowledgeBaseId = useKnowledgeBaseId();
|
||||
|
||||
const removeDocument = (documentId: string) => () => {
|
||||
return dispatch({
|
||||
type: 'kFModel/document_rm',
|
||||
payload: {
|
||||
doc_id: documentId,
|
||||
kb_id: knowledgeBaseId,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const onRmDocument = (documentId: string): Promise<number> => {
|
||||
return showDeleteConfirm({ onOk: removeDocument(documentId) });
|
||||
};
|
||||
|
||||
return {
|
||||
removeDocument: onRmDocument,
|
||||
};
|
||||
};
|
||||
|
||||
export const useGetDocumentDefaultParser = (knowledgeBaseId: string) => {
|
||||
const data: IKnowledge[] = useSelector(
|
||||
(state: any) => state.knowledgeModel.data,
|
||||
);
|
||||
|
||||
const item = data.find((x) => x.id === knowledgeBaseId);
|
||||
|
||||
return {
|
||||
defaultParserId: item?.parser_id ?? '',
|
||||
parserConfig: item?.parser_config ?? '',
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user