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
15 changes: 8 additions & 7 deletions src/lib/components/labelCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@
{#if icon}
<span class={`icon-${icon} u-margin-inline-start-auto`} aria-hidden="true" />
{/if}
{/if}
{#if imageIcon}
<img
class="u-margin-inline-start-auto"
style:--p-text-size="1.25rem"
src={`${base}/icons/${$app.themeInUse}/color/${imageIcon}.svg`}
alt={imageIcon} />
{#if imageIcon}
<img
class="u-margin-inline-start-auto"
style:max-inline-size="1.25rem"
style:max-block-size="1.25rem"
src={`${base}/icons/${$app.themeInUse}/color/${imageIcon}.svg`}
alt={imageIcon} />
{/if}
{/if}
</div>
</label>
17 changes: 13 additions & 4 deletions src/routes/console/project-[project]/messaging/provider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Vonage = 'vonage',
Mailgun = 'mailgun',
Sendgrid = 'sendgrid',
SMTP = 'smtp',
FCM = 'fcm',
APNS = 'apns'
}
Expand Down Expand Up @@ -49,6 +50,10 @@
case Providers.Mailgun:
icon = 'mailgun';
break;
case Providers.SMTP:
icon = 'smtp';
displayName = name || 'SMTP';
break;
case Providers.Twilio:
icon = 'twilio';
break;
Expand Down Expand Up @@ -78,10 +83,14 @@
class="avatar"
class:is-size-large={size === 'l'}
class:is-size-small={size === 's'}>
<img
style:--p-text-size={textSize}
src={`${base}/icons/${$app.themeInUse}/color/${icon}.svg`}
alt={displayName} />
{#if provider === Providers.SMTP}
<span style:--p-text-size={textSize} class="icon-mail" />
{:else}
<img
style:--p-text-size={textSize}
src={`${base}/icons/${$app.themeInUse}/color/${icon}.svg`}
alt={displayName} />
{/if}
</div>
{/if}
<slot>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,24 @@
$providerParams[$provider].enabled
);
break;
case Providers.SMTP:
response = await sdk.forProject.messaging.createSMTPProvider(
providerId,
$providerParams[$provider].name,
$providerParams[$provider].host,
$providerParams[$provider].port || undefined,
$providerParams[$provider].username || undefined,
$providerParams[$provider].password || undefined,
$providerParams[$provider].encryption,
$providerParams[$provider].autoTLS,
$providerParams[$provider].mailer || undefined,
$providerParams[$provider].fromName || undefined,
$providerParams[$provider].fromEmail,
$providerParams[$provider].replyToName || undefined,
$providerParams[$provider].replyToEmail || undefined,
$providerParams[$provider].enabled
);
break;
case Providers.FCM:
response = await sdk.forProject.messaging.createFCMProvider(
providerId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@
fromEmail: $provider.options['from']
};
break;
case Providers.SMTP:
$providerParams[$wizardProvider] = {
providerId: $provider.$id,
name: $provider.name,
enabled: $provider.enabled,
host: $provider.credentials['host'],
port: $provider.credentials['port'],
username: $provider.credentials['username'],
password: $provider.credentials['password'],
fromName: $provider.options['fromName'],
fromEmail: $provider.options['fromEmail'],
replyToName: $provider.options['replyToName'],
replyToEmail: $provider.options['replyToEmail'],
encryption: $provider.options['encryption'],
autoTLS: $provider.options['autoTLS'],
mailer: $provider.options['mailer']
};
break;
case Providers.FCM:
$providerParams[$wizardProvider] = {
providerId: $provider.$id,
Expand Down Expand Up @@ -186,6 +204,23 @@
enabled
);
break;
case Providers.SMTP:
response = await sdk.forProject.messaging.updateSMTPProvider(
providerId,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
enabled
);
break;
case Providers.FCM:
response = await sdk.forProject.messaging.updateFCMProvider(
providerId,
Expand Down
100 changes: 97 additions & 3 deletions src/routes/console/project-[project]/messaging/providers/store.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Column } from '$lib/helpers/types';
import { writable } from 'svelte/store';
import { Providers } from '../provider.svelte';
import { MessagingProviderType } from '@appwrite.io/console';
import { MessagingProviderType, SMTPEncryption } from '@appwrite.io/console';

export const columns = writable<Column[]>([
{ id: '$id', title: 'Provider ID', type: 'string', show: true },
Expand All @@ -18,17 +18,20 @@ type ProvidersMap = {
icon: string;
providers: {
[key in Providers]?: {
imageIcon: string;
imageIcon?: string;
classIcon?: string;
title: string;
description: string;
configure: {
label: string;
name: string;
type: 'text' | 'phone' | 'email' | 'domain' | 'file' | 'switch';
type: 'text' | 'phone' | 'email' | 'domain' | 'file' | 'switch' | 'select';
placeholder?: string;
description?: string;
popover?: string[];
allowedFileExtensions?: string[];
optional?: boolean;
options?: { label: string; value: string | number | boolean }[];
}[];
};
};
Expand Down Expand Up @@ -184,18 +187,21 @@ export const providers: ProvidersMap = {
label: 'Sender name',
name: 'fromName',
type: 'text',
optional: true,
placeholder: 'Enter name'
},
{
label: 'Reply-to email',
name: 'replyToEmail',
type: 'email',
optional: true,
placeholder: 'Enter email'
},
{
label: 'Reply-to name',
name: 'replyToName',
type: 'text',
optional: true,
placeholder: 'Enter name'
}
]
Expand Down Expand Up @@ -226,18 +232,106 @@ export const providers: ProvidersMap = {
label: 'Sender name',
name: 'fromName',
type: 'text',
optional: true,
placeholder: 'Enter name'
},
{
label: 'Reply-to email',
name: 'replyToEmail',
type: 'email',
optional: true,
placeholder: 'Enter email'
},
{
label: 'Reply-to name',
name: 'replyToName',
type: 'text',
optional: true,
placeholder: 'Enter name'
}
]
},
[Providers.SMTP]: {
classIcon: 'mail',
title: 'SMTP',
description: '',
configure: [
{
label: 'Host',
name: 'host',
type: 'text',
placeholder: 'Enter host'
},
{
label: 'Port',
name: 'port',
type: 'text',
optional: true,
placeholder: 'Enter port'
},
{
label: 'Username',
name: 'username',
type: 'text',
optional: true,
placeholder: 'Enter username'
},
{
label: 'Password',
name: 'password',
type: 'text',
optional: true,
placeholder: 'Enter password'
},
{
label: 'Encryption',
name: 'encryption',
type: 'select',
options: [
{ label: 'None', value: SMTPEncryption.None },
{ label: 'SSL', value: SMTPEncryption.Ssl },
{ label: 'TLS', value: SMTPEncryption.Tls }
]
},
{
label: 'Auto TLS',
name: 'autoTLS',
description: 'Automatically uses TLS encryption',
type: 'switch',
optional: true
},
{
label: 'Mailer',
name: 'mailer',
type: 'text',
optional: true,
placeholder: 'Enter mailer'
},
{
label: 'Sender email',
name: 'fromEmail',
type: 'email',
placeholder: 'Enter email'
},
{
label: 'Sender name',
name: 'fromName',
type: 'text',
optional: true,
placeholder: 'Enter name'
},
{
label: 'Reply-to email',
name: 'replyToEmail',
type: 'email',
optional: true,
placeholder: 'Enter email'
},
{
label: 'Reply-to name',
name: 'replyToName',
type: 'text',
optional: true,
placeholder: 'Enter name'
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@
$providerParams[$provider].replyToEmail
);
break;
case Providers.SMTP:
response = await sdk.forProject.messaging.updateSMTPProvider(
providerId,
$providerParams[$provider].name,
$providerParams[$provider].host,
$providerParams[$provider].port || undefined,
$providerParams[$provider].username || undefined,
$providerParams[$provider].password || undefined,
$providerParams[$provider].encryption,
$providerParams[$provider].autoTLS,
$providerParams[$provider].fromName || undefined,
$providerParams[$provider].fromEmail,
$providerParams[$provider].replyToName || undefined,
$providerParams[$provider].replyToEmail || undefined,
$providerParams[$provider].enabled
);
break;
case Providers.FCM:
response = await sdk.forProject.messaging.updateFCMProvider(
providerId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
InputDomain,
InputEmail,
InputFile,
InputSelect,
InputSwitch,
InputText
} from '$lib/elements/forms';
Expand Down Expand Up @@ -56,6 +57,7 @@
id={input.name}
label={input.label}
placeholder={input.placeholder}
required={!input.optional}
bind:value={$providerParams[$provider][input.name]}>
<svelte:fragment slot="popover">
{@html input.popover?.join('<br/><br/>')}
Expand All @@ -66,6 +68,7 @@
id={input.name}
label={input.label}
placeholder={input.placeholder}
required={!input.optional}
bind:value={$providerParams[$provider][input.name]}>
<svelte:fragment slot="popover">
<p class="body-text-2 u-margin-block-end-16">
Expand All @@ -78,6 +81,7 @@
id={input.name}
label={input.label}
placeholder={input.placeholder}
required={!input.optional}
bind:value={$providerParams[$provider][input.name]}>
<svelte:fragment slot="popover">
<p class="body-text-2 u-margin-block-end-16">
Expand All @@ -90,6 +94,7 @@
id={input.name}
label={input.label}
placeholder={input.placeholder}
required={!input.optional}
bind:value={$providerParams[$provider][input.name]}>
<svelte:fragment slot="popover">
<p class="body-text-2 u-margin-block-end-16">
Expand All @@ -101,6 +106,7 @@
<InputFile
label={input.label}
allowedFileExtensions={input.allowedFileExtensions}
required={!input.optional}
bind:files={files[input.name]}>
<svelte:fragment slot="popover">
<p class="body-text-2 u-margin-block-end-16">
Expand All @@ -112,11 +118,19 @@
<InputSwitch
label={input.label}
id={input.name}
required={!input.optional}
bind:value={$providerParams[$provider][input.name]}>
<svelte:fragment slot="description">
{input.description}
</svelte:fragment>
</InputSwitch>
{:else if input.type === 'select'}
<InputSelect
label={input.label}
id={input.name}
options={input.options}
required={!input.optional}
bind:value={$providerParams[$provider][input.name]} />
{/if}
{/each}
</FormList>
Expand Down
Loading