From 6ee2663374604c1a36671b8baefca76407dd810f Mon Sep 17 00:00:00 2001 From: Ronni Skansing Date: Thu, 9 Oct 2025 12:35:06 +0200 Subject: [PATCH] support for saving updates with CTRL+s Signed-off-by: Ronni Skansing --- frontend/src/lib/components/FormGrid.svelte | 30 ++++++++++++++- frontend/src/routes/api-sender/+page.svelte | 15 +++++--- frontend/src/routes/domain/+page.svelte | 42 ++++++++++++++------- frontend/src/routes/email/+page.svelte | 17 +++++---- frontend/src/routes/page/+page.svelte | 17 +++++---- frontend/src/routes/proxy/+page.svelte | 17 +++++---- 6 files changed, 97 insertions(+), 41 deletions(-) diff --git a/frontend/src/lib/components/FormGrid.svelte b/frontend/src/lib/components/FormGrid.svelte index 939d98d..8c6b6bb 100644 --- a/frontend/src/lib/components/FormGrid.svelte +++ b/frontend/src/lib/components/FormGrid.svelte @@ -1,7 +1,35 @@
diff --git a/frontend/src/routes/api-sender/+page.svelte b/frontend/src/routes/api-sender/+page.svelte index e67a4ee..92dec83 100644 --- a/frontend/src/routes/api-sender/+page.svelte +++ b/frontend/src/routes/api-sender/+page.svelte @@ -126,14 +126,15 @@ return []; }; - const onSubmit = async () => { + const onSubmit = async (event) => { try { isSubmitting = true; + const saveOnly = event?.detail?.saveOnly || false; if (modalMode === 'create' || modalMode === 'copy') { await onClickCreate(); return; } else { - await onClickUpdate(); + await onClickUpdate(saveOnly); return; } } finally { @@ -157,15 +158,17 @@ } }; - const onClickUpdate = async () => { + const onClickUpdate = async (saveOnly = false) => { try { const res = await api.apiSender.update(formValues); if (!res.success) { modalError = res.error; throw res.error; } - addToast('Updated API sender', 'Success'); - closeEditModal(); + addToast(saveOnly ? 'API sender saved' : 'Updated API sender', 'Success'); + if (!saveOnly) { + closeEditModal(); + } refreshConfigurations(); } catch (err) { console.error('failed to update API sender:', err); @@ -352,7 +355,7 @@ {/each} - + diff --git a/frontend/src/routes/domain/+page.svelte b/frontend/src/routes/domain/+page.svelte index 6235eef..59b9e51 100644 --- a/frontend/src/routes/domain/+page.svelte +++ b/frontend/src/routes/domain/+page.svelte @@ -172,7 +172,8 @@ return null; }; - const onSubmitPageUpdate = async () => { + const onSubmitPageUpdate = async (event) => { + const saveOnly = event?.detail?.saveOnly || false; try { isSubmitting = true; updateContentError = ''; @@ -218,20 +219,23 @@ updateContentError = res.error; return; } - addToast('Domain updated', 'Success'); - closeAllModals(); + addToast(saveOnly ? 'Domain content saved' : 'Domain updated', 'Success'); + if (!saveOnly) { + closeAllModals(); + } refreshDomains(); } catch (e) { - addToast('Failed to update domain', 'Error'); + addToast(saveOnly ? 'Failed to save domain content' : 'Failed to update domain', 'Error'); console.error('failed to update domain', e); } finally { isSubmitting = false; } }; - const onSubmit = async () => { + const onSubmit = async (event) => { try { // reset validate + const saveOnly = event?.detail?.saveOnly || false; managedTLSInputElement?.setCustomValidity(''); ownManagedTLSInputElement?.setCustomValidity(''); ownManagedTLSKeyElement?.setCustomValidity(''); @@ -262,7 +266,7 @@ await onClickCreate(); return; } else { - await onClickUpdate(); + await onClickUpdate(saveOnly); return; } } finally { @@ -305,7 +309,7 @@ } }; - const onClickUpdate = async () => { + const onClickUpdate = async (saveOnly = false) => { modalError = ''; // clear site contents if not hosting a website or if proxy domain if (!formValues.hostWebsite || isProxyDomain) { @@ -350,11 +354,13 @@ modalError = res.error; return; } - addToast('Domain updated', 'Success'); - closeAllModals(); + addToast(saveOnly ? 'Domain saved' : 'Domain updated', 'Success'); + if (!saveOnly) { + closeAllModals(); + } refreshDomains(); } catch (e) { - addToast('Failed to update domain', 'Error'); + addToast(saveOnly ? 'Failed to save domain' : 'Failed to update domain', 'Error'); console.error('failed to update domain', e); } }; @@ -716,7 +722,7 @@ onClose={closeAllModals} {isSubmitting} > - + @@ -821,7 +827,12 @@ onClose={closeAllModals} {isSubmitting} > - + - + { + const onSubmit = async (event) => { try { isSubmitting = true; + const saveOnly = event?.detail?.saveOnly || false; if (modalMode === 'create' || modalMode === 'copy') { await onClickCreate(); return; } else { - await onClickUpdate(); + await onClickUpdate(saveOnly); return; } } finally { @@ -176,7 +177,7 @@ } }; - const onClickUpdate = async () => { + const onClickUpdate = async (saveOnly = false) => { try { const res = await api.email.update({ id: formValues.id, @@ -192,11 +193,13 @@ return; } modalError = ''; - closeModal(); - addToast('Email updated', 'Success'); + addToast(saveOnly ? 'Email saved' : 'Email updated', 'Success'); + if (!saveOnly) { + closeModal(); + } refreshEmails(); } catch (e) { - addToast('Failed to update email', 'Error'); + addToast(saveOnly ? 'Failed to save email' : 'Failed to update email', 'Error'); console.error('failed to update email', e); } }; @@ -423,7 +426,7 @@ {/each} - +
diff --git a/frontend/src/routes/page/+page.svelte b/frontend/src/routes/page/+page.svelte index df85fe4..508f520 100644 --- a/frontend/src/routes/page/+page.svelte +++ b/frontend/src/routes/page/+page.svelte @@ -140,14 +140,15 @@ } }; - const onSubmit = async () => { + const onSubmit = async (event) => { try { isSubmitting = true; + const saveOnly = event?.detail?.saveOnly || false; if (modalMode === 'create' || modalMode === 'copy') { await create(); return; } else { - await update(); + await update(saveOnly); return; } } finally { @@ -171,7 +172,7 @@ } }; - const update = async () => { + const update = async (saveOnly = false) => { try { const updateData = { name: formValues.name, @@ -183,11 +184,13 @@ formError = res.error; return; } - addToast('Page updated', 'Success'); - closeModal(); + addToast(saveOnly ? 'Page saved' : 'Page updated', 'Success'); + if (!saveOnly) { + closeModal(); + } refreshPages(); } catch (e) { - addToast('Failed to update page', 'Error'); + addToast(saveOnly ? 'Failed to save page' : 'Failed to update page', 'Error'); console.error('failed to update page', e); } }; @@ -359,7 +362,7 @@ {/each} - +
{ + const onSubmit = async (event) => { try { isSubmitting = true; + const saveOnly = event?.detail?.saveOnly || false; if (modalMode === 'create' || modalMode === 'copy') { await create(); return; } else { - await update(); + await update(saveOnly); return; } } finally { @@ -185,7 +186,7 @@ portal.example.com: } }; - const update = async () => { + const update = async (saveOnly = false) => { try { const updateData = { name: formValues.name, @@ -199,11 +200,13 @@ portal.example.com: formError = res.error; return; } - addToast('Proxy updated', 'Success'); - closeModal(); + addToast(saveOnly ? 'Proxy saved' : 'Proxy updated', 'Success'); + if (!saveOnly) { + closeModal(); + } refreshProxies(); } catch (e) { - addToast('Failed to update Proxy', 'Error'); + addToast(saveOnly ? 'Failed to save Proxy' : 'Failed to update Proxy', 'Error'); console.error('failed to update Proxy', e); } }; @@ -372,7 +375,7 @@ portal.example.com: {/each} - +