mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
basic flow setup
This commit is contained in:
1 parent
48a8a03458
commit
e24bd15ebb
5 files changed
+208
-4
No files matched your search
@@ -1,16 +1,71 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import Alert from '$lib/components/alert.svelte';
|
||||
import Container from '$lib/layout/container.svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { Alert, CardGrid, Collapsible, CollapsibleItem, Heading } from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { project } from '../../store';
|
||||
import EmailTemplate from './emailTemplate.svelte';
|
||||
import SmsTemplate from './smsTemplate.svelte';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
|
||||
let template: any;
|
||||
onMount(() => {
|
||||
loadEmailTemplate('verification', 'en_us');
|
||||
});
|
||||
async function loadEmailTemplate(type: string, locale: string) {
|
||||
const path = '/projects/' + projectId + '/templates/email/' + type + '/' + locale;
|
||||
|
||||
try {
|
||||
template = await sdk.forConsole.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forConsole.client.config.endpoint + path)
|
||||
);
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function saveEmailTemplate(type: string, data: any) {
|
||||
const path = '/projects/' + projectId + '/templates/email/' + type + '/' + data.locale;
|
||||
|
||||
try {
|
||||
template = await sdk.forConsole.client.call(
|
||||
'PATCH',
|
||||
new URL(sdk.forConsole.client.config.endpoint + path),
|
||||
{ 'content-type': 'application/json' },
|
||||
{
|
||||
senderName: data.senderName,
|
||||
senderEmail: data.senderEmail,
|
||||
subject: data.subject,
|
||||
message: data.message
|
||||
}
|
||||
);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Template updated'
|
||||
});
|
||||
} catch (e) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: e.message
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if !$project.smtpEnabled}
|
||||
<Alert
|
||||
dismissible
|
||||
info
|
||||
type="info"
|
||||
buttons={[
|
||||
{
|
||||
name: 'Add SMTP server',
|
||||
@@ -26,4 +81,69 @@
|
||||
labeled as spam.
|
||||
</Alert>
|
||||
{/if}
|
||||
|
||||
<CardGrid>
|
||||
<Heading size="6" tag="h6">Email Templates</Heading>
|
||||
<p class="text">
|
||||
Use templates to send and process account management emails. <a
|
||||
href="https://appwrite.io/docs"
|
||||
class="link">
|
||||
Learn more about Email templates
|
||||
</a>. <!-- TODO Docs link -->
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<Collapsible>
|
||||
<CollapsibleItem open>
|
||||
<svelte:fragment slot="title">Verification</svelte:fragment>
|
||||
<p class="text">
|
||||
Send a verification email to users that sign in with their email and
|
||||
password.
|
||||
</p>
|
||||
<EmailTemplate
|
||||
bind:template
|
||||
onSubmit={(data) => saveEmailTemplate('verification', data)} />
|
||||
</CollapsibleItem>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Magic URL</svelte:fragment>
|
||||
<EmailTemplate onSubmit={(data) => saveEmailTemplate('verification', data)} />
|
||||
</CollapsibleItem>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Reset Password</svelte:fragment>
|
||||
<EmailTemplate onSubmit={saveEmailTemplate} />
|
||||
</CollapsibleItem>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Invite User</svelte:fragment>
|
||||
<EmailTemplate onSubmit={saveEmailTemplate} />
|
||||
</CollapsibleItem>
|
||||
</Collapsible>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<CardGrid>
|
||||
<Heading size="6" tag="h6">SMS Templates</Heading>
|
||||
<p class="text">
|
||||
Use templates to send and process account management mobile messages. <a
|
||||
href="https://appwrite.io/docs"
|
||||
class="link">
|
||||
Learn more about SMS templates
|
||||
</a>. <!-- TODO Docs link -->
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<Collapsible>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Verification</svelte:fragment>
|
||||
<p class="text">
|
||||
Send a verification SMS to users that sign in with their phone
|
||||
</p>
|
||||
<SmsTemplate onSubmit={saveEmailTemplate} />
|
||||
</CollapsibleItem>
|
||||
<CollapsibleItem>
|
||||
<svelte:fragment slot="title">Login</svelte:fragment>
|
||||
<SmsTemplate onSubmit={saveEmailTemplate} />
|
||||
</CollapsibleItem>
|
||||
</Collapsible>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Container>
|
||||
@@ -0,0 +1,56 @@
|
||||
<script lang="ts">
|
||||
import { Box } from '$lib/components';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
FormList,
|
||||
InputEmail,
|
||||
InputText,
|
||||
InputTextarea
|
||||
} from '$lib/elements/forms';
|
||||
import { afterUpdate } from 'svelte';
|
||||
import LocaleOptions from './localeOptions.svelte';
|
||||
export let onSubmit: (data: any) => Promise<void> | void;
|
||||
|
||||
export let template: any = undefined;
|
||||
let senderName: string;
|
||||
let senderEmail: string;
|
||||
let message: string;
|
||||
let subject: string;
|
||||
let locale: string;
|
||||
|
||||
afterUpdate(() => {
|
||||
senderName = template?.senderName;
|
||||
senderEmail = template?.senderEmail;
|
||||
message = template?.message;
|
||||
subject = template?.subject;
|
||||
locale = template?.locale;
|
||||
});
|
||||
function submit() {
|
||||
if (onSubmit) {
|
||||
onSubmit({ senderName, senderEmail, message, subject, locale });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Box>
|
||||
<Form onSubmit={submit}>
|
||||
<FormList>
|
||||
<LocaleOptions />
|
||||
<InputText
|
||||
id="senderName"
|
||||
label="Sender Name"
|
||||
bind:value={senderName}
|
||||
placeholder={'{{project}}'} />
|
||||
<InputEmail
|
||||
bind:value={senderEmail}
|
||||
id="senderEmail"
|
||||
label="Sender Email"
|
||||
placeholder="" />
|
||||
<InputEmail id="replyTo" label="Reply to" placeholder="DoNotReply" />
|
||||
<InputText bind:value={subject} id="subject" label="Subject" />
|
||||
<InputTextarea bind:value={message} id="message" label="Message" />
|
||||
<Button submit>Update</Button>
|
||||
</FormList>
|
||||
</Form>
|
||||
</Box>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
|
||||
</script>
|
||||
|
||||
<InputSelect
|
||||
label="Language"
|
||||
id="language"
|
||||
value="en_us"
|
||||
options={[
|
||||
{
|
||||
label: 'English',
|
||||
value: 'en_us'
|
||||
}
|
||||
]} />
|
||||
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { Box } from '$lib/components';
|
||||
import { Form, FormList, InputEmail, InputText, InputTextarea } from '$lib/elements/forms';
|
||||
export let onSubmit: () => Promise<void> | void;
|
||||
</script>
|
||||
|
||||
<Box>
|
||||
<Form {onSubmit}>
|
||||
<FormList>
|
||||
<InputTextarea id="message" label="Message" />
|
||||
</FormList>
|
||||
</Form>
|
||||
</Box>
|
||||
@@ -26,6 +26,7 @@
|
||||
host = $project.smtpHost;
|
||||
port = $project.smtpPort;
|
||||
username = $project.smtpUsername;
|
||||
password = $project.smtpPassword;
|
||||
});
|
||||
|
||||
async function updateSmtp() {
|
||||
@@ -37,7 +38,7 @@
|
||||
host,
|
||||
port,
|
||||
username,
|
||||
password: password ? password : $project.smtpPassword
|
||||
password
|
||||
};
|
||||
try {
|
||||
await sdk.forConsole.client.call(
|
||||
|
||||
Reference in new issue
Block a user