import { useSelectDocumentList, useSetDocumentStatus, } from '@/hooks/documentHooks'; import { useSelectParserList } from '@/hooks/userSettingHook'; import { IKnowledgeFile } from '@/interfaces/database/knowledge'; import { FileOutlined, FileTextOutlined, PlusOutlined, SearchOutlined, } from '@ant-design/icons'; import type { MenuProps } from 'antd'; import { Button, Divider, Dropdown, Input, Space, Switch, Table, Tag, } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { useMemo } from 'react'; import ChunkMethodModal from './chunk-method-modal'; import CreateFileModal from './create-file-modal'; import { useChangeDocumentParser, useCreateEmptyDocument, useFetchDocumentListOnMount, useGetPagination, useHandleSearchChange, useNavigateToOtherPage, useRenameDocument, useSetSelectedRecord, } from './hooks'; import ParsingActionCell from './parsing-action-cell'; import ParsingStatusCell from './parsing-status-cell'; import RenameModal from './rename-modal'; import styles from './index.less'; const KnowledgeFile = () => { const data = useSelectDocumentList(); const { fetchDocumentList } = useFetchDocumentListOnMount(); const parserList = useSelectParserList(); const { pagination, setPagination, total, searchString } = useGetPagination(fetchDocumentList); const onChangeStatus = useSetDocumentStatus(); const { linkToUploadPage, toChunk } = useNavigateToOtherPage(); const { handleInputChange } = useHandleSearchChange(setPagination); const { currentRecord, setRecord } = useSetSelectedRecord(); const { renameLoading, onRenameOk, renameVisible, hideRenameModal, showRenameModal, } = useRenameDocument(currentRecord.id); const { createLoading, onCreateOk, createVisible, hideCreateModal, showCreateModal, } = useCreateEmptyDocument(); const { changeParserLoading, onChangeParserOk, changeParserVisible, hideChangeParserModal, showChangeParserModal, } = useChangeDocumentParser(currentRecord.id); const actionItems: MenuProps['items'] = useMemo(() => { return [ { key: '1', onClick: linkToUploadPage, label: (
), }, { type: 'divider' }, { key: '2', onClick: showCreateModal, label: (
), // disabled: true, }, ]; }, [linkToUploadPage, showCreateModal]); const columns: ColumnsType = [ { title: 'Name', dataIndex: 'name', key: 'name', fixed: 'left', render: (text: any, { id, thumbnail }) => (
toChunk(id)}> {text}
), }, { title: 'Chunk Number', dataIndex: 'chunk_num', key: 'chunk_num', }, { title: 'Upload Date', dataIndex: 'create_date', key: 'create_date', }, { title: 'Chunk Method', dataIndex: 'parser_id', key: 'parser_id', render: (text) => { return parserList.find((x) => x.value === text)?.label; }, }, { title: 'Enabled', key: 'status', dataIndex: 'status', render: (_, { status, id }) => ( <> { onChangeStatus(e, id); }} /> ), }, { title: 'Parsing Status', dataIndex: 'run', key: 'run', render: (text, record) => { return ; }, }, { title: 'Action', key: 'action', render: (_, record) => ( { setRecord(record)(); showRenameModal(); }} showChangeParserModal={showChangeParserModal} record={record} > ), }, ]; const finalColumns = columns.map((x) => ({ ...x, className: `${styles.column}`, })); return (

Dataset

Hey, don't forget to adjust the chunk after adding the dataset! 😉

Total

{total} files
} />
); }; export default KnowledgeFile;