yangdx
commited on
Commit
·
82a4723
1
Parent(s):
b91c1e8
Fix document list sorting problem while filter is off
Browse files
lightrag/api/__init__.py
CHANGED
@@ -1 +1 @@
|
|
1 |
-
__api_version__ = "
|
|
|
1 |
+
__api_version__ = "0142"
|
lightrag_webui/src/features/DocumentManager.tsx
CHANGED
@@ -216,33 +216,42 @@ export default function DocumentManager() {
|
|
216 |
});
|
217 |
}, [sortField, sortDirection, showFileName]);
|
218 |
|
|
|
|
|
|
|
219 |
const filteredAndSortedDocs = useMemo(() => {
|
220 |
if (!docs) return null;
|
221 |
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
}
|
234 |
-
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
235 |
}
|
236 |
|
237 |
-
if
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
acc[status as DocStatus] = sortedDocuments;
|
242 |
-
return acc;
|
243 |
-
}, {} as DocsStatusesResponse['statuses']);
|
244 |
|
245 |
-
return
|
246 |
}, [docs, sortField, sortDirection, statusFilter, sortDocuments]);
|
247 |
|
248 |
// Calculate document counts for each status
|
@@ -641,69 +650,71 @@ export default function DocumentManager() {
|
|
641 |
</TableRow>
|
642 |
</TableHeader>
|
643 |
<TableBody className="text-sm overflow-auto">
|
644 |
-
{filteredAndSortedDocs
|
645 |
-
|
646 |
-
<
|
647 |
-
|
648 |
-
|
649 |
-
<>
|
650 |
-
<div className="group relative overflow-visible tooltip-container">
|
651 |
-
<div className="truncate">
|
652 |
-
{getDisplayFileName(doc, 30)}
|
653 |
-
</div>
|
654 |
-
<div className="invisible group-hover:visible tooltip">
|
655 |
-
{doc.file_path}
|
656 |
-
</div>
|
657 |
-
</div>
|
658 |
-
<div className="text-xs text-gray-500">{doc.id}</div>
|
659 |
-
</>
|
660 |
-
) : (
|
661 |
<div className="group relative overflow-visible tooltip-container">
|
662 |
<div className="truncate">
|
663 |
-
{doc
|
664 |
</div>
|
665 |
<div className="invisible group-hover:visible tooltip">
|
666 |
{doc.file_path}
|
667 |
</div>
|
668 |
</div>
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
<div className="group relative overflow-visible tooltip-container">
|
673 |
<div className="truncate">
|
674 |
-
{doc.
|
675 |
</div>
|
676 |
<div className="invisible group-hover:visible tooltip">
|
677 |
-
{doc.
|
678 |
</div>
|
679 |
</div>
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
)}
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
</TableBody>
|
708 |
</Table>
|
709 |
</div>
|
|
|
216 |
});
|
217 |
}, [sortField, sortDirection, showFileName]);
|
218 |
|
219 |
+
// Define a new type that includes status information
|
220 |
+
type DocStatusWithStatus = DocStatusResponse & { status: DocStatus };
|
221 |
+
|
222 |
const filteredAndSortedDocs = useMemo(() => {
|
223 |
if (!docs) return null;
|
224 |
|
225 |
+
// Create a flat array of documents with status information
|
226 |
+
const allDocuments: DocStatusWithStatus[] = [];
|
227 |
+
|
228 |
+
if (statusFilter === 'all') {
|
229 |
+
// When filter is 'all', include documents from all statuses
|
230 |
+
Object.entries(docs.statuses).forEach(([status, documents]) => {
|
231 |
+
documents.forEach(doc => {
|
232 |
+
allDocuments.push({
|
233 |
+
...doc,
|
234 |
+
status: status as DocStatus
|
235 |
+
});
|
236 |
+
});
|
237 |
+
});
|
238 |
+
} else {
|
239 |
+
// When filter is specific status, only include documents from that status
|
240 |
+
const documents = docs.statuses[statusFilter] || [];
|
241 |
+
documents.forEach(doc => {
|
242 |
+
allDocuments.push({
|
243 |
+
...doc,
|
244 |
+
status: statusFilter
|
245 |
+
});
|
246 |
+
});
|
247 |
}
|
248 |
|
249 |
+
// Sort all documents together if sort field and direction are specified
|
250 |
+
if (sortField && sortDirection) {
|
251 |
+
return sortDocuments(allDocuments);
|
252 |
+
}
|
|
|
|
|
|
|
253 |
|
254 |
+
return allDocuments;
|
255 |
}, [docs, sortField, sortDirection, statusFilter, sortDocuments]);
|
256 |
|
257 |
// Calculate document counts for each status
|
|
|
650 |
</TableRow>
|
651 |
</TableHeader>
|
652 |
<TableBody className="text-sm overflow-auto">
|
653 |
+
{filteredAndSortedDocs && filteredAndSortedDocs.map((doc) => (
|
654 |
+
<TableRow key={doc.id}>
|
655 |
+
<TableCell className="truncate font-mono overflow-visible max-w-[250px]">
|
656 |
+
{showFileName ? (
|
657 |
+
<>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
658 |
<div className="group relative overflow-visible tooltip-container">
|
659 |
<div className="truncate">
|
660 |
+
{getDisplayFileName(doc, 30)}
|
661 |
</div>
|
662 |
<div className="invisible group-hover:visible tooltip">
|
663 |
{doc.file_path}
|
664 |
</div>
|
665 |
</div>
|
666 |
+
<div className="text-xs text-gray-500">{doc.id}</div>
|
667 |
+
</>
|
668 |
+
) : (
|
669 |
<div className="group relative overflow-visible tooltip-container">
|
670 |
<div className="truncate">
|
671 |
+
{doc.id}
|
672 |
</div>
|
673 |
<div className="invisible group-hover:visible tooltip">
|
674 |
+
{doc.file_path}
|
675 |
</div>
|
676 |
</div>
|
677 |
+
)}
|
678 |
+
</TableCell>
|
679 |
+
<TableCell className="max-w-xs min-w-45 truncate overflow-visible">
|
680 |
+
<div className="group relative overflow-visible tooltip-container">
|
681 |
+
<div className="truncate">
|
682 |
+
{doc.content_summary}
|
683 |
+
</div>
|
684 |
+
<div className="invisible group-hover:visible tooltip">
|
685 |
+
{doc.content_summary}
|
686 |
+
</div>
|
687 |
+
</div>
|
688 |
+
</TableCell>
|
689 |
+
<TableCell>
|
690 |
+
{doc.status === 'processed' && (
|
691 |
+
<span className="text-green-600">{t('documentPanel.documentManager.status.completed')}</span>
|
692 |
+
)}
|
693 |
+
{doc.status === 'processing' && (
|
694 |
+
<span className="text-blue-600">{t('documentPanel.documentManager.status.processing')}</span>
|
695 |
+
)}
|
696 |
+
{doc.status === 'pending' && (
|
697 |
+
<span className="text-yellow-600">{t('documentPanel.documentManager.status.pending')}</span>
|
698 |
+
)}
|
699 |
+
{doc.status === 'failed' && (
|
700 |
+
<span className="text-red-600">{t('documentPanel.documentManager.status.failed')}</span>
|
701 |
+
)}
|
702 |
+
{doc.error && (
|
703 |
+
<span className="ml-2 text-red-500" title={doc.error}>
|
704 |
+
⚠️
|
705 |
+
</span>
|
706 |
+
)}
|
707 |
+
</TableCell>
|
708 |
+
<TableCell>{doc.content_length ?? '-'}</TableCell>
|
709 |
+
<TableCell>{doc.chunks_count ?? '-'}</TableCell>
|
710 |
+
<TableCell className="truncate">
|
711 |
+
{new Date(doc.created_at).toLocaleString()}
|
712 |
+
</TableCell>
|
713 |
+
<TableCell className="truncate">
|
714 |
+
{new Date(doc.updated_at).toLocaleString()}
|
715 |
+
</TableCell>
|
716 |
+
</TableRow>
|
717 |
+
))}
|
718 |
</TableBody>
|
719 |
</Table>
|
720 |
</div>
|