diff --git a/ui/src/lib/model/domain.ts b/ui/src/lib/model/domain.ts index 4301254..e5c3daa 100644 --- a/ui/src/lib/model/domain.ts +++ b/ui/src/lib/model/domain.ts @@ -1,10 +1,18 @@ +export interface ZoneHistory { + id: string; + id_author: string; + default_ttl: number; + last_modified: Date; + published?: Date; +}; + export interface Domain { id: string; id_owner: string; id_provider: string; domain: string; group: string; - zone_history: Array; + zone_history: Array; // interface property wait: boolean; diff --git a/ui/src/routes/domains/[dn]/[[historyid]]/+layout.svelte b/ui/src/routes/domains/[dn]/[[historyid]]/+layout.svelte index f72630d..9859100 100644 --- a/ui/src/routes/domains/[dn]/[[historyid]]/+layout.svelte +++ b/ui/src/routes/domains/[dn]/[[historyid]]/+layout.svelte @@ -18,6 +18,7 @@ } from 'sveltestrap'; import { + getDomain as APIGetDomain, deleteDomain as APIDeleteDomain, } from '$lib/api/domains'; import { @@ -61,8 +62,8 @@ } let selectedHistory: string | undefined = data.history; - $: if (!data.history && domain && domain.zone_history && domain.zone_history.length > 0) { - selectedHistory = domain.zone_history[0]; + $: if (!data.history && $domains_idx[selectedDomain] && $domains_idx[selectedDomain].zone_history && $domains_idx[selectedDomain].zone_history.length > 0) { + selectedHistory = $domains_idx[selectedDomain].zone_history[0]; } $: if (selectedHistory && data.history != selectedHistory) { goto('/domains/' + encodeURIComponent(selectedDomain) + '/' + encodeURIComponent(selectedHistory)); @@ -88,18 +89,27 @@ selectedHistory = zm.id; } + async function getDomain(id: string): Promise { + return await APIGetDomain(id); + } + let domain: null | Domain = null; $: if ($domains_idx[selectedDomain]) { - domain = $domains_idx[selectedDomain]; - if (!domain.zone_history || domain.zone_history.length == 0) { + if (!$domains_idx[selectedDomain].zone_history || $domains_idx[selectedDomain].zone_history.length == 0) { importInProgress = true; - APIImportZone(domain).then( + APIImportZone($domains_idx[selectedDomain]).then( importZoneDone, (err: any) => { importInProgress = false; throw err; } ) + } else { + getDomain($domains_idx[selectedDomain].id).then( + (dn) => { + domain = dn; + } + ); } } @@ -228,7 +238,7 @@ class="bg-light py-2 sticky-top d-flex flex-column justify-content-between" style="overflow-y: auto; max-height: 100vh; z-index: 0" > - {#if domain} + {#if $domains_idx[selectedDomain]}
- {#if domain.zone_history} + {#if domain && domain.zone_history}
- {#if domain.zone_history.length && selectedHistory === domain.zone_history[0]} + {#if domain.zone_history.length && selectedHistory === $domains_idx[selectedDomain].zone_history[0]}