diff --git a/src/components/domains/ARow.svelte b/src/components/domains/ARow.svelte index c730b50..d01b334 100644 --- a/src/components/domains/ARow.svelte +++ b/src/components/domains/ARow.svelte @@ -1,5 +1,5 @@ @@ -36,6 +44,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/components/domains/CaaRow.svelte b/src/components/domains/CaaRow.svelte index 9665d65..e7e2ae9 100644 --- a/src/components/domains/CaaRow.svelte +++ b/src/components/domains/CaaRow.svelte @@ -18,9 +18,17 @@ }; let editPopup: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -41,6 +49,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/components/domains/CnameRow.svelte b/src/components/domains/CnameRow.svelte index b2ccd2a..7fbe737 100644 --- a/src/components/domains/CnameRow.svelte +++ b/src/components/domains/CnameRow.svelte @@ -14,9 +14,17 @@ }; let editPopup: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -36,6 +44,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/components/domains/MxRow.svelte b/src/components/domains/MxRow.svelte index cc70698..d5559e5 100644 --- a/src/components/domains/MxRow.svelte +++ b/src/components/domains/MxRow.svelte @@ -17,9 +17,17 @@ }; let editPopup: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -40,6 +48,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/components/domains/NsRow.svelte b/src/components/domains/NsRow.svelte index c0aec7d..34cd1c6 100644 --- a/src/components/domains/NsRow.svelte +++ b/src/components/domains/NsRow.svelte @@ -15,9 +15,17 @@ let editPopup: boolean = false; export let locked: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -39,6 +47,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/components/domains/SoaRow.svelte b/src/components/domains/SoaRow.svelte index e96814c..ea2cc10 100644 --- a/src/components/domains/SoaRow.svelte +++ b/src/components/domains/SoaRow.svelte @@ -22,9 +22,17 @@ let editPopup: boolean = false; export let locked: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } function numLength(n: number) { @@ -64,6 +72,10 @@
Expire
+ + {#if errorMessage} +
{errorMessage}
+ {/if} diff --git a/src/components/domains/SrvRow.svelte b/src/components/domains/SrvRow.svelte index bd849c6..0d3d129 100644 --- a/src/components/domains/SrvRow.svelte +++ b/src/components/domains/SrvRow.svelte @@ -19,9 +19,17 @@ }; let editPopup: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -44,6 +52,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/components/domains/TxtRow.svelte b/src/components/domains/TxtRow.svelte index b14165b..b21d21c 100644 --- a/src/components/domains/TxtRow.svelte +++ b/src/components/domains/TxtRow.svelte @@ -15,9 +15,17 @@ }; let editPopup: boolean = false; + let errorMessage: string | null = null; function save() { - item.update(editItem); + item + .update(editItem) + .then(() => { + editPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -37,6 +45,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
diff --git a/src/utils/rest-table.ts b/src/utils/rest-table.ts index 0d91f8f..e5796bc 100644 --- a/src/utils/rest-table.ts +++ b/src/utils/rest-table.ts @@ -58,13 +58,11 @@ export class RestTable implements IPromiseLike> { })(); } - addItem(item: T) { - (async () => { - let f = await LOGIN.clientRequest(this.apiUrl, {method: "POST", body: JSON.stringify(item)}); - if (f.status !== 200) throw new Error("Unexpected status code: " + f.status); - this.rows.push(new RestItem(this, item)); - this.updateSubs(); - })(); + async addItem(item: T): Promise { + let f = await LOGIN.clientRequest(this.apiUrl, {method: "POST", body: JSON.stringify(item)}); + if (f.status !== 201) throw new Error("Unexpected status code: " + f.status); + this.rows.push(new RestItem(this, item)); + this.updateSubs(); } subscribe(run: Subscriber>): Unsubscriber { diff --git a/src/views/DomainTableView.svelte b/src/views/DomainTableView.svelte index b73ac9c..b5ab88a 100644 --- a/src/views/DomainTableView.svelte +++ b/src/views/DomainTableView.svelte @@ -20,10 +20,18 @@ let createItem: ApiRecordFormat | null = emptyRecord == null ? null : emptyRecord(); let createPopup: boolean = false; + let errorMessage: string | null = null; function createRecord() { if (createItem == null) return; - table.addItem(createItem); + table + .addItem(createItem) + .then(() => { + createPopup = false; + }) + .catch(x => { + errorMessage = x; + }); } @@ -34,6 +42,10 @@ + + {#if errorMessage} +
{errorMessage}
+ {/if}
{/if} @@ -51,7 +63,7 @@ - Error loading row for {item.data.Hdr.Name}: {reason} + Error loading row for {item.data.name} ({item.data.id}): {reason}