From 1b81647ff4688e17bf337f4c8ade51dba92cdc4a Mon Sep 17 00:00:00 2001 From: Wayne <5291640+ringoinca@users.noreply.github.com> Date: Tue, 22 Jul 2025 16:46:13 +0300 Subject: [PATCH] Ingestion form update --- .../custom/IngestionSourceForm.svelte | 21 +++++++-- .../routes/dashboard/ingestions/+page.svelte | 45 ++++++++++++++++--- 2 files changed, 56 insertions(+), 10 deletions(-) diff --git a/packages/frontend/src/lib/components/custom/IngestionSourceForm.svelte b/packages/frontend/src/lib/components/custom/IngestionSourceForm.svelte index 386bed8..13b4f7f 100644 --- a/packages/frontend/src/lib/components/custom/IngestionSourceForm.svelte +++ b/packages/frontend/src/lib/components/custom/IngestionSourceForm.svelte @@ -12,7 +12,7 @@ onSubmit }: { source?: IngestionSource | null; - onSubmit: (data: CreateIngestionSourceDto) => void; + onSubmit: (data: CreateIngestionSourceDto) => Promise; } = $props(); const providerOptions = [ @@ -38,9 +38,16 @@ providerOptions.find((p) => p.value === formData.provider)?.label ?? 'Select a provider' ); - const handleSubmit = (event: Event) => { + let isSubmitting = $state(false); + + const handleSubmit = async (event: Event) => { event.preventDefault(); - onSubmit(formData); + isSubmitting = true; + try { + await onSubmit(formData); + } finally { + isSubmitting = false; + } }; @@ -118,6 +125,12 @@ {/if} - + diff --git a/packages/frontend/src/routes/dashboard/ingestions/+page.svelte b/packages/frontend/src/routes/dashboard/ingestions/+page.svelte index f655cd8..fdf1d1b 100644 --- a/packages/frontend/src/routes/dashboard/ingestions/+page.svelte +++ b/packages/frontend/src/routes/dashboard/ingestions/+page.svelte @@ -16,7 +16,10 @@ let ingestionSources = $state(data.ingestionSources); let isDialogOpen = $state(false); + let isDeleteDialogOpen = $state(false); let selectedSource = $state(null); + let sourceToDelete = $state(null); + let isDeleting = $state(false); const openCreateDialog = () => { selectedSource = null; @@ -28,12 +31,22 @@ isDialogOpen = true; }; - const handleDelete = async (id: string) => { - if (!confirm('Are you sure you want to delete this ingestion source?')) { - return; + const openDeleteDialog = (source: IngestionSource) => { + sourceToDelete = source; + isDeleteDialogOpen = true; + }; + + const confirmDelete = async () => { + if (!sourceToDelete) return; + isDeleting = true; + try { + await api(`/ingestion-sources/${sourceToDelete.id}`, { method: 'DELETE' }); + ingestionSources = ingestionSources.filter((s) => s.id !== sourceToDelete!.id); + isDeleteDialogOpen = false; + sourceToDelete = null; + } finally { + isDeleting = false; } - await api(`/ingestion-sources/${id}`, { method: 'DELETE' }); - ingestionSources = ingestionSources.filter((s) => s.id !== id); }; const handleSync = async (id: string) => { @@ -170,7 +183,7 @@ handleSync(source.id)}>Sync - handleDelete(source.id)} + openDeleteDialog(source)} >Delete @@ -201,3 +214,23 @@ + + + + + Are you sure you want to delete this ingestion? + + This will delete all archived emails, attachments, indexing, and files associated with this + ingestion. If you only want to stop syncing new emails, you can pause the ingestion instead. + + + + + + + + + +