mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
feat: domains
This commit is contained in:
+11
-9
@@ -8,6 +8,7 @@
|
||||
import { removeFile } from '$lib/helpers/files';
|
||||
import { page } from '$app/state';
|
||||
import { createRecord, parseDnsRecords } from '$lib/helpers/domains';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export let show = false;
|
||||
let files: FileList;
|
||||
@@ -19,22 +20,23 @@
|
||||
|
||||
const file = files[0];
|
||||
const content = await file.text();
|
||||
const parsedRecords = parseDnsRecords(content);
|
||||
// const parsedRecords = parseDnsRecords(content);
|
||||
|
||||
let recordCount = 0;
|
||||
// let recordCount = 0;
|
||||
|
||||
for (const [type, records] of Object.entries(parsedRecords)) {
|
||||
recordCount += records.length;
|
||||
// for (const [type, records] of Object.entries(parsedRecords)) {
|
||||
// recordCount += records.length;
|
||||
|
||||
for (const record of records) {
|
||||
await createRecord(record, page.params.domain);
|
||||
}
|
||||
}
|
||||
// for (const record of records) {
|
||||
// await createRecord(record, page.params.domain);
|
||||
// }
|
||||
// }
|
||||
|
||||
await sdk.forConsole.domains.updateZone(page.params.domain, content);
|
||||
show = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${recordCount} DNS records have been imported successfully`
|
||||
message: `DNS records have been imported successfully`
|
||||
});
|
||||
trackEvent(Submit.RecordCreate);
|
||||
} catch (e) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
<Container>
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<SearchQuery search={data.search} placeholder="Search domain" />
|
||||
<SearchQuery placeholder="Search domain" />
|
||||
<Button
|
||||
href={`${base}/project-${page.params.project}/sites/site-${page.params.site}/domains/add-domain`}
|
||||
on:click={() => {
|
||||
|
||||
+74
-10
@@ -1,6 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { IconGlobeAlt } from '@appwrite.io/pink-icons-svelte';
|
||||
import { Card, Divider, Icon, Layout, Typography } from '@appwrite.io/pink-svelte';
|
||||
import {
|
||||
Card,
|
||||
Divider,
|
||||
Fieldset,
|
||||
Icon,
|
||||
Layout,
|
||||
Tabs,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import VerificationFieldset from './verificationFieldset.svelte';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
@@ -13,15 +21,27 @@
|
||||
import Wizard from '$lib/layout/wizard.svelte';
|
||||
import { base } from '$app/paths';
|
||||
import { writable } from 'svelte/store';
|
||||
import { consoleVariables } from '$routes/(console)/store';
|
||||
import NameserverTable from '$lib/components/domains/nameserverTable.svelte';
|
||||
import RecordTable from '$lib/components/domains/recordTable.svelte';
|
||||
|
||||
export let data;
|
||||
let { data } = $props();
|
||||
|
||||
const ruleId = page.url.searchParams.get('rule');
|
||||
let selectedTab: 'cname' | 'nameserver' | 'a' | 'aaaa';
|
||||
let verified = false;
|
||||
let selectedTab: 'cname' | 'nameserver' | 'a' | 'aaaa' = $state(
|
||||
!!$consoleVariables._APP_DOMAIN_TARGET_CNAME
|
||||
? 'cname'
|
||||
: !!$consoleVariables._APP_DOMAIN_TARGET_A
|
||||
? 'a'
|
||||
: !!$consoleVariables._APP_DOMAIN_TARGET_AAAA
|
||||
? 'aaaa'
|
||||
: 'nameserver'
|
||||
);
|
||||
let verified = $state(false);
|
||||
|
||||
let routeBase = `${base}/project-${page.params.project}/sites/site-${page.params.site}/domains`;
|
||||
let isSubmitting = writable(false);
|
||||
let isSubmitting = $state(writable(false));
|
||||
let isSubDomain = $derived(page.params.domain?.split('.')?.length >= 3);
|
||||
|
||||
async function verify() {
|
||||
const isNewDomain =
|
||||
@@ -82,14 +102,58 @@
|
||||
</Layout.Stack>
|
||||
</Card.Base>
|
||||
|
||||
<VerificationFieldset domain={page.params.domain} {verified} bind:selectedTab>
|
||||
<Divider />
|
||||
<Layout.Stack direction="row" justifyContent="flex-end">
|
||||
<Fieldset legend="Verification">
|
||||
<Layout.Stack gap="xl">
|
||||
<div>
|
||||
<Button submit disabled={$isSubmitting}>Verify</Button>
|
||||
<Tabs.Root variant="secondary" let:root>
|
||||
{#if isSubDomain && !!$consoleVariables._APP_DOMAIN_TARGET_CNAME && $consoleVariables._APP_DOMAIN_TARGET_CNAME !== 'localhost'}
|
||||
<Tabs.Item.Button
|
||||
{root}
|
||||
on:click={() => (selectedTab = 'cname')}
|
||||
active={selectedTab === 'cname'}>
|
||||
CNAME
|
||||
</Tabs.Item.Button>
|
||||
{/if}
|
||||
{#if isCloud}
|
||||
<Tabs.Item.Button
|
||||
{root}
|
||||
on:click={() => (selectedTab = 'nameserver')}
|
||||
active={selectedTab === 'nameserver'}>
|
||||
Nameservers
|
||||
</Tabs.Item.Button>
|
||||
{/if}
|
||||
{#if !!$consoleVariables._APP_DOMAIN_TARGET_A && $consoleVariables._APP_DOMAIN_TARGET_A !== '127.0.0.1'}
|
||||
<Tabs.Item.Button
|
||||
{root}
|
||||
on:click={() => (selectedTab = 'a')}
|
||||
active={selectedTab === 'a'}>
|
||||
A
|
||||
</Tabs.Item.Button>
|
||||
{/if}
|
||||
{#if !!$consoleVariables._APP_DOMAIN_TARGET_AAAA && $consoleVariables._APP_DOMAIN_TARGET_AAAA !== '::1'}
|
||||
<Tabs.Item.Button
|
||||
{root}
|
||||
on:click={() => (selectedTab = 'aaaa')}
|
||||
active={selectedTab === 'aaaa'}>
|
||||
AAAA
|
||||
</Tabs.Item.Button>
|
||||
{/if}
|
||||
</Tabs.Root>
|
||||
<Divider />
|
||||
</div>
|
||||
{#if selectedTab === 'nameserver'}
|
||||
<NameserverTable domain={page.params.domain} {verified} />
|
||||
{:else}
|
||||
<RecordTable domain={page.params.domain} {verified} variant={selectedTab} />
|
||||
{/if}
|
||||
<Divider />
|
||||
<Layout.Stack direction="row" justifyContent="flex-end">
|
||||
<div>
|
||||
<Button submit disabled={$isSubmitting}>Verify</Button>
|
||||
</div>
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
</VerificationFieldset>
|
||||
</Fieldset>
|
||||
</Layout.Stack>
|
||||
</Form>
|
||||
</Wizard>
|
||||
|
||||
Reference in New Issue
Block a user