Merge pull request #1326 from danielaskdd/main
Fix document list sorting problem while filter is off
This commit is contained in:
@@ -1 +1 @@
|
||||
__api_version__ = "0141"
|
||||
__api_version__ = "0142"
|
||||
|
File diff suppressed because one or more lines are too long
2
lightrag/api/webui/index.html
generated
2
lightrag/api/webui/index.html
generated
@@ -8,7 +8,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="logo.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Lightrag</title>
|
||||
<script type="module" crossorigin src="/webui/assets/index-DVJJypi_.js"></script>
|
||||
<script type="module" crossorigin src="/webui/assets/index-Cicy56pP.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/webui/assets/index-CTB4Vp_z.css">
|
||||
</head>
|
||||
<body>
|
||||
|
@@ -216,33 +216,42 @@ export default function DocumentManager() {
|
||||
});
|
||||
}, [sortField, sortDirection, showFileName]);
|
||||
|
||||
// Define a new type that includes status information
|
||||
type DocStatusWithStatus = DocStatusResponse & { status: DocStatus };
|
||||
|
||||
const filteredAndSortedDocs = useMemo(() => {
|
||||
if (!docs) return null;
|
||||
|
||||
let filteredDocs = { ...docs };
|
||||
// Create a flat array of documents with status information
|
||||
const allDocuments: DocStatusWithStatus[] = [];
|
||||
|
||||
if (statusFilter !== 'all') {
|
||||
filteredDocs = {
|
||||
...docs,
|
||||
statuses: {
|
||||
pending: [],
|
||||
processing: [],
|
||||
processed: [],
|
||||
failed: [],
|
||||
[statusFilter]: docs.statuses[statusFilter] || []
|
||||
}
|
||||
};
|
||||
if (statusFilter === 'all') {
|
||||
// When filter is 'all', include documents from all statuses
|
||||
Object.entries(docs.statuses).forEach(([status, documents]) => {
|
||||
documents.forEach(doc => {
|
||||
allDocuments.push({
|
||||
...doc,
|
||||
status: status as DocStatus
|
||||
});
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// When filter is specific status, only include documents from that status
|
||||
const documents = docs.statuses[statusFilter] || [];
|
||||
documents.forEach(doc => {
|
||||
allDocuments.push({
|
||||
...doc,
|
||||
status: statusFilter
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (!sortField || !sortDirection) return filteredDocs;
|
||||
// Sort all documents together if sort field and direction are specified
|
||||
if (sortField && sortDirection) {
|
||||
return sortDocuments(allDocuments);
|
||||
}
|
||||
|
||||
const sortedStatuses = Object.entries(filteredDocs.statuses).reduce((acc, [status, documents]) => {
|
||||
const sortedDocuments = sortDocuments(documents);
|
||||
acc[status as DocStatus] = sortedDocuments;
|
||||
return acc;
|
||||
}, {} as DocsStatusesResponse['statuses']);
|
||||
|
||||
return { ...filteredDocs, statuses: sortedStatuses };
|
||||
return allDocuments;
|
||||
}, [docs, sortField, sortDirection, statusFilter, sortDocuments]);
|
||||
|
||||
// Calculate document counts for each status
|
||||
@@ -641,8 +650,7 @@ export default function DocumentManager() {
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody className="text-sm overflow-auto">
|
||||
{filteredAndSortedDocs?.statuses && Object.entries(filteredAndSortedDocs.statuses).flatMap(([status, documents]) =>
|
||||
documents.map((doc) => (
|
||||
{filteredAndSortedDocs && filteredAndSortedDocs.map((doc) => (
|
||||
<TableRow key={doc.id}>
|
||||
<TableCell className="truncate font-mono overflow-visible max-w-[250px]">
|
||||
{showFileName ? (
|
||||
@@ -679,14 +687,18 @@ export default function DocumentManager() {
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{status === 'processed' && (
|
||||
{doc.status === 'processed' && (
|
||||
<span className="text-green-600">{t('documentPanel.documentManager.status.completed')}</span>
|
||||
)}
|
||||
{status === 'processing' && (
|
||||
{doc.status === 'processing' && (
|
||||
<span className="text-blue-600">{t('documentPanel.documentManager.status.processing')}</span>
|
||||
)}
|
||||
{status === 'pending' && <span className="text-yellow-600">{t('documentPanel.documentManager.status.pending')}</span>}
|
||||
{status === 'failed' && <span className="text-red-600">{t('documentPanel.documentManager.status.failed')}</span>}
|
||||
{doc.status === 'pending' && (
|
||||
<span className="text-yellow-600">{t('documentPanel.documentManager.status.pending')}</span>
|
||||
)}
|
||||
{doc.status === 'failed' && (
|
||||
<span className="text-red-600">{t('documentPanel.documentManager.status.failed')}</span>
|
||||
)}
|
||||
{doc.error && (
|
||||
<span className="ml-2 text-red-500" title={doc.error}>
|
||||
⚠️
|
||||
@@ -702,8 +714,7 @@ export default function DocumentManager() {
|
||||
{new Date(doc.updated_at).toLocaleString()}
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)))
|
||||
}
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user