Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 66 additions & 3 deletions src/lib/components/domains/viewLogsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,80 @@
import { Modal } from '$lib/components';
import { Logs } from '@appwrite.io/pink-svelte';
import { app } from '$lib/stores/app';
import type { Models } from '@appwrite.io/console';
import { ProxyRuleStatus, type Models } from '@appwrite.io/console';
import { Button } from '$lib/elements/forms';
import { getApexDomain } from '$lib/helpers/tlds';
import { isCloud } from '$lib/system';
import { sdk } from '$lib/stores/sdk';
import { page } from '$app/state';
import { Dependencies } from '$lib/constants';
import { invalidate } from '$app/navigation';
import { addNotification } from '$lib/stores/notifications';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';

let {
show = $bindable(false),
selectedProxyRule
selectedProxyRule,
domainsList
}: {
show: boolean;
selectedProxyRule: Models.ProxyRule;
domainsList?: Models.DomainsList;
} = $props();

let error = $state(null);

async function retryDomain() {
error = null;

try {
const apexDomain = getApexDomain(selectedProxyRule.domain);
const domain = domainsList?.domains.find((d) => d.domain === apexDomain);
if (isCloud && domain) {
await sdk.forConsole.domains.updateNameservers({
domainId: domain.$id
});
}
} catch {
// Ignore error
}

try {
selectedProxyRule = await sdk
.forProject(page.params.region, page.params.project)
.proxy.updateRuleVerification({ ruleId: selectedProxyRule.$id });

await invalidate(Dependencies.DOMAINS);
show = false;
addNotification({
type: 'success',
message: 'Domain verified successfully'
});
trackEvent(Submit.DomainUpdateVerification);
} catch (e) {
error = e.message;
trackError(e, Submit.DomainUpdateVerification);
}
}

$effect(() => {
if (!show) {
error = null;
}
});
</script>

<Modal title="Certificate logs" bind:show size="m" hideFooter>
<Modal
title="Certificate logs"
size="m"
bind:show
bind:error
onSubmit={retryDomain}
hideFooter={selectedProxyRule.status !== ProxyRuleStatus.Unverified}>
<Logs logs={selectedProxyRule.logs} theme={$app.themeInUse} showScrollButton height="250px" />
<svelte:fragment slot="footer">
{#if selectedProxyRule.status === ProxyRuleStatus.Unverified}
<Button submit>Retry</Button>
{/if}
</svelte:fragment>
</Modal>
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
{/if}

{#if showLogs}
<ViewLogsModal bind:show={showLogs} {selectedProxyRule} />
<ViewLogsModal bind:show={showLogs} {selectedProxyRule} domainsList={organizationDomains} />
{/if}

<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
{/if}

{#if showLogs}
<ViewLogsModal bind:show={showLogs} {selectedProxyRule} />
<ViewLogsModal bind:show={showLogs} {selectedProxyRule} domainsList={organizationDomains} />
{/if}

<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
{/if}

{#if showLogs}
<ViewLogsModal bind:show={showLogs} {selectedProxyRule} />
<ViewLogsModal bind:show={showLogs} {selectedProxyRule} domainsList={organizationDomains} />
{/if}

<style>
Expand Down