From 8d27132e12608f6de314e0720afc035e88e0fd4e Mon Sep 17 00:00:00 2001 From: perf3ct Date: Wed, 2 Jul 2025 18:26:22 +0000 Subject: [PATCH] feat(client): impelement retry all button on Document Management page --- frontend/src/pages/DocumentManagementPage.tsx | 112 ++++++++++++++++-- 1 file changed, 103 insertions(+), 9 deletions(-) diff --git a/frontend/src/pages/DocumentManagementPage.tsx b/frontend/src/pages/DocumentManagementPage.tsx index 96079a6..da50d4c 100644 --- a/frontend/src/pages/DocumentManagementPage.tsx +++ b/frontend/src/pages/DocumentManagementPage.tsx @@ -19,6 +19,7 @@ import { Dialog, DialogTitle, DialogContent, + DialogContentText, DialogActions, Pagination, CircularProgress, @@ -233,6 +234,7 @@ const DocumentManagementPage: React.FC = () => { const [retryHistoryModalOpen, setRetryHistoryModalOpen] = useState(false); const [selectedDocumentForHistory, setSelectedDocumentForHistory] = useState(null); const [selectedDocumentIds, setSelectedDocumentIds] = useState([]); + const [confirmRetryAllOpen, setConfirmRetryAllOpen] = useState(false); const fetchFailedDocuments = async () => { try { @@ -358,6 +360,42 @@ const DocumentManagementPage: React.FC = () => { } }; + const handleRetryAllDocuments = async () => { + try { + setRetryingAll(true); + const response = await documentService.bulkRetryOcr({ + mode: 'all', + preview_only: false + }); + + if (response.data.queued_count > 0) { + setSnackbar({ + open: true, + message: `Successfully queued ${response.data.queued_count} documents for OCR retry. Estimated processing time: ${Math.ceil(response.data.estimated_total_time_minutes)} minutes.`, + severity: 'success' + }); + + // Refresh all tabs since we're retrying all documents + await refreshCurrentTab(); + } else { + setSnackbar({ + open: true, + message: 'No documents found to retry', + severity: 'info' + }); + } + } catch (error) { + console.error('Error retrying all documents:', error); + setSnackbar({ + open: true, + message: 'Failed to retry documents. Please try again.', + severity: 'error' + }); + } finally { + setRetryingAll(false); + } + }; + const handleRetryAllFailed = async () => { try { setRetryingAll(true); @@ -735,14 +773,33 @@ const DocumentManagementPage: React.FC = () => { Document Management - + + + + @@ -825,7 +882,7 @@ const DocumentManagementPage: React.FC = () => { size="small" fullWidth > - {retryingAll ? 'Retrying All...' : 'Retry All Failed OCR'} + {retryingAll ? 'Retrying...' : 'Retry Failed Only'} @@ -2219,6 +2276,43 @@ const DocumentManagementPage: React.FC = () => { + {/* Confirm Retry All Documents Dialog */} + setConfirmRetryAllOpen(false)}> + + + + Retry All Documents + + + + + This will retry OCR processing for all documents in your library, regardless of their current OCR status. + This includes documents that have already been successfully processed. + + + + Note: This is a resource-intensive operation that may take a significant amount of time depending on the number of documents. + + + + + + + + + {/* Advanced Retry Modal */}