Fix some typescript errors

This commit is contained in:
nemunaire 2023-11-28 11:24:42 +01:00
parent 820db44d7a
commit 51d4687012
21 changed files with 62 additions and 21 deletions

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">
@ -20,11 +22,12 @@
applyZone as APIApplyZone,
diffZone as APIDiffZone,
} from '$lib/api/zone';
import type { Domain, DomainInList } from '$lib/model/domain';
import { t } from '$lib/translations';
const dispatch = createEventDispatcher();
export let domain: string = '';
export let domain: DomainInList | Domain;
export let selectedHistory: string = '';
export let isOpen = false;

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">
@ -20,11 +22,12 @@
import {
importZone as APIImportZone,
} from '$lib/api/zone';
import type { Domain, DomainInList } from '$lib/model/domain';
import { t } from '$lib/translations';
const dispatch = createEventDispatcher();
export let domain: string = '';
export let domain: Domain | DomainInList;
export let selectedHistory: string = '';
export let isOpen = false;

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">
@ -14,12 +16,13 @@
import {
viewZone as APIViewZone,
} from '$lib/api/zone';
import type { Domain, DomainInList } from '$lib/model/domain';
import { t } from '$lib/translations';
export let isOpen = false;
let zoneContent: null | string = null;
function Open(domain: string, selectedHistory: string): void {
function Open(domain: Domain | DomainInList, selectedHistory: string): void {
zoneContent = null;
isOpen = true;
APIViewZone(domain, selectedHistory).then(

View File

@ -11,6 +11,7 @@
domain: string;
id_provider: string;
group?: string;
href?: string;
}
export let button = false;

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">

View File

@ -1,5 +1,7 @@
<script context="module" lang="ts">
export const controls = { };
import type { ModalController } from '$lib/model/modal_controller';
export const controls: ModalController = { };
</script>
<script lang="ts">

View File

@ -26,7 +26,7 @@
url = value;
}
function updateValue(url) {
function updateValue(url: string) {
if (kind == "mail") {
value = "mailto:" + url;
} else {

View File

@ -86,6 +86,7 @@
<span
role="button"
on:click={() => {value.Parameters.splice(k, 1); value = value;}}
on:keypress={() => {value.Parameters.splice(k, 1); value = value;}}
>
<Icon
name="x-circle-fill"
@ -99,6 +100,7 @@
class="badge bg-primary"
role="button"
on:click={() => {if (value.Parameters == null) value.Parameters = []; value.Parameters.push({Tag:"", Value: "", edit: true}); value = value;}}
on:keypress={() => {if (value.Parameters == null) value.Parameters = []; value.Parameters.push({Tag:"", Value: "", edit: true}); value = value;}}
>
<Icon name="plus" /> Add parameter
</span>

View File

@ -41,7 +41,7 @@
}
}
function checkBase64(val: string): bool {
function checkBase64(val: string): boolean {
try {
atob(val);
return true;
@ -50,7 +50,7 @@
}
}
let feedback: string|null = null;
let feedback: string|undefined = undefined;
$: {
if (inputmax && value > inputmax) {
feedback = t.get('errors.too-high', {max: inputmax});
@ -67,7 +67,7 @@
feedback = t.get("errors.base64") + " " + t.get("errors.base64-illegal-char");
}
} else {
feedback = null;
feedback = undefined;
}
}
</script>
@ -92,7 +92,7 @@
type={inputtype}
class="fw-bold"
{feedback}
invalid={feedback !== null}
invalid={feedback !== undefined}
min={inputmin}
max={inputmax}
placeholder={specs.placeholder}

View File

@ -1,3 +1,5 @@
import type { Domain } from '$lib/model/domain';
export const dns_common_types: Array<string> = ['ANY', 'A', 'AAAA', 'NS', 'SRV', 'MX', 'TXT', 'SOA'];
export function fqdn(input: string, origin: string) {

View File

@ -3,6 +3,8 @@ export interface ZoneHistory {
id_author: string;
default_ttl: number;
last_modified: Date;
commit_message: string;
commit_date: Date;
published?: Date;
};

View File

@ -0,0 +1,3 @@
export interface ModalController {
Open?: function(): void;
};

View File

@ -15,8 +15,8 @@ export interface LoginForm {
export interface User {
id: string;
email: string;
CreatedAt: Date;
LastSeen: Date;
created_at: Date;
last_seen: Date;
settings: UserSettings;
}

View File

@ -47,6 +47,10 @@ export const domains_by_groups = derived(
($domains: null|Array<DomainInList>) => {
const groups: Record<string, Array<DomainInList>> = { };
if ($domains === null) {
return groups;
}
for (const domain of $domains) {
if (groups[domain.group] === undefined) {
groups[domain.group] = [];

View File

@ -4,6 +4,7 @@ import {
retrieveZone as APIRetrieveZone,
getZone as APIGetZone,
} from '$lib/api/zone';
import type { Domain, DomainInList } from '$lib/model/domain';
import type { Zone } from '$lib/model/zone';
import { refreshDomains } from '$lib/stores/domains';
@ -24,7 +25,7 @@ export const sortedDomains = derived(
},
);
export async function getZone(domain: string, zoneId: string) {
export async function getZone(domain: DomainInList | Domain, zoneId: string) {
thisZone.set(null);
const zone = await APIGetZone(domain, zoneId);

View File

@ -22,7 +22,7 @@ const mutex = new Mutex();
const requests: Record<string, Promise<User>> = { };
export async function getUser(id: string, force: bool) {
export async function getUser(id: string, force: boolean) {
let unlock = await mutex.lock();
if (requests[id]) {
unlock();

View File

@ -15,6 +15,9 @@ interface Params {
'first-step'?: string;
n?: number;
count?: number;
min?: number;
max?: number;
suggestion?: string;
// add more parameters that are used here
}

View File

@ -2,6 +2,7 @@ import { error } from '@sveltejs/kit';
import { get_store_value } from 'svelte/internal';
import type { Load } from '@sveltejs/kit';
import type { DomainInList } from '$lib/model/domain';
import { domains, domains_idx, refreshDomains } from '$lib/stores/domains';
export const load: Load = async({ parent, params }) => {
@ -9,11 +10,17 @@ export const load: Load = async({ parent, params }) => {
if (!get_store_value(domains)) await refreshDomains();
if (!params.dn) {
throw error(404, {
message: 'Domain not found',
});
}
const domain: DomainInList | null = get_store_value(domains_idx)[params.dn];
if (!domain) {
throw error(404, {
message: 'Domain not found'
message: 'Domain not found',
});
}

View File

@ -7,7 +7,6 @@
Spinner,
} from 'sveltestrap';
import { getZone } from '$lib/api/zone';
import SubdomainList from '$lib/components/domains/SubdomainList.svelte';
import type { DomainInList } from '$lib/model/domain';
import type { Zone } from '$lib/model/zone';