abort and search

This commit is contained in:
seb
2026-09-19 08:14:11 +02:00
parent abe078ff05
commit d3b4743b66
9 changed files with 690 additions and 76 deletions

View File

@@ -92,19 +92,21 @@ function EventLog({ messages, streaming }) {
);
}
export default function ManifestPdfDialog({ open, filename, data, onClose }) {
export default function ManifestPdfDialog({ open, filename, data, onClose, onAbort }) {
if (!open) return null;
const { streaming = false, messages = [], result = null, error = null } = data ?? {};
const { streaming = false, messages = [], result = null, error = null, aborted = false } = data ?? {};
const hasResult = Boolean(result);
const isTextDoc =
filename?.toLowerCase().endsWith('.txt') || filename?.toLowerCase().endsWith('.csv');
const handleAbortOrClose = streaming ? (onAbort || onClose) : onClose;
return (
<Dialog
open={open}
onClose={streaming ? undefined : onClose}
onClose={handleAbortOrClose}
maxWidth="sm"
fullWidth
aria-labelledby="pdf-dialog-title"
@@ -121,7 +123,9 @@ export default function ManifestPdfDialog({ open, filename, data, onClose }) {
borderColor: 'divider',
}}
>
{error ? (
{aborted ? (
<ErrorOutlinedIcon color="warning" />
) : error ? (
<ErrorOutlinedIcon color="error" />
) : streaming ? (
<CircularProgress size={22} />
@@ -134,6 +138,8 @@ export default function ManifestPdfDialog({ open, filename, data, onClose }) {
<Typography variant="subtitle1" component="div" fontWeight={600}>
{streaming
? (isTextDoc ? 'Dokument wird analysiert…' : 'PDF wird analysiert…')
: aborted
? 'Analyse abgebrochen'
: error
? 'Analyse fehlgeschlagen'
: (isTextDoc ? 'Dokument-Analyse abgeschlossen' : 'PDF-Analyse abgeschlossen')}
@@ -146,9 +152,8 @@ export default function ManifestPdfDialog({ open, filename, data, onClose }) {
</Box>
<IconButton
aria-label="close"
onClick={onClose}
onClick={handleAbortOrClose}
size="small"
disabled={streaming}
sx={{ color: (theme) => theme.palette.grey[500] }}
>
<CloseIcon fontSize="small" />
@@ -156,9 +161,9 @@ export default function ManifestPdfDialog({ open, filename, data, onClose }) {
</DialogTitle>
<DialogContent dividers sx={{ p: 2 }}>
{/* Error */}
{/* Error or Aborted Alert */}
{error && (
<Alert severity="error" icon={<ErrorOutlinedIcon />} sx={{ mb: 2 }}>
<Alert severity={aborted ? 'warning' : 'error'} icon={aborted ? undefined : <ErrorOutlinedIcon />} sx={{ mb: 2 }}>
<Typography variant="body2" fontWeight={600}>{error}</Typography>
</Alert>
)}
@@ -167,7 +172,7 @@ export default function ManifestPdfDialog({ open, filename, data, onClose }) {
<EventLog messages={messages} streaming={streaming} />
{/* Success notification */}
{hasResult && !streaming && !error && (
{hasResult && !streaming && !error && !aborted && (
<Alert severity="success" sx={{ mt: 2 }}>
Daten erfolgreich in das Formular übernommen.
</Alert>
@@ -175,9 +180,21 @@ export default function ManifestPdfDialog({ open, filename, data, onClose }) {
</DialogContent>
<DialogActions sx={{ p: 1.5, px: 2 }}>
<Button onClick={onClose} variant="contained" size="small" disabled={streaming}>
Schließen
</Button>
{streaming ? (
<Button
onClick={onAbort || onClose}
variant="outlined"
color="error"
size="small"
startIcon={<CloseIcon />}
>
Abbrechen
</Button>
) : (
<Button onClick={onClose} variant="contained" size="small">
Schließen
</Button>
)}
</DialogActions>
</Dialog>
);