diff --git a/frontend/src/components/DocumentChunks.tsx b/frontend/src/components/DocumentChunks.tsx index 94307bc0..f619afb0 100644 --- a/frontend/src/components/DocumentChunks.tsx +++ b/frontend/src/components/DocumentChunks.tsx @@ -7,11 +7,13 @@ import userService from '../api/services/userService'; import ArrowLeft from '../assets/arrow-left.svg'; import NoFilesIcon from '../assets/no-files.svg'; import NoFilesDarkIcon from '../assets/no-files-dark.svg'; +import OutlineSource from '../assets/outline-source.svg'; import Spinner from '../components/Spinner'; -import Input from '../components/Input'; import ChunkModal from '../modals/ChunkModal'; import { ActiveState } from '../models/misc'; import { ChunkType } from '../settings/types'; +import EditIcon from '../assets/edit.svg'; +import Pagination from './DocumentPagination'; interface DocumentChunksProps { documentId: string; @@ -43,6 +45,8 @@ const DocumentChunks: React.FC = ({ chunk: ChunkType | null; }>({ state: 'INACTIVE', chunk: null }); + const pathParts = path ? path.split('/') : []; + const fetchChunks = () => { setLoading(true); try { @@ -138,40 +142,71 @@ const DocumentChunks: React.FC = ({ fetchChunks(); }, [page, perPage]); + const filteredChunks = paginatedChunks.filter((chunk) => { + if (!chunk.metadata?.title) return true; + return chunk.metadata.title + .toLowerCase() + .includes(searchTerm.toLowerCase()); + }); + return (
- {showHeader && ( -
+
+ {showHeader && ( -

{t('settings.documents.backToAll')}

+ )} + +
+ source + + {documentName} + + + {pathParts.length > 0 && ( + <> + / + {pathParts.map((part, index) => ( + + + {part} + + {index < pathParts.length - 1 && ( + / + )} + + ))} + + )}
- )} -
-
-

{`${totalChunks} ${t('settings.documents.chunks')}`}

- - { - setSearchTerm(e.target.value); - }} - borderVariant="thin" - /> +
+ +
+
+
+ {totalChunks > 999999 + ? `${(totalChunks / 1000000).toFixed(2)}M` + : totalChunks > 999 + ? `${(totalChunks / 1000).toFixed(2)}K` + : totalChunks} {t('settings.documents.chunks')} +
+
+
+ setSearchTerm(e.target.value)} + className="w-full h-full px-3 py-2 bg-transparent border-none outline-none font-normal text-[13.56px] leading-[100%] dark:text-[#E0E0E0]" + /> +
) : ( -
- {paginatedChunks.filter((chunk) => { - if (!chunk.metadata?.title) return true; - return chunk.metadata.title - .toLowerCase() - .includes(searchTerm.toLowerCase()); - }).length === 0 ? ( -
+
+ {filteredChunks.length === 0 ? ( +
{t('settings.documents.noChunksAlt')} = ({ {t('settings.documents.noChunks')}
) : ( - paginatedChunks - .filter((chunk) => { - if (!chunk.metadata?.title) return true; - return chunk.metadata.title - .toLowerCase() - .includes(searchTerm.toLowerCase()); - }) - .map((chunk, index) => ( -
-
-
- -
-
-

- {chunk.text} -

+ filteredChunks.map((chunk, index) => ( +
+
+
+
+ {chunk.metadata.token_count ? chunk.metadata.token_count.toLocaleString() : '-'} tokens
+ +
+
+

+ {chunk.text} +

- )) +
+ )) )}
)} + {!loading && filteredChunks.length > 0 && ( + { + setPerPage(rows); + setPage(1); + }} + /> + )} +