From cde7f904d7babb98e3fea7f4bcdef1a37136e750 Mon Sep 17 00:00:00 2001 From: Arman Date: Tue, 18 Feb 2025 17:12:29 +0100 Subject: [PATCH] feat: more work on domains --- src/lib/components/usageCard.svelte | 8 +- .../domains/+page.svelte | 8 +- .../domains/domain-[domain]/+page.svelte | 208 +++++++----------- .../domain-[domain]/SSLCertificates.svelte | 29 --- .../domain-[domain]/addPresetModal.svelte | 83 +++++++ .../domain-[domain]/certificates/+page.svelte | 46 +++- .../domain-[domain]/certificates/+page.ts | 2 +- .../certificates/certificateInfoModal.svelte | 6 +- .../domain-[domain]/createRecordModal.svelte | 4 +- .../domain-[domain]/domainMetrics.svelte | 8 +- .../settings/changeOrganization.svelte | 6 +- .../domains/domain-[domain]/store.ts | 13 +- .../domains/domain-[domain]/table.svelte | 137 ++++++++++++ .../repository-[repository]/+page.svelte | 1 - 14 files changed, 380 insertions(+), 179 deletions(-) delete mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/SSLCertificates.svelte create mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte create mode 100644 src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte diff --git a/src/lib/components/usageCard.svelte b/src/lib/components/usageCard.svelte index fc5f331a5..befb5c1f6 100644 --- a/src/lib/components/usageCard.svelte +++ b/src/lib/components/usageCard.svelte @@ -8,15 +8,15 @@ + + {description} + {#if value !== null && value !== undefined} - {value} + {value} {:else} {/if} - - {description} - diff --git a/src/routes/(console)/organization-[organization]/domains/+page.svelte b/src/routes/(console)/organization-[organization]/domains/+page.svelte index 448a8c39c..3631617b9 100644 --- a/src/routes/(console)/organization-[organization]/domains/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/+page.svelte @@ -94,11 +94,11 @@ {/if} - {domain?.registrar ?? 'N/A'} - {domain?.nameservers ?? 'N/A'} - {domain?.expiry ?? 'N/A'} + {domain?.registrar ?? '-'} + {domain?.nameservers ?? '-'} + {domain?.expiry ?? '-'} - {domain.renewAt ? toLocaleDateTime(domain.renewAt) : 'N/A'} + {domain.renewAt ? toLocaleDateTime(domain.renewAt) : '-'} {domain.autoRenewal ? 'On' : 'Off'} diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte index 4c52de886..e398d88e5 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/+page.svelte @@ -4,145 +4,107 @@ ActionMenu, Card, Empty, - HiddenText, Icon, InlineCode, Layout, - Popover, - Table, - Typography + Button as PinkButton, + Popover } from '@appwrite.io/pink-svelte'; import DomainMetrics from './domainMetrics.svelte'; import { base } from '$app/paths'; import { app } from '$lib/stores/app'; import { Button } from '$lib/elements/forms'; - import { IconDotsHorizontal, IconPencil, IconTrash } from '@appwrite.io/pink-icons-svelte'; - import { PaginationWithLimit } from '$lib/components'; - import { timeFromNow } from '$lib/helpers/date'; + import { IconDownload, IconPlus, IconUpload } from '@appwrite.io/pink-icons-svelte'; + import { ViewSelector } from '$lib/components'; + import { View } from '$lib/helpers/load'; + import { columns } from './store'; + import CreateRecordModal from './createRecordModal.svelte'; + import Table from './table.svelte'; + import AddPresetModal from './addPresetModal.svelte'; export let data; - let selectedRecord; //TODO: add type - let showCreate = false; - let showEdit = false; - let showDelete = false; + let showPresetModal = false; + let selectedPreset = ''; + + const presets = ['Zoho', 'Mailgun', 'Outlook', 'Proton Mail', 'iCloud', 'Google Workspace']; - + + - {#if data.records.total} - - - Name - Type - Value - TTL - Created - - - {#each data.records.records as record} - - - - {record.name} - - - - - {record.type} - - - - - - - - {record.ttl} - - - - - {timeFromNow(record.$createdAt)} - - - - - - - - - - + + {#if data.records.total} + + + + + + + + + + + + + + {#each presets as preset} { - e.preventDefault(); - selectedRecord = record; - showEdit = true; - toggle(e); - }}> - Edit - - { - e.preventDefault(); - selectedRecord = record; - showDelete = true; - toggle(e); - }}> - Delete - - - - - - - - {/each} - + on:click={() => { + selectedPreset = preset; + showPresetModal = true; + }}>{preset} + {/each} + + + + + + + + {:else} + + + + Navigate to your domain provider and update the nameservers to and . + Note that DNS changes may take time to propagate fully. + + + - - {:else} - - - - Navigate to your domain provider and update the nameservers to and . Note - that DNS changes may take time to propagate fully. - - - - - - - - - {/if} + + + + + {/if} + + + +{#if showCreate} + +{/if} + +{#if showPresetModal} + +{/if} diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/SSLCertificates.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/SSLCertificates.svelte deleted file mode 100644 index 3d1666c9d..000000000 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/SSLCertificates.svelte +++ /dev/null @@ -1,29 +0,0 @@ - - - - SSL certificates - SSL certificates secure your site with HTTPS, protecting data and boosting trust. Appwrite renews - your SSL certificates automatically. - - - - Domain - Expiration date - Renewal - Created - - - {#each domain.logs as log} - - {JSON.stringify(log)} - - {/each} - - - diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte new file mode 100644 index 000000000..61b30d753 --- /dev/null +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/addPresetModal.svelte @@ -0,0 +1,83 @@ + + + + + Forward emails to your domain using the following {capitalize(selectedPreset)} DNS records. + + + + + Type + Name + Value + TTL + Priority + + {#await fetchPreset()} + {#each Array(2) as _} + + {#each Array(5) as _} + + + + {/each} + + {/each} + {:then presetData} + {#each presetData as record} + + {record.type} + {record.name} + {record.value} + {record.ttl} + {record.priority} + + {/each} + {/await} + + + + + + + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.svelte index b79cb20b3..4e2523e7c 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.svelte @@ -1,33 +1,38 @@ - + {#if data.certificates.total} @@ -39,15 +44,41 @@ {#each data.certificates.certificates as certificate} + {@const isExpired = new Date(certificate.expiresAt) < now} {certificate.$id} - {certificate.autoRenewal ? 'Auto' : ''} - {certificate.renewAt ? toLocaleDateTime(certificate.renewAt) : '-'} + {#if certificate?.renewAt && !isExpired} + + {certificate.autoRenewal ? 'Auto' : ''} + + + {:else} + - + {/if} + + + {#if isExpired} + + + + {toLocaleDateTime(certificate?.expiresAt)} + + + {:else} + {toLocaleDate(certificate?.expiresAt)} + {/if} - {certificate?.expiresAt ?? '-'} @@ -132,3 +163,6 @@ {#if showAdvancedInfo} {/if} +{#if showDelete} + +{/if} diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.ts b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.ts index dbe25f057..18c950f0d 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.ts +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/+page.ts @@ -28,7 +28,7 @@ const mockCertificates = { renewAt: '2023-01-15T10:30:00Z', autoRenewal: true, issuedAt: '2023-01-15T10:30:00Z', - expiresAt: '2024-01-15T10:30:00Z', + expiresAt: '2026-01-15T10:30:00Z', issuer: "Let's Encrypt", status: 'active', type: 'SSL/TLS', diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/certificateInfoModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/certificateInfoModal.svelte index be4d4a56d..98029a467 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/certificateInfoModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/certificates/certificateInfoModal.svelte @@ -1,13 +1,13 @@ - + Issued to @@ -69,4 +69,4 @@ - + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte index c1566d731..0571b00e4 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte @@ -7,7 +7,7 @@ InputTextarea } from '$lib/elements/forms'; import { Modal } from '$lib/components'; - import { Icon, Input, Layout, Tooltip, Typography } from '@appwrite.io/pink-svelte'; + import { Icon, Layout, Tooltip } from '@appwrite.io/pink-svelte'; import { IconInfo } from '@appwrite.io/pink-icons-svelte'; import { addNotification } from '$lib/stores/notifications'; import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; @@ -147,6 +147,6 @@ - + diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte index 2a6911ab6..de58a9bef 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/domainMetrics.svelte @@ -11,15 +11,15 @@ description: 'Domain' }, { - value: domain?.registrar || 'N/A', + value: domain?.registrar || '-', description: 'Registrar' }, { - value: domain?.nameservers || 'N/A', + value: domain?.nameservers || '-', description: 'Nameservers' }, { - value: domain?.expiresAt ? toLocaleDate(domain?.expiresAt) : 'N/A', + value: domain?.expiresAt ? toLocaleDate(domain?.expiresAt) : '-', description: 'Exipiry date' }, { @@ -27,7 +27,7 @@ description: 'Auto renewal' }, { - value: domain?.renewalPrice || 'N/A', + value: domain?.renewalPrice || '-', description: 'Renewal price' } ]; diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte index af789e8f2..9a6d7989d 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/settings/changeOrganization.svelte @@ -1,4 +1,5 @@ @@ -25,6 +28,7 @@ id="orgs" label="Move to" placeholder="Select destination" + disabled={options?.length === 0} {options} bind:value={selectedOrg} /> diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/store.ts b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/store.ts index 0d63bad20..5e7a313e9 100644 --- a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/store.ts +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/store.ts @@ -1,5 +1,16 @@ import { page } from '$app/stores'; +import type { Column } from '$lib/helpers/types'; import type { Models } from '@appwrite.io/console'; -import { derived } from 'svelte/store'; +import { derived, writable } from 'svelte/store'; export const domain = derived(page, ($page) => $page.data.domain as Models.ProxyRule); +// columns: namem type, value, ttl, priority, comment, created +export const columns = writable([ + { id: 'name', title: 'Name', type: 'string', show: true }, + { id: 'type', title: 'Type', type: 'string', show: true }, + { id: 'value', title: 'Value', type: 'string', show: true }, + { id: 'ttl', title: 'TTL', type: 'integer', show: true }, + { id: 'priority', title: 'Priority', type: 'integer', show: false }, + { id: 'comment', title: 'Comment', type: 'string', show: false }, + { id: '$createdAt', title: 'Created', type: 'datetime', show: true } +]); diff --git a/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte new file mode 100644 index 000000000..4a2a84b3b --- /dev/null +++ b/src/routes/(console)/organization-[organization]/domains/domain-[domain]/table.svelte @@ -0,0 +1,137 @@ + + + + + + {#each $columns as column} + {#if column.show} + + {column.title} + + {/if} + {/each} + + + + {#each data.records.records as record} + + {#each $columns as column} + {#if column.show} + {#if column.id === 'name'} + + + {record.name} + + + {:else if column.id === 'type'} + + + {record.type} + + + {:else if column.id === 'value'} + +
+ +
+
+ {:else if column.id === 'ttl'} + + + {record.ttl} + + + {:else if column.id === 'priority'} + + + {record?.priority ?? '-'} + + + {:else if column.id === 'comment'} + + + {record?.comment ?? '-'} + + + {:else if column.id === '$createdAt'} + + + {timeFromNow(record.$createdAt)} + + + {/if} + {/if} + {/each} + + + + + + + + { + e.preventDefault(); + selectedRecord = record; + showEdit = true; + toggle(e); + }}> + Edit + + { + e.preventDefault(); + selectedRecord = record; + showDelete = true; + toggle(e); + }}> + Delete + + + + + + +
+ {/each} +
+ + +
diff --git a/src/routes/(console)/project-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte b/src/routes/(console)/project-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte index a0ecbbf88..d22b0c1c8 100644 --- a/src/routes/(console)/project-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte +++ b/src/routes/(console)/project-[project]/sites/create-site/repositories/repository-[repository]/+page.svelte @@ -96,7 +96,6 @@ ); // Add domain - console.log('test'); await sdk.forProject.proxy.createRule( `${domain}.${$consoleVariables._APP_DOMAIN_SITES}`, ResourceType.Site,