ui: Fix typescript error with new history in domains
This commit is contained in:
parent
d980711e37
commit
8a51572ad5
|
@ -1,10 +1,10 @@
|
|||
import { handleEmptyApiResponse, handleApiResponse } from '$lib/errors';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { Provider } from '$lib/model/provider';
|
||||
|
||||
export async function listDomains(): Promise<Array<Domain>> {
|
||||
export async function listDomains(): Promise<Array<DomainInList>> {
|
||||
const res = await fetch('/api/domains', {headers: {'Accept': 'application/json'}});
|
||||
return (await handleApiResponse<Array<Domain>>(res));
|
||||
return (await handleApiResponse<Array<DomainInList>>(res));
|
||||
}
|
||||
|
||||
export async function getDomain(id: string): Promise<Domain> {
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { handleApiResponse } from '$lib/errors';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ServiceCombined, ServiceMeta } from '$lib/model/service';
|
||||
import type { ServiceRecord, Zone, ZoneMeta } from '$lib/model/zone';
|
||||
|
||||
export async function getZone(domain: Domain, id: string): Promise<Zone> {
|
||||
export async function getZone(domain: Domain | DomainInList, id: string): Promise<Zone> {
|
||||
const dnid = encodeURIComponent(domain.id);
|
||||
id = encodeURIComponent(id);
|
||||
const res = await fetch(`/api/domains/${dnid}/zone/${id}`, {headers: {'Accept': 'application/json'}});
|
||||
return await handleApiResponse<Zone>(res);
|
||||
}
|
||||
|
||||
export async function viewZone(domain: Domain, id: string): Promise<string> {
|
||||
export async function viewZone(domain: Domain | DomainInList, id: string): Promise<string> {
|
||||
const dnid = encodeURIComponent(domain.id);
|
||||
id = encodeURIComponent(id);
|
||||
const res = await fetch(`/api/domains/${dnid}/zone/${id}/view`, {
|
||||
|
@ -20,7 +20,7 @@ export async function viewZone(domain: Domain, id: string): Promise<string> {
|
|||
return await handleApiResponse<string>(res);
|
||||
}
|
||||
|
||||
export async function importZone(domain: Domain): Promise<ZoneMeta> {
|
||||
export async function importZone(domain: Domain | DomainInList): Promise<ZoneMeta> {
|
||||
const dnid = encodeURIComponent(domain.id);
|
||||
const res = await fetch(`/api/domains/${dnid}/import_zone`, {
|
||||
method: 'POST',
|
||||
|
@ -29,7 +29,7 @@ export async function importZone(domain: Domain): Promise<ZoneMeta> {
|
|||
return await handleApiResponse<ZoneMeta>(res);
|
||||
}
|
||||
|
||||
export async function applyZone(domain: Domain, id: string, selectedDiffs: Array<string>): Promise<ZoneMeta> {
|
||||
export async function applyZone(domain: Domain | DomainInList, id: string, selectedDiffs: Array<string>): Promise<ZoneMeta> {
|
||||
const dnid = encodeURIComponent(domain.id);
|
||||
id = encodeURIComponent(id);
|
||||
const res = await fetch(`/api/domains/${dnid}/zone/${id}/apply_changes`, {
|
||||
|
@ -40,7 +40,7 @@ export async function applyZone(domain: Domain, id: string, selectedDiffs: Array
|
|||
return await handleApiResponse<ZoneMeta>(res);
|
||||
}
|
||||
|
||||
export async function diffZone(domain: Domain, id1: string, id2: string): Promise<Array<string>> {
|
||||
export async function diffZone(domain: Domain | DomainInList, id1: string, id2: string): Promise<Array<string>> {
|
||||
const dnid = encodeURIComponent(domain.id);
|
||||
id1 = encodeURIComponent(id1);
|
||||
id2 = encodeURIComponent(id2);
|
||||
|
@ -51,7 +51,7 @@ export async function diffZone(domain: Domain, id1: string, id2: string): Promis
|
|||
return await handleApiResponse<Array<string>>(res);
|
||||
}
|
||||
|
||||
export async function addZoneService(domain: Domain, id: string, service: ServiceCombined): Promise<Zone> {
|
||||
export async function addZoneService(domain: Domain | DomainInList, id: string, service: ServiceCombined): Promise<Zone> {
|
||||
let subdomain = service._domain;
|
||||
if (subdomain === '') subdomain = '@';
|
||||
|
||||
|
@ -67,7 +67,7 @@ export async function addZoneService(domain: Domain, id: string, service: Servic
|
|||
return await handleApiResponse<Zone>(res);
|
||||
}
|
||||
|
||||
export async function updateZoneService(domain: Domain, id: string, service: ServiceCombined): Promise<Zone> {
|
||||
export async function updateZoneService(domain: Domain | DomainInList, id: string, service: ServiceCombined): Promise<Zone> {
|
||||
const dnid = encodeURIComponent(domain.id);
|
||||
id = encodeURIComponent(id);
|
||||
|
||||
|
@ -79,7 +79,7 @@ export async function updateZoneService(domain: Domain, id: string, service: Ser
|
|||
return await handleApiResponse<Zone>(res);
|
||||
}
|
||||
|
||||
export async function deleteZoneService(domain: Domain, id: string, service: ServiceMeta): Promise<Zone> {
|
||||
export async function deleteZoneService(domain: Domain | DomainInList, id: string, service: ServiceMeta): Promise<Zone> {
|
||||
let subdomain = service._domain;
|
||||
if (subdomain === '') subdomain = '@';
|
||||
|
||||
|
@ -95,7 +95,7 @@ export async function deleteZoneService(domain: Domain, id: string, service: Ser
|
|||
return await handleApiResponse<Zone>(res);
|
||||
}
|
||||
|
||||
export async function getServiceRecords(domain: Domain, id: string, service: ServiceMeta): Promise<Array<ServiceRecord>> {
|
||||
export async function getServiceRecords(domain: Domain | DomainInList, id: string, service: ServiceMeta): Promise<Array<ServiceRecord>> {
|
||||
let subdomain = service._domain;
|
||||
if (subdomain === '') subdomain = '@';
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
import NewDomainInput from '$lib/components/NewDomainInput.svelte';
|
||||
import ZoneList from '$lib/components/ZoneList.svelte';
|
||||
import ProviderList from '$lib/components/providers/List.svelte';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { DomainInList } from '$lib/model/domain';
|
||||
import type { Provider } from '$lib/model/provider';
|
||||
import { domains, refreshDomains } from '$lib/stores/domains';
|
||||
import { providers, providersSpecs, refreshProviders, refreshProvidersSpecs } from '$lib/stores/providers';
|
||||
|
@ -31,7 +31,7 @@
|
|||
|
||||
let noDomainsList = false;
|
||||
|
||||
let filteredDomains: Array<Domain> = [];
|
||||
let filteredDomains: Array<DomainInList> = [];
|
||||
export let filteredProvider: Provider | null = null;
|
||||
let filteredGroup: string | null = null;
|
||||
let isGroupModalOpen = false;
|
||||
|
@ -45,7 +45,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function showDomain(event: CustomEvent<Domain>) {
|
||||
function showDomain(event: CustomEvent<DomainInList>) {
|
||||
goto('/domains/' + encodeURIComponent(event.detail.domain));
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { getProviderSpec } from '$lib/api/provider_specs';
|
||||
import ServiceSelectorItem from '$lib/components/ServiceSelectorItem.svelte';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ProviderInfos } from '$lib/model/provider';
|
||||
import type { ServiceCombined } from '$lib/model/service';
|
||||
import { passRestrictions, type ServiceInfos } from '$lib/model/service_specs';
|
||||
|
@ -17,7 +17,7 @@
|
|||
import { t } from '$lib/translations';
|
||||
|
||||
export let dn: string;
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let value: string | null = null;
|
||||
export let zservices: Record<string, Array<ServiceCombined>>;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { addZoneService } from '$lib/api/zone';
|
||||
import { fqdn, validateDomain } from '$lib/dns';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { Zone } from '$lib/model/zone';
|
||||
import { t } from '$lib/translations';
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
|||
}
|
||||
|
||||
export let dn: string;
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let value: string = "";
|
||||
export let zone: Zone;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
import ModalFooter from '$lib/components/domains/ModalFooter.svelte';
|
||||
import ModalHeader from '$lib/components/domains/ModalHeader.svelte';
|
||||
import { validateDomain } from '$lib/dns';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import { t } from '$lib/translations';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
@ -21,13 +21,9 @@
|
|||
export let isOpen = false;
|
||||
const toggle = () => (isOpen = !isOpen);
|
||||
|
||||
$: {
|
||||
if (isOpen) {
|
||||
value = "";
|
||||
}
|
||||
}
|
||||
$: if (isOpen) value = "";
|
||||
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let value: string = "";
|
||||
|
||||
let newDomainState: boolean | undefined = undefined;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import { deleteZoneService, getServiceRecords, updateZoneService } from '$lib/api/zone';
|
||||
import Record from '$lib/components/domains/Record.svelte';
|
||||
import ResourceInput from '$lib/components/ResourceInput.svelte';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ServiceCombined } from '$lib/model/service';
|
||||
import { ZoneViewGrid, ZoneViewList, ZoneViewRecords } from '$lib/model/usersettings';
|
||||
import type { ServiceRecord } from '$lib/model/zone';
|
||||
|
@ -27,7 +27,7 @@
|
|||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let service: ServiceCombined | null = null;
|
||||
export let zoneId: string;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
import ModalHeader from '$lib/components/domains/ModalHeader.svelte';
|
||||
import ResourceInput from '$lib/components/ResourceInput.svelte';
|
||||
import { fqdn } from '$lib/dns';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ServiceCombined } from '$lib/model/service';
|
||||
import { servicesSpecs } from '$lib/stores/services';
|
||||
import type { Zone } from '$lib/model/zone';
|
||||
|
@ -22,7 +22,7 @@
|
|||
export let isOpen = false;
|
||||
const toggle = () => (isOpen = !isOpen);
|
||||
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let service: ServiceCombined;
|
||||
export let zone: Zone;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import ModalHeader from '$lib/components/domains/ModalHeader.svelte';
|
||||
import ServiceSelector from '$lib/components/ServiceSelector.svelte';
|
||||
import { fqdn } from '$lib/dns';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ServiceCombined } from '$lib/model/service';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
@ -25,7 +25,7 @@
|
|||
}
|
||||
|
||||
export let dn: string;
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let value: string | null = null;
|
||||
export let zservices: Record<string, Array<ServiceCombined>>;
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
import { deleteZoneService } from '$lib/api/zone';
|
||||
import Service from '$lib/components/domains/Service.svelte';
|
||||
import { fqdn } from '$lib/dns';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ServiceCombined } from '$lib/model/service';
|
||||
import { ZoneViewGrid } from '$lib/model/usersettings';
|
||||
import { userSession } from '$lib/stores/usersession';
|
||||
|
@ -22,7 +22,7 @@
|
|||
|
||||
export let aliases: Array<string> = [];
|
||||
export let dn: string;
|
||||
export let origin: Domain;
|
||||
export let origin: Domain | DomainInList;
|
||||
export let showSubdomainsList = false;
|
||||
export let services: Array<ServiceCombined>;
|
||||
export let zoneId: string;
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
import ServiceModal from '$lib/components/domains/ServiceModal.svelte';
|
||||
import ServiceSelectorModal from '$lib/components/domains/ServiceSelectorModal.svelte';
|
||||
import SubdomainItem from '$lib/components/domains/SubdomainItem.svelte';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ServiceCombined } from '$lib/model/service';
|
||||
import type { Zone } from '$lib/model/zone';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
export let origin: Domain;
|
||||
export let origin: DomainInList | Domain;
|
||||
export let showSubdomainsList: boolean;
|
||||
export let sortedDomains: Array<string>;
|
||||
export let zone: Zone;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
import { addDomain } from '$lib/api/domains';
|
||||
import { listImportableDomains } from '$lib/api/provider';
|
||||
import ZoneList from '$lib/components/ZoneList.svelte';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { DomainInList } from '$lib/model/domain';
|
||||
import type { Provider } from '$lib/model/provider';
|
||||
import { providersSpecs } from '$lib/stores/providers';
|
||||
import { domains_idx, refreshDomains } from '$lib/stores/domains';
|
||||
|
@ -44,8 +44,8 @@
|
|||
);
|
||||
}
|
||||
|
||||
function haveDomain($domains_idx: Record<string, Domain>, name: string) {
|
||||
let domain: Domain | undefined = undefined;
|
||||
function haveDomain($domains_idx: Record<string, DomainInList>, name: string) {
|
||||
let domain: DomainInList | undefined = undefined;
|
||||
if (name[name.length-1] == ".") {
|
||||
domain = $domains_idx[name];
|
||||
} else {
|
||||
|
|
|
@ -6,13 +6,25 @@ export interface ZoneHistory {
|
|||
published?: Date;
|
||||
};
|
||||
|
||||
export interface DomainInList {
|
||||
id: string;
|
||||
id_owner: string;
|
||||
id_provider: string;
|
||||
domain: string;
|
||||
group: string;
|
||||
zone_history: Array<string>;
|
||||
|
||||
// interface property
|
||||
wait: boolean;
|
||||
};
|
||||
|
||||
export interface Domain {
|
||||
id: string;
|
||||
id_owner: string;
|
||||
id_provider: string;
|
||||
domain: string;
|
||||
group: string;
|
||||
zone_history: Array<string | ZoneHistory>;
|
||||
zone_history: Array<ZoneHistory>;
|
||||
|
||||
// interface property
|
||||
wait: boolean;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { derived, writable, type Writable } from 'svelte/store';
|
||||
import { listDomains } from '$lib/api/domains';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { DomainInList } from '$lib/model/domain';
|
||||
|
||||
export const domains: Writable<null | Array<Domain>> = writable(null);
|
||||
export const domains: Writable<null | Array<DomainInList>> = writable(null);
|
||||
|
||||
export async function refreshDomains() {
|
||||
const data = await listDomains();
|
||||
|
@ -12,7 +12,7 @@ export async function refreshDomains() {
|
|||
|
||||
export const groups = derived(
|
||||
domains,
|
||||
($domains: null|Array<Domain>) => {
|
||||
($domains: null|Array<DomainInList>) => {
|
||||
const groups: Record<string, null> = { };
|
||||
|
||||
if ($domains) {
|
||||
|
@ -29,8 +29,8 @@ export const groups = derived(
|
|||
|
||||
export const domains_idx = derived(
|
||||
domains,
|
||||
($domains: null|Array<Domain>) => {
|
||||
const idx: Record<string, Domain> = { };
|
||||
($domains: null|Array<DomainInList>) => {
|
||||
const idx: Record<string, DomainInList> = { };
|
||||
|
||||
if ($domains) {
|
||||
for (const d of $domains) {
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
viewZone as APIViewZone,
|
||||
} from '$lib/api/zone';
|
||||
import ImgProvider from '$lib/components/providers/ImgProvider.svelte';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { Domain, DomainInList } from '$lib/model/domain';
|
||||
import type { ZoneMeta } from '$lib/model/zone';
|
||||
import { domains, domains_idx, refreshDomains } from '$lib/stores/domains';
|
||||
import { providers, providers_idx, refreshProviders } from '$lib/stores/providers';
|
||||
|
@ -44,10 +44,10 @@
|
|||
if (!$domains) refreshDomains();
|
||||
if (!$providers) refreshProviders();
|
||||
|
||||
let domainsByGroup: Record<string, Array<Domain>> = {};
|
||||
let domainsByGroup: Record<string, Array<DomainInList>> = {};
|
||||
$: {
|
||||
if ($domains) {
|
||||
const tmp: Record<string, Array<Domain>> = { };
|
||||
const tmp: Record<string, Array<DomainInList>> = { };
|
||||
|
||||
for (const domain of $domains) {
|
||||
if (tmp[domain.group] === undefined) {
|
||||
|
@ -63,7 +63,7 @@
|
|||
|
||||
let selectedHistory: string | undefined = data.history;
|
||||
$: 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];
|
||||
selectedHistory = $domains_idx[selectedDomain].zone_history[0] as string;
|
||||
}
|
||||
$: if (selectedHistory && data.history != selectedHistory) {
|
||||
goto('/domains/' + encodeURIComponent(selectedDomain) + '/' + encodeURIComponent(selectedHistory));
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
import { getZone } from '$lib/api/zone';
|
||||
import SubdomainList from '$lib/components/domains/SubdomainList.svelte';
|
||||
import { domainCompare, fqdn } from '$lib/dns';
|
||||
import type { Domain } from '$lib/model/domain';
|
||||
import type { DomainInList } from '$lib/model/domain';
|
||||
import type { Zone } from '$lib/model/zone';
|
||||
import { domains_idx } from '$lib/stores/domains';
|
||||
import { servicesSpecs, refreshServicesSpecs } from '$lib/stores/services';
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
export let data: {domain: string; history: string;};
|
||||
|
||||
let domain: Domain|null = null;
|
||||
let domain: DomainInList | null = null;
|
||||
$: if ($domains_idx[data.domain]) {
|
||||
domain = $domains_idx[data.domain];
|
||||
zoneId = null;
|
||||
|
@ -40,7 +40,7 @@
|
|||
}
|
||||
|
||||
let zone: Zone | null = null;
|
||||
async function refreshZone(domain: Domain, zoneId: string) {
|
||||
async function refreshZone(domain: DomainInList, zoneId: string) {
|
||||
zone = await getZone(domain, zoneId);
|
||||
}
|
||||
$: if (domain && zoneId) refreshZone(domain, zoneId);
|
||||
|
|
Loading…
Reference in New Issue
Block a user