mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge pull request #596 from appwrite/feat-messaging-overview
Add messaging overview route
This commit is contained in:
109 files changed
+7226
-42
No files matched your search
@@ -18,8 +18,8 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
# - name: Audit dependencies
|
||||
# run: npm audit --audit-level low
|
||||
- name: Audit dependencies
|
||||
run: npm audit --audit-level low
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Svelte Diagnostics
|
||||
|
||||
@@ -287,5 +287,16 @@ export enum Submit {
|
||||
SmsResetTemplate = 'submit_sms_reset_template',
|
||||
SmsUpdateInviteTemplate = 'submit_sms_update_invite_template',
|
||||
SmsUpdateLoginTemplate = 'submit_sms_update_login_template',
|
||||
SmsUpdateVerificationTemplate = 'submit_sms_update_verification_template'
|
||||
SmsUpdateVerificationTemplate = 'submit_sms_update_verification_template',
|
||||
MessagingProviderCreate = 'submit_messaging_provider_create',
|
||||
MessagingProviderDelete = 'submit_messaging_provider_delete',
|
||||
MessagingProviderUpdate = 'submit_messaging_provider_update',
|
||||
MessagingMessageCreate = 'submit_messaging_message_create',
|
||||
MessagingMessageDelete = 'submit_messaging_message_delete',
|
||||
MessagingTopicCreate = 'submit_messaging_topic_create',
|
||||
MessagingTopicDelete = 'submit_messaging_topic_delete',
|
||||
MessagingTopicUpdateName = 'submit_messaging_topic_update_name',
|
||||
MessagingTopicUpdateDescription = 'submit_messaging_topic_update_description',
|
||||
MessagingTopicSubscriberAdd = 'submit_messaging_topic_subscriber_add',
|
||||
MessagingTopicSubscriberDelete = 'submit_messaging_topic_subscriber_delete'
|
||||
}
|
||||
@@ -17,6 +17,7 @@ const groups = [
|
||||
'platforms',
|
||||
'databases',
|
||||
'functions',
|
||||
'messaging',
|
||||
'storage',
|
||||
'domains',
|
||||
'webhooks',
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
export let noStyle = false;
|
||||
export let fullWidth = false;
|
||||
export let fixed = false;
|
||||
export let display = 'block';
|
||||
|
||||
const dispatch = createEventDispatcher<{
|
||||
blur: undefined;
|
||||
@@ -100,7 +101,11 @@
|
||||
|
||||
<svelte:window on:click={onBlur} on:keydown={onKeyDown} />
|
||||
|
||||
<div class:drop-wrapper={!noStyle} class:u-cross-child-start={childStart} bind:this={element}>
|
||||
<div
|
||||
class:drop-wrapper={!noStyle}
|
||||
class:u-cross-child-start={childStart}
|
||||
bind:this={element}
|
||||
style:display>
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { EmptySearch } from '.';
|
||||
import { queries } from './filters';
|
||||
|
||||
export let resource;
|
||||
</script>
|
||||
|
||||
<EmptySearch hidePages>
|
||||
<div class="common-section">
|
||||
<div class="u-text-center common-section">
|
||||
<b class="body-text-2 u-bold">Sorry, we couldn't find any {resource}.</b>
|
||||
<p>There are no {resource} that match your filters.</p>
|
||||
</div>
|
||||
<div class="u-flex common-section u-main-center">
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => {
|
||||
queries.clearAll();
|
||||
queries.apply();
|
||||
}}>
|
||||
Clear filters
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</EmptySearch>
|
||||
@@ -118,10 +118,12 @@
|
||||
<div class="selects u-flex u-gap-8 u-margin-block-start-16">
|
||||
<InputSelect
|
||||
id="column"
|
||||
options={$columns.map((c) => ({
|
||||
label: c.title,
|
||||
value: c.id
|
||||
}))}
|
||||
options={$columns
|
||||
.filter((c) => c.filter !== false)
|
||||
.map((c) => ({
|
||||
label: c.title,
|
||||
value: c.id
|
||||
}))}
|
||||
placeholder="Select column"
|
||||
bind:value={columnId} />
|
||||
<InputSelect
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export { default as filters } from './filters.svelte';
|
||||
export { default as Filters } from './filters.svelte';
|
||||
export { hasPageQueries, queryParamToMap, queries } from '$lib/components/filters/store';
|
||||
@@ -15,6 +15,7 @@ export { default as UploadBox } from './uploadBox.svelte';
|
||||
export { default as List } from './list.svelte';
|
||||
export { default as ListItem } from './listItem.svelte';
|
||||
export { default as Empty } from './empty.svelte';
|
||||
export { default as EmptyFilter } from './emptyFilter.svelte';
|
||||
export { default as EmptySearch } from './emptySearch.svelte';
|
||||
export { default as Drop } from './drop.svelte';
|
||||
export { default as DropList } from './dropList.svelte';
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
export let name: string;
|
||||
export let group: string;
|
||||
@@ -7,6 +9,7 @@
|
||||
export let disabled = false;
|
||||
export let padding = 1;
|
||||
export let icon: string = null;
|
||||
export let imageIcon: string = null;
|
||||
export let fullHeight = true;
|
||||
export let borderRadius: 'xsmall' | 'small' | 'medium' | 'large' = 'small';
|
||||
export let backgroundColor: string = null;
|
||||
@@ -58,5 +61,12 @@
|
||||
<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}
|
||||
</div>
|
||||
</label>
|
||||
@@ -46,7 +46,13 @@ export enum Dependencies {
|
||||
MIGRATIONS = 'dependency:migrations',
|
||||
COLLECTIONS = 'dependency:collections',
|
||||
RUNTIMES = 'dependency:runtimes',
|
||||
CONSOLE_VARIABLES = 'dependency:console_variables'
|
||||
CONSOLE_VARIABLES = 'dependency:console_variables',
|
||||
MESSAGING_PROVIDERS = 'dependency:messaging_providers',
|
||||
MESSAGING_PROVIDER = 'dependency:messaging_provider',
|
||||
MESSAGING_MESSAGE = 'dependency:messaging_message',
|
||||
MESSAGING_TOPICS = 'dependency:messaging_topics',
|
||||
MESSAGING_TOPIC = 'dependency:messaging_topic',
|
||||
MESSAGING_TOPIC_SUBSCRIBERS = 'dependency:messaging_topic_subscribers'
|
||||
}
|
||||
|
||||
export const scopes: {
|
||||
|
||||
@@ -29,3 +29,4 @@ export { default as Label } from './label.svelte';
|
||||
export { default as InputProjectId } from './inputProjectId.svelte';
|
||||
export { default as InputDate } from './inputDate.svelte';
|
||||
export { default as InputDateRange } from './inputDateRange.svelte';
|
||||
export { default as InputTime } from './inputTime.svelte';
|
||||
@@ -1,13 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
import { FormItem, Helper } from '.';
|
||||
import type { FormItemTag } from './formItem.svelte';
|
||||
|
||||
interface $$Props extends Partial<HTMLLabelElement> {
|
||||
id: string;
|
||||
label?: string;
|
||||
optionalText?: string;
|
||||
tooltip?: string;
|
||||
showLabel?: boolean;
|
||||
checked?: boolean;
|
||||
required?: boolean;
|
||||
disabled?: boolean;
|
||||
@@ -26,7 +23,6 @@
|
||||
export let disabled = false;
|
||||
export let element: HTMLInputElement | undefined = undefined;
|
||||
export let wrapperTag: FormItemTag = 'li';
|
||||
|
||||
let error: string;
|
||||
|
||||
const handleInvalid = (event: Event) => {
|
||||
@@ -44,25 +40,27 @@
|
||||
</script>
|
||||
|
||||
<FormItem tag={wrapperTag}>
|
||||
{#if label}
|
||||
<Label {required} {tooltip} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
{disabled}
|
||||
{required}
|
||||
{...$$restProps}
|
||||
type="checkbox"
|
||||
bind:this={element}
|
||||
bind:checked
|
||||
on:invalid={handleInvalid}
|
||||
on:click
|
||||
on:change />
|
||||
</div>
|
||||
<label class="choice-item" for={id}>
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
{disabled}
|
||||
{required}
|
||||
{...$$restProps}
|
||||
type="checkbox"
|
||||
bind:this={element}
|
||||
bind:checked
|
||||
on:invalid={handleInvalid}
|
||||
on:click
|
||||
on:change />
|
||||
</div>
|
||||
<div class="choice-item-content">
|
||||
{#if label}
|
||||
<div class="choice-item-title">{label}</div>
|
||||
{/if}
|
||||
<slot name="description" />
|
||||
</div>
|
||||
</label>
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
{/if}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
export let value = '';
|
||||
export let required = false;
|
||||
export let nullable = false;
|
||||
export let min: string | number | undefined = undefined;
|
||||
export let max: string | number | undefined = undefined;
|
||||
export let disabled = false;
|
||||
export let readonly = false;
|
||||
export let autofocus = false;
|
||||
@@ -65,6 +67,8 @@
|
||||
{readonly}
|
||||
{required}
|
||||
step=".001"
|
||||
{min}
|
||||
{max}
|
||||
autocomplete={autocomplete ? 'on' : 'off'}
|
||||
type="date"
|
||||
class="input-text"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
import { Drop } from '$lib/components';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
@@ -19,6 +20,7 @@
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let error: string;
|
||||
let show = false;
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
@@ -48,7 +50,26 @@
|
||||
|
||||
<FormItem>
|
||||
<Label {required} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{label}{#if $$slots.popover}
|
||||
<Drop bind:show display="inline-block">
|
||||
<!-- TODO: make unclicked icon greyed out and hover and clicked filled -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (show = !show)}
|
||||
class="tooltip"
|
||||
aria-label="input tooltip">
|
||||
<span
|
||||
class="icon-info"
|
||||
aria-hidden="true"
|
||||
style="font-size: var(--icon-size-small)" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<div class="dropped card u-max-width-250" style="--p-card-padding: .75rem">
|
||||
<slot name="popover" />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Drop>
|
||||
{/if}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
import NullCheckbox from './nullCheckbox.svelte';
|
||||
import { Drop } from '$lib/components';
|
||||
|
||||
export let label: string;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
@@ -19,6 +20,7 @@
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let error: string;
|
||||
let show = false;
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
@@ -57,7 +59,26 @@
|
||||
|
||||
<FormItem>
|
||||
<Label {required} {optionalText} {tooltip} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{label}{#if $$slots.popover}
|
||||
<Drop bind:show display="inline-block">
|
||||
<!-- TODO: make unclicked icon greyed out and hover and clicked filled -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (show = !show)}
|
||||
class="tooltip"
|
||||
aria-label="input tooltip">
|
||||
<span
|
||||
class="icon-info"
|
||||
aria-hidden="true"
|
||||
style="font-size: var(--icon-size-small)" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<div class="dropped card u-max-width-250" style="--p-card-padding: .75rem">
|
||||
<slot name="popover" />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Drop>
|
||||
{/if}
|
||||
</Label>
|
||||
|
||||
<div
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Trim } from '$lib/components';
|
||||
import { Drop, Trim } from '$lib/components';
|
||||
import { humanFileSize } from '$lib/helpers/sizeConvertion';
|
||||
import { onMount } from 'svelte';
|
||||
import { Helper, Label } from '.';
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
let input: HTMLInputElement;
|
||||
let hovering = false;
|
||||
let show = false;
|
||||
|
||||
function setFiles(value: FileList) {
|
||||
if (!value) return;
|
||||
@@ -94,7 +95,26 @@
|
||||
<div>
|
||||
{#if label}
|
||||
<Label {required} {optionalText} {tooltip} hide={!label}>
|
||||
{label}
|
||||
{label}{#if $$slots.popover}
|
||||
<Drop bind:show display="inline-block">
|
||||
<!-- TODO: make unclicked icon greyed out and hover and clicked filled -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (show = !show)}
|
||||
class="tooltip"
|
||||
aria-label="input tooltip">
|
||||
<span
|
||||
class="icon-info"
|
||||
aria-hidden="true"
|
||||
style="font-size: var(--icon-size-small)" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<div class="dropped card u-max-width-250" style="--p-card-padding: .75rem">
|
||||
<slot name="popover" />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Drop>
|
||||
{/if}
|
||||
</Label>
|
||||
{/if}
|
||||
<div
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
|
||||
export let label: string = null;
|
||||
export let showLabel = true;
|
||||
// export let label: string;
|
||||
export let id: string;
|
||||
export let group: string;
|
||||
export let value: string;
|
||||
export let name: string;
|
||||
export let required = false;
|
||||
export let disabled = false;
|
||||
export let fullWidth = false;
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let error: string;
|
||||
@@ -47,6 +49,24 @@
|
||||
<slot />
|
||||
{/if}
|
||||
</Label>
|
||||
<!-- <label class="choice-item" for={id}>
|
||||
<input
|
||||
{id}
|
||||
{name}
|
||||
{disabled}
|
||||
{required}
|
||||
{value}
|
||||
type="radio"
|
||||
bind:group
|
||||
bind:this={element}
|
||||
on:invalid={handleInvalid} />
|
||||
<div
|
||||
class="choice-item-content u-cross-child-center"
|
||||
class:u-width-full-line={fullWidth}>
|
||||
<div class="choice-item-title">{label}</div>
|
||||
<slot name="description" />
|
||||
</div>
|
||||
</label> -->
|
||||
</div>
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { FormItem, FormItemPart, Helper, Label } from '.';
|
||||
import NullCheckbox from './nullCheckbox.svelte';
|
||||
import TextCounter from './textCounter.svelte';
|
||||
import { Drop } from '$lib/components';
|
||||
|
||||
export let label: string = undefined;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
@@ -25,6 +26,7 @@
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let error: string;
|
||||
let show = false;
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
@@ -74,7 +76,26 @@
|
||||
<svelte:component this={wrapper} {fullWidth}>
|
||||
{#if label}
|
||||
<Label {required} {hideRequired} {tooltip} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
{label}{#if $$slots.popover}
|
||||
<Drop bind:show display="inline-block">
|
||||
<!-- TODO: make unclicked icon greyed out and hover and clicked filled -->
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (show = !show)}
|
||||
class="tooltip"
|
||||
aria-label="input tooltip">
|
||||
<span
|
||||
class="icon-info"
|
||||
aria-hidden="true"
|
||||
style="font-size: var(--icon-size-small)" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<div class="dropped card u-max-width-250" style="--p-card-padding: .75rem">
|
||||
<slot name="popover" />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</Drop>
|
||||
{/if}
|
||||
</Label>
|
||||
{/if}
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { FormItem, Helper, Label } from '.';
|
||||
|
||||
export let label: string;
|
||||
export let showLabel = true;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let id: string;
|
||||
export let value = '';
|
||||
export let required = false;
|
||||
export let min: string | number | undefined = undefined;
|
||||
export let max: string | number | undefined = undefined;
|
||||
export let disabled = false;
|
||||
export let readonly = false;
|
||||
export let autofocus = false;
|
||||
export let autocomplete = false;
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let error: string;
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
element.focus();
|
||||
}
|
||||
});
|
||||
|
||||
function handleInvalid(event: Event) {
|
||||
event.preventDefault();
|
||||
|
||||
if (element.validity.valueMissing) {
|
||||
error = 'This field is required';
|
||||
return;
|
||||
}
|
||||
|
||||
error = element.validationMessage;
|
||||
}
|
||||
|
||||
$: if (value) {
|
||||
error = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<Label {required} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="input-text-wrapper" style="--amount-of-buttons:1; --button-size: 1rem">
|
||||
<input
|
||||
{id}
|
||||
{disabled}
|
||||
{readonly}
|
||||
{required}
|
||||
{min}
|
||||
{max}
|
||||
step="60"
|
||||
autocomplete={autocomplete ? 'on' : 'off'}
|
||||
type="time"
|
||||
class="input-text"
|
||||
bind:value
|
||||
bind:this={element}
|
||||
on:invalid={handleInvalid} />
|
||||
</div>
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
{/if}
|
||||
</FormItem>
|
||||
@@ -19,6 +19,13 @@ export type Column = {
|
||||
id: string;
|
||||
title: string;
|
||||
type: ColumnType;
|
||||
/**
|
||||
* Set to false to hide by default
|
||||
*/
|
||||
show: boolean;
|
||||
width?: number;
|
||||
/**
|
||||
* Set to false to disable filtering for this column
|
||||
*/
|
||||
filter?: boolean;
|
||||
};
|
||||
+1
-2
@@ -1,8 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Empty, EmptySearch, Heading, PaginationWithLimit } from '$lib/components';
|
||||
import Filters from '$lib/components/filters/filters.svelte';
|
||||
import { hasPageQueries, queries } from '$lib/components/filters/store';
|
||||
import { Filters, hasPageQueries, queries } from '$lib/components/filters';
|
||||
import ViewSelector from '$lib/components/viewSelector.svelte';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import type { ColumnType } from '$lib/helpers/types';
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import { getLimit, getPage, getQuery, getView, pageToOffset, View } from '$lib/h
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import type { PageLoad } from './$types';
|
||||
import { queries, queryParamToMap } from '$lib/components/filters/store';
|
||||
import { queries, queryParamToMap } from '$lib/components/filters';
|
||||
|
||||
export const load: PageLoad = async ({ params, depends, url, route }) => {
|
||||
depends(Dependencies.DOCUMENTS);
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
|
||||
import { project } from '../store';
|
||||
import { showCreate } from './store';
|
||||
|
||||
// TODO: finalize the commands
|
||||
|
||||
$: $registerCommands([
|
||||
{
|
||||
label: 'Create message',
|
||||
callback: () => {
|
||||
if (!$page.url.pathname.endsWith('messaging')) {
|
||||
goto(`/console/project-${$project.$id}/messaging`);
|
||||
}
|
||||
$showCreate = true;
|
||||
},
|
||||
keys: $page.url.pathname.endsWith('messaging') ? ['c'] : ['c', 'm'],
|
||||
icon: 'plus',
|
||||
group: 'messaging'
|
||||
},
|
||||
{
|
||||
label: 'Go to topics',
|
||||
callback() {
|
||||
goto(`/console/project-${$project.$id}/messaging/topics`);
|
||||
},
|
||||
keys: ['g', 't'],
|
||||
disabled:
|
||||
$page.url.pathname.endsWith('topics') || $page.url.pathname.includes('message-'),
|
||||
group: 'navigation',
|
||||
rank: 10
|
||||
},
|
||||
{
|
||||
label: 'Go to providers',
|
||||
callback() {
|
||||
goto(`/console/project-${$project.$id}/messaging/providers`);
|
||||
},
|
||||
keys: ['g', 'p'],
|
||||
disabled:
|
||||
$page.url.pathname.endsWith('topics') || $page.url.pathname.includes('message-'),
|
||||
group: 'navigation',
|
||||
rank: 10
|
||||
}
|
||||
// {
|
||||
// label: 'Find messages',
|
||||
// callback: () => {
|
||||
// addSubPanel(BucketsPanel);
|
||||
// },
|
||||
// group: 'messaging',
|
||||
// rank: -1
|
||||
// }
|
||||
]);
|
||||
|
||||
$: $updateCommandGroupRanks({ messaging: 200, navigation: 100 });
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Messaging - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<slot />
|
||||
@@ -0,0 +1,10 @@
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import Header from './header.svelte';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async () => {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,246 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import {
|
||||
Empty,
|
||||
EmptyFilter,
|
||||
EmptySearch,
|
||||
FloatingActionBar,
|
||||
Heading,
|
||||
Id,
|
||||
PaginationWithLimit,
|
||||
SearchQuery,
|
||||
ViewSelector
|
||||
} from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellCheck,
|
||||
TableCellHead,
|
||||
TableCellHeadCheck,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRowLink,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { Container } from '$lib/layout';
|
||||
import type { PageData } from './$types';
|
||||
import { columns, showCreate } from './store';
|
||||
import MessageStatusPill from './messageStatusPill.svelte';
|
||||
import CreateMessageDropdown from './createMessageDropdown.svelte';
|
||||
import ProviderType, { ProviderTypes } from './providerType.svelte';
|
||||
import { Filters, hasPageQueries } from '$lib/components/filters';
|
||||
import FailedModal from './failedModal.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
let selected: string[] = [];
|
||||
let showDelete = false;
|
||||
let showFailed = false;
|
||||
let errors: string[] = [];
|
||||
let showCreateDropdownMobile = false;
|
||||
let showCreateDropdownDesktop = false;
|
||||
let showCreateDropdownEmpty = false;
|
||||
|
||||
const project = $page.params.project;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<Heading tag="h2" size="5">Messages</Heading>
|
||||
<div class="is-only-mobile">
|
||||
<CreateMessageDropdown bind:showCreateDropdown={showCreateDropdownMobile} />
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO: fix width of search input in mobile -->
|
||||
<SearchQuery search={data.search} placeholder="Search by channel, topic, provider, or ID">
|
||||
<div class="u-flex u-gap-16 is-not-mobile">
|
||||
<!-- TODO: make this not database-specific -->
|
||||
<Filters query={data.query} {columns} />
|
||||
<ViewSelector
|
||||
view={data.view}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
<CreateMessageDropdown bind:showCreateDropdown={showCreateDropdownDesktop} />
|
||||
</div>
|
||||
</SearchQuery>
|
||||
<div class="u-flex u-gap-16 is-only-mobile u-margin-block-start-16">
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<ViewSelector
|
||||
view={data.view}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
</div>
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<Filters query={data.query} {columns} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if data.messages.total}
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHeadCheck
|
||||
bind:selected
|
||||
pageItemsIds={data.messages.messages.map((d) => d.$id)} />
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
<TableCellHead width={column.width}>{column.title}</TableCellHead>
|
||||
{/if}
|
||||
{/each}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.messages.messages as message}
|
||||
<TableRowLink
|
||||
href={`${base}/console/project-${project}/messaging/message-${message.$id}`}>
|
||||
<TableCellCheck bind:selectedIds={selected} id={message.$id} />
|
||||
|
||||
{#each $columns as column (column.id)}
|
||||
{#if column.show}
|
||||
{#if column.id === '$id'}
|
||||
{#key $columns}
|
||||
<TableCell title={column.title} width={column.width}>
|
||||
<Id value={message.$id}>{message.$id}</Id>
|
||||
</TableCell>
|
||||
{/key}
|
||||
{:else if column.id === 'message'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{#if message.providerType === ProviderTypes.Push}
|
||||
{message.data.title}
|
||||
{:else if message.providerType === ProviderTypes.Sms}
|
||||
{message.data.content}
|
||||
{:else if message.providerType === ProviderTypes.Email}
|
||||
{message.data.subject}
|
||||
{:else}
|
||||
Invalid provider
|
||||
{/if}
|
||||
</TableCellText>
|
||||
{:else if column.id === 'providerType'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
<ProviderType type={message.providerType} size="s" />
|
||||
</TableCellText>
|
||||
{:else if column.id === 'status'}
|
||||
<TableCellText onlyDesktop title="Status">
|
||||
<MessageStatusPill
|
||||
status={message.status}
|
||||
on:click={(e) => {
|
||||
e.preventDefault();
|
||||
errors = message.deliveryErrors;
|
||||
showFailed = true;
|
||||
}} />
|
||||
</TableCellText>
|
||||
{:else if column.type === 'datetime'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{#if !message[column.id]}
|
||||
-
|
||||
{:else}
|
||||
{toLocaleDateTime(message[column.id])}
|
||||
{/if}
|
||||
</TableCellText>
|
||||
{:else}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{message[column.id]}
|
||||
</TableCellText>
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
|
||||
<FloatingActionBar show={selected.length > 0}>
|
||||
<div class="u-flex u-cross-center u-main-space-between actions">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<span class="indicator body-text-2 u-bold">{selected.length}</span>
|
||||
<p>
|
||||
<span class="is-only-desktop">
|
||||
{selected.length > 1 ? 'messages' : 'message'}
|
||||
</span>
|
||||
selected
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<Button text on:click={() => (selected = [])}>Cancel</Button>
|
||||
<!-- TODO: handle delete -->
|
||||
<Button secondary on:click={() => (showDelete = true)}>
|
||||
<p>Delete</p>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FloatingActionBar>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Messages"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.messages.total} />
|
||||
{:else if $hasPageQueries}
|
||||
<EmptyFilter resource="messages" />
|
||||
<!-- TODO: remove data.search != 'empty' when the API is ready with data -->
|
||||
{:else if data.search && data.search != 'empty'}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{data.search}'</b>
|
||||
<p>There are no messages that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16">
|
||||
<!-- TODO: update docs link -->
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/products/storage/upload-download"
|
||||
text>
|
||||
Documentation
|
||||
</Button>
|
||||
<Button secondary href={`/console/project-${$page.params.project}/messaging`}>
|
||||
Clear search
|
||||
</Button>
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<!-- TODO: update docs link -->
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs"
|
||||
target="message"
|
||||
on:click={() => ($showCreate = true)}>
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2" trimmed={false}>
|
||||
Create your first message to get started.
|
||||
</Heading>
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Learn more in our documentation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-flex-wrap u-gap-16 u-main-center">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/references/cloud/client-web/messages"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create message`}>
|
||||
Documentation
|
||||
</Button>
|
||||
<CreateMessageDropdown bind:showCreateDropdown={showCreateDropdownEmpty}>
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => (showCreateDropdownEmpty = !showCreateDropdownEmpty)}
|
||||
event="create_message">
|
||||
<span class="text">Create message</span>
|
||||
</Button>
|
||||
</CreateMessageDropdown>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<FailedModal bind:show={showFailed} {errors} />
|
||||
@@ -0,0 +1,72 @@
|
||||
import {
|
||||
View,
|
||||
getLimit,
|
||||
getPage,
|
||||
getQuery,
|
||||
getSearch,
|
||||
getView,
|
||||
pageToOffset
|
||||
} from '$lib/helpers/load';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import { messages as data, providersById } from './store';
|
||||
import type { Message } from './store';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { queries, queryParamToMap } from '$lib/components/filters';
|
||||
|
||||
export const load: PageLoad = async ({ url, route }) => {
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const view = getView(url, route, View.Grid);
|
||||
const limit = getLimit(url, route, CARD_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
const query = getQuery(url);
|
||||
|
||||
const parsedQueries = queryParamToMap(query || '[]');
|
||||
queries.set(parsedQueries);
|
||||
|
||||
// TODO: remove when the API is ready with data
|
||||
// This allows us to mock w/ data and when search returns 0 results
|
||||
let messages: { messages: Message[]; total: number } = { messages: [], total: 0 };
|
||||
if (search === 'demo') {
|
||||
messages = data;
|
||||
} else {
|
||||
const params = {
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
]
|
||||
};
|
||||
|
||||
if (search) {
|
||||
params['search'] = search;
|
||||
}
|
||||
|
||||
const response = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/messages'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
params
|
||||
);
|
||||
|
||||
messages = response;
|
||||
}
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
query,
|
||||
page,
|
||||
view,
|
||||
messages,
|
||||
providersById
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<script lang="ts">
|
||||
import { DropList, DropListItem } from '$lib/components';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { targetsById } from './wizard/store';
|
||||
import UserTargetsModal from './userTargetsModal.svelte';
|
||||
import type { ProviderTypes } from './providerType.svelte';
|
||||
import TopicsModal from './topicsModal.svelte';
|
||||
import { topicsById } from './store';
|
||||
|
||||
export let showDropdown: boolean;
|
||||
export let showUserTargets: boolean;
|
||||
export let showTopics: boolean;
|
||||
export let providerType: ProviderTypes = null;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
$: if (showUserTargets || showTopics) {
|
||||
showDropdown = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<DropList bind:show={showDropdown} placement="bottom-end" fixed>
|
||||
<slot />
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem on:click={() => (showTopics = true)}>Select topics</DropListItem>
|
||||
<DropListItem on:click={() => (showUserTargets = true)}>Select targets</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
|
||||
<TopicsModal
|
||||
bind:show={showTopics}
|
||||
bind:topicsById={$topicsById}
|
||||
on:update={(e) => {
|
||||
showTopics = false;
|
||||
dispatch('addTopics', e.detail);
|
||||
}} />
|
||||
<UserTargetsModal
|
||||
{providerType}
|
||||
bind:show={showUserTargets}
|
||||
bind:targetsById={$targetsById}
|
||||
on:update={(e) => {
|
||||
showUserTargets = false;
|
||||
dispatch('addTargets', e.detail);
|
||||
}} />
|
||||
@@ -0,0 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { Breadcrumbs } from '$lib/layout';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { project } from '../store';
|
||||
|
||||
$: breadcrumbs = [
|
||||
{
|
||||
href: `/console/organization-${$organization.$id}`,
|
||||
title: $organization.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}`,
|
||||
title: $project.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}/messaging`,
|
||||
title: 'Messaging'
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Breadcrumbs {breadcrumbs} />
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5 10.5C4.49857 13.5086 1.66667 16.3333 0 17C6.4 17 10.5 14.8333 11.5 13.5L16.5 15L16 0H5.5V2V4V4.5C5.5 5.5 5.5 7.5 5 10.5Z" fill="#333333"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -0,0 +1,3 @@
|
||||
<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M5 10.5C4.49857 13.5086 1.66667 16.3333 0 17C6.4 17 10.5 14.8333 11.5 13.5L16.5 15L16 0H5.5V2V4V4.5C5.5 5.5 5.5 7.5 5 10.5Z" fill="#E9E9EB"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -0,0 +1,114 @@
|
||||
<script lang="ts">
|
||||
import { Wizard } from '$lib/layout';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import Step1 from './wizard/step1.svelte';
|
||||
import Step2 from './wizard/step2.svelte';
|
||||
import Step3 from './wizard/step3.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { project } from '../store';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { providerType, messageParams } from './wizard/store';
|
||||
import { ProviderTypes } from './providerType.svelte';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
let response = { $id: '' };
|
||||
const messageId = $messageParams[$providerType].messageId || ID.unique();
|
||||
switch ($providerType) {
|
||||
case ProviderTypes.Email:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/messages/email'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
...$messageParams[$providerType],
|
||||
messageId
|
||||
}
|
||||
);
|
||||
break;
|
||||
case ProviderTypes.Sms:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/messages/sms'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
...$messageParams[$providerType],
|
||||
messageId
|
||||
}
|
||||
);
|
||||
break;
|
||||
case ProviderTypes.Push:
|
||||
const customData: Record<string, string> = {};
|
||||
const { data } = $messageParams[ProviderTypes.Push];
|
||||
if (data && data.length > 0) {
|
||||
data.forEach((item) => {
|
||||
if (item[0] === '') return;
|
||||
customData[item[0]] = item[1];
|
||||
});
|
||||
}
|
||||
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/messages/push'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
...$messageParams[$providerType],
|
||||
data: customData,
|
||||
messageId
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
wizard.hide();
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `The message has been sent.`
|
||||
});
|
||||
trackEvent(Submit.MessagingMessageCreate, {
|
||||
providerType: $providerType
|
||||
});
|
||||
await goto(`${base}/console/project-${$project.$id}/messaging/message-${response.$id}`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingProviderCreate);
|
||||
}
|
||||
}
|
||||
|
||||
const stepsComponents: WizardStepsType = new Map();
|
||||
stepsComponents.set(1, {
|
||||
label: 'Message',
|
||||
component: Step1
|
||||
});
|
||||
stepsComponents.set(2, {
|
||||
label: 'Targets',
|
||||
component: Step2
|
||||
});
|
||||
stepsComponents.set(3, {
|
||||
label: 'Schedule',
|
||||
component: Step3
|
||||
});
|
||||
</script>
|
||||
|
||||
<Wizard title="Create message" steps={stepsComponents} on:finish={create} finalAction="Send" />
|
||||
@@ -0,0 +1,69 @@
|
||||
<script lang="ts">
|
||||
import { DropList, DropListItem } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { providers } from './providers/store';
|
||||
import Create from './create.svelte';
|
||||
import { messageParams, providerType, targetsById } from './wizard/store';
|
||||
import { ProviderTypes } from './providerType.svelte';
|
||||
import { topicsById } from './store';
|
||||
|
||||
export let showCreateDropdown = false;
|
||||
</script>
|
||||
|
||||
<DropList bind:show={showCreateDropdown} scrollable placement="bottom-end">
|
||||
<slot>
|
||||
<Button on:click={() => (showCreateDropdown = !showCreateDropdown)} event="create_message">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create message</span>
|
||||
</Button>
|
||||
</slot>
|
||||
<svelte:fragment slot="list">
|
||||
{#each Object.entries(providers) as [type, option]}
|
||||
<DropListItem
|
||||
icon={option.icon}
|
||||
on:click={() => {
|
||||
if (
|
||||
type !== ProviderTypes.Email &&
|
||||
type !== ProviderTypes.Sms &&
|
||||
type !== ProviderTypes.Push
|
||||
)
|
||||
return;
|
||||
$providerType = type;
|
||||
$topicsById = {};
|
||||
$targetsById = {};
|
||||
const common = {
|
||||
topics: [],
|
||||
users: [],
|
||||
targets: []
|
||||
};
|
||||
switch (type) {
|
||||
case ProviderTypes.Email:
|
||||
$messageParams[$providerType] = {
|
||||
...common,
|
||||
subject: '',
|
||||
content: ''
|
||||
};
|
||||
break;
|
||||
case ProviderTypes.Sms:
|
||||
$messageParams[$providerType] = {
|
||||
...common,
|
||||
content: ''
|
||||
};
|
||||
break;
|
||||
case ProviderTypes.Push:
|
||||
$messageParams[$providerType] = {
|
||||
...common,
|
||||
title: '',
|
||||
body: ''
|
||||
};
|
||||
break;
|
||||
}
|
||||
showCreateDropdown = false;
|
||||
wizard.start(Create);
|
||||
}}>
|
||||
{option.name}
|
||||
</DropListItem>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import Code from '$lib/components/code.svelte';
|
||||
import Modal from '$lib/components/modal.svelte';
|
||||
import Button from '$lib/elements/forms/button.svelte';
|
||||
|
||||
export let show: boolean;
|
||||
export let errors: string[];
|
||||
</script>
|
||||
|
||||
<Modal title="Message error" headerDivider={false} bind:show size="big">
|
||||
<div class="box u-flex-vertical u-gap-24">
|
||||
<p>Some messages failed to send.</p>
|
||||
<div style="max-inline-size: 524px">
|
||||
<Code language="html" code={errors.join('\n')} noMargin noBoxPadding allowScroll />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (show = false)}>Close</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Tab, Tabs } from '$lib/components';
|
||||
import { isTabSelected } from '$lib/helpers/load';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const path = `/console/project-${projectId}/messaging`;
|
||||
const tabs = [
|
||||
{
|
||||
href: path,
|
||||
title: 'Messages',
|
||||
event: 'messages',
|
||||
hasChildren: true
|
||||
},
|
||||
{
|
||||
href: `${path}/topics`,
|
||||
title: 'Topics',
|
||||
event: 'topics',
|
||||
hasChildren: true
|
||||
},
|
||||
{
|
||||
href: `${path}/providers`,
|
||||
title: 'Providers',
|
||||
event: 'providers'
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Cover>
|
||||
<svelte:fragment slot="header">
|
||||
<CoverTitle>Messaging</CoverTitle>
|
||||
</svelte:fragment>
|
||||
<Tabs>
|
||||
{#each tabs as tab}
|
||||
<Tab
|
||||
href={tab.href}
|
||||
selected={isTabSelected(tab, $page.url.pathname, path, tabs)}
|
||||
event={tab.event}>
|
||||
{tab.title}
|
||||
</Tab>
|
||||
{/each}
|
||||
</Tabs>
|
||||
</Cover>
|
||||
@@ -0,0 +1,5 @@
|
||||
<svelte:head>
|
||||
<title>Message - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<slot />
|
||||
@@ -0,0 +1,33 @@
|
||||
import type { LayoutLoad } from './$types';
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import Header from './header.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import type { Message } from '../store';
|
||||
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.MESSAGING_MESSAGE);
|
||||
|
||||
try {
|
||||
const response: Message = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/messages/${params.message}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
message: response
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { Container } from '$lib/layout';
|
||||
import Delete from './delete.svelte';
|
||||
import EmailPreview from './emailPreview.svelte';
|
||||
import Overview from './overview.svelte';
|
||||
import { message } from './store';
|
||||
import { ProviderTypes } from '../providerType.svelte';
|
||||
import SMSPreview from './smsPreview.svelte';
|
||||
import PushPreview from './pushPreview.svelte';
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Overview />
|
||||
{#if $message.providerType === ProviderTypes.Email}
|
||||
<EmailPreview />
|
||||
{:else if $message.providerType === ProviderTypes.Sms}
|
||||
<SMSPreview />
|
||||
{:else if $message.providerType === ProviderTypes.Push}
|
||||
<PushPreview />
|
||||
{/if}
|
||||
<Delete />
|
||||
</Container>
|
||||
@@ -0,0 +1,24 @@
|
||||
<script lang="ts">
|
||||
import { Breadcrumbs } from '$lib/layout';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { project } from '../../store';
|
||||
import { message } from './store';
|
||||
|
||||
$: breadcrumbs = [
|
||||
{
|
||||
href: `/console/organization-${$organization.$id}`,
|
||||
title: $organization.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}`,
|
||||
title: $project.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}/messaging`,
|
||||
title:
|
||||
$message.data.title ?? $message.data.subject ?? $message.data.content ?? 'Message'
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Breadcrumbs {breadcrumbs} />
|
||||
@@ -0,0 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { BoxAvatar, CardGrid, Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import DeleteModal from './deleteModal.svelte';
|
||||
import { message } from './store';
|
||||
|
||||
let showDelete = false;
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Delete message</Heading>
|
||||
<p>
|
||||
The message will be permanently deleted, including all data associated with this message.
|
||||
This action is irreversible.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<BoxAvatar>
|
||||
<svelte:fragment slot="title">
|
||||
<h6 class="u-bold u-trim-1" data-private>
|
||||
{$message.data.title ??
|
||||
$message.data.subject ??
|
||||
$message.data.content ??
|
||||
'Message'}
|
||||
</h6>
|
||||
</svelte:fragment>
|
||||
<p>
|
||||
Last updated: {toLocaleDateTime($message.$updatedAt)}
|
||||
</p>
|
||||
</BoxAvatar>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button secondary on:click={() => (showDelete = true)} event="delete_file">Delete</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<DeleteModal bind:show={showDelete} />
|
||||
@@ -0,0 +1,56 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { message } from './store';
|
||||
|
||||
export let show = false;
|
||||
|
||||
const deleteMessage = async () => {
|
||||
try {
|
||||
await sdk.forProject.client.call(
|
||||
'DELETE',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/messages/${$message.$id}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
show = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Message has been deleted`
|
||||
});
|
||||
trackEvent(Submit.MessagingMessageDelete);
|
||||
await goto(`${base}/console/project-${$page.params.project}/messaging`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingMessageDelete);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
title="Delete message"
|
||||
bind:show
|
||||
onSubmit={deleteMessage}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<p data-private>Are you sure you want to delete this message?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (show = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { FormList, InputText, InputTextarea } from '$lib/elements/forms';
|
||||
import { message } from './store';
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16">
|
||||
<Heading tag="h6" size="7">Preview</Heading>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="subject"
|
||||
label="Subject"
|
||||
disabled={true}
|
||||
bind:value={$message.data.subject}>
|
||||
</InputText>
|
||||
<InputTextarea
|
||||
id="message"
|
||||
label="Message"
|
||||
disabled={true}
|
||||
bind:value={$message.data.content}>
|
||||
</InputTextarea>
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<!-- TODO: Add support for editing draft messages -->
|
||||
<!-- <Button disabled={$message.status !== 'draft'} on:click={() => console.log('click')}
|
||||
>Edit message</Button> -->
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -0,0 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Id } from '$lib/components';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
import { message } from './store';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
</script>
|
||||
|
||||
<Cover>
|
||||
<svelte:fragment slot="header">
|
||||
<CoverTitle href={`/console/project-${projectId}/messaging`}>
|
||||
{$message.data.title ?? $message.data.subject ?? $message.data.content ?? 'Message'}
|
||||
</CoverTitle>
|
||||
<Id value={$message.$id} event="message">{$message.$id}</Id>
|
||||
</svelte:fragment>
|
||||
</Cover>
|
||||
@@ -0,0 +1,52 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { message } from './store';
|
||||
import ProviderType, { ProviderTypes } from '../providerType.svelte';
|
||||
import MessageStatusPill from '../messageStatusPill.svelte';
|
||||
|
||||
let scheduledAt: string = '';
|
||||
if ($message.status === 'sent') {
|
||||
scheduledAt = $message.deliveredAt;
|
||||
} else if ($message.status === 'scheduled') {
|
||||
scheduledAt = $message.scheduledAt;
|
||||
}
|
||||
|
||||
let providerType = 'Invalid provider type';
|
||||
switch ($message.providerType) {
|
||||
case ProviderTypes.Email:
|
||||
providerType = 'Email';
|
||||
break;
|
||||
case ProviderTypes.Sms:
|
||||
providerType = 'SMS';
|
||||
break;
|
||||
case ProviderTypes.Push:
|
||||
providerType = 'Push';
|
||||
break;
|
||||
}
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16" data-private>
|
||||
<ProviderType type={$message.providerType} size="l">
|
||||
<Heading tag="h6" size="7">{providerType}</Heading>
|
||||
</ProviderType>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<div data-private>
|
||||
<p class="title">Created: {toLocaleDateTime($message.$createdAt)}</p>
|
||||
<p class="title">Scheduled at: {toLocaleDateTime(scheduledAt)}</p>
|
||||
</div>
|
||||
<div class="u-flex u-flex-vertical u-cross-end">
|
||||
<MessageStatusPill status={$message.status} />
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<!-- TODO: Add support for editing draft messages -->
|
||||
<!-- <Button disabled={$message.status !== 'draft'} on:click={() => console.log('click')}
|
||||
>Edit message</Button> -->
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -0,0 +1,33 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { FormList, InputText, InputTextarea } from '$lib/elements/forms';
|
||||
import { message } from './store';
|
||||
import PushPhone from '../pushPhone.svelte';
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<div class="grid-1-2-col-1 u-flex-vertical u-cross-start u-gap-16">
|
||||
<Heading tag="h6" size="7">Preview</Heading>
|
||||
<div class="u-flex u-main-center u-margin-block-start-24 u-width-full-line">
|
||||
<PushPhone title={$message.data.title} body={$message.data.body} />
|
||||
</div>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText id="title" label="Title" disabled={true} bind:value={$message.data.title}>
|
||||
</InputText>
|
||||
<InputTextarea
|
||||
id="message"
|
||||
label="Message"
|
||||
disabled={true}
|
||||
bind:value={$message.data.body}>
|
||||
</InputTextarea>
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<!-- TODO: Add support for editing draft messages -->
|
||||
<!-- <Button disabled={$message.status !== 'draft'} on:click={() => console.log('click')}
|
||||
>Edit message</Button> -->
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { FormList, InputTextarea } from '$lib/elements/forms';
|
||||
import { message } from './store';
|
||||
import SMSPhone from '../smsPhone.svelte';
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<div class="grid-1-2-col-1 u-flex-vertical u-cross-start u-gap-16">
|
||||
<Heading tag="h6" size="7">Preview</Heading>
|
||||
<SMSPhone content={$message.data.content} />
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputTextarea
|
||||
id="message"
|
||||
label="Message"
|
||||
disabled={true}
|
||||
bind:value={$message.data.content}>
|
||||
</InputTextarea>
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<!-- TODO: Add support for editing draft messages -->
|
||||
<!-- <Button disabled={$message.status !== 'draft'} on:click={() => console.log('click')}
|
||||
>Edit message</Button> -->
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -0,0 +1,5 @@
|
||||
import { derived } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import type { Message } from '../store';
|
||||
|
||||
export const message = derived(page, ($page) => $page.data.message as Message);
|
||||
@@ -0,0 +1,20 @@
|
||||
<script lang="ts">
|
||||
import { Pill } from '$lib/elements';
|
||||
|
||||
export let status: string;
|
||||
</script>
|
||||
|
||||
<Pill
|
||||
success={status === 'sent'}
|
||||
info={status === 'scheduled'}
|
||||
button={status == 'failed'}
|
||||
on:click>
|
||||
{#if status === 'sent'}
|
||||
<span class="icon-check-circle" aria-hidden="true"></span>
|
||||
{:else if status === 'scheduled'}
|
||||
<span class="icon-clock" aria-hidden="true"></span>
|
||||
{/if}
|
||||
<span class="text u-trim">
|
||||
{status}
|
||||
</span>
|
||||
</Pill>
|
||||
@@ -0,0 +1,96 @@
|
||||
<script context="module" lang="ts">
|
||||
export enum Providers {
|
||||
Twilio = 'twilio',
|
||||
Msg91 = 'msg91',
|
||||
Telesign = 'telesign',
|
||||
Textmagic = 'textmagic',
|
||||
Vonage = 'vonage',
|
||||
Mailgun = 'mailgun',
|
||||
Sendgrid = 'sendgrid',
|
||||
FCM = 'fcm',
|
||||
APNS = 'apns',
|
||||
MQTT = 'mqtt'
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { app } from '$lib/stores/app';
|
||||
|
||||
export let provider: Providers;
|
||||
export let name: string = '';
|
||||
export let noIcon = false;
|
||||
export let size: 's' | 'm' | 'l' = 'm';
|
||||
|
||||
let icon = '';
|
||||
let displayName = name || provider.charAt(0).toUpperCase() + provider.slice(1);
|
||||
|
||||
let textSize = '1.25rem';
|
||||
switch (size) {
|
||||
case 's':
|
||||
textSize = '1rem';
|
||||
break;
|
||||
case 'l':
|
||||
textSize = '1.5rem';
|
||||
break;
|
||||
}
|
||||
|
||||
switch (provider) {
|
||||
case Providers.FCM:
|
||||
icon = 'firebase';
|
||||
displayName = name || 'FCM';
|
||||
break;
|
||||
case Providers.APNS:
|
||||
icon = 'apple';
|
||||
displayName = name || 'APNS';
|
||||
break;
|
||||
case Providers.MQTT:
|
||||
icon = 'mqtt';
|
||||
displayName = name || 'MQTT';
|
||||
break;
|
||||
case Providers.Sendgrid:
|
||||
icon = 'sendgrid';
|
||||
break;
|
||||
case Providers.Mailgun:
|
||||
icon = 'mailgun';
|
||||
break;
|
||||
case Providers.Twilio:
|
||||
icon = 'twilio';
|
||||
break;
|
||||
case Providers.Telesign:
|
||||
icon = 'telesign';
|
||||
break;
|
||||
case Providers.Msg91:
|
||||
icon = 'msg91';
|
||||
displayName = name || 'MSG91';
|
||||
break;
|
||||
case Providers.Textmagic:
|
||||
icon = 'textmagic';
|
||||
displayName = name || 'TextMagic';
|
||||
break;
|
||||
case Providers.Vonage:
|
||||
icon = 'vonage';
|
||||
break;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if icon === ''}
|
||||
Invalid provider
|
||||
{:else}
|
||||
<div class="u-inline-flex u-cross-center u-gap-8">
|
||||
{#if !noIcon}
|
||||
<div
|
||||
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} />
|
||||
</div>
|
||||
{/if}
|
||||
<slot>
|
||||
{displayName}
|
||||
</slot>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,59 @@
|
||||
<script context="module" lang="ts">
|
||||
export enum ProviderTypes {
|
||||
Email = 'email',
|
||||
Sms = 'sms',
|
||||
Push = 'push'
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export let type: ProviderTypes;
|
||||
export let noIcon = false;
|
||||
export let size: 's' | 'm' | 'l' = 'm';
|
||||
|
||||
let icon = '';
|
||||
let text = '';
|
||||
|
||||
switch (type) {
|
||||
case ProviderTypes.Email:
|
||||
icon = 'icon-mail';
|
||||
text = 'Email';
|
||||
break;
|
||||
case ProviderTypes.Sms:
|
||||
icon = 'icon-annotation';
|
||||
text = 'SMS';
|
||||
break;
|
||||
case ProviderTypes.Push:
|
||||
icon = 'icon-device-mobile';
|
||||
text = 'Push';
|
||||
break;
|
||||
}
|
||||
|
||||
let textSize = '1.25rem';
|
||||
switch (size) {
|
||||
case 's':
|
||||
textSize = '1rem';
|
||||
break;
|
||||
case 'l':
|
||||
textSize = '1.5rem';
|
||||
break;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if text === ''}
|
||||
Invalid provider type
|
||||
{:else}
|
||||
<div class="u-inline-flex u-cross-center u-gap-8">
|
||||
{#if !noIcon}
|
||||
<div
|
||||
class="avatar"
|
||||
class:is-size-large={size === 'l'}
|
||||
class:is-size-small={size === 's'}>
|
||||
<span class={icon} style:font-size={textSize} aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
<slot>
|
||||
{text}
|
||||
</slot>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -0,0 +1,115 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Empty,
|
||||
EmptySearch,
|
||||
SearchQuery,
|
||||
PaginationWithLimit,
|
||||
Heading,
|
||||
ViewSelector,
|
||||
EmptyFilter
|
||||
} from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import type { PageData } from './$types';
|
||||
import { columns } from './store';
|
||||
import { Filters, hasPageQueries } from '$lib/components/filters';
|
||||
import CreateProviderDropdown from './createProviderDropdown.svelte';
|
||||
import Table from './table.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showCreateDropdownMobile = false;
|
||||
let showCreateDropdownDesktop = false;
|
||||
let showCreateDropdownEmpty = false;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<Heading tag="h2" size="5">Providers</Heading>
|
||||
<div class="is-only-mobile">
|
||||
<CreateProviderDropdown bind:showCreateDropdown={showCreateDropdownMobile} />
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO: fix width of search input in mobile -->
|
||||
<SearchQuery search={data.search} placeholder="Search provider">
|
||||
<div class="u-flex u-gap-16 is-not-mobile">
|
||||
<Filters query={data.query} {columns} />
|
||||
<ViewSelector
|
||||
view={data.view}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
<CreateProviderDropdown bind:showCreateDropdown={showCreateDropdownDesktop} />
|
||||
</div>
|
||||
</SearchQuery>
|
||||
<div class="u-flex u-gap-16 is-only-mobile u-margin-block-start-16">
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<ViewSelector
|
||||
view={data.view}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
</div>
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<Filters query={data.query} {columns} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if data.providers.total}
|
||||
<Table {data} />
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Providers"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.providers.total} />
|
||||
{:else if $hasPageQueries}
|
||||
<EmptyFilter resource="providers" />
|
||||
{:else if data.search && data.search != 'empty'}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{data.search}'</b>
|
||||
<p>There are no providers that match your search.</p>
|
||||
</div>
|
||||
<Button secondary href={`/console/project-${$page.params.project}/messaging/providers`}>
|
||||
Clear search
|
||||
</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<!-- TODO: Update docs links -->
|
||||
<Empty single target="provider">
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2" trimmed={false}>
|
||||
Create your first provider to get started.
|
||||
</Heading>
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Learn more in our documentation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-flex-wrap u-gap-16 u-main-center">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/references/cloud/client-web/providers"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create provider`}>
|
||||
Documentation
|
||||
</Button>
|
||||
<CreateProviderDropdown bind:showCreateDropdown={showCreateDropdownEmpty}>
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => (showCreateDropdownEmpty = !showCreateDropdownEmpty)}
|
||||
event="create_provider">
|
||||
<span class="text">Create provider</span>
|
||||
</Button>
|
||||
</CreateProviderDropdown>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
</Container>
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import {
|
||||
View,
|
||||
getLimit,
|
||||
getPage,
|
||||
getQuery,
|
||||
getSearch,
|
||||
getView,
|
||||
pageToOffset
|
||||
} from '$lib/helpers/load';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import { providersById, type Provider } from '../store';
|
||||
import { queries, queryParamToMap } from '$lib/components/filters';
|
||||
|
||||
const providers = Object.values(providersById);
|
||||
|
||||
let data: { providers: Provider[]; total: number } = {
|
||||
providers: [...providers],
|
||||
total: providers.length
|
||||
};
|
||||
|
||||
export const load = async ({ depends, url, route }) => {
|
||||
depends(Dependencies.MESSAGING_PROVIDERS);
|
||||
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const view = getView(url, route, View.Grid);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
const query = getQuery(url);
|
||||
|
||||
const parsedQueries = queryParamToMap(query || '[]');
|
||||
queries.set(parsedQueries);
|
||||
|
||||
// TODO: get rid of demo data
|
||||
let providers: { providers: Provider[]; total: number } = { providers: [], total: 0 };
|
||||
if (search == 'demo') {
|
||||
providers = data;
|
||||
} else {
|
||||
const params = {
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
]
|
||||
};
|
||||
|
||||
if (search) {
|
||||
params['search'] = search;
|
||||
}
|
||||
|
||||
const response = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/providers'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
params
|
||||
);
|
||||
|
||||
providers = response;
|
||||
}
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
query,
|
||||
page,
|
||||
view,
|
||||
providers
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,274 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy } from 'svelte';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import Provider from './wizard/provider.svelte';
|
||||
import Configure from './wizard/configure.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { project } from '../../store';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { provider, providerParams } from './wizard/store';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import { Providers } from '../provider.svelte';
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
let response = { $id: '', name: '' };
|
||||
const providerId = $providerParams[$provider].providerId || ID.unique();
|
||||
switch ($provider) {
|
||||
case Providers.Twilio:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/twilio'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
accountSid: $providerParams[$provider].accountSid,
|
||||
authToken: $providerParams[$provider].authToken,
|
||||
from: $providerParams[$provider].from
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Msg91:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/msg91'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
senderId: $providerParams[$provider].senderId,
|
||||
authKey: $providerParams[$provider].authKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Telesign:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/telesign'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
username: $providerParams[$provider].username,
|
||||
password: $providerParams[$provider].password
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Textmagic:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/textmagic'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
username: $providerParams[$provider].username,
|
||||
apiKey: $providerParams[$provider].apiKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Vonage:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/vonage'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
apiKey: $providerParams[$provider].apiKey,
|
||||
apiSecret: $providerParams[$provider].apiSecret
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Mailgun:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/mailgun'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
isEuRegion: $providerParams[$provider].isEuRegion,
|
||||
from: $providerParams[$provider].from,
|
||||
apiKey: $providerParams[$provider].apiKey,
|
||||
domain: $providerParams[$provider].domain
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Sendgrid:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/sendgrid'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
apiKey: $providerParams[$provider].apiKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.FCM:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/providers/fcm'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
serverKey: $providerParams[$provider].serverKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.APNS:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/apns'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
authKey: $providerParams[$provider].authKey,
|
||||
authKeyId: $providerParams[$provider].authKeyId,
|
||||
teamId: $providerParams[$provider].teamId,
|
||||
bundleId: $providerParams[$provider].bundleId
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.MQTT:
|
||||
response = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/mqtt'
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
serverKey: $providerParams[$provider].serverKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
wizard.hide();
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${response.name} has been created`
|
||||
});
|
||||
trackEvent(Submit.MessagingProviderCreate, {
|
||||
provider: $provider
|
||||
});
|
||||
await goto(
|
||||
`${base}/console/project-${$project.$id}/messaging/providers/provider-${response.$id}`
|
||||
);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingProviderCreate);
|
||||
}
|
||||
}
|
||||
|
||||
onDestroy(() => {
|
||||
console.log('destroy');
|
||||
});
|
||||
|
||||
const stepsComponents: WizardStepsType = new Map();
|
||||
stepsComponents.set(1, {
|
||||
label: 'Proivder',
|
||||
component: Provider
|
||||
});
|
||||
stepsComponents.set(2, {
|
||||
label: 'Configure',
|
||||
component: Configure
|
||||
});
|
||||
</script>
|
||||
|
||||
<Wizard title="Create provider" steps={stepsComponents} on:finish={create} />
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<script lang="ts">
|
||||
import { DropList, DropListItem } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { providers } from './store';
|
||||
import Create from './create.svelte';
|
||||
import { providerType, provider } from './wizard/store';
|
||||
import { ProviderTypes } from '../providerType.svelte';
|
||||
import { Providers } from '../provider.svelte';
|
||||
|
||||
export let showCreateDropdown = false;
|
||||
|
||||
const isValueOfStringEnum = <T extends Record<string, string>>(
|
||||
enumType: T,
|
||||
value: string
|
||||
): value is T[keyof T] => Object.values<string>(enumType).includes(value);
|
||||
</script>
|
||||
|
||||
<DropList bind:show={showCreateDropdown} scrollable placement="bottom-end">
|
||||
<slot>
|
||||
<Button on:click={() => (showCreateDropdown = !showCreateDropdown)} event="create_provider">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create provider</span>
|
||||
</Button>
|
||||
</slot>
|
||||
<svelte:fragment slot="list">
|
||||
{#each Object.entries(providers) as [type, option]}
|
||||
<DropListItem
|
||||
icon={option.icon}
|
||||
on:click={() => {
|
||||
if (
|
||||
type !== ProviderTypes.Email &&
|
||||
type !== ProviderTypes.Sms &&
|
||||
type !== ProviderTypes.Push
|
||||
)
|
||||
return;
|
||||
$providerType = type;
|
||||
const p = Object.keys(providers[type].providers).shift();
|
||||
if (p && isValueOfStringEnum(Providers, p)) {
|
||||
$provider = p;
|
||||
}
|
||||
showCreateDropdown = false;
|
||||
wizard.start(Create);
|
||||
}}>
|
||||
{option.name}
|
||||
</DropListItem>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<svelte:head>
|
||||
<title>Provider - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<slot />
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
import type { LayoutLoad } from './$types';
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import Header from './header.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.MESSAGING_PROVIDER);
|
||||
|
||||
const response = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/providers/' + params.provider),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
provider: response
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
}
|
||||
};
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<script lang="ts">
|
||||
import { Container } from '$lib/layout';
|
||||
import DangerZone from './dangerZone.svelte';
|
||||
import UpdateName from './updateName.svelte';
|
||||
import UpdateStatus from './updateStatus.svelte';
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<UpdateStatus />
|
||||
<UpdateName />
|
||||
<DangerZone />
|
||||
</Container>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { Breadcrumbs } from '$lib/layout';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import { provider } from './store';
|
||||
|
||||
$: breadcrumbs = [
|
||||
{
|
||||
href: `/console/organization-${$organization.$id}`,
|
||||
title: $organization.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}`,
|
||||
title: $project.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}/messaging`,
|
||||
title: 'Messaging'
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}/messaging/providers/provider-${$provider?.$id}`,
|
||||
title: $provider?.name
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Breadcrumbs {breadcrumbs} />
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
<script lang="ts" context="module">
|
||||
import { get } from 'svelte/store';
|
||||
|
||||
let showDelete = writable(false);
|
||||
|
||||
export const promptDeleteUser = (id: string) => {
|
||||
showDelete.set(true);
|
||||
goto(`/console/project-${get(project).$id}/auth/user-${id}`);
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { CardGrid, BoxAvatar, Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { writable } from 'svelte/store';
|
||||
import { provider } from './store';
|
||||
import { goto } from '$app/navigation';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import DeleteProvider from './deleteProvider.svelte';
|
||||
</script>
|
||||
|
||||
<CardGrid danger>
|
||||
<div>
|
||||
<Heading tag="h6" size="7">Delete provider</Heading>
|
||||
</div>
|
||||
<p>The provider's instance will be permanently deleted. This action is irreversible.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<BoxAvatar>
|
||||
<svelte:fragment slot="title">
|
||||
<h6 class="u-bold u-trim-1">{$provider.name}</h6>
|
||||
</svelte:fragment>
|
||||
<p>
|
||||
Last updated: {toLocaleDateTime($provider.$updatedAt)}
|
||||
</p>
|
||||
</BoxAvatar>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button secondary on:click={() => ($showDelete = true)} event="delete_messaging_provider"
|
||||
>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<DeleteProvider bind:showDelete={$showDelete} />
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { provider } from './store';
|
||||
import { project } from '../../../store';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
|
||||
export let showDelete = false;
|
||||
|
||||
const deleteProvider = async () => {
|
||||
try {
|
||||
await sdk.forProject.client.call(
|
||||
'DELETE',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint + '/messaging/providers/' + $provider.$id
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$provider.name} has been deleted`
|
||||
});
|
||||
trackEvent(Submit.MessagingProviderDelete);
|
||||
await goto(`${base}/console/project-${$page.params.project}/messaging/providers`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingProviderDelete);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
title="Delete provider"
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteProvider}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>{$provider.name}</b> from '{$project.name}'?
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Id } from '$lib/components';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
import { provider } from './store';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
</script>
|
||||
|
||||
<Cover>
|
||||
<svelte:fragment slot="header">
|
||||
<CoverTitle href={`/console/project-${projectId}/messaging/providers`}>
|
||||
{$provider?.name ? $provider?.name : '-'}
|
||||
</CoverTitle>
|
||||
<Id value={$provider?.$id} event="provider">{$provider?.$id}</Id>
|
||||
</svelte:fragment>
|
||||
</Cover>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { derived } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import type { Provider } from '../../store';
|
||||
|
||||
export const provider = derived(
|
||||
page,
|
||||
// TODO: Set actual type
|
||||
($page) => $page.data.provider as Provider
|
||||
);
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { Button, Form, InputText } from '$lib/elements/forms';
|
||||
import { onMount } from 'svelte';
|
||||
import { provider } from './store';
|
||||
|
||||
let providerName: string = null;
|
||||
onMount(async () => {
|
||||
providerName ??= $provider.name;
|
||||
});
|
||||
|
||||
async function updateName() {
|
||||
// TODO: switch on provider and update name
|
||||
// try {
|
||||
// await sdk.forProject.users.updateName($provider.$id, providerName);
|
||||
// await invalidate(Dependencies.USER);
|
||||
// addNotification({
|
||||
// message: 'Name has been updated',
|
||||
// type: 'success'
|
||||
// });
|
||||
// trackEvent(Submit.UserUpdateName);
|
||||
// } catch (error) {
|
||||
// addNotification({
|
||||
// message: error.message,
|
||||
// type: 'error'
|
||||
// });
|
||||
// trackError(error, Submit.UserUpdateName);
|
||||
// }
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateName}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Name</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ul data-private>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
autocomplete={false}
|
||||
bind:value={providerName} />
|
||||
</ul>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={providerName === $provider.name} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
+367
@@ -0,0 +1,367 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { Button, InputSwitch } from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { onMount } from 'svelte';
|
||||
import { provider } from './store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import Provider, { Providers } from '../../provider.svelte';
|
||||
import ProviderType from '../../providerType.svelte';
|
||||
import { provider as wizardProvider, providerType, providerParams } from '../wizard/store';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import Update from '../update.svelte';
|
||||
|
||||
let enabled: boolean = null;
|
||||
|
||||
onMount(() => {
|
||||
enabled ??= $provider.enabled;
|
||||
});
|
||||
|
||||
function configure() {
|
||||
$providerType = $provider.type;
|
||||
$wizardProvider = $provider.provider;
|
||||
|
||||
switch ($wizardProvider) {
|
||||
case Providers.Twilio:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
accountSid: $provider.credentials['accountSid'],
|
||||
authToken: $provider.credentials['authToken'],
|
||||
from: $provider.options['from']
|
||||
};
|
||||
break;
|
||||
case Providers.Msg91:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
from: $provider.options['from'],
|
||||
senderId: $provider.credentials['senderId'],
|
||||
authKey: $provider.credentials['authKey']
|
||||
};
|
||||
break;
|
||||
case Providers.Telesign:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
username: $provider.credentials['username'],
|
||||
password: $provider.credentials['password'],
|
||||
from: $provider.options['from']
|
||||
};
|
||||
break;
|
||||
case Providers.Textmagic:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
username: $provider.credentials['username'],
|
||||
apiKey: $provider.credentials['apiKey'],
|
||||
from: $provider.options['from']
|
||||
};
|
||||
break;
|
||||
case Providers.Vonage:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
apiKey: $provider.credentials['apiKey'],
|
||||
apiSecret: $provider.credentials['apiSecret'],
|
||||
from: $provider.options['from']
|
||||
};
|
||||
break;
|
||||
case Providers.Mailgun:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
isEuRegion: false,
|
||||
from: $provider.options['from'],
|
||||
apiKey: $provider.credentials['apiKey'],
|
||||
domain: $provider.credentials['domain']
|
||||
};
|
||||
break;
|
||||
case Providers.Sendgrid:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
apiKey: $provider.credentials['apiKey'],
|
||||
from: $provider.options['from']
|
||||
};
|
||||
break;
|
||||
case Providers.FCM:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
serverKey: $provider.credentials['serverKey']
|
||||
};
|
||||
break;
|
||||
case Providers.APNS:
|
||||
$providerParams[$wizardProvider] = {
|
||||
providerId: $provider.$id,
|
||||
name: $provider.name,
|
||||
default: $provider.default,
|
||||
enabled: $provider.enabled,
|
||||
authKey: $provider.credentials['authKey'],
|
||||
authKeyId: $provider.credentials['authKeyId'],
|
||||
teamId: $provider.credentials['teamId'],
|
||||
bundleId: $provider.credentials['bundleId']
|
||||
};
|
||||
break;
|
||||
case Providers.MQTT:
|
||||
break;
|
||||
}
|
||||
|
||||
wizard.start(Update);
|
||||
}
|
||||
|
||||
async function updateStatus() {
|
||||
try {
|
||||
let response = { $id: '', name: '' };
|
||||
const providerId = $provider.$id;
|
||||
switch ($provider.provider) {
|
||||
case Providers.Twilio:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/twilio/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Msg91:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/msg91/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Telesign:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/telesign/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Textmagic:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/textmagic/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Vonage:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/vonage/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Mailgun:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/mailgun/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Sendgrid:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/sendgrid/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.FCM:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/fcm/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.APNS:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/apns/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.MQTT:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
sdk.forProject.client.config.endpoint +
|
||||
'/messaging/providers/mqtt/' +
|
||||
providerId
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
enabled: enabled
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
await invalidate(Dependencies.MESSAGING_PROVIDER);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${response.name} has been ${enabled ? 'enabled' : 'disabled'}`
|
||||
});
|
||||
trackEvent(Submit.MessagingProviderUpdate, {
|
||||
provider: $provider
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingProviderUpdate);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16" data-private>
|
||||
<Provider provider={$provider.provider} size="l">
|
||||
<Heading tag="h6" size="7">{$provider.name}</Heading>
|
||||
</Provider>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<div data-private>
|
||||
<ul>
|
||||
<InputSwitch
|
||||
id="enabled"
|
||||
label={enabled ? 'Enabled' : 'Disabled'}
|
||||
bind:value={enabled} />
|
||||
</ul>
|
||||
<p class="title">Provider: <Provider noIcon provider={$provider.provider} /></p>
|
||||
<p class="title">Channel: <ProviderType noIcon type={$provider.type} /></p>
|
||||
<p>Created: {toLocaleDateTime($provider.$createdAt)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<div class="u-flex u-flex-wrap u-gap-12">
|
||||
<Button secondary on:click={() => configure()}>Configure</Button>
|
||||
<Button disabled={$provider.enabled === enabled} on:click={() => updateStatus()}
|
||||
>Update</Button>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -0,0 +1,382 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { Providers } from '../provider.svelte';
|
||||
import { ProviderTypes } from '../providerType.svelte';
|
||||
|
||||
export let showCreate = writable(false);
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Provider ID', type: 'string', show: true },
|
||||
{ id: 'name', title: 'Name', type: 'string', show: true },
|
||||
{ id: 'provider', title: 'Provider', type: 'string', show: true },
|
||||
{ id: 'type', title: 'Type', type: 'string', show: true },
|
||||
{ id: 'enabled', title: 'Status', type: 'boolean', show: true }
|
||||
]);
|
||||
|
||||
type ProvidersMap = {
|
||||
[key in ProviderTypes]: {
|
||||
name: string;
|
||||
text: string;
|
||||
icon: string;
|
||||
providers: {
|
||||
[key in Providers]?: {
|
||||
imageIcon: string;
|
||||
title: string;
|
||||
description: string;
|
||||
configure: {
|
||||
label: string;
|
||||
name: string;
|
||||
type: 'text' | 'phone' | 'email' | 'domain' | 'file' | 'switch';
|
||||
placeholder?: string;
|
||||
description?: string;
|
||||
popover?: string[];
|
||||
allowedFileExtensions?: string[];
|
||||
}[];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export const providers: ProvidersMap = {
|
||||
[ProviderTypes.Push]: {
|
||||
name: 'Push notification',
|
||||
text: 'notifications',
|
||||
icon: 'device-mobile',
|
||||
providers: {
|
||||
[Providers.FCM]: {
|
||||
imageIcon: 'firebase',
|
||||
title: 'FCM',
|
||||
description: 'Firebase Cloud Messaging',
|
||||
configure: [
|
||||
{
|
||||
label: 'Server key (.json file)',
|
||||
name: 'serverKey',
|
||||
type: 'file',
|
||||
allowedFileExtensions: ['json'],
|
||||
placeholder: 'Enter server key',
|
||||
popover: [
|
||||
'<b>How to get the FCM server key?</b>',
|
||||
'Head to <b>Project settings -> Service accounts -> Generate new private key.</b>',
|
||||
'Generating the new key will result in the download of a JSON file.'
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
[Providers.APNS]: {
|
||||
imageIcon: 'apple',
|
||||
title: 'APNS',
|
||||
description: 'Apple Push Notification Service',
|
||||
configure: [
|
||||
{
|
||||
label: 'Team ID',
|
||||
name: 'teamId',
|
||||
type: 'text',
|
||||
placeholder: 'Enter team ID',
|
||||
popover: [
|
||||
'<b>How to get the team ID?</b>',
|
||||
'Head to <b>Apple Developer Member Center -> Membership details -> Team ID.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Bundle ID',
|
||||
name: 'bundleId',
|
||||
type: 'text',
|
||||
placeholder: 'Enter bundle ID',
|
||||
popover: [
|
||||
'<b>How to get the bundle ID?</b>',
|
||||
'Head to <b>Apple Developer Member Center -> Certificates, Identifiers & Profiles -> Identifiers.</b>',
|
||||
`<a
|
||||
href="/images/apns-bundle-id.png"
|
||||
class="file-preview is-with-image"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label="open file in new window">
|
||||
<div class="file-preview-image">
|
||||
<img
|
||||
width="205"
|
||||
height="125"
|
||||
src="/images/apns-bundle-id.png"
|
||||
alt="Screenshot of Bundle ID in Apple" />
|
||||
</div>
|
||||
<div class="file-preview-content">
|
||||
<div class="avatar">
|
||||
<span class="icon-external-link" aria-hidden="true" />
|
||||
</div>
|
||||
</div>
|
||||
</a>`
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Authentication key ID',
|
||||
name: 'authKeyId',
|
||||
type: 'text',
|
||||
placeholder: 'Enter key ID',
|
||||
popover: [
|
||||
'<b>How to get the auth key ID?</b>',
|
||||
'Head to <b>Apple Developer Member Center -> Certificates, Identifiers & Profiles -> Keys.</b>',
|
||||
'Click on your key to view details.'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Auth key (.p8 file)',
|
||||
name: 'authKey',
|
||||
type: 'file',
|
||||
allowedFileExtensions: ['p8'],
|
||||
popover: [
|
||||
'<b>How to get the authentication key?</b>',
|
||||
'Head to <b>Apple Developer Member Center</b> (under Program resources) <b>-> Certificates, Identifiers & Profiles -> Keys.</b>',
|
||||
'Create a key and give it a name. Enable the Apple Push Notifications service (APNS), and register your key.'
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
// [Providers.MQTT]: {
|
||||
// imageIcon: 'mqtt',
|
||||
// title: 'MQTT',
|
||||
// description: 'Message Queuing Telemtry Transport'
|
||||
// }
|
||||
}
|
||||
},
|
||||
[ProviderTypes.Email]: {
|
||||
name: 'Email',
|
||||
text: 'emails',
|
||||
icon: 'mail',
|
||||
providers: {
|
||||
[Providers.Mailgun]: {
|
||||
imageIcon: 'mailgun',
|
||||
title: 'Mailgun',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'API key',
|
||||
name: 'apiKey',
|
||||
type: 'text',
|
||||
placeholder: 'Enter API key',
|
||||
popover: [
|
||||
'<b>How to get the API key?</b>',
|
||||
'Create an account in Mailgun.',
|
||||
'Head to <b>Profile -> API Security -> Add new key.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Domain',
|
||||
name: 'domain',
|
||||
type: 'domain',
|
||||
placeholder: 'Enter domain',
|
||||
popover: [
|
||||
'<b>How to create a domain?</b>',
|
||||
'Head to <b>Sending -> Domains -> Add new domain.</b>',
|
||||
'Follow <b>Mailgun instructions</b> to verify the domain name.'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'EU region',
|
||||
name: 'isEuRegion',
|
||||
type: 'switch',
|
||||
description:
|
||||
'Enable the EU region setting if your domain is within the European Union.'
|
||||
},
|
||||
{
|
||||
label: 'Sender email',
|
||||
name: 'from',
|
||||
type: 'email',
|
||||
placeholder: 'Enter email'
|
||||
}
|
||||
]
|
||||
},
|
||||
[Providers.Sendgrid]: {
|
||||
imageIcon: 'sendgrid',
|
||||
title: 'Sendgrid',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'API key',
|
||||
name: 'apiKey',
|
||||
type: 'text',
|
||||
placeholder: 'Enter API key',
|
||||
popover: [
|
||||
'<b>How to get the API key?</b>',
|
||||
'Create an account in Mailgun.',
|
||||
'Head to <b>Profile -> API Security -> Add new key.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Sender email',
|
||||
name: 'from',
|
||||
type: 'email',
|
||||
placeholder: 'Enter email'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
[ProviderTypes.Sms]: {
|
||||
name: 'SMS',
|
||||
text: 'SMS',
|
||||
icon: 'annotation',
|
||||
providers: {
|
||||
[Providers.Twilio]: {
|
||||
imageIcon: 'twilio',
|
||||
title: 'Twilio',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'Account SID',
|
||||
name: 'accountSid',
|
||||
type: 'text',
|
||||
placeholder: 'Enter Account SID',
|
||||
popover: [
|
||||
'<b>How to get the Account SID?</b>',
|
||||
'Head to <b>Twilio console -> Account info -> Account SID.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Auth token',
|
||||
name: 'authToken',
|
||||
type: 'text',
|
||||
placeholder: 'Enter Auth token',
|
||||
popover: [
|
||||
'<b>How to get the Auth token?</b>',
|
||||
'Head to <b>Twilio console -> Account info -> Auth Token.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Sender number',
|
||||
name: 'from',
|
||||
type: 'phone',
|
||||
placeholder: 'Enter phone',
|
||||
popover: [
|
||||
'<b>How to get sender number?</b>',
|
||||
'Head to <b>Twilio console -> Account info -> My Twilio phone number.</b>',
|
||||
'If you have multiple Twilio phone numbers, you can select one as the default number.'
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
[Providers.Msg91]: {
|
||||
imageIcon: 'msg91',
|
||||
title: 'MSG91',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'Auth key',
|
||||
name: 'authKey',
|
||||
type: 'text',
|
||||
placeholder: 'Enter auth key',
|
||||
popover: [
|
||||
'<b>How to get the Auth key?</b>',
|
||||
'Create an account in MSG91.',
|
||||
'Click to open the <b>Username dropdown -> Authkey -> Verify your mobile number -> Create Authkey.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Sender ID',
|
||||
name: 'senderId',
|
||||
type: 'text',
|
||||
placeholder: 'Enter sender ID',
|
||||
popover: [
|
||||
'<b>How to create a Sender ID?</b>',
|
||||
'Head to <b>MSG91 dashboard -> SMS -> Sender ID -> Create sender ID.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Sender number',
|
||||
name: 'from',
|
||||
type: 'phone',
|
||||
placeholder: 'Enter phone'
|
||||
}
|
||||
]
|
||||
},
|
||||
[Providers.Telesign]: {
|
||||
imageIcon: 'telesign',
|
||||
title: 'Telesign',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'Username',
|
||||
name: 'username',
|
||||
type: 'text',
|
||||
placeholder: 'Enter username'
|
||||
},
|
||||
{
|
||||
label: 'Password',
|
||||
name: 'password',
|
||||
type: 'text',
|
||||
placeholder: 'Enter password'
|
||||
},
|
||||
{
|
||||
label: 'Sender number',
|
||||
name: 'from',
|
||||
type: 'phone',
|
||||
placeholder: 'Enter phone'
|
||||
}
|
||||
]
|
||||
},
|
||||
[Providers.Textmagic]: {
|
||||
imageIcon: 'textmagic',
|
||||
title: 'Textmagic',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'API key',
|
||||
name: 'apiKey',
|
||||
type: 'text',
|
||||
placeholder: 'Enter API key',
|
||||
popover: [
|
||||
'<b>How to get the API key?</b>',
|
||||
'Create an account in Textmagic.',
|
||||
'Head to <b>TextMagic dashboard -> API Settings -> Add new API key.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Username',
|
||||
name: 'username',
|
||||
type: 'text',
|
||||
placeholder: 'Enter username'
|
||||
},
|
||||
{
|
||||
label: 'Sender number',
|
||||
name: 'from',
|
||||
type: 'phone',
|
||||
placeholder: 'Enter phone'
|
||||
}
|
||||
]
|
||||
},
|
||||
[Providers.Vonage]: {
|
||||
imageIcon: 'vonage',
|
||||
title: 'Vonage',
|
||||
description: '',
|
||||
configure: [
|
||||
{
|
||||
label: 'API key',
|
||||
name: 'apiKey',
|
||||
type: 'text',
|
||||
placeholder: 'Enter API key',
|
||||
popover: [
|
||||
'<b>How to get the API key?</b>',
|
||||
'Create an account in Vonage.',
|
||||
'Head to <b>Vonage dashboard and copy the API key.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'API secret',
|
||||
name: 'apiSecret',
|
||||
type: 'text',
|
||||
placeholder: 'Enter API secret',
|
||||
popover: [
|
||||
'<b>How to get the API secret?</b>',
|
||||
'Head to <b>Vonage dashboard and copy the API secret.</b>'
|
||||
]
|
||||
},
|
||||
{
|
||||
label: 'Sender number',
|
||||
name: 'from',
|
||||
type: 'phone',
|
||||
placeholder: 'Enter phone'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,170 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { FloatingActionBar, Id, Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellCheck,
|
||||
TableCellHead,
|
||||
TableCellHeadCheck,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRowLink,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { PageData } from './$types';
|
||||
import { columns } from './store';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import Provider from '../provider.svelte';
|
||||
import ProviderType from '../providerType.svelte';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let selectedIds: string[] = [];
|
||||
let showDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
async function handleDelete() {
|
||||
showDelete = false;
|
||||
|
||||
function deleteProvider(providerId: string) {
|
||||
return sdk.forProject.client.call(
|
||||
'DELETE',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const promises = selectedIds.map((id) => deleteProvider(id));
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.MessagingProviderDelete, {
|
||||
total: selectedIds.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedIds.length} provider${
|
||||
selectedIds.length > 1 ? 's' : ''
|
||||
} deleted`
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingProviderDelete);
|
||||
} finally {
|
||||
invalidate(Dependencies.MESSAGING_PROVIDERS);
|
||||
selectedIds = [];
|
||||
showDelete = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHeadCheck
|
||||
bind:selected={selectedIds}
|
||||
pageItemsIds={data.providers.providers.map((d) => d.$id)} />
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
<TableCellHead width={column.width}>{column.title}</TableCellHead>
|
||||
{/if}
|
||||
{/each}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.providers.providers as provider (provider.$id)}
|
||||
<TableRowLink
|
||||
href={`${base}/console/project-${$project.$id}/messaging/providers/provider-${provider.$id}`}>
|
||||
<TableCellCheck bind:selectedIds id={provider.$id} />
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
{#if column.id === '$id'}
|
||||
{#key $columns}
|
||||
<TableCell title={column.title} width={column.width}>
|
||||
<Id value={provider.$id}>{provider.$id}</Id>
|
||||
</TableCell>
|
||||
{/key}
|
||||
{:else if column.id === 'provider'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
<Provider provider={provider.provider} size="s" />
|
||||
</TableCellText>
|
||||
{:else if column.id === 'type'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
<ProviderType type={provider.type} size="s" />
|
||||
</TableCellText>
|
||||
{:else if column.id === 'enabled'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
<Pill success={provider.enabled}>
|
||||
{#if provider.enabled}
|
||||
<span class="icon-check-circle" aria-hidden="true"></span>
|
||||
{/if}
|
||||
<span class="text u-trim">
|
||||
{provider.enabled ? 'enabled' : 'disabled'}
|
||||
</span>
|
||||
</Pill>
|
||||
</TableCellText>
|
||||
{:else}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{provider[column.id]}
|
||||
</TableCellText>
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
|
||||
<FloatingActionBar show={selectedIds.length > 0}>
|
||||
<div class="u-flex u-cross-center u-main-space-between actions">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<span class="indicator body-text-2 u-bold">{selectedIds.length}</span>
|
||||
<p>
|
||||
<span class="is-only-desktop">
|
||||
{selectedIds.length > 1 ? 'providers' : 'provider'}
|
||||
</span>
|
||||
selected
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<Button text on:click={() => (selectedIds = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>
|
||||
<p>Delete</p>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FloatingActionBar>
|
||||
|
||||
<Modal
|
||||
title="Delete providers"
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
headerDivider={false}
|
||||
closable={!deleting}>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to delete <b>{selectedIds.length}</b>
|
||||
{selectedIds.length > 1 ? 'providers' : 'provider'}?
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)} disabled={deleting}>Cancel</Button>
|
||||
<Button secondary submit disabled={deleting}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,268 @@
|
||||
<script lang="ts">
|
||||
import { onDestroy } from 'svelte';
|
||||
import { Wizard } from '$lib/layout';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import Configure from './wizard/configure.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { project } from '../../store';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { provider, providerParams } from './wizard/store';
|
||||
import { Providers } from '../provider.svelte';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
|
||||
async function update() {
|
||||
try {
|
||||
let response = { $id: '', name: '' };
|
||||
const providerId = $providerParams[$provider].providerId;
|
||||
switch ($provider) {
|
||||
case Providers.Twilio:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/twilio/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
accountSid: $providerParams[$provider].accountSid,
|
||||
authToken: $providerParams[$provider].authToken,
|
||||
from: $providerParams[$provider].from
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Msg91:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/msg91/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
senderId: $providerParams[$provider].senderId,
|
||||
authKey: $providerParams[$provider].authKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Telesign:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/telesign/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
username: $providerParams[$provider].username,
|
||||
password: $providerParams[$provider].password
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Textmagic:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/textmagic/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
username: $providerParams[$provider].username,
|
||||
apiKey: $providerParams[$provider].apiKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Vonage:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/vonage/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
apiKey: $providerParams[$provider].apiKey,
|
||||
apiSecret: $providerParams[$provider].apiSecret
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Mailgun:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/mailgun/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
isEuRegion: $providerParams[$provider].isEuRegion,
|
||||
from: $providerParams[$provider].from,
|
||||
apiKey: $providerParams[$provider].apiKey,
|
||||
domain: $providerParams[$provider].domain
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.Sendgrid:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/sendgrid/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
from: $providerParams[$provider].from,
|
||||
apiKey: $providerParams[$provider].apiKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.FCM:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/fcm')/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
serverKey: $providerParams[$provider].serverKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.APNS:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/apns/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
authKey: $providerParams[$provider].authKey,
|
||||
authKeyId: $providerParams[$provider].authKeyId,
|
||||
teamId: $providerParams[$provider].teamId,
|
||||
bundleId: $providerParams[$provider].bundleId
|
||||
}
|
||||
);
|
||||
break;
|
||||
case Providers.MQTT:
|
||||
response = await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/providers/mqtt/${providerId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
providerId: providerId,
|
||||
name: $providerParams[$provider].name,
|
||||
default: $providerParams[$provider].default,
|
||||
enabled: $providerParams[$provider].enabled,
|
||||
serverKey: $providerParams[$provider].serverKey
|
||||
}
|
||||
);
|
||||
break;
|
||||
}
|
||||
await invalidate(Dependencies.MESSAGING_PROVIDER);
|
||||
wizard.hide();
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${response.name} has been updated`
|
||||
});
|
||||
trackEvent(Submit.MessagingProviderUpdate, {
|
||||
provider: $provider
|
||||
});
|
||||
await goto(
|
||||
`${base}/console/project-${$project.$id}/messaging/providers/provider-${response.$id}`
|
||||
);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingProviderUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
const stepsComponents: WizardStepsType = new Map();
|
||||
stepsComponents.set(1, {
|
||||
label: 'Configure',
|
||||
component: Configure
|
||||
});
|
||||
</script>
|
||||
|
||||
<Wizard title="Update provider" steps={stepsComponents} on:finish={update} finalAction="Update" />
|
||||
@@ -0,0 +1,147 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
FormList,
|
||||
InputDomain,
|
||||
InputEmail,
|
||||
InputFile,
|
||||
InputSwitch,
|
||||
InputText
|
||||
} from '$lib/elements/forms';
|
||||
import InputPhone from '$lib/elements/forms/inputPhone.svelte';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { onMount } from 'svelte';
|
||||
import { providers } from '../store';
|
||||
import { providerType, provider, providerParams } from './store';
|
||||
|
||||
let files: Record<string, FileList> = {};
|
||||
const inputs = providers[$providerType].providers[$provider].configure;
|
||||
|
||||
onMount(() => {
|
||||
for (const input of inputs) {
|
||||
if (input.type === 'file' && $providerParams[$provider][input.name].length > 0) {
|
||||
const dataTransfer = new DataTransfer();
|
||||
const f = new File(
|
||||
[$providerParams[$provider][input.name]],
|
||||
`${input.name}.${input.allowedFileExtensions}`
|
||||
);
|
||||
dataTransfer.items.add(f);
|
||||
files[input.name] = dataTransfer.files;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
async function beforeSubmit() {
|
||||
const promises = [];
|
||||
for (const [key, value] of Object.entries(files)) {
|
||||
const promise = value[0].text().then((text) => {
|
||||
$providerParams[$provider][key] = text;
|
||||
});
|
||||
promises.push(promise);
|
||||
}
|
||||
await Promise.all(promises);
|
||||
}
|
||||
</script>
|
||||
|
||||
<WizardStep {beforeSubmit}>
|
||||
<svelte:fragment slot="title">Configure</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
Set up the credentials below to enable {providers[$providerType].providers[$provider].title}
|
||||
for sending
|
||||
{providers[$providerType].text}.
|
||||
</svelte:fragment>
|
||||
<FormList>
|
||||
{#each inputs as input}
|
||||
{#if input.type === 'text'}
|
||||
<InputText
|
||||
id={input.name}
|
||||
label={input.label}
|
||||
placeholder={input.placeholder}
|
||||
bind:value={$providerParams[$provider][input.name]}>
|
||||
<svelte:fragment slot="popover">
|
||||
{@html input.popover?.join('<br/><br/>')}
|
||||
</svelte:fragment>
|
||||
</InputText>
|
||||
{:else if input.type === 'email'}
|
||||
<InputEmail
|
||||
id={input.name}
|
||||
label={input.label}
|
||||
placeholder={input.placeholder}
|
||||
bind:value={$providerParams[$provider][input.name]}>
|
||||
<svelte:fragment slot="popover">
|
||||
<p class="body-text-2 u-margin-block-end-16">
|
||||
{@html input.popover?.join('<br/><br/>')}
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
</InputEmail>
|
||||
{:else if input.type === 'domain'}
|
||||
<InputDomain
|
||||
id={input.name}
|
||||
label={input.label}
|
||||
placeholder={input.placeholder}
|
||||
bind:value={$providerParams[$provider][input.name]}>
|
||||
<svelte:fragment slot="popover">
|
||||
<p class="body-text-2 u-margin-block-end-16">
|
||||
{@html input.popover?.join('<br/><br/>')}
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
</InputDomain>
|
||||
{:else if input.type === 'phone'}
|
||||
<InputPhone
|
||||
id={input.name}
|
||||
label={input.label}
|
||||
placeholder={input.placeholder}
|
||||
bind:value={$providerParams[$provider][input.name]}>
|
||||
<svelte:fragment slot="popover">
|
||||
<p class="body-text-2 u-margin-block-end-16">
|
||||
{@html input.popover?.join('<br/><br/>')}
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
</InputPhone>
|
||||
{:else if input.type === 'file'}
|
||||
<InputFile
|
||||
label={input.label}
|
||||
allowedFileExtensions={input.allowedFileExtensions}
|
||||
bind:files={files[input.name]}>
|
||||
<svelte:fragment slot="popover">
|
||||
<p class="body-text-2 u-margin-block-end-16">
|
||||
{@html input.popover?.join('<br/><br/>')}
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
</InputFile>
|
||||
{:else if input.type === 'switch'}
|
||||
<InputSwitch
|
||||
label={input.label}
|
||||
id={input.name}
|
||||
bind:value={$providerParams[$provider][input.name]}>
|
||||
<svelte:fragment slot="description">
|
||||
{input.description}
|
||||
</svelte:fragment>
|
||||
</InputSwitch>
|
||||
{/if}
|
||||
{/each}
|
||||
</FormList>
|
||||
|
||||
<p class="body-text-2 u-bold u-margin-block-start-48">Need a hand?</p>
|
||||
|
||||
<div
|
||||
class="u-flex u-cross-center u-main-space-between u-padding-block-16"
|
||||
style="border-block-end: solid .0625rem hsl(var(--color-border))">
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-book-open" style:--p-text-size="1.25rem" aria-hidden="true" />
|
||||
</div>
|
||||
Read the full guide in the documentation
|
||||
</div>
|
||||
<span class="icon-arrow-right" aria-hidden="true" />
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-main-space-between u-padding-block-16">
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-user-group" style:--p-text-size="1.25rem" aria-hidden="true" />
|
||||
</div>
|
||||
Invite a team member to complete this step
|
||||
</div>
|
||||
<span class="icon-arrow-right" aria-hidden="true" />
|
||||
</div>
|
||||
</WizardStep>
|
||||
@@ -0,0 +1,161 @@
|
||||
<script lang="ts">
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { providerType, provider, providerParams } from './store';
|
||||
import { CustomId, LabelCard } from '$lib/components';
|
||||
import { providers } from '../store';
|
||||
import { FormList, InputText } from '$lib/elements/forms';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Providers } from '../../provider.svelte';
|
||||
|
||||
let name = '';
|
||||
let showCustomId = false;
|
||||
let id: string = null;
|
||||
|
||||
async function beforeSubmit() {
|
||||
console.log($provider);
|
||||
|
||||
switch ($provider) {
|
||||
case Providers.Twilio:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
accountSid: '',
|
||||
authToken: '',
|
||||
from: ''
|
||||
};
|
||||
break;
|
||||
case Providers.Msg91:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
from: '',
|
||||
senderId: '',
|
||||
authKey: ''
|
||||
};
|
||||
break;
|
||||
case Providers.Telesign:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
username: '',
|
||||
password: '',
|
||||
from: ''
|
||||
};
|
||||
break;
|
||||
case Providers.Textmagic:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
username: '',
|
||||
apiKey: '',
|
||||
from: ''
|
||||
};
|
||||
break;
|
||||
case Providers.Vonage:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
apiKey: '',
|
||||
apiSecret: '',
|
||||
from: ''
|
||||
};
|
||||
break;
|
||||
case Providers.Mailgun:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
isEuRegion: false,
|
||||
from: '',
|
||||
apiKey: '',
|
||||
domain: ''
|
||||
};
|
||||
break;
|
||||
case Providers.Sendgrid:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
apiKey: '',
|
||||
from: ''
|
||||
};
|
||||
break;
|
||||
case Providers.FCM:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
serverKey: ''
|
||||
};
|
||||
break;
|
||||
case Providers.APNS:
|
||||
$providerParams[$provider] = {
|
||||
providerId: id,
|
||||
name: name,
|
||||
default: false,
|
||||
enabled: false,
|
||||
authKey: '',
|
||||
authKeyId: '',
|
||||
teamId: '',
|
||||
bundleId: ''
|
||||
};
|
||||
break;
|
||||
case Providers.MQTT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<WizardStep {beforeSubmit}>
|
||||
<svelte:fragment slot="title">Provider</svelte:fragment>
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Provider name"
|
||||
bind:value={name}
|
||||
autofocus
|
||||
required />
|
||||
|
||||
{#if !showCustomId}
|
||||
<div>
|
||||
<Pill button on:click={() => (showCustomId = !showCustomId)}
|
||||
><span class="icon-pencil" aria-hidden="true" /><span class="text">
|
||||
Provider ID
|
||||
</span></Pill>
|
||||
</div>
|
||||
{:else}
|
||||
<CustomId bind:show={showCustomId} name="Provider" bind:id autofocus={false} />
|
||||
{/if}
|
||||
<p class="u-margin-block-start-24">
|
||||
Select a provider you would like to enable for sending {providers[$providerType].text}.
|
||||
</p>
|
||||
<div class="grid-box">
|
||||
{#each Object.entries(providers[$providerType].providers) as [value, option]}
|
||||
<LabelCard
|
||||
name="provider"
|
||||
{value}
|
||||
bind:group={$provider}
|
||||
imageIcon={option.imageIcon}>
|
||||
<svelte:fragment slot="title">{option.title}</svelte:fragment>
|
||||
{#if option.description}
|
||||
{option.description}
|
||||
{/if}
|
||||
</LabelCard>
|
||||
{/each}
|
||||
</div>
|
||||
</FormList>
|
||||
</WizardStep>
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { Providers } from '../../provider.svelte';
|
||||
import type { ProviderTypes } from '../../providerType.svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
type ProviderParams = {
|
||||
providerId: string;
|
||||
name: string;
|
||||
default: boolean;
|
||||
enabled: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* SMS providers
|
||||
*/
|
||||
|
||||
export type TwilioProviderParams = ProviderParams & {
|
||||
accountSid: string;
|
||||
authToken: string;
|
||||
from: string;
|
||||
};
|
||||
|
||||
export type Msg91ProviderParams = ProviderParams & {
|
||||
from: string;
|
||||
senderId: string;
|
||||
authKey: string;
|
||||
};
|
||||
|
||||
export type TelesignProviderParams = ProviderParams & {
|
||||
from: string;
|
||||
username: string;
|
||||
password: string;
|
||||
};
|
||||
|
||||
export type TextmagicProviderParams = ProviderParams & {
|
||||
from: string;
|
||||
username: string;
|
||||
apiKey: string;
|
||||
};
|
||||
|
||||
export type VonageProviderParams = ProviderParams & {
|
||||
from: string;
|
||||
apiKey: string;
|
||||
apiSecret: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Email providers
|
||||
*/
|
||||
|
||||
export type MailgunProviderParams = ProviderParams & {
|
||||
isEuRegion: boolean;
|
||||
from: string;
|
||||
apiKey: string;
|
||||
domain: string;
|
||||
};
|
||||
|
||||
export type SendgridProviderParams = ProviderParams & {
|
||||
from: string;
|
||||
apiKey: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Push providers
|
||||
*/
|
||||
|
||||
export type FCMProviderParams = ProviderParams & {
|
||||
serverKey: string;
|
||||
};
|
||||
|
||||
export type APNSProviderParams = ProviderParams & {
|
||||
authKey: string;
|
||||
authKeyId: string;
|
||||
teamId: string;
|
||||
bundleId: string;
|
||||
};
|
||||
|
||||
export type MQTTProviderParams = ProviderParams & {
|
||||
serverKey: string;
|
||||
};
|
||||
|
||||
export const providerType = writable<ProviderTypes>(null);
|
||||
export const provider = writable<Providers>(null);
|
||||
export const providerParams = writable<{
|
||||
twilio: Partial<TwilioProviderParams>;
|
||||
msg91: Partial<Msg91ProviderParams>;
|
||||
telesign: Partial<TelesignProviderParams>;
|
||||
textmagic: Partial<TextmagicProviderParams>;
|
||||
vonage: Partial<VonageProviderParams>;
|
||||
mailgun: Partial<MailgunProviderParams>;
|
||||
sendgrid: Partial<SendgridProviderParams>;
|
||||
fcm: Partial<FCMProviderParams>;
|
||||
apns: Partial<APNSProviderParams>;
|
||||
}>({
|
||||
twilio: null,
|
||||
msg91: null,
|
||||
telesign: null,
|
||||
textmagic: null,
|
||||
vonage: null,
|
||||
mailgun: null,
|
||||
sendgrid: null,
|
||||
fcm: null,
|
||||
apns: null
|
||||
});
|
||||
@@ -0,0 +1,161 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Column } from '$lib/components/viewSelector.svelte';
|
||||
|
||||
export let showCreate = writable(false);
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Provider ID', show: true },
|
||||
{ id: 'name', title: 'Name', show: true },
|
||||
{ id: 'provider', title: 'Provider', show: true },
|
||||
{ id: 'channel', title: 'Channel', show: true },
|
||||
{ id: 'status', title: 'Status', show: true }
|
||||
]);
|
||||
|
||||
export type Instruction = {
|
||||
text: string;
|
||||
input: {
|
||||
label: string;
|
||||
name: string;
|
||||
type: 'text' | 'domain' | 'email';
|
||||
placeholder: string;
|
||||
};
|
||||
};
|
||||
|
||||
export const providers = {
|
||||
sms: {
|
||||
name: 'SMS',
|
||||
text: 'SMS',
|
||||
icon: 'annotation',
|
||||
providers: {
|
||||
twilio: {
|
||||
imageIcon: 'twilio',
|
||||
title: 'Twilio',
|
||||
description: ''
|
||||
},
|
||||
msg91: {
|
||||
imageIcon: 'msg91',
|
||||
title: 'MSG91',
|
||||
description: ''
|
||||
},
|
||||
telesign: {
|
||||
imageIcon: 'telesign',
|
||||
title: 'Telesign',
|
||||
description: ''
|
||||
},
|
||||
textmagic: {
|
||||
imageIcon: 'textmagic',
|
||||
title: 'Textmagic',
|
||||
description: ''
|
||||
},
|
||||
vonage: {
|
||||
imageIcon: 'vonage',
|
||||
title: 'Vonage',
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
email: {
|
||||
name: 'Email',
|
||||
text: 'emails',
|
||||
icon: 'mail',
|
||||
providers: {
|
||||
mailgun: {
|
||||
imageIcon: 'mailgun',
|
||||
title: 'Mailgun',
|
||||
description: '',
|
||||
initialize: [
|
||||
{
|
||||
text: 'Before you can create a Mailgun provider, you need to first create a <a href="https://www.mailgun.com/" class="link" target="_blank" rel="noopener noreferrer">Mailgun</a> account.'
|
||||
},
|
||||
{
|
||||
text: 'Head to your <b>Profile > API Security</b>.'
|
||||
},
|
||||
{
|
||||
text: '<b>Generate a key</b> and give it a name. Copy and paste it in the field below.',
|
||||
input: {
|
||||
label: 'API key',
|
||||
name: 'apiKey',
|
||||
type: 'text',
|
||||
placeholder: 'Enter API key'
|
||||
}
|
||||
},
|
||||
{
|
||||
// TODO: Update link to domain verification
|
||||
text: 'Head to <b>Sending > Domains</b> and click on \'Add New Domain\'. Verify your domain by following the <a href="https://www.mailgun.com/" class="link" target="_blank" rel="noopener noreferrer">instructions</a>.',
|
||||
input: {
|
||||
label: 'Base URL',
|
||||
name: 'baseUrl',
|
||||
type: 'text',
|
||||
placeholder: 'Enter base URL'
|
||||
}
|
||||
}
|
||||
],
|
||||
configure: [
|
||||
{
|
||||
text: 'Provide a display name your recipient will see when they receive your emails.',
|
||||
input: {
|
||||
label: 'From',
|
||||
name: 'from',
|
||||
type: 'text',
|
||||
placeholder: 'Enter name'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Provide an email address that will be visible to the recipient as the senders email address for this message.',
|
||||
input: {
|
||||
label: 'From email address',
|
||||
name: 'email',
|
||||
type: 'email',
|
||||
placeholder: 'Enter email'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Provide an email address for users to use when replying to your emails.',
|
||||
input: {
|
||||
label: 'Reply to',
|
||||
name: 'replyTo',
|
||||
type: 'email',
|
||||
placeholder: 'Enter email'
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Provide the domain as it is registered on Mailgun.',
|
||||
input: {
|
||||
label: 'Domain',
|
||||
name: 'domain',
|
||||
type: 'domain',
|
||||
placeholder: 'Enter domain'
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
sendgrid: {
|
||||
imageIcon: 'sendgrid',
|
||||
title: 'Sendgrid',
|
||||
description: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
push: {
|
||||
name: 'Push notification',
|
||||
text: 'notifications',
|
||||
icon: 'device-mobile',
|
||||
providers: {
|
||||
fcm: {
|
||||
imageIcon: 'firebase',
|
||||
title: 'FCM',
|
||||
description: 'Firebase Cloud Messaging'
|
||||
},
|
||||
apns: {
|
||||
imageIcon: 'apple',
|
||||
title: 'APNS',
|
||||
description: 'Apple Push Notification Service'
|
||||
},
|
||||
mqtt: {
|
||||
imageIcon: 'mqtt',
|
||||
title: 'MQTT',
|
||||
description: 'Message Queuing Telemtry Transport'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<svg width="352" height="529" viewBox="0 0 352 529" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="path-1-inside-1_7_28" fill="white">
|
||||
<path d="M0 64C0 28.6538 28.6538 0 64 0H256C291.346 0 320 28.6538 320 64V529H0V64Z"/>
|
||||
</mask>
|
||||
<path d="M0 64C0 28.6538 28.6538 0 64 0H256C291.346 0 320 28.6538 320 64V529H0V64Z" fill="url(#paint0_linear_7_28)"/>
|
||||
<path d="M-1.25 64C-1.25 27.9634 27.9634 -1.25 64 -1.25H256C292.037 -1.25 321.25 27.9634 321.25 64H318.75C318.75 29.3441 290.656 1.25 256 1.25H64C29.3441 1.25 1.25 29.3441 1.25 64H-1.25ZM320 529H0H320ZM-1.25 529V64C-1.25 27.9634 27.9634 -1.25 64 -1.25V1.25C29.3441 1.25 1.25 29.3441 1.25 64V529H-1.25ZM256 -1.25C292.037 -1.25 321.25 27.9634 321.25 64V529H318.75V64C318.75 29.3441 290.656 1.25 256 1.25V-1.25Z" fill="url(#paint1_linear_7_28)" fill-opacity="0.08" mask="url(#path-1-inside-1_7_28)"/>
|
||||
<path d="M7 65C7 32.9675 32.9675 7 65 7H254C286.033 7 312 32.9675 312 65V529H7V65Z" fill="url(#paint2_linear_7_28)"/>
|
||||
<path d="M114.024 214.504C108.368 214.504 103.748 213.02 100.164 210.052C96.58 207.084 94.452 203.024 93.78 197.872H102.936C103.608 200.616 104.924 202.8 106.884 204.424C108.844 205.992 111.364 206.776 114.444 206.776C118.98 206.776 122.48 204.984 124.944 201.4C127.408 197.76 128.64 192.86 128.64 186.7C128.64 185.86 128.612 185.076 128.556 184.348C128.5 184.404 128.388 184.656 128.22 185.104C128.052 185.496 127.884 185.832 127.716 186.112C126.372 188.632 124.384 190.62 121.752 192.076C119.176 193.476 116.18 194.176 112.764 194.176C106.884 194.176 102.096 192.384 98.4 188.8C94.76 185.216 92.94 180.456 92.94 174.52C92.94 168.752 94.9 164.02 98.82 160.324C102.74 156.572 107.808 154.696 114.024 154.696C121.808 154.696 127.8 157.776 132 163.936C135.472 169.256 137.208 176.004 137.208 184.18C137.208 193.644 135.164 201.064 131.076 206.44C127.044 211.816 121.36 214.504 114.024 214.504ZM113.94 186.616C117.524 186.616 120.436 185.496 122.676 183.256C124.916 180.96 126.036 177.992 126.036 174.352C126.036 170.824 124.916 167.94 122.676 165.7C120.492 163.46 117.636 162.34 114.108 162.34C110.58 162.34 107.724 163.488 105.54 165.784C103.356 168.024 102.264 170.936 102.264 174.52C102.264 178.048 103.328 180.96 105.456 183.256C107.584 185.496 110.412 186.616 113.94 186.616ZM143.727 182.416C142.663 181.352 142.131 179.98 142.131 178.3C142.131 176.62 142.663 175.248 143.727 174.184C144.847 173.12 146.247 172.588 147.927 172.588C149.607 172.588 151.007 173.12 152.127 174.184C153.247 175.248 153.807 176.62 153.807 178.3C153.807 179.98 153.247 181.352 152.127 182.416C151.007 183.48 149.607 184.012 147.927 184.012C146.247 184.012 144.847 183.48 143.727 182.416ZM143.727 212.908C142.663 211.844 142.131 210.472 142.131 208.792C142.131 207.112 142.663 205.74 143.727 204.676C144.847 203.612 146.247 203.08 147.927 203.08C149.607 203.08 151.007 203.612 152.127 204.676C153.247 205.74 153.807 207.112 153.807 208.792C153.807 210.472 153.247 211.844 152.127 212.908C151.007 213.972 149.607 214.504 147.927 214.504C146.247 214.504 144.847 213.972 143.727 212.908ZM155.644 200.392V192.496L183.952 155.2H194.872V192.328H203.776V200.392H194.872V214H185.716V200.392H155.644ZM185.716 165.364L165.22 192.328H185.716V165.364ZM214.064 161.164V155.2H223.22V214H213.896V173.68C213.056 174.184 211.824 174.436 210.2 174.436H200.624V166.456H209.78C212.636 166.456 214.064 164.692 214.064 161.164Z" fill="#ADADB0" fill-opacity="0.08"/>
|
||||
<path d="M98.7727 134.273C98.7045 133.697 98.428 133.25 97.9432 132.932C97.4583 132.614 96.8636 132.455 96.1591 132.455C95.6439 132.455 95.1932 132.538 94.8068 132.705C94.4242 132.871 94.125 133.1 93.9091 133.392C93.697 133.684 93.5909 134.015 93.5909 134.386C93.5909 134.697 93.6648 134.964 93.8125 135.188C93.964 135.407 94.1572 135.591 94.392 135.739C94.6269 135.883 94.8731 136.002 95.1307 136.097C95.3883 136.187 95.625 136.261 95.8409 136.318L97.0227 136.636C97.3258 136.716 97.6629 136.826 98.0341 136.966C98.4091 137.106 98.767 137.297 99.108 137.54C99.4527 137.778 99.7367 138.085 99.9602 138.46C100.184 138.835 100.295 139.295 100.295 139.841C100.295 140.47 100.131 141.038 99.8011 141.545C99.4754 142.053 98.9981 142.456 98.3693 142.756C97.7443 143.055 96.9848 143.205 96.0909 143.205C95.2576 143.205 94.536 143.07 93.9261 142.801C93.3201 142.532 92.8428 142.157 92.4943 141.676C92.1496 141.195 91.9545 140.636 91.9091 140H93.3636C93.4015 140.439 93.5492 140.803 93.8068 141.091C94.0682 141.375 94.3977 141.587 94.7955 141.727C95.197 141.864 95.6288 141.932 96.0909 141.932C96.6288 141.932 97.1117 141.845 97.5398 141.67C97.9678 141.492 98.3068 141.246 98.5568 140.932C98.8068 140.614 98.9318 140.242 98.9318 139.818C98.9318 139.432 98.8239 139.117 98.608 138.875C98.392 138.633 98.108 138.436 97.7557 138.284C97.4034 138.133 97.0227 138 96.6136 137.886L95.1818 137.477C94.2727 137.216 93.553 136.843 93.0227 136.358C92.4924 135.873 92.2273 135.239 92.2273 134.455C92.2273 133.803 92.4034 133.235 92.7557 132.75C93.1117 132.261 93.589 131.883 94.1875 131.614C94.7898 131.341 95.4621 131.205 96.2045 131.205C96.9545 131.205 97.6212 131.339 98.2045 131.608C98.7879 131.873 99.25 132.237 99.5909 132.699C99.9356 133.161 100.117 133.686 100.136 134.273H98.7727ZM107.858 139.432V134.273H109.199V143H107.858V141.523H107.767C107.563 141.966 107.245 142.343 106.813 142.653C106.381 142.96 105.836 143.114 105.177 143.114C104.631 143.114 104.146 142.994 103.722 142.756C103.298 142.513 102.964 142.15 102.722 141.665C102.48 141.176 102.358 140.561 102.358 139.818V134.273H103.699V139.727C103.699 140.364 103.877 140.871 104.233 141.25C104.593 141.629 105.052 141.818 105.608 141.818C105.942 141.818 106.281 141.733 106.625 141.562C106.974 141.392 107.266 141.131 107.5 140.778C107.739 140.426 107.858 139.977 107.858 139.432ZM112.924 137.75V143H111.583V134.273H112.879V135.636H112.992C113.197 135.193 113.508 134.837 113.924 134.568C114.341 134.295 114.879 134.159 115.538 134.159C116.129 134.159 116.646 134.28 117.089 134.523C117.532 134.761 117.877 135.125 118.123 135.614C118.369 136.098 118.492 136.712 118.492 137.455V143H117.151V137.545C117.151 136.86 116.973 136.326 116.617 135.943C116.261 135.557 115.773 135.364 115.151 135.364C114.723 135.364 114.341 135.456 114.004 135.642C113.67 135.828 113.407 136.098 113.214 136.455C113.021 136.811 112.924 137.242 112.924 137.75ZM124.166 143.182C123.439 143.182 122.797 142.998 122.24 142.631C121.683 142.259 121.248 141.737 120.933 141.062C120.619 140.384 120.462 139.583 120.462 138.659C120.462 137.742 120.619 136.947 120.933 136.273C121.248 135.598 121.685 135.078 122.246 134.71C122.806 134.343 123.454 134.159 124.189 134.159C124.757 134.159 125.206 134.254 125.535 134.443C125.869 134.629 126.123 134.841 126.297 135.08C126.475 135.314 126.613 135.508 126.712 135.659H126.825V131.364H128.166V143H126.871V141.659H126.712C126.613 141.818 126.473 142.019 126.291 142.261C126.109 142.5 125.85 142.714 125.513 142.903C125.176 143.089 124.727 143.182 124.166 143.182ZM124.348 141.977C124.886 141.977 125.34 141.837 125.712 141.557C126.083 141.273 126.365 140.881 126.558 140.381C126.751 139.877 126.848 139.295 126.848 138.636C126.848 137.985 126.753 137.415 126.564 136.926C126.374 136.434 126.094 136.051 125.723 135.778C125.352 135.502 124.893 135.364 124.348 135.364C123.78 135.364 123.306 135.509 122.927 135.801C122.552 136.089 122.27 136.481 122.081 136.977C121.895 137.47 121.802 138.023 121.802 138.636C121.802 139.258 121.897 139.822 122.087 140.33C122.28 140.833 122.564 141.235 122.939 141.534C123.318 141.83 123.787 141.977 124.348 141.977ZM133.304 143.205C132.751 143.205 132.249 143.1 131.799 142.892C131.348 142.68 130.99 142.375 130.725 141.977C130.46 141.576 130.327 141.091 130.327 140.523C130.327 140.023 130.426 139.617 130.623 139.307C130.819 138.992 131.083 138.746 131.412 138.568C131.742 138.39 132.105 138.258 132.503 138.17C132.905 138.08 133.308 138.008 133.713 137.955C134.244 137.886 134.674 137.835 135.003 137.801C135.337 137.763 135.579 137.701 135.73 137.614C135.886 137.527 135.963 137.375 135.963 137.159V137.114C135.963 136.553 135.81 136.117 135.503 135.807C135.2 135.496 134.74 135.341 134.123 135.341C133.482 135.341 132.98 135.481 132.617 135.761C132.253 136.042 131.998 136.341 131.85 136.659L130.577 136.205C130.804 135.674 131.107 135.261 131.486 134.966C131.869 134.667 132.285 134.458 132.736 134.341C133.191 134.22 133.638 134.159 134.077 134.159C134.357 134.159 134.679 134.193 135.043 134.261C13Line truncated
|
||||
<rect x="114" y="20" width="90" height="24" rx="12" fill="#DBDBDB" fill-opacity="0.04"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M230.025 27.7143H230.875C231.344 27.7143 231.725 28.0981 231.725 28.5714V35.4286C231.725 35.902 231.344 36.2857 230.875 36.2857H230.025C229.556 36.2857 229.175 35.902 229.175 35.4286V28.5714C229.175 28.0981 229.556 27.7143 230.025 27.7143Z" fill="#F9F9F9" fill-opacity="0.18"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M226.2 29.4286H227.05C227.519 29.4286 227.9 29.8123 227.9 30.2857V35.4286C227.9 35.9019 227.519 36.2857 227.05 36.2857H226.2C225.731 36.2857 225.35 35.9019 225.35 35.4286V30.2857C225.35 29.8123 225.731 29.4286 226.2 29.4286Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M222.375 31.1429H223.225C223.694 31.1429 224.075 31.5266 224.075 32V35.4286C224.075 35.902 223.694 36.2857 223.225 36.2857H222.375C221.906 36.2857 221.525 35.902 221.525 35.4286V32C221.525 31.5266 221.906 31.1429 222.375 31.1429Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M218.55 32.4286H219.4C219.869 32.4286 220.25 32.8123 220.25 33.2857V35.4286C220.25 35.9019 219.869 36.2857 219.4 36.2857H218.55C218.081 36.2857 217.7 35.9019 217.7 35.4286V33.2857C217.7 32.8123 218.081 32.4286 218.55 32.4286Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M245.116 33.6625C245.676 33.6625 246.219 33.8065 246.698 34.0812L246.893 34.1925C247.04 34.2768 247.066 34.4743 246.945 34.5921L245.288 36.2111C245.186 36.3106 245.021 36.3106 244.919 36.2111L243.272 34.6026C243.152 34.4852 243.177 34.2888 243.323 34.2038L243.515 34.092C243.999 33.8104 244.549 33.6625 245.116 33.6625Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M245.116 30.6884C246.508 30.6884 247.845 31.1408 248.933 31.9785L249.087 32.0969C249.21 32.1913 249.221 32.3691 249.11 32.477L248.121 33.4435C248.029 33.5329 247.884 33.5432 247.781 33.4677L247.66 33.3798C246.925 32.8445 246.038 32.5573 245.116 32.5573C244.188 32.5573 243.297 32.8481 242.559 33.3896L242.438 33.4782C242.334 33.5543 242.189 33.5443 242.097 33.4546L241.108 32.4885C240.998 32.3808 241.008 32.2034 241.13 32.1089L241.283 31.9904C242.375 31.1452 243.717 30.6884 245.116 30.6884Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M245.116 27.7143C247.325 27.7143 249.438 28.4776 251.11 29.8768L251.253 29.9962C251.368 30.0928 251.375 30.2648 251.267 30.3697L250.281 31.3331C250.186 31.4264 250.033 31.433 249.929 31.3482L249.807 31.2481C248.491 30.1698 246.841 29.5832 245.116 29.5832C243.386 29.5832 241.73 30.1738 240.412 31.2589L240.29 31.3595C240.186 31.4447 240.033 31.4383 239.937 31.3448L238.951 30.3815C238.844 30.2768 238.851 30.105 238.966 30.0084L239.108 29.8889C240.782 28.4822 242.9 27.7143 245.116 27.7143Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M275 31V31C275.552 31 276 31.4477 276 32V33C276 33.5523 275.552 34 275 34V34V31Z" fill="#424245"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M259.217 28H271.783C273.007 28 274 29.0074 274 30.25V34.75C274 35.9926 273.007 37 271.783 37H259.217C257.993 37 257 35.9926 257 34.75V30.25C257 29.0074 257.993 28 259.217 28ZM259.217 28.75C258.401 28.75 257.739 29.4216 257.739 30.25V34.75C257.739 35.5784 258.401 36.25 259.217 36.25H271.783C272.599 36.25 273.261 35.5784 273.261 34.75V30.25C273.261 29.4216 272.599 28.75 271.783 28.75H259.217Z" fill="#424245"/>
|
||||
<path d="M258 30.5C258 29.6716 258.672 29 259.5 29H271.5C272.328 29 273 29.6716 273 30.5V34.5C273 35.3284 272.328 36 271.5 36H259.5C258.672 36 258 35.3284 258 34.5V30.5Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_7_28" x1="160" y1="0" x2="160" y2="529" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E1E22"/>
|
||||
<stop offset="1" stop-color="#1E1E22" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_7_28" x1="160" y1="0" x2="160" y2="673" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.262534" stop-color="#EDEDF0"/>
|
||||
<stop offset="1" stop-color="#EDEDF0" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_7_28" x1="159.5" y1="7" x2="159.5" y2="543.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#19191C"/>
|
||||
<stop offset="0.676095" stop-color="#1D1D21"/>
|
||||
<stop offset="1" stop-color="#1D1D21"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,35 @@
|
||||
<svg width="352" height="529" viewBox="0 0 352 529" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="path-1-inside-1_1_1925" fill="white">
|
||||
<path d="M0 64C0 28.6538 28.6538 0 64 0H256C291.346 0 320 28.6538 320 64V529H0V64Z"/>
|
||||
</mask>
|
||||
<path d="M0 64C0 28.6538 28.6538 0 64 0H256C291.346 0 320 28.6538 320 64V529H0V64Z" fill="white"/>
|
||||
<path d="M-1.25 64C-1.25 27.9634 27.9634 -1.25 64 -1.25H256C292.037 -1.25 321.25 27.9634 321.25 64H318.75C318.75 29.3441 290.656 1.25 256 1.25H64C29.3441 1.25 1.25 29.3441 1.25 64H-1.25ZM320 529H0H320ZM-1.25 529V64C-1.25 27.9634 27.9634 -1.25 64 -1.25V1.25C29.3441 1.25 1.25 29.3441 1.25 64V529H-1.25ZM256 -1.25C292.037 -1.25 321.25 27.9634 321.25 64V529H318.75V64C318.75 29.3441 290.656 1.25 256 1.25V-1.25Z" fill="url(#paint0_linear_1_1925)" fill-opacity="0.08" mask="url(#path-1-inside-1_1_1925)"/>
|
||||
<path d="M7 65C7 32.9675 32.9675 7 65 7H254C286.033 7 312 32.9675 312 65V529H7V65Z" fill="url(#paint1_linear_1_1925)"/>
|
||||
<path d="M114.024 214.504C108.368 214.504 103.748 213.02 100.164 210.052C96.58 207.084 94.452 203.024 93.78 197.872H102.936C103.608 200.616 104.924 202.8 106.884 204.424C108.844 205.992 111.364 206.776 114.444 206.776C118.98 206.776 122.48 204.984 124.944 201.4C127.408 197.76 128.64 192.86 128.64 186.7C128.64 185.86 128.612 185.076 128.556 184.348C128.5 184.404 128.388 184.656 128.22 185.104C128.052 185.496 127.884 185.832 127.716 186.112C126.372 188.632 124.384 190.62 121.752 192.076C119.176 193.476 116.18 194.176 112.764 194.176C106.884 194.176 102.096 192.384 98.4 188.8C94.76 185.216 92.94 180.456 92.94 174.52C92.94 168.752 94.9 164.02 98.82 160.324C102.74 156.572 107.808 154.696 114.024 154.696C121.808 154.696 127.8 157.776 132 163.936C135.472 169.256 137.208 176.004 137.208 184.18C137.208 193.644 135.164 201.064 131.076 206.44C127.044 211.816 121.36 214.504 114.024 214.504ZM113.94 186.616C117.524 186.616 120.436 185.496 122.676 183.256C124.916 180.96 126.036 177.992 126.036 174.352C126.036 170.824 124.916 167.94 122.676 165.7C120.492 163.46 117.636 162.34 114.108 162.34C110.58 162.34 107.724 163.488 105.54 165.784C103.356 168.024 102.264 170.936 102.264 174.52C102.264 178.048 103.328 180.96 105.456 183.256C107.584 185.496 110.412 186.616 113.94 186.616ZM143.727 182.416C142.663 181.352 142.131 179.98 142.131 178.3C142.131 176.62 142.663 175.248 143.727 174.184C144.847 173.12 146.247 172.588 147.927 172.588C149.607 172.588 151.007 173.12 152.127 174.184C153.247 175.248 153.807 176.62 153.807 178.3C153.807 179.98 153.247 181.352 152.127 182.416C151.007 183.48 149.607 184.012 147.927 184.012C146.247 184.012 144.847 183.48 143.727 182.416ZM143.727 212.908C142.663 211.844 142.131 210.472 142.131 208.792C142.131 207.112 142.663 205.74 143.727 204.676C144.847 203.612 146.247 203.08 147.927 203.08C149.607 203.08 151.007 203.612 152.127 204.676C153.247 205.74 153.807 207.112 153.807 208.792C153.807 210.472 153.247 211.844 152.127 212.908C151.007 213.972 149.607 214.504 147.927 214.504C146.247 214.504 144.847 213.972 143.727 212.908ZM155.644 200.392V192.496L183.952 155.2H194.872V192.328H203.776V200.392H194.872V214H185.716V200.392H155.644ZM185.716 165.364L165.22 192.328H185.716V165.364ZM214.064 161.164V155.2H223.22V214H213.896V173.68C213.056 174.184 211.824 174.436 210.2 174.436H200.624V166.456H209.78C212.636 166.456 214.064 164.692 214.064 161.164Z" fill="#19191C" fill-opacity="0.04"/>
|
||||
<path d="M98.7727 134.273C98.7045 133.697 98.428 133.25 97.9432 132.932C97.4583 132.614 96.8636 132.455 96.1591 132.455C95.6439 132.455 95.1932 132.538 94.8068 132.705C94.4242 132.871 94.125 133.1 93.9091 133.392C93.697 133.684 93.5909 134.015 93.5909 134.386C93.5909 134.697 93.6648 134.964 93.8125 135.188C93.964 135.407 94.1572 135.591 94.392 135.739C94.6269 135.883 94.8731 136.002 95.1307 136.097C95.3883 136.187 95.625 136.261 95.8409 136.318L97.0227 136.636C97.3258 136.716 97.6629 136.826 98.0341 136.966C98.4091 137.106 98.767 137.297 99.108 137.54C99.4527 137.778 99.7367 138.085 99.9602 138.46C100.184 138.835 100.295 139.295 100.295 139.841C100.295 140.47 100.131 141.038 99.8011 141.545C99.4754 142.053 98.9981 142.456 98.3693 142.756C97.7443 143.055 96.9848 143.205 96.0909 143.205C95.2576 143.205 94.536 143.07 93.9261 142.801C93.3201 142.532 92.8428 142.157 92.4943 141.676C92.1496 141.195 91.9545 140.636 91.9091 140H93.3636C93.4015 140.439 93.5492 140.803 93.8068 141.091C94.0682 141.375 94.3977 141.587 94.7955 141.727C95.197 141.864 95.6288 141.932 96.0909 141.932C96.6288 141.932 97.1117 141.845 97.5398 141.67C97.9678 141.492 98.3068 141.246 98.5568 140.932C98.8068 140.614 98.9318 140.242 98.9318 139.818C98.9318 139.432 98.8239 139.117 98.608 138.875C98.392 138.633 98.108 138.436 97.7557 138.284C97.4034 138.133 97.0227 138 96.6136 137.886L95.1818 137.477C94.2727 137.216 93.553 136.843 93.0227 136.358C92.4924 135.873 92.2273 135.239 92.2273 134.455C92.2273 133.803 92.4034 133.235 92.7557 132.75C93.1117 132.261 93.589 131.883 94.1875 131.614C94.7898 131.341 95.4621 131.205 96.2045 131.205C96.9545 131.205 97.6212 131.339 98.2045 131.608C98.7879 131.873 99.25 132.237 99.5909 132.699C99.9356 133.161 100.117 133.686 100.136 134.273H98.7727ZM107.858 139.432V134.273H109.199V143H107.858V141.523H107.767C107.563 141.966 107.245 142.343 106.813 142.653C106.381 142.96 105.836 143.114 105.177 143.114C104.631 143.114 104.146 142.994 103.722 142.756C103.298 142.513 102.964 142.15 102.722 141.665C102.48 141.176 102.358 140.561 102.358 139.818V134.273H103.699V139.727C103.699 140.364 103.877 140.871 104.233 141.25C104.593 141.629 105.052 141.818 105.608 141.818C105.942 141.818 106.281 141.733 106.625 141.562C106.974 141.392 107.266 141.131 107.5 140.778C107.739 140.426 107.858 139.977 107.858 139.432ZM112.924 137.75V143H111.583V134.273H112.879V135.636H112.992C113.197 135.193 113.508 134.837 113.924 134.568C114.341 134.295 114.879 134.159 115.538 134.159C116.129 134.159 116.646 134.28 117.089 134.523C117.532 134.761 117.877 135.125 118.123 135.614C118.369 136.098 118.492 136.712 118.492 137.455V143H117.151V137.545C117.151 136.86 116.973 136.326 116.617 135.943C116.261 135.557 115.773 135.364 115.151 135.364C114.723 135.364 114.341 135.456 114.004 135.642C113.67 135.828 113.407 136.098 113.214 136.455C113.021 136.811 112.924 137.242 112.924 137.75ZM124.166 143.182C123.439 143.182 122.797 142.998 122.24 142.631C121.683 142.259 121.248 141.737 120.933 141.062C120.619 140.384 120.462 139.583 120.462 138.659C120.462 137.742 120.619 136.947 120.933 136.273C121.248 135.598 121.685 135.078 122.246 134.71C122.806 134.343 123.454 134.159 124.189 134.159C124.757 134.159 125.206 134.254 125.535 134.443C125.869 134.629 126.123 134.841 126.297 135.08C126.475 135.314 126.613 135.508 126.712 135.659H126.825V131.364H128.166V143H126.871V141.659H126.712C126.613 141.818 126.473 142.019 126.291 142.261C126.109 142.5 125.85 142.714 125.513 142.903C125.176 143.089 124.727 143.182 124.166 143.182ZM124.348 141.977C124.886 141.977 125.34 141.837 125.712 141.557C126.083 141.273 126.365 140.881 126.558 140.381C126.751 139.877 126.848 139.295 126.848 138.636C126.848 137.985 126.753 137.415 126.564 136.926C126.374 136.434 126.094 136.051 125.723 135.778C125.352 135.502 124.893 135.364 124.348 135.364C123.78 135.364 123.306 135.509 122.927 135.801C122.552 136.089 122.27 136.481 122.081 136.977C121.895 137.47 121.802 138.023 121.802 138.636C121.802 139.258 121.897 139.822 122.087 140.33C122.28 140.833 122.564 141.235 122.939 141.534C123.318 141.83 123.787 141.977 124.348 141.977ZM133.304 143.205C132.751 143.205 132.249 143.1 131.799 142.892C131.348 142.68 130.99 142.375 130.725 141.977C130.46 141.576 130.327 141.091 130.327 140.523C130.327 140.023 130.426 139.617 130.623 139.307C130.819 138.992 131.083 138.746 131.412 138.568C131.742 138.39 132.105 138.258 132.503 138.17C132.905 138.08 133.308 138.008 133.713 137.955C134.244 137.886 134.674 137.835 135.003 137.801C135.337 137.763 135.579 137.701 135.73 137.614C135.886 137.527 135.963 137.375 135.963 137.159V137.114C135.963 136.553 135.81 136.117 135.503 135.807C135.2 135.496 134.74 135.341 134.123 135.341C133.482 135.341 132.98 135.481 132.617 135.761C132.253 136.042 131.998 136.341 131.85 136.659L130.577 136.205C130.804 135.674 131.107 135.261 131.486 134.966C131.869 134.667 132.285 134.458 132.736 134.341C133.191 134.22 133.638 134.159 134.077 134.159C134.357 134.159 134.679 134.193 135.043 134.261C13Line truncated
|
||||
<rect x="114" y="20" width="90" height="24" rx="12" fill="#19191C" fill-opacity="0.04"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M226.2 29.4286H227.05C227.519 29.4286 227.9 29.8123 227.9 30.2857V35.4286C227.9 35.902 227.519 36.2857 227.05 36.2857H226.2C225.731 36.2857 225.35 35.902 225.35 35.4286V30.2857C225.35 29.8123 225.731 29.4286 226.2 29.4286Z" fill="#F9F9F9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M222.375 31.1429H223.225C223.694 31.1429 224.075 31.5266 224.075 32V35.4286C224.075 35.902 223.694 36.2857 223.225 36.2857H222.375C221.906 36.2857 221.525 35.902 221.525 35.4286V32C221.525 31.5266 221.906 31.1429 222.375 31.1429Z" fill="#F9F9F9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M218.55 32.4286H219.4C219.869 32.4286 220.25 32.8123 220.25 33.2857V35.4286C220.25 35.902 219.869 36.2857 219.4 36.2857H218.55C218.081 36.2857 217.7 35.902 217.7 35.4286V33.2857C217.7 32.8123 218.081 32.4286 218.55 32.4286Z" fill="#F9F9F9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M230.025 27.7143H230.875C231.344 27.7143 231.725 28.098 231.725 28.5714V35.4286C231.725 35.902 231.344 36.2857 230.875 36.2857H230.025C229.556 36.2857 229.175 35.902 229.175 35.4286V28.5714C229.175 28.098 229.556 27.7143 230.025 27.7143Z" fill="#19191C" fill-opacity="0.06"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M226.2 29.4286H227.05C227.519 29.4286 227.9 29.8123 227.9 30.2857V35.4286C227.9 35.902 227.519 36.2857 227.05 36.2857H226.2C225.731 36.2857 225.35 35.902 225.35 35.4286V30.2857C225.35 29.8123 225.731 29.4286 226.2 29.4286Z" fill="black" fill-opacity="0.12"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M222.375 31.1429H223.225C223.694 31.1429 224.075 31.5266 224.075 32V35.4286C224.075 35.902 223.694 36.2857 223.225 36.2857H222.375C221.906 36.2857 221.525 35.902 221.525 35.4286V32C221.525 31.5266 221.906 31.1429 222.375 31.1429Z" fill="black" fill-opacity="0.12"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M218.55 32.4286H219.4C219.869 32.4286 220.25 32.8123 220.25 33.2857V35.4286C220.25 35.902 219.869 36.2857 219.4 36.2857H218.55C218.081 36.2857 217.7 35.902 217.7 35.4286V33.2857C217.7 32.8123 218.081 32.4286 218.55 32.4286Z" fill="black" fill-opacity="0.12"/>
|
||||
<path d="M245.116 33.6625C245.676 33.6625 246.219 33.8065 246.698 34.0812L246.893 34.1925C247.04 34.2768 247.066 34.4743 246.945 34.5921L245.288 36.2111C245.186 36.3106 245.021 36.3106 244.919 36.2111L243.272 34.6025C243.152 34.4852 243.177 34.2887 243.323 34.2038L243.515 34.092C243.999 33.8104 244.549 33.6625 245.116 33.6625Z" fill="black" fill-opacity="0.12"/>
|
||||
<path d="M245.116 30.6884C246.508 30.6884 247.845 31.1408 248.933 31.9785L249.087 32.0969C249.21 32.1913 249.221 32.3691 249.11 32.477L248.121 33.4435C248.029 33.5329 247.884 33.5432 247.781 33.4677L247.66 33.3798C246.925 32.8445 246.038 32.5573 245.116 32.5573C244.188 32.5573 243.297 32.8481 242.559 33.3896L242.438 33.4782C242.334 33.5543 242.189 33.5443 242.097 33.4546L241.108 32.4885C240.998 32.3808 241.008 32.2034 241.13 32.1089L241.283 31.9904C242.375 31.1452 243.717 30.6884 245.116 30.6884Z" fill="black" fill-opacity="0.12"/>
|
||||
<path d="M245.116 27.7143C247.325 27.7143 249.438 28.4776 251.11 29.8768L251.253 29.9962C251.368 30.0927 251.375 30.2648 251.267 30.3697L250.281 31.3331C250.186 31.4264 250.033 31.433 249.929 31.3482L249.807 31.2481C248.491 30.1698 246.841 29.5832 245.116 29.5832C243.386 29.5832 241.73 30.1738 240.412 31.2589L240.29 31.3595C240.186 31.4446 240.033 31.4383 239.937 31.3448L238.951 30.3815C238.844 30.2767 238.851 30.105 238.966 30.0084L239.108 29.8889C240.782 28.4822 242.9 27.7143 245.116 27.7143Z" fill="black" fill-opacity="0.12"/>
|
||||
<path d="M275 31V31C275.552 31 276 31.4477 276 32V33C276 33.5523 275.552 34 275 34V34V31Z" fill="#19191C" fill-opacity="0.08"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M259.217 28H271.783C273.007 28 274 29.0074 274 30.25V34.75C274 35.9926 273.007 37 271.783 37H259.217C257.993 37 257 35.9926 257 34.75V30.25C257 29.0074 257.993 28 259.217 28ZM259.217 28.75C258.401 28.75 257.739 29.4216 257.739 30.25V34.75C257.739 35.5784 258.401 36.25 259.217 36.25H271.783C272.599 36.25 273.261 35.5784 273.261 34.75V30.25C273.261 29.4216 272.599 28.75 271.783 28.75H259.217Z" fill="#19191C" fill-opacity="0.08"/>
|
||||
<path d="M258 30.5C258 29.6716 258.672 29 259.5 29H271.5C272.328 29 273 29.6716 273 30.5V34.5C273 35.3284 272.328 36 271.5 36H259.5C258.672 36 258 35.3284 258 34.5V30.5Z" fill="black" fill-opacity="0.12"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_1_1925" x1="160" y1="0" x2="160" y2="673" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.262534" stop-color="#19191C"/>
|
||||
<stop offset="1" stop-color="#19191C" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_1_1925" x1="159.5" y1="7" x2="159.5" y2="543.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#FAFAFB"/>
|
||||
<stop offset="0.676095" stop-color="#FAFAFB"/>
|
||||
<stop offset="1" stop-color="white"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 22 KiB |
@@ -0,0 +1,73 @@
|
||||
<script lang="ts">
|
||||
import { project } from '../store';
|
||||
|
||||
export let title = '';
|
||||
export let body = '';
|
||||
export let classes = '';
|
||||
</script>
|
||||
|
||||
<div class="phone {classes}">
|
||||
<div
|
||||
class="u-flex u-flex-vertical card u-margin-inline-start-24 u-margin-inline-end-24 u-gap-8">
|
||||
<div class="u-flex u-main-space-between header">
|
||||
<div class="u-flex u-gap-4 u-cross-center">
|
||||
<span class="u-icon icon-bell u-line-height-1" /><span class=""
|
||||
>{$project.name}</span>
|
||||
</div>
|
||||
<div class="u-flex u-cross-center">now</div>
|
||||
</div>
|
||||
<div>
|
||||
<p class="body-text-1 u-small u-bold">{title || 'Message Title'}</p>
|
||||
<p class="body-text-2 u-x-small">
|
||||
{body || 'Enter your message in the input field on the left to see it here'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.phone {
|
||||
width: 320px;
|
||||
height: 539px;
|
||||
background-image: url('./push-notification-preview-light.svg');
|
||||
background-repeat: no-repeat;
|
||||
padding-top: 197px;
|
||||
--p-body-text-color: hsl(var(--color-neutral-120));
|
||||
|
||||
.card {
|
||||
position: relative;
|
||||
width: 329px;
|
||||
--card-padding: 1rem;
|
||||
|
||||
.header {
|
||||
--p-body-text-color: hsl(var(--color-neutral-100));
|
||||
|
||||
.icon-bell {
|
||||
--p-body-text-color: hsl(var(--color-neutral-50));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(.theme-dark) .phone {
|
||||
background-image: url('./push-notification-preview-dark.svg');
|
||||
|
||||
.card {
|
||||
--p-card-bg-color: 240, 3%, 14%, 0.9;
|
||||
|
||||
.header {
|
||||
.icon-bell {
|
||||
--p-body-text-color: hsl(var(--color-neutral-150));
|
||||
}
|
||||
}
|
||||
|
||||
.body-text-1 {
|
||||
--p-body-text-color: #e4e4e7;
|
||||
}
|
||||
|
||||
.body-text-2 {
|
||||
--p-body-text-color: #adadb0;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,46 @@
|
||||
<svg width="320" height="529" viewBox="0 0 320 529" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="path-1-inside-1_10_77" fill="white">
|
||||
<path d="M0 60C0 26.8629 26.8629 0 60 0H260C293.137 0 320 26.8629 320 60V529H0V60Z"/>
|
||||
</mask>
|
||||
<path d="M0 60C0 26.8629 26.8629 0 60 0H260C293.137 0 320 26.8629 320 60V529H0V60Z" fill="url(#paint0_linear_10_77)"/>
|
||||
<path d="M-1.25 60C-1.25 26.1726 26.1726 -1.25 60 -1.25H260C293.827 -1.25 321.25 26.1726 321.25 60H318.75C318.75 27.5533 292.447 1.25 260 1.25H60C27.5533 1.25 1.25 27.5533 1.25 60H-1.25ZM320 529H0H320ZM-1.25 529V60C-1.25 26.1726 26.1726 -1.25 60 -1.25V1.25C27.5533 1.25 1.25 27.5533 1.25 60V529H-1.25ZM260 -1.25C293.827 -1.25 321.25 26.1726 321.25 60V529H318.75V60C318.75 27.5533 292.447 1.25 260 1.25V-1.25Z" fill="url(#paint1_linear_10_77)" fill-opacity="0.08" mask="url(#path-1-inside-1_10_77)"/>
|
||||
<rect x="7" y="7" width="305" height="522" rx="57" fill="url(#paint2_linear_10_77)"/>
|
||||
<mask id="path-4-inside-2_10_77" fill="white">
|
||||
<path d="M7 65C7 32.9675 32.9675 7 65 7H254C286.033 7 312 32.9675 312 65V139H7V65Z"/>
|
||||
</mask>
|
||||
<path d="M7 65C7 32.9675 32.9675 7 65 7H254C286.033 7 312 32.9675 312 65V139H7V65Z" fill="#17171A"/>
|
||||
<path d="M7 7H312H7ZM312 140H7V138H312V140ZM7 139V7V139ZM312 7V139V7Z" fill="#3C3C43" fill-opacity="0.06" mask="url(#path-4-inside-2_10_77)"/>
|
||||
<path d="M25 95.939C25 96.3208 25.146 96.6465 25.4492 96.9385L34.209 105.507C34.4448 105.754 34.7593 105.878 35.1187 105.878C35.8486 105.878 36.4214 105.316 36.4214 104.575C36.4214 104.216 36.2754 103.89 36.0283 103.643L28.1333 95.939L36.0283 88.2349C36.2754 87.9766 36.4214 87.6509 36.4214 87.2915C36.4214 86.5615 35.8486 86 35.1187 86C34.7593 86 34.4448 86.1235 34.209 86.3706L25.4492 94.9395C25.146 95.2314 25.0112 95.5571 25 95.939Z" fill="#007AFF"/>
|
||||
<rect x="135.5" y="63" width="48" height="48" rx="24" fill="url(#paint3_linear_10_77)"/>
|
||||
<path d="M274.674 104.412H285.368C287.865 104.412 289.359 102.959 289.359 100.462V99.0597L293.227 102.334C293.636 102.672 294.086 102.907 294.506 102.907C295.406 102.907 296 102.242 296 101.291V90.7095C296 89.7578 295.406 89.0926 294.506 89.0926C294.086 89.0926 293.636 89.328 293.227 89.6657L289.359 92.9403V91.5281C289.359 89.0415 287.865 87.5884 285.368 87.5884H274.674C272.29 87.5884 270.683 89.0415 270.683 91.5281V100.462C270.683 102.959 272.177 104.412 274.674 104.412ZM274.961 102.866C273.283 102.866 272.331 101.997 272.331 100.226V91.7737C272.331 89.9932 273.283 89.1233 274.961 89.1233H285.081C286.749 89.1233 287.711 89.9932 287.711 91.7737V100.226C287.711 101.997 286.749 102.866 285.081 102.866H274.961ZM293.994 100.943L289.359 97.1154V94.8846L293.994 91.0574C294.086 90.9858 294.148 90.9346 294.24 90.9346C294.363 90.9346 294.414 91.0369 294.414 91.1802V100.82C294.414 100.963 294.363 101.055 294.24 101.055C294.148 101.055 294.086 101.004 293.994 100.943Z" fill="#007AFF"/>
|
||||
<path d="M59.2984 28.4162C59.72 28.4193 60.1355 28.4962 60.5449 28.647C60.9542 28.7978 61.3235 29.044 61.6528 29.3857C61.9852 29.7273 62.2499 30.1889 62.4468 30.7706C62.6469 31.3492 62.7485 32.0694 62.7515 32.9311C62.7515 33.759 62.6684 34.4961 62.5022 35.1424C62.336 35.7856 62.0975 36.3288 61.7867 36.772C61.4789 37.2152 61.105 37.5522 60.6649 37.783C60.2248 38.0138 59.7293 38.1293 59.1784 38.1293C58.6152 38.1293 58.115 38.0185 57.678 37.7969C57.241 37.5753 56.8855 37.2691 56.6116 36.8782C56.3377 36.4843 56.1669 36.0318 56.0992 35.521H57.5072C57.5995 35.9272 57.7873 36.2565 58.0704 36.5089C58.3566 36.7582 58.726 36.8828 59.1784 36.8828C59.8708 36.8828 60.411 36.5812 60.7988 35.978C61.1865 35.3717 61.382 34.5253 61.3851 33.4389H61.3112C61.1511 33.7036 60.9511 33.9313 60.711 34.1222C60.4741 34.313 60.2078 34.4607 59.9124 34.5653C59.6169 34.67 59.3015 34.7223 58.966 34.7223C58.4213 34.7223 57.9258 34.5884 57.4795 34.3207C57.0333 34.0529 56.6778 33.6851 56.4131 33.2173C56.1484 32.7495 56.0161 32.2156 56.0161 31.6154C56.0161 31.0183 56.1515 30.4767 56.4223 29.9904C56.6962 29.5041 57.0779 29.1194 57.5672 28.8363C58.0596 28.5501 58.6367 28.41 59.2984 28.4162ZM59.303 29.6165C58.9429 29.6165 58.6182 29.7057 58.3289 29.8842C58.0427 30.0597 57.8165 30.2982 57.6503 30.5998C57.4841 30.8983 57.401 31.2307 57.401 31.5969C57.401 31.9632 57.4811 32.2956 57.6411 32.5941C57.8042 32.8896 58.0258 33.125 58.3059 33.3004C58.589 33.4728 58.9122 33.5589 59.2753 33.5589C59.5462 33.5589 59.7985 33.5066 60.0324 33.402C60.2663 33.2973 60.471 33.1527 60.6464 32.968C60.8218 32.7803 60.9588 32.5679 61.0573 32.331C61.1558 32.094 61.205 31.8447 61.205 31.5831C61.205 31.2353 61.1219 30.9122 60.9557 30.6136C60.7926 30.3151 60.5679 30.075 60.2817 29.8935C59.9955 29.7088 59.6693 29.6165 59.303 29.6165ZM65.0271 36.8274C64.7748 36.8274 64.5578 36.7382 64.3762 36.5597C64.1946 36.3781 64.1038 36.1596 64.1038 35.9041C64.1038 35.6518 64.1946 35.4363 64.3762 35.2578C64.5578 35.0762 64.7748 34.9854 65.0271 34.9854C65.2795 34.9854 65.4965 35.0762 65.6781 35.2578C65.8596 35.4363 65.9504 35.6518 65.9504 35.9041C65.9504 36.0734 65.9074 36.2288 65.8212 36.3704C65.7381 36.5089 65.6273 36.6197 65.4888 36.7028C65.3503 36.7859 65.1964 36.8274 65.0271 36.8274ZM65.0271 32.0909C64.7748 32.0909 64.5578 32.0017 64.3762 31.8232C64.1946 31.6416 64.1038 31.4231 64.1038 31.1676C64.1038 30.9152 64.1946 30.6998 64.3762 30.5213C64.5578 30.3397 64.7748 30.2489 65.0271 30.2489C65.2795 30.2489 65.4965 30.3397 65.6781 30.5213C65.8596 30.6998 65.9504 30.9152 65.9504 31.1676C65.9504 31.3369 65.9074 31.4923 65.8212 31.6339C65.7381 31.7724 65.6273 31.8832 65.4888 31.9663C65.3503 32.0494 65.1964 32.0909 65.0271 32.0909ZM67.2624 36.1534V34.9993L71.3479 28.5455H72.2574V30.2443H71.6803L68.7581 34.87V34.9439H74.3579V36.1534H67.2624ZM71.745 38V35.8026L71.7542 35.2763V28.5455H73.1068V38H71.745ZM79.1068 28.5455V38H77.6757V29.9766H77.6203L75.3582 31.4538V30.0874L77.7172 28.5455H79.1068Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<rect x="115" y="20" width="89" height="24" rx="12" fill="#DBDBDB" fill-opacity="0.04"/>
|
||||
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M238.025 27.7143H238.875C239.344 27.7143 239.725 28.0981 239.725 28.5714V35.4286C239.725 35.902 239.344 36.2857 238.875 36.2857H238.025C237.556 36.2857 237.175 35.902 237.175 35.4286V28.5714C237.175 28.0981 237.556 27.7143 238.025 27.7143Z" fill="#F9F9F9" fill-opacity="0.18"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M234.2 29.4286H235.05C235.519 29.4286 235.9 29.8123 235.9 30.2857V35.4286C235.9 35.9019 235.519 36.2857 235.05 36.2857H234.2C233.731 36.2857 233.35 35.9019 233.35 35.4286V30.2857C233.35 29.8123 233.731 29.4286 234.2 29.4286Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M230.375 31.1429H231.225C231.694 31.1429 232.075 31.5266 232.075 32V35.4286C232.075 35.902 231.694 36.2857 231.225 36.2857H230.375C229.906 36.2857 229.525 35.902 229.525 35.4286V32C229.525 31.5266 229.906 31.1429 230.375 31.1429Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M226.55 32.4286H227.4C227.869 32.4286 228.25 32.8123 228.25 33.2857V35.4286C228.25 35.9019 227.869 36.2857 227.4 36.2857H226.55C226.081 36.2857 225.7 35.9019 225.7 35.4286V33.2857C225.7 32.8123 226.081 32.4286 226.55 32.4286Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M253.116 33.6625C253.676 33.6625 254.219 33.8065 254.698 34.0812L254.893 34.1925C255.04 34.2768 255.066 34.4743 254.945 34.5921L253.288 36.2111C253.186 36.3106 253.021 36.3106 252.919 36.2111L251.272 34.6026C251.152 34.4852 251.177 34.2888 251.323 34.2038L251.515 34.092C251.999 33.8104 252.549 33.6625 253.116 33.6625Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M253.116 30.6884C254.508 30.6884 255.845 31.1408 256.933 31.9785L257.087 32.0969C257.21 32.1913 257.221 32.3691 257.11 32.477L256.121 33.4435C256.029 33.5329 255.884 33.5432 255.781 33.4677L255.66 33.3798C254.925 32.8445 254.038 32.5573 253.116 32.5573C252.188 32.5573 251.297 32.8481 250.559 33.3896L250.438 33.4782C250.334 33.5543 250.189 33.5443 250.097 33.4546L249.108 32.4885C248.998 32.3808 249.008 32.2034 249.13 32.1089L249.283 31.9904C250.375 31.1452 251.717 30.6884 253.116 30.6884Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path d="M253.116 27.7143C255.325 27.7143 257.438 28.4776 259.11 29.8768L259.253 29.9962C259.368 30.0928 259.375 30.2648 259.267 30.3697L258.281 31.3331C258.186 31.4264 258.033 31.433 257.929 31.3482L257.807 31.2481C256.491 30.1698 254.841 29.5832 253.116 29.5832C251.386 29.5832 249.73 30.1738 248.412 31.2589L248.29 31.3595C248.186 31.4447 248.033 31.4383 247.937 31.3448L246.951 30.3815C246.844 30.2768 246.851 30.105 246.966 30.0084L247.108 29.8889C248.782 28.4822 250.9 27.7143 253.116 27.7143Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<path opacity="0.4" d="M283 31V31C283.552 31 284 31.4477 284 32V33C284 33.5523 283.552 34 283 34V34V31Z" fill="#F9F9F9" fill-opacity="0.18"/>
|
||||
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M267.217 28H279.783C281.007 28 282 29.0074 282 30.25V34.75C282 35.9926 281.007 37 279.783 37H267.217C265.993 37 265 35.9926 265 34.75V30.25C265 29.0074 265.993 28 267.217 28ZM267.217 28.75C266.401 28.75 265.739 29.4216 265.739 30.25V34.75C265.739 35.5784 266.401 36.25 267.217 36.25H279.783C280.599 36.25 281.261 35.5784 281.261 34.75V30.25C281.261 29.4216 280.599 28.75 279.783 28.75H267.217Z" fill="#F9F9F9" fill-opacity="0.18"/>
|
||||
<path d="M266 30.5C266 29.6716 266.672 29 267.5 29H279.5C280.328 29 281 29.6716 281 30.5V34.5C281 35.3284 280.328 36 279.5 36H267.5C266.672 36 266 35.3284 266 34.5V30.5Z" fill="#DBDBDB" fill-opacity="0.7"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_10_77" x1="160" y1="0" x2="160" y2="529" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#1E1E22"/>
|
||||
<stop offset="1" stop-color="#1E1E22" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_10_77" x1="160" y1="0" x2="160" y2="673" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.262534" stop-color="#EDEDF0"/>
|
||||
<stop offset="1" stop-color="#EDEDF0" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_10_77" x1="159.5" y1="7" x2="159.5" y2="529" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#19191C"/>
|
||||
<stop offset="1" stop-color="#1D1D21"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_10_77" x1="142.5" y1="70.5" x2="173.5" y2="106.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#9FA5B2"/>
|
||||
<stop offset="1" stop-color="#8D929D"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,41 @@
|
||||
<svg width="320" height="529" viewBox="0 0 320 529" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="path-1-inside-1_1_1738" fill="white">
|
||||
<path d="M0 60C0 26.8629 26.8629 0 60 0H260C293.137 0 320 26.8629 320 60V529H0V60Z"/>
|
||||
</mask>
|
||||
<path d="M0 60C0 26.8629 26.8629 0 60 0H260C293.137 0 320 26.8629 320 60V529H0V60Z" fill="white"/>
|
||||
<path d="M-1.25 60C-1.25 26.1726 26.1726 -1.25 60 -1.25H260C293.827 -1.25 321.25 26.1726 321.25 60H318.75C318.75 27.5533 292.447 1.25 260 1.25H60C27.5533 1.25 1.25 27.5533 1.25 60H-1.25ZM320 529H0H320ZM-1.25 529V60C-1.25 26.1726 26.1726 -1.25 60 -1.25V1.25C27.5533 1.25 1.25 27.5533 1.25 60V529H-1.25ZM260 -1.25C293.827 -1.25 321.25 26.1726 321.25 60V529H318.75V60C318.75 27.5533 292.447 1.25 260 1.25V-1.25Z" fill="url(#paint0_linear_1_1738)" fill-opacity="0.08" mask="url(#path-1-inside-1_1_1738)"/>
|
||||
<rect x="7" y="7" width="305" height="522" rx="57" fill="white"/>
|
||||
<mask id="path-4-inside-2_1_1738" fill="white">
|
||||
<path d="M7 65C7 32.9675 32.9675 7 65 7H254C286.033 7 312 32.9675 312 65V139H7V65Z"/>
|
||||
</mask>
|
||||
<path d="M7 65C7 32.9675 32.9675 7 65 7H254C286.033 7 312 32.9675 312 65V139H7V65Z" fill="#F5F4F4"/>
|
||||
<path d="M7 7H312H7ZM312 140H7V138H312V140ZM7 139V7V139ZM312 7V139V7Z" fill="#3C3C43" fill-opacity="0.06" mask="url(#path-4-inside-2_1_1738)"/>
|
||||
<path d="M25 95.939C25 96.3208 25.146 96.6465 25.4492 96.9385L34.209 105.507C34.4448 105.754 34.7593 105.878 35.1187 105.878C35.8486 105.878 36.4214 105.316 36.4214 104.575C36.4214 104.216 36.2754 103.89 36.0283 103.643L28.1333 95.939L36.0283 88.2349C36.2754 87.9766 36.4214 87.6509 36.4214 87.2915C36.4214 86.5615 35.8486 86 35.1187 86C34.7593 86 34.4448 86.1235 34.209 86.3706L25.4492 94.9395C25.146 95.2314 25.0112 95.5571 25 95.939Z" fill="#007AFF"/>
|
||||
<rect x="135.5" y="63" width="48" height="48" rx="24" fill="url(#paint1_linear_1_1738)"/>
|
||||
<path d="M274.674 104.412H285.368C287.865 104.412 289.359 102.959 289.359 100.462V99.0597L293.227 102.334C293.636 102.672 294.086 102.907 294.506 102.907C295.406 102.907 296 102.242 296 101.291V90.7095C296 89.7578 295.406 89.0926 294.506 89.0926C294.086 89.0926 293.636 89.328 293.227 89.6657L289.359 92.9403V91.5281C289.359 89.0415 287.865 87.5884 285.368 87.5884H274.674C272.29 87.5884 270.683 89.0415 270.683 91.5281V100.462C270.683 102.959 272.177 104.412 274.674 104.412ZM274.961 102.866C273.283 102.866 272.331 101.997 272.331 100.226V91.7737C272.331 89.9932 273.283 89.1233 274.961 89.1233H285.081C286.749 89.1233 287.711 89.9932 287.711 91.7737V100.226C287.711 101.997 286.749 102.866 285.081 102.866H274.961ZM293.994 100.943L289.359 97.1154V94.8846L293.994 91.0574C294.086 90.9858 294.148 90.9346 294.24 90.9346C294.363 90.9346 294.414 91.0369 294.414 91.1802V100.82C294.414 100.963 294.363 101.055 294.24 101.055C294.148 101.055 294.086 101.004 293.994 100.943Z" fill="#007AFF"/>
|
||||
<path d="M59.2984 28.4162C59.72 28.4193 60.1355 28.4962 60.5449 28.647C60.9542 28.7978 61.3235 29.044 61.6528 29.3857C61.9852 29.7273 62.2499 30.1889 62.4468 30.7706C62.6469 31.3492 62.7485 32.0694 62.7515 32.9311C62.7515 33.759 62.6684 34.4961 62.5022 35.1424C62.336 35.7856 62.0975 36.3288 61.7867 36.772C61.4789 37.2152 61.105 37.5522 60.6649 37.783C60.2248 38.0138 59.7293 38.1293 59.1784 38.1293C58.6152 38.1293 58.115 38.0185 57.678 37.7969C57.241 37.5753 56.8855 37.2691 56.6116 36.8782C56.3377 36.4843 56.1669 36.0318 56.0992 35.521H57.5072C57.5995 35.9272 57.7873 36.2565 58.0704 36.5089C58.3566 36.7582 58.726 36.8828 59.1784 36.8828C59.8708 36.8828 60.411 36.5812 60.7988 35.978C61.1865 35.3717 61.382 34.5253 61.3851 33.4389H61.3112C61.1511 33.7036 60.9511 33.9313 60.711 34.1222C60.4741 34.313 60.2078 34.4607 59.9124 34.5653C59.6169 34.67 59.3015 34.7223 58.966 34.7223C58.4213 34.7223 57.9258 34.5884 57.4795 34.3207C57.0333 34.0529 56.6778 33.6851 56.4131 33.2173C56.1484 32.7495 56.0161 32.2156 56.0161 31.6154C56.0161 31.0183 56.1515 30.4767 56.4223 29.9904C56.6962 29.5041 57.0779 29.1194 57.5672 28.8363C58.0596 28.5501 58.6367 28.41 59.2984 28.4162ZM59.303 29.6165C58.9429 29.6165 58.6182 29.7057 58.3289 29.8842C58.0427 30.0597 57.8165 30.2982 57.6503 30.5998C57.4841 30.8983 57.401 31.2307 57.401 31.5969C57.401 31.9632 57.4811 32.2956 57.6411 32.5941C57.8042 32.8896 58.0258 33.125 58.3059 33.3004C58.589 33.4728 58.9122 33.5589 59.2753 33.5589C59.5462 33.5589 59.7985 33.5066 60.0324 33.402C60.2663 33.2973 60.471 33.1527 60.6464 32.968C60.8218 32.7803 60.9588 32.5679 61.0573 32.331C61.1558 32.094 61.205 31.8447 61.205 31.5831C61.205 31.2353 61.1219 30.9122 60.9557 30.6136C60.7926 30.3151 60.5679 30.075 60.2817 29.8935C59.9955 29.7088 59.6693 29.6165 59.303 29.6165ZM65.0271 36.8274C64.7748 36.8274 64.5578 36.7382 64.3762 36.5597C64.1946 36.3781 64.1038 36.1596 64.1038 35.9041C64.1038 35.6518 64.1946 35.4363 64.3762 35.2578C64.5578 35.0762 64.7748 34.9854 65.0271 34.9854C65.2795 34.9854 65.4965 35.0762 65.6781 35.2578C65.8596 35.4363 65.9504 35.6518 65.9504 35.9041C65.9504 36.0734 65.9074 36.2288 65.8212 36.3704C65.7381 36.5089 65.6273 36.6197 65.4888 36.7028C65.3503 36.7859 65.1964 36.8274 65.0271 36.8274ZM65.0271 32.0909C64.7748 32.0909 64.5578 32.0017 64.3762 31.8232C64.1946 31.6416 64.1038 31.4231 64.1038 31.1676C64.1038 30.9152 64.1946 30.6998 64.3762 30.5213C64.5578 30.3397 64.7748 30.2489 65.0271 30.2489C65.2795 30.2489 65.4965 30.3397 65.6781 30.5213C65.8596 30.6998 65.9504 30.9152 65.9504 31.1676C65.9504 31.3369 65.9074 31.4923 65.8212 31.6339C65.7381 31.7724 65.6273 31.8832 65.4888 31.9663C65.3503 32.0494 65.1964 32.0909 65.0271 32.0909ZM67.2624 36.1534V34.9993L71.3479 28.5455H72.2574V30.2443H71.6803L68.7581 34.87V34.9439H74.3579V36.1534H67.2624ZM71.745 38V35.8026L71.7542 35.2763V28.5455H73.1068V38H71.745ZM79.1068 28.5455V38H77.6757V29.9766H77.6203L75.3582 31.4538V30.0874L77.7172 28.5455H79.1068Z" fill="black"/>
|
||||
<rect x="115" y="20" width="89" height="24" rx="12" fill="#19191C" fill-opacity="0.04"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M234.2 29.4286H235.05C235.519 29.4286 235.9 29.8123 235.9 30.2857V35.4286C235.9 35.902 235.519 36.2857 235.05 36.2857H234.2C233.731 36.2857 233.35 35.902 233.35 35.4286V30.2857C233.35 29.8123 233.731 29.4286 234.2 29.4286Z" fill="#F9F9F9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M230.375 31.1429H231.225C231.694 31.1429 232.075 31.5266 232.075 32V35.4286C232.075 35.902 231.694 36.2857 231.225 36.2857H230.375C229.906 36.2857 229.525 35.902 229.525 35.4286V32C229.525 31.5266 229.906 31.1429 230.375 31.1429Z" fill="#F9F9F9"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M226.55 32.4286H227.4C227.869 32.4286 228.25 32.8123 228.25 33.2857V35.4286C228.25 35.902 227.869 36.2857 227.4 36.2857H226.55C226.081 36.2857 225.7 35.902 225.7 35.4286V33.2857C225.7 32.8123 226.081 32.4286 226.55 32.4286Z" fill="#F9F9F9"/>
|
||||
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M238.025 27.7143H238.875C239.344 27.7143 239.725 28.098 239.725 28.5714V35.4286C239.725 35.902 239.344 36.2857 238.875 36.2857H238.025C237.556 36.2857 237.175 35.902 237.175 35.4286V28.5714C237.175 28.098 237.556 27.7143 238.025 27.7143Z" fill="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M234.2 29.4286H235.05C235.519 29.4286 235.9 29.8123 235.9 30.2857V35.4286C235.9 35.902 235.519 36.2857 235.05 36.2857H234.2C233.731 36.2857 233.35 35.902 233.35 35.4286V30.2857C233.35 29.8123 233.731 29.4286 234.2 29.4286Z" fill="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M230.375 31.1429H231.225C231.694 31.1429 232.075 31.5266 232.075 32V35.4286C232.075 35.902 231.694 36.2857 231.225 36.2857H230.375C229.906 36.2857 229.525 35.902 229.525 35.4286V32C229.525 31.5266 229.906 31.1429 230.375 31.1429Z" fill="black"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M226.55 32.4286H227.4C227.869 32.4286 228.25 32.8123 228.25 33.2857V35.4286C228.25 35.902 227.869 36.2857 227.4 36.2857H226.55C226.081 36.2857 225.7 35.902 225.7 35.4286V33.2857C225.7 32.8123 226.081 32.4286 226.55 32.4286Z" fill="black"/>
|
||||
<path d="M253.116 33.6625C253.676 33.6625 254.219 33.8065 254.698 34.0812L254.893 34.1925C255.04 34.2768 255.066 34.4743 254.945 34.5921L253.288 36.2111C253.186 36.3106 253.021 36.3106 252.919 36.2111L251.272 34.6025C251.152 34.4852 251.177 34.2887 251.323 34.2038L251.515 34.092C251.999 33.8104 252.549 33.6625 253.116 33.6625Z" fill="black"/>
|
||||
<path d="M253.116 30.6884C254.508 30.6884 255.845 31.1408 256.933 31.9785L257.087 32.0969C257.21 32.1913 257.221 32.3691 257.11 32.477L256.121 33.4435C256.029 33.5329 255.884 33.5432 255.781 33.4677L255.66 33.3798C254.925 32.8445 254.038 32.5573 253.116 32.5573C252.188 32.5573 251.297 32.8481 250.559 33.3896L250.438 33.4782C250.334 33.5543 250.189 33.5443 250.097 33.4546L249.108 32.4885C248.998 32.3808 249.008 32.2034 249.13 32.1089L249.283 31.9904C250.375 31.1452 251.717 30.6884 253.116 30.6884Z" fill="black"/>
|
||||
<path d="M253.116 27.7143C255.325 27.7143 257.438 28.4776 259.11 29.8768L259.253 29.9962C259.368 30.0927 259.375 30.2648 259.267 30.3697L258.281 31.3331C258.186 31.4264 258.033 31.433 257.929 31.3482L257.807 31.2481C256.491 30.1698 254.841 29.5832 253.116 29.5832C251.386 29.5832 249.73 30.1738 248.412 31.2589L248.29 31.3595C248.186 31.4446 248.033 31.4383 247.937 31.3448L246.951 30.3815C246.844 30.2767 246.851 30.105 246.966 30.0084L247.108 29.8889C248.782 28.4822 250.9 27.7143 253.116 27.7143Z" fill="black"/>
|
||||
<path opacity="0.4" d="M283 31C283.552 31 284 31.4477 284 32V33C284 33.5523 283.552 34 283 34V31Z" fill="black"/>
|
||||
<path opacity="0.4" fill-rule="evenodd" clip-rule="evenodd" d="M267.217 28H279.783C281.007 28 282 29.0074 282 30.25V34.75C282 35.9926 281.007 37 279.783 37H267.217C265.993 37 265 35.9926 265 34.75V30.25C265 29.0074 265.993 28 267.217 28ZM267.217 28.75C266.401 28.75 265.739 29.4216 265.739 30.25V34.75C265.739 35.5784 266.401 36.25 267.217 36.25H279.783C280.599 36.25 281.261 35.5784 281.261 34.75V30.25C281.261 29.4216 280.599 28.75 279.783 28.75H267.217Z" fill="black"/>
|
||||
<path d="M266 30.5C266 29.6716 266.672 29 267.5 29H279.5C280.328 29 281 29.6716 281 30.5V34.5C281 35.3284 280.328 36 279.5 36H267.5C266.672 36 266 35.3284 266 34.5V30.5Z" fill="black"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_1_1738" x1="160" y1="0" x2="160" y2="673" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0.262534" stop-color="#19191C"/>
|
||||
<stop offset="1" stop-color="#19191C" stop-opacity="0"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_1_1738" x1="142.5" y1="70.5" x2="173.5" y2="106.5" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#9FA5B2"/>
|
||||
<stop offset="1" stop-color="#8D929D"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 10 KiB |
@@ -0,0 +1,124 @@
|
||||
<script lang="ts">
|
||||
import { project } from '../store';
|
||||
|
||||
export let content = '';
|
||||
export let classes = '';
|
||||
|
||||
function getIntials(name: string) {
|
||||
let words = name.split(' ');
|
||||
// If there is only one word, split it by underscore
|
||||
if (words.length === 1) {
|
||||
words = words[0].split('_');
|
||||
}
|
||||
|
||||
// Get 1st 2 initials, skipping words that don't start with a letter
|
||||
const initials = words
|
||||
.filter((word) => word.match(/^[a-z]/i))
|
||||
.map((word) => word[0].toUpperCase())
|
||||
.slice(0, 2)
|
||||
.join('');
|
||||
|
||||
return initials;
|
||||
}
|
||||
|
||||
// Current time as H:MM AM/PM
|
||||
function getTime() {
|
||||
const now = new Date();
|
||||
return now.toLocaleTimeString(undefined, {
|
||||
hour: 'numeric',
|
||||
minute: 'numeric',
|
||||
hour12: true
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="phone {classes}">
|
||||
<div class="avatar-initials u-text-center u-width-full-line u-line-height-1-5 u-medium u-bold">
|
||||
{getIntials($project.name)}
|
||||
</div>
|
||||
<div class="project-name u-text-center u-x-small u-width-full-line">{$project.name}</div>
|
||||
<div class="chat u-text-center u-width-full-line">
|
||||
<div class="time u-text-center u-x-small u-width-full-line u-line-height-0-7">
|
||||
Today {getTime()}
|
||||
</div>
|
||||
<div class="chat-bubble-container">
|
||||
<div class="chat-bubble u-text-start">
|
||||
{content || 'Enter your message in the input field on the left to see it here'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.phone {
|
||||
position: relative;
|
||||
width: 320px;
|
||||
height: 539px;
|
||||
background-image: url('./sms-preview-light.svg');
|
||||
background-repeat: no-repeat;
|
||||
|
||||
.avatar-initials {
|
||||
position: absolute;
|
||||
top: 75px;
|
||||
height: 24px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.project-name {
|
||||
position: absolute;
|
||||
top: 116px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.chat {
|
||||
position: absolute;
|
||||
top: 151px;
|
||||
|
||||
.time {
|
||||
color: #909093;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.chat-bubble-container {
|
||||
background-image: url('./bubble-tail-light.svg');
|
||||
background-position: bottom 0px left 2px;
|
||||
background-repeat: no-repeat;
|
||||
margin-inline-start: 7px;
|
||||
margin-block-start: 8px;
|
||||
|
||||
.chat-bubble {
|
||||
color: black;
|
||||
background-color: #e9e9eb;
|
||||
border-radius: 20px;
|
||||
padding-inline: 12px;
|
||||
padding-block: 7px;
|
||||
margin-inline-start: 6px;
|
||||
margin-inline-end: 33px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:global(.theme-dark) .phone {
|
||||
background-image: url('./sms-preview-dark.svg');
|
||||
|
||||
.avatar-initials {
|
||||
color: hsl(var(--color-neutral-150));
|
||||
}
|
||||
|
||||
.project-name {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.chat {
|
||||
.chat-bubble-container {
|
||||
background-image: url('./bubble-tail-dark.svg');
|
||||
|
||||
.chat-bubble {
|
||||
color: #e0e0e0;
|
||||
background-color: #333333;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,265 @@
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { Providers } from './provider.svelte';
|
||||
import { ProviderTypes } from './providerType.svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const showCreate = writable(false);
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Message ID', type: 'string', show: true, width: 140 },
|
||||
{ id: 'description', title: 'Description', type: 'string', show: true, width: 140 },
|
||||
{ id: 'message', title: 'Message', type: 'string', show: false, width: 140 },
|
||||
{ id: 'providerType', title: 'Type', type: 'string', show: true, width: 100 },
|
||||
{ id: 'status', title: 'Status', type: 'string', show: true, width: 120 },
|
||||
{ id: 'scheduledAt', title: 'Scheduled at', type: 'datetime', show: true, width: 120 },
|
||||
{ id: 'deliveredAt', title: 'Delivered at', type: 'datetime', show: false, width: 120 }
|
||||
]);
|
||||
|
||||
export const targetsById = writable<Record<string, Target>>({});
|
||||
export const topicsById = writable<Record<string, Topic>>({});
|
||||
|
||||
// TODO: remove this when the SDK and API are ready
|
||||
export type Message = {
|
||||
$id: string;
|
||||
$createdAt: string;
|
||||
$updatedAt: string;
|
||||
topics: string[];
|
||||
users: string[];
|
||||
targets: string[];
|
||||
scheduledAt: string;
|
||||
deliveredAt: string;
|
||||
deliveryErrors: string[];
|
||||
deliveredTo: number;
|
||||
status: string;
|
||||
providerType: ProviderTypes;
|
||||
description: string;
|
||||
data: {
|
||||
content?: string;
|
||||
body?: string;
|
||||
subject?: string;
|
||||
title?: string;
|
||||
};
|
||||
};
|
||||
|
||||
// TODO: remove this when the SDK and API are ready
|
||||
export const messages: { messages: Message[]; total: number } = {
|
||||
messages: [
|
||||
{
|
||||
$id: '637a40ba7a703e3936e1',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
description: 'Welcome',
|
||||
providerType: ProviderTypes.Push,
|
||||
topics: [],
|
||||
users: ['user-1', 'user-2'],
|
||||
targets: [],
|
||||
scheduledAt: '2021-03-01T00:00:00.000Z',
|
||||
deliveredAt: '2021-03-01T00:00:00.000Z',
|
||||
deliveryErrors: [],
|
||||
deliveredTo: 2,
|
||||
status: 'sent',
|
||||
data: {
|
||||
title: 'Welcome to the Cloud',
|
||||
body: 'Detailed body'
|
||||
}
|
||||
},
|
||||
{
|
||||
$id: '637a40ba7a703e3936e2',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
description: 'Public beta announcement',
|
||||
providerType: ProviderTypes.Sms,
|
||||
topics: [],
|
||||
users: ['user-1', 'user-2'],
|
||||
targets: [],
|
||||
scheduledAt: '2021-03-01T00:00:00.000Z',
|
||||
deliveredAt: '2021-03-01T00:00:00.000Z',
|
||||
deliveryErrors: [],
|
||||
deliveredTo: 2,
|
||||
status: 'scheduled',
|
||||
data: {
|
||||
content: 'Cloud is live on public beta'
|
||||
}
|
||||
},
|
||||
{
|
||||
$id: '637a40ba7a703e3936e3',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
description: 'Welcome',
|
||||
providerType: ProviderTypes.Email,
|
||||
topics: [],
|
||||
users: ['user-1', 'user-2'],
|
||||
targets: [],
|
||||
scheduledAt: '',
|
||||
deliveredAt: '',
|
||||
deliveryErrors: [],
|
||||
deliveredTo: 2,
|
||||
status: 'draft',
|
||||
data: {
|
||||
subject: 'Welcome to the Cloud',
|
||||
content: 'Detailed content'
|
||||
}
|
||||
}
|
||||
],
|
||||
total: 3
|
||||
};
|
||||
|
||||
// TODO: remove this when the SDK and API are ready
|
||||
export type Provider = {
|
||||
$id: string;
|
||||
$createdAt: string;
|
||||
$updatedAt: string;
|
||||
name: string;
|
||||
provider: Providers;
|
||||
default: boolean;
|
||||
enabled: boolean;
|
||||
type: ProviderTypes;
|
||||
credentials: object;
|
||||
options: object;
|
||||
};
|
||||
|
||||
// TODO: remove this when the SDK and API are ready
|
||||
export const providersById: { [providerId: string]: Provider } = {
|
||||
'637a40ba7a703e3936e1': {
|
||||
$id: '637a40ba7a703e3936e1',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Firebase',
|
||||
provider: Providers.FCM,
|
||||
type: ProviderTypes.Push,
|
||||
default: false,
|
||||
enabled: true,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e2': {
|
||||
$id: '637a40ba7a703e3936e2',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My APNS',
|
||||
provider: Providers.APNS,
|
||||
type: ProviderTypes.Push,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e3': {
|
||||
$id: '637a40ba7a703e3936e3',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My MQTT',
|
||||
provider: Providers.MQTT,
|
||||
type: ProviderTypes.Push,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e4': {
|
||||
$id: '637a40ba7a703e3936e4',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Sendgrid',
|
||||
provider: Providers.Sendgrid,
|
||||
type: ProviderTypes.Email,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e5': {
|
||||
$id: '637a40ba7a703e3936e5',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Mailgun',
|
||||
provider: Providers.Mailgun,
|
||||
type: ProviderTypes.Email,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e6': {
|
||||
$id: '637a40ba7a703e3936e6',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Telesign',
|
||||
provider: Providers.Telesign,
|
||||
type: ProviderTypes.Sms,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e7': {
|
||||
$id: '637a40ba7a703e3936e7',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Msg91',
|
||||
provider: Providers.Msg91,
|
||||
type: ProviderTypes.Sms,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e8': {
|
||||
$id: '637a40ba7a703e3936e8',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Textmagic',
|
||||
provider: Providers.Textmagic,
|
||||
type: ProviderTypes.Sms,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936e9': {
|
||||
$id: '637a40ba7a703e3936e9',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Vonage',
|
||||
provider: Providers.Vonage,
|
||||
type: ProviderTypes.Sms,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
},
|
||||
'637a40ba7a703e3936f0': {
|
||||
$id: '637a40ba7a703e3936f0',
|
||||
$createdAt: '2021-08-31T12:00:00.000Z',
|
||||
$updatedAt: '2021-08-31T12:00:00.000Z',
|
||||
name: 'My Twilio',
|
||||
provider: Providers.Twilio,
|
||||
type: ProviderTypes.Sms,
|
||||
default: false,
|
||||
enabled: false,
|
||||
credentials: {},
|
||||
options: {}
|
||||
}
|
||||
};
|
||||
|
||||
// TODO: remove when sdk has the model
|
||||
export type Topic = {
|
||||
$id: string;
|
||||
$createdAt: string;
|
||||
$updatedAt: string;
|
||||
providerId: string;
|
||||
name: string;
|
||||
total: number;
|
||||
description: string;
|
||||
};
|
||||
|
||||
export type Target = {
|
||||
$id: string;
|
||||
$createdAt: string;
|
||||
$updatedAt: string;
|
||||
name: string;
|
||||
userId: string;
|
||||
providerId: string;
|
||||
providerType: ProviderTypes;
|
||||
identifier: string;
|
||||
};
|
||||
@@ -0,0 +1,106 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Empty,
|
||||
EmptySearch,
|
||||
SearchQuery,
|
||||
PaginationWithLimit,
|
||||
Heading,
|
||||
ViewSelector,
|
||||
EmptyFilter
|
||||
} from '$lib/components';
|
||||
import Create from './create.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { Container } from '$lib/layout';
|
||||
import { base } from '$app/paths';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { PageData } from './$types';
|
||||
import { columns, showCreate } from './store';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { Filters, hasPageQueries } from '$lib/components/filters';
|
||||
import Table from './table.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const project = $page.params.project;
|
||||
const topicCreated = async (event: CustomEvent<Models.Team<Record<string, unknown>>>) => {
|
||||
await goto(`${base}/console/project-${project}/messaging/topics/topic-${event.detail.$id}`);
|
||||
};
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<Heading tag="h2" size="5">Topics</Heading>
|
||||
<div class="is-only-mobile">
|
||||
<Button on:click={() => ($showCreate = true)} event="create_topic">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create topic</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO: fix width of search input in mobile -->
|
||||
<SearchQuery search={data.search} placeholder="Search by name or ID">
|
||||
<div class="u-flex u-gap-16 is-not-mobile">
|
||||
<Filters query={data.query} {columns} />
|
||||
<ViewSelector
|
||||
view={View.Table}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
<Button on:click={() => ($showCreate = true)} event="create_topic">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create topic</span>
|
||||
</Button>
|
||||
</div>
|
||||
</SearchQuery>
|
||||
<div class="u-flex u-gap-16 is-only-mobile u-margin-block-start-16">
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<ViewSelector
|
||||
view={View.Table}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
</div>
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<Filters query={data.query} {columns} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if data.topics.total}
|
||||
<Table {data} />
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Topics"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.topics.total} />
|
||||
{:else if $hasPageQueries}
|
||||
<EmptyFilter resource="topics" />
|
||||
<!-- TODO: remove data.search != 'empty' when the API is ready with data -->
|
||||
{:else if data.search && data.search != 'empty'}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{data.search}'</b>
|
||||
<p>There are no topics that match your search.</p>
|
||||
</div>
|
||||
<Button secondary href={`/console/project-${$page.params.project}/messaging/topics`}>
|
||||
Clear Search
|
||||
</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<!-- TODO: update docs link -->
|
||||
<Empty
|
||||
single
|
||||
on:click={() => ($showCreate = true)}
|
||||
href="https://appwrite.io/docs/references/cloud/client-web/teams"
|
||||
target="topic" />
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<Create bind:showCreate={$showCreate} on:created={topicCreated} />
|
||||
@@ -0,0 +1,53 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getQuery, getSearch, pageToOffset } from '$lib/helpers/load';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import { queryParamToMap, queries } from '$lib/components/filters';
|
||||
import type { Topic } from '../store';
|
||||
|
||||
export const load = async ({ depends, url, route }) => {
|
||||
depends(Dependencies.MESSAGING_TOPICS);
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
const query = getQuery(url);
|
||||
|
||||
const parsedQueries = queryParamToMap(query || '[]');
|
||||
queries.set(parsedQueries);
|
||||
|
||||
const payload = {
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
]
|
||||
};
|
||||
|
||||
if (search) {
|
||||
payload['search'] = search;
|
||||
}
|
||||
|
||||
// TODO: remove when the API is ready with data
|
||||
// This allows us to mock w/ data and when search returns 0 results
|
||||
const topics: { topics: Topic[]; total: number } = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/topics'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
payload
|
||||
);
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
query,
|
||||
page,
|
||||
topics
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,88 @@
|
||||
<script lang="ts">
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { Modal, CustomId } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, Button, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
export let showCreate = false;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let name: string, description: string, id: string, error: string;
|
||||
let showCustomId = false;
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
const topic = await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/topics'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
name,
|
||||
description,
|
||||
topicId: id ?? ID.unique()
|
||||
}
|
||||
);
|
||||
name = '';
|
||||
description = '';
|
||||
showCreate = false;
|
||||
showCustomId = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${topic.name} has been created`
|
||||
});
|
||||
trackEvent(Submit.MessagingTopicCreate, {
|
||||
customId: !!id
|
||||
});
|
||||
dispatch('created', topic);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.MessagingTopicCreate);
|
||||
}
|
||||
};
|
||||
|
||||
$: if (!showCreate) {
|
||||
showCustomId = false;
|
||||
error = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal title="Create topic" {error} size="big" bind:show={showCreate} onSubmit={create}>
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
autofocus={true}
|
||||
required
|
||||
bind:value={name} />
|
||||
<InputText
|
||||
id="description"
|
||||
label="Description"
|
||||
placeholder="Enter description"
|
||||
bind:value={description}>
|
||||
</InputText>
|
||||
{#if !showCustomId}
|
||||
<div>
|
||||
<Pill button on:click={() => (showCustomId = !showCustomId)}
|
||||
><span class="icon-pencil" aria-hidden="true" />
|
||||
<span class="text"> Topic ID </span>
|
||||
</Pill>
|
||||
</div>
|
||||
{:else}
|
||||
<CustomId bind:show={showCustomId} name="Topic" bind:id />
|
||||
{/if}
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (showCreate = false)}>Cancel</Button>
|
||||
<Button submit>Create</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export let showCreate = writable(false);
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Topic ID', type: 'string', show: true, width: 140 },
|
||||
{ id: 'name', title: 'Name', type: 'string', show: true, width: 140 },
|
||||
{ id: 'description', title: 'Description', type: 'string', show: true, width: 140 },
|
||||
{ id: 'total', title: 'Subscribers', type: 'integer', show: true, width: 140 },
|
||||
{ id: '$createdAt', title: 'Created', type: 'datetime', show: true, width: 140 }
|
||||
]);
|
||||
@@ -0,0 +1,154 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { FloatingActionBar, Id, Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellCheck,
|
||||
TableCellHead,
|
||||
TableCellHeadCheck,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRowLink,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { PageData } from './$types';
|
||||
import { columns } from './store';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let selectedIds: string[] = [];
|
||||
let showDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
async function handleDelete() {
|
||||
showDelete = false;
|
||||
|
||||
function deleteTopic(topicId: string) {
|
||||
return sdk.forProject.client.call(
|
||||
'DELETE',
|
||||
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${topicId}`),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const promises = selectedIds.map((id) => deleteTopic(id));
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.MessagingTopicDelete, {
|
||||
total: selectedIds.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedIds.length} topic${selectedIds.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingTopicDelete);
|
||||
} finally {
|
||||
invalidate(Dependencies.MESSAGING_TOPICS);
|
||||
selectedIds = [];
|
||||
showDelete = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHeadCheck
|
||||
bind:selected={selectedIds}
|
||||
pageItemsIds={data.topics.topics.map((d) => d.$id)} />
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
<TableCellHead width={column.width}>{column.title}</TableCellHead>
|
||||
{/if}
|
||||
{/each}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.topics.topics as topic (topic.$id)}
|
||||
<TableRowLink
|
||||
href={`${base}/console/project-${$project.$id}/messaging/topics/topic-${topic.$id}`}>
|
||||
<TableCellCheck bind:selectedIds id={topic.$id} />
|
||||
|
||||
{#each $columns as column (column.id)}
|
||||
{#if column.show}
|
||||
{#if column.id === '$id'}
|
||||
{#key $columns}
|
||||
<TableCell title={column.title} width={column.width}>
|
||||
<Id value={topic.$id}>{topic.$id}</Id>
|
||||
</TableCell>
|
||||
{/key}
|
||||
{:else if column.type === 'datetime'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{#if !topic[column.id]}
|
||||
-
|
||||
{:else}
|
||||
{toLocaleDateTime(topic[column.id])}
|
||||
{/if}
|
||||
</TableCellText>
|
||||
{:else}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{topic[column.id]}
|
||||
</TableCellText>
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
|
||||
<FloatingActionBar show={selectedIds.length > 0}>
|
||||
<div class="u-flex u-cross-center u-main-space-between actions">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<span class="indicator body-text-2 u-bold">{selectedIds.length}</span>
|
||||
<p>
|
||||
<span class="is-only-desktop">
|
||||
{selectedIds.length > 1 ? 'topics' : 'topic'}
|
||||
</span>
|
||||
selected
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<Button text on:click={() => (selectedIds = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>
|
||||
<p>Delete</p>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FloatingActionBar>
|
||||
|
||||
<Modal
|
||||
title="Delete topics"
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
headerDivider={false}
|
||||
closable={!deleting}>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to delete <b>{selectedIds.length}</b>
|
||||
{selectedIds.length > 1 ? 'topics' : 'topic'}?
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)} disabled={deleting}>Cancel</Button>
|
||||
<Button secondary submit disabled={deleting}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,5 @@
|
||||
<svelte:head>
|
||||
<title>Topic - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<slot />
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { LayoutLoad } from './$types';
|
||||
import Breadcrumbs from './breadcrumbs.svelte';
|
||||
import Header from './header.svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.MESSAGING_TOPIC);
|
||||
|
||||
const response = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/topics/' + params.topic),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
|
||||
try {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
topic: response
|
||||
};
|
||||
} catch (e) {
|
||||
throw error(e.code, e.message);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { Container } from '$lib/layout';
|
||||
import DangerZone from './dangerZone.svelte';
|
||||
import Details from './details.svelte';
|
||||
import UpdateDescription from './updateDescription.svelte';
|
||||
import UpdateName from './updateName.svelte';
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Details />
|
||||
<UpdateName />
|
||||
<UpdateDescription />
|
||||
<DangerZone />
|
||||
</Container>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<script lang="ts">
|
||||
import type { PageData } from './$types';
|
||||
import { Activity } from '$lib/layout';
|
||||
|
||||
export let data: PageData;
|
||||
</script>
|
||||
|
||||
<Activity {...data} />
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, url, route }) => {
|
||||
const page = getPage(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
|
||||
const payload = {
|
||||
queries: [Query.limit(limit), Query.offset(offset)]
|
||||
};
|
||||
|
||||
// TODO: remove when the API is ready with data
|
||||
// This allows us to mock w/ data and when search returns 0 results
|
||||
const logs: Models.LogList = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${params.topic}/logs`),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
payload
|
||||
);
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
logs
|
||||
};
|
||||
};
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { Breadcrumbs } from '$lib/layout';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import { topic } from './store';
|
||||
|
||||
$: breadcrumbs = [
|
||||
{
|
||||
href: `/console/organization-${$organization.$id}`,
|
||||
title: $organization.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}`,
|
||||
title: $project.name
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}/messaging`,
|
||||
title: 'Messaging'
|
||||
},
|
||||
{
|
||||
href: `/console/project-${$project.$id}/messaging/topics/topic-${$topic?.$id}`,
|
||||
title: $topic?.name
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Breadcrumbs {breadcrumbs} />
|
||||
@@ -0,0 +1,45 @@
|
||||
<script lang="ts" context="module">
|
||||
import { get } from 'svelte/store';
|
||||
let showDelete = writable(false);
|
||||
export const promptDeleteUser = (id: string) => {
|
||||
showDelete.set(true);
|
||||
goto(`/console/project-${get(project).$id}/auth/user-${id}`);
|
||||
};
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { CardGrid, BoxAvatar, Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { writable } from 'svelte/store';
|
||||
import { topic } from './store';
|
||||
import { goto } from '$app/navigation';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import DeleteTopic from './deleteTopic.svelte';
|
||||
</script>
|
||||
|
||||
<CardGrid danger>
|
||||
<div>
|
||||
<Heading tag="h6" size="7">Delete topic</Heading>
|
||||
</div>
|
||||
<p>
|
||||
The topic will be permanently deleted, including all data associated with this topic. This
|
||||
action is irreversible.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<BoxAvatar>
|
||||
<svelte:fragment slot="title">
|
||||
<h6 class="u-bold u-trim-1">{$topic.name}</h6>
|
||||
</svelte:fragment>
|
||||
<p>
|
||||
{$topic.total} subscriber{$topic.total === 1 ? '' : 's'}
|
||||
</p>
|
||||
</BoxAvatar>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button secondary on:click={() => ($showDelete = true)} event="delete_messaging_provider"
|
||||
>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
<DeleteTopic bind:showDelete={$showDelete} />
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { topic } from './store';
|
||||
import { project } from '../../../store';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
|
||||
export let showDelete = false;
|
||||
const deleteTopic = async () => {
|
||||
try {
|
||||
await sdk.forProject.client.call(
|
||||
'DELETE',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/topics/' + $topic.$id),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$topic.name} has been deleted`
|
||||
});
|
||||
trackEvent(Submit.MessagingTopicDelete);
|
||||
await goto(`${base}/console/project-${$page.params.project}/messaging/topics`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingTopicDelete);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
title="Delete topic"
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteTopic}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>{$topic.name}</b> from '{$project.name}'?
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { topic } from './store';
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16" data-private>
|
||||
<Heading tag="h6" size="7">Details</Heading>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<div data-private>
|
||||
<p class="title">{$topic.total} subscriber{$topic.total === 1 ? '' : 's'}</p>
|
||||
<p>Created: {toLocaleDateTime($topic.$createdAt)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
@@ -0,0 +1,48 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Id, Tab, Tabs } from '$lib/components';
|
||||
import { isTabSelected } from '$lib/helpers/load';
|
||||
import { Cover, CoverTitle } from '$lib/layout';
|
||||
import { topic } from './store';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const topicId = $page.params.topic;
|
||||
const path = `/console/project-${projectId}/messaging/topics/topic-${topicId}`;
|
||||
const tabs = [
|
||||
{
|
||||
href: path,
|
||||
title: 'Overview',
|
||||
event: 'overview'
|
||||
},
|
||||
{
|
||||
href: `${path}/subscribers`,
|
||||
title: 'Subscribers',
|
||||
event: 'subscribers'
|
||||
},
|
||||
{
|
||||
href: `${path}/activity`,
|
||||
title: 'Activity',
|
||||
event: 'activity'
|
||||
}
|
||||
];
|
||||
</script>
|
||||
|
||||
<Cover>
|
||||
<svelte:fragment slot="header">
|
||||
<CoverTitle href={`/console/project-${projectId}/messaging/topics`}>
|
||||
{$topic.name}
|
||||
</CoverTitle>
|
||||
<Id value={$topic.$id} event="topic">{$topic.$id}</Id>
|
||||
</svelte:fragment>
|
||||
|
||||
<Tabs>
|
||||
{#each tabs as tab}
|
||||
<Tab
|
||||
href={tab.href}
|
||||
selected={isTabSelected(tab, $page.url.pathname, path, tabs)}
|
||||
event={tab.event}>
|
||||
{tab.title}
|
||||
</Tab>
|
||||
{/each}
|
||||
</Tabs>
|
||||
</Cover>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { derived } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import type { Topic } from '../../store';
|
||||
|
||||
export const topic = derived(
|
||||
page,
|
||||
// TODO: Set actual type
|
||||
($page) => $page.data.topic as Topic
|
||||
);
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Empty,
|
||||
EmptySearch,
|
||||
SearchQuery,
|
||||
PaginationWithLimit,
|
||||
Heading,
|
||||
ViewSelector,
|
||||
EmptyFilter
|
||||
} from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import { ID } from '@appwrite.io/console';
|
||||
import type { PageData } from './$types';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import Table from './table.svelte';
|
||||
import { type Target, targetsById } from '../../../store';
|
||||
import UserTargetsModal from '../../../userTargetsModal.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import type { Subscriber } from './+page';
|
||||
import { Filters, hasPageQueries } from '$lib/components/filters';
|
||||
import { columns } from './store';
|
||||
import { View } from '$lib/helpers/load';
|
||||
|
||||
export let data: PageData;
|
||||
let showAdd = false;
|
||||
let subscribersByTargetId: Record<string, Subscriber> = {};
|
||||
|
||||
onMount(() => {
|
||||
$targetsById = {};
|
||||
for (const subscriber of $page.data.subscribers.subscribers) {
|
||||
const { target } = subscriber;
|
||||
$targetsById[target.$id] = target;
|
||||
subscribersByTargetId[target.$id] = subscriber;
|
||||
}
|
||||
});
|
||||
|
||||
async function addTargets(event: CustomEvent<Record<string, Target>>) {
|
||||
showAdd = false;
|
||||
$targetsById = event.detail;
|
||||
async function addSubscriber(targetId: string) {
|
||||
await sdk.forProject.client.call(
|
||||
'POST',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/topics/${$page.params.topic}/subscribers`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
subscriberId: ID.unique(),
|
||||
topicId: $page.params.topic,
|
||||
targetId: targetId
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
const targetIds = Object.keys($targetsById).filter(
|
||||
(targetId) => !(targetId in subscribersByTargetId)
|
||||
);
|
||||
const promises = targetIds.map(addSubscriber);
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Added ${targetIds.length} subscriber${
|
||||
targetIds.length > 1 ? 's' : ''
|
||||
} to topic`
|
||||
});
|
||||
trackEvent(Submit.MessagingTopicSubscriberAdd);
|
||||
await invalidate(Dependencies.MESSAGING_TOPIC_SUBSCRIBERS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingTopicSubscriberAdd);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-flex-vertical">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<Heading tag="h2" size="5">Subscribers</Heading>
|
||||
<div class="is-only-mobile">
|
||||
<Button on:click={() => (showAdd = true)} event="create_subscriber">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add subscriber</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- TODO: fix width of search input in mobile -->
|
||||
<SearchQuery search={data.search} placeholder="Search by name">
|
||||
<div class="u-flex u-gap-16 is-not-mobile">
|
||||
<Filters query={data.query} {columns} />
|
||||
<ViewSelector
|
||||
view={View.Table}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
<Button on:click={() => (showAdd = true)} event="create_subscriber">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add subscriber</span>
|
||||
</Button>
|
||||
</div>
|
||||
</SearchQuery>
|
||||
<div class="u-flex u-gap-16 is-only-mobile u-margin-block-start-16">
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<ViewSelector
|
||||
view={View.Table}
|
||||
{columns}
|
||||
hideView
|
||||
allowNoColumns
|
||||
showColsTextMobile />
|
||||
</div>
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<!-- TODO: fix width -->
|
||||
<Filters query={data.query} {columns} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{#if data.subscribers.total}
|
||||
<Table {data} />
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Subscribers"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.subscribers.total} />
|
||||
{:else if $hasPageQueries}
|
||||
<EmptyFilter resource="subscribers" />
|
||||
<!-- TODO: remove data.search != 'empty' when the API is ready with data -->
|
||||
{:else if data.search && data.search != 'empty'}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{data.search}'</b>
|
||||
<p>There are no subscribers that match your search.</p>
|
||||
</div>
|
||||
<Button
|
||||
secondary
|
||||
href={`/console/project-${$page.params.project}/messaging/topics/topic-${$page.params.topic}/subscribers`}>
|
||||
Clear Search
|
||||
</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<!-- TODO: update docs link -->
|
||||
<Empty
|
||||
single
|
||||
on:click={() => (showAdd = true)}
|
||||
href="https://appwrite.io/docs/references/cloud/client-web/teams"
|
||||
target="subscriber" />
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<UserTargetsModal bind:show={showAdd} bind:targetsById={$targetsById} on:update={addTargets} />
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getQuery, getSearch, pageToOffset } from '$lib/helpers/load';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import type { Target } from '../../../store';
|
||||
import { queryParamToMap, queries } from '$lib/components/filters';
|
||||
|
||||
export type Subscriber = {
|
||||
$id: string;
|
||||
$createdAt: string;
|
||||
$updatedAt: string;
|
||||
targetId: string;
|
||||
target: Target;
|
||||
userName: string;
|
||||
topicId: string;
|
||||
};
|
||||
|
||||
export const load: PageLoad = async ({ params, url, route, depends, parent }) => {
|
||||
depends(Dependencies.MESSAGING_TOPIC_SUBSCRIBERS);
|
||||
const page = getPage(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
const search = getSearch(url);
|
||||
const query = getQuery(url);
|
||||
|
||||
const parsedQueries = queryParamToMap(query || '[]');
|
||||
queries.set(parsedQueries);
|
||||
|
||||
const payload = {
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
]
|
||||
};
|
||||
|
||||
if (search) {
|
||||
payload['search'] = search;
|
||||
}
|
||||
|
||||
const { topic } = await parent();
|
||||
|
||||
// TODO: remove when the API is ready with data
|
||||
// This allows us to mock w/ data and when search returns 0 results
|
||||
const subscribers: { subscribers: Subscriber[]; total: number } =
|
||||
await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/topics/${params.topic}/subscribers`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
payload
|
||||
);
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
query,
|
||||
topic,
|
||||
subscribers
|
||||
};
|
||||
};
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Subscriber ID', type: 'string', show: true, width: 140 },
|
||||
{ id: 'userName', title: 'Name', type: 'string', show: true, width: 100 },
|
||||
{ id: 'targetId', title: 'Target ID', type: 'string', show: true, width: 140 },
|
||||
{ id: 'target', title: 'Target', type: 'string', show: true, filter: false, width: 140 },
|
||||
{ id: 'type', title: 'Type', type: 'string', show: true, filter: false, width: 80 },
|
||||
{ id: '$createdAt', title: 'Created', type: 'string', show: true, width: 100 }
|
||||
]);
|
||||
+191
@@ -0,0 +1,191 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { FloatingActionBar, Id, Modal } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellCheck,
|
||||
TableCellHead,
|
||||
TableCellHeadCheck,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRowLink,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { PageData } from './$types';
|
||||
import { columns } from './store';
|
||||
import ProviderType, { ProviderTypes } from '../../../providerType.svelte';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { project } from '$routes/console/project-[project]/store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { page } from '$app/stores';
|
||||
import { targetsById } from '../../../store';
|
||||
import type { Subscriber } from './+page';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let subscribers: Record<string, Subscriber> = {};
|
||||
let selectedIds: string[] = [];
|
||||
let selected: Record<string, Subscriber> = {};
|
||||
let showDelete = false;
|
||||
let deleting = false;
|
||||
|
||||
async function handleDelete() {
|
||||
showDelete = false;
|
||||
|
||||
async function deleteSubscriber(subscriberId: string) {
|
||||
await sdk.forProject.client.call(
|
||||
'DELETE',
|
||||
new URL(
|
||||
`${sdk.forProject.client.config.endpoint}/messaging/topics/${$page.params.topic}/subscribers/${subscriberId}`
|
||||
),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
}
|
||||
);
|
||||
const { target } = subscribers[subscriberId];
|
||||
const { [target.$id]: _, ...rest } = $targetsById;
|
||||
$targetsById = rest;
|
||||
}
|
||||
|
||||
const promises = selectedIds.map((id) => deleteSubscriber(id));
|
||||
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.MessagingTopicSubscriberDelete, {
|
||||
total: selectedIds.length
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selectedIds.length} subscriber${
|
||||
selectedIds.length > 1 ? 's' : ''
|
||||
} deleted`
|
||||
});
|
||||
invalidate(Dependencies.MESSAGING_TOPIC_SUBSCRIBERS);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.MessagingTopicSubscriberDelete);
|
||||
} finally {
|
||||
selectedIds = [];
|
||||
showDelete = false;
|
||||
}
|
||||
}
|
||||
|
||||
$: data.subscribers.subscribers.forEach((s) => {
|
||||
subscribers[s.$id] = s;
|
||||
});
|
||||
$: selectedIds.forEach((id) => {
|
||||
selected[id] = subscribers[id];
|
||||
});
|
||||
</script>
|
||||
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHeadCheck
|
||||
bind:selected={selectedIds}
|
||||
pageItemsIds={data.subscribers.subscribers.map((d) => d.$id)} />
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
<TableCellHead width={column.width}>{column.title}</TableCellHead>
|
||||
{/if}
|
||||
{/each}
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.subscribers.subscribers as subscriber (subscriber.$id)}
|
||||
{@const target = subscriber.target}
|
||||
<TableRowLink
|
||||
href={`${base}/console/project-${$project.$id}/auth/user-${subscriber.target.userId}`}>
|
||||
<TableCellCheck bind:selectedIds id={subscriber.$id} />
|
||||
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
{#if column.id === '$id'}
|
||||
{#key $columns}
|
||||
<TableCell title="Subscriber ID">
|
||||
<Id value={subscriber.$id}>
|
||||
{subscriber.$id}
|
||||
</Id>
|
||||
</TableCell>
|
||||
{/key}
|
||||
{:else if column.id === 'targetId'}
|
||||
<TableCell title={column.title}>
|
||||
<Id value={subscriber[column.id]}>
|
||||
{subscriber[column.id]}
|
||||
</Id>
|
||||
</TableCell>
|
||||
{:else if column.id === 'target'}
|
||||
<TableCell title={column.title}>
|
||||
{#if target.providerType === ProviderTypes.Push}
|
||||
{target.name}
|
||||
{:else}
|
||||
{target.identifier}
|
||||
{/if}
|
||||
</TableCell>
|
||||
{:else if column.id === 'type'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
<ProviderType type={subscriber.target.providerType} size="s" />
|
||||
</TableCellText>
|
||||
{:else if column.id === '$createdAt'}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{toLocaleDateTime(subscriber[column.id])}
|
||||
</TableCellText>
|
||||
{:else}
|
||||
<TableCellText title={column.title} width={column.width}>
|
||||
{subscriber[column.id]}
|
||||
</TableCellText>
|
||||
{/if}
|
||||
{/if}
|
||||
{/each}
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
|
||||
<FloatingActionBar show={selectedIds.length > 0}>
|
||||
<div class="u-flex u-cross-center u-main-space-between actions">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<span class="indicator body-text-2 u-bold">{selectedIds.length}</span>
|
||||
<p>
|
||||
<span class="is-only-desktop">
|
||||
{selectedIds.length > 1 ? 'subscribers' : 'subscriber'}
|
||||
</span>
|
||||
selected
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
<Button text on:click={() => (selectedIds = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>
|
||||
<p>Delete</p>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FloatingActionBar>
|
||||
|
||||
<Modal
|
||||
title="Delete subscriber"
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
headerDivider={false}
|
||||
closable={!deleting}>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to delete <b>{selectedIds.length}</b>
|
||||
{selectedIds.length > 1 ? 'subscribers' : 'subscriber'}?
|
||||
</p>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)} disabled={deleting}>Cancel</Button>
|
||||
<Button secondary submit disabled={deleting}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { Button, Form, InputText } from '$lib/elements/forms';
|
||||
import { onMount } from 'svelte';
|
||||
import { topic } from './store';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { trackEvent, Submit, trackError } from '$lib/actions/analytics';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
let description: string = null;
|
||||
onMount(async () => {
|
||||
description ??= $topic.description;
|
||||
});
|
||||
async function updateDescription() {
|
||||
try {
|
||||
await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${$topic.$id}`),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
description
|
||||
}
|
||||
);
|
||||
await invalidate(Dependencies.MESSAGING_TOPIC);
|
||||
addNotification({
|
||||
message: 'Description has been updated',
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.MessagingTopicUpdateDescription);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
trackError(error, Submit.MessagingTopicUpdateDescription);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateDescription}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Description</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ul data-private>
|
||||
<InputText
|
||||
id="description"
|
||||
label="Description"
|
||||
placeholder="Enter description"
|
||||
autocomplete={false}
|
||||
bind:value={description} />
|
||||
</ul>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={description === $topic.description} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,66 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { Button, Form, InputText } from '$lib/elements/forms';
|
||||
import { onMount } from 'svelte';
|
||||
import { topic } from './store';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { trackEvent, Submit, trackError } from '$lib/actions/analytics';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
let name: string = null;
|
||||
onMount(async () => {
|
||||
name ??= $topic.name;
|
||||
});
|
||||
async function updateName() {
|
||||
try {
|
||||
// await sdk.forProject.users.updateName($provider.$id, providerName);
|
||||
await sdk.forProject.client.call(
|
||||
'PATCH',
|
||||
new URL(`${sdk.forProject.client.config.endpoint}/messaging/topics/${$topic.$id}`),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
{
|
||||
name: name
|
||||
}
|
||||
);
|
||||
await invalidate(Dependencies.MESSAGING_TOPIC);
|
||||
addNotification({
|
||||
message: 'Name has been updated',
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.MessagingTopicUpdateName);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
trackError(error, Submit.MessagingTopicUpdateName);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateName}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Name</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ul data-private>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
autocomplete={false}
|
||||
bind:value={name} />
|
||||
</ul>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={name === $topic.name} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,167 @@
|
||||
<script lang="ts">
|
||||
import { Button, InputCheckbox, InputSearch } from '$lib/elements/forms';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { EmptySearch, Modal, PaginationInline } from '$lib/components';
|
||||
import type { Topic } from './store';
|
||||
|
||||
export let show: boolean;
|
||||
export let topicsById: Record<string, Topic>;
|
||||
export let title = 'Select topics';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let search = '';
|
||||
let offset = 0;
|
||||
let totalResults = 0;
|
||||
let topicResultsById: Record<string, Topic> = {}; // use a hash map so we can quickly look up a user by id
|
||||
let selected: Record<string, Topic> = {};
|
||||
let hasSelection = false;
|
||||
|
||||
function reset() {
|
||||
offset = 0;
|
||||
search = '';
|
||||
}
|
||||
|
||||
function submit() {
|
||||
dispatch('update', selected);
|
||||
reset();
|
||||
}
|
||||
|
||||
async function request() {
|
||||
if (!show) return;
|
||||
const queries = [Query.limit(5), Query.offset(offset)];
|
||||
|
||||
const params = {
|
||||
queries
|
||||
};
|
||||
|
||||
if (search) {
|
||||
params['search'] = search;
|
||||
}
|
||||
|
||||
// TODO: replace with sdk.forProject.users.list once User type has targets
|
||||
const response = await sdk.forProject.client.call(
|
||||
'GET',
|
||||
new URL(sdk.forProject.client.config.endpoint + '/messaging/topics'),
|
||||
{
|
||||
'X-Appwrite-Project': sdk.forProject.client.config.project,
|
||||
'content-type': 'application/json',
|
||||
'X-Appwrite-Mode': 'admin'
|
||||
},
|
||||
params
|
||||
);
|
||||
|
||||
totalResults = response.total;
|
||||
topicResultsById = {};
|
||||
response.topics.forEach((topic) => {
|
||||
topicResultsById = {
|
||||
...topicResultsById,
|
||||
[topic.$id]: topic
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function onTopicSelection(event: Event, topic: Topic) {
|
||||
const { checked } = event.currentTarget as HTMLInputElement;
|
||||
|
||||
if (checked) {
|
||||
selected = {
|
||||
...selected,
|
||||
[topic.$id]: topic
|
||||
};
|
||||
} else {
|
||||
const { [topic.$id]: _, ...rest } = selected;
|
||||
selected = rest;
|
||||
}
|
||||
}
|
||||
|
||||
$: if (show) {
|
||||
request();
|
||||
}
|
||||
$: if (offset !== null) {
|
||||
request();
|
||||
}
|
||||
$: if (search !== null) {
|
||||
offset = 0;
|
||||
request();
|
||||
}
|
||||
|
||||
$: selectedSize = Object.keys(selected).length;
|
||||
|
||||
$: hasSelection = selectedSize > 0;
|
||||
|
||||
$: if (show) {
|
||||
selected = topicsById;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {title} bind:show onSubmit={submit} on:close={reset} size="big">
|
||||
<p class="text">Select existing topics you want to send this message to its recipients.</p>
|
||||
<InputSearch
|
||||
autofocus
|
||||
disabled={totalResults === 0 && !search}
|
||||
placeholder="Search for topics"
|
||||
bind:value={search} />
|
||||
{#if Object.keys(topicResultsById).length > 0}
|
||||
{#each Object.entries(topicResultsById) as [topicId, topic]}
|
||||
<InputCheckbox
|
||||
id={topicId}
|
||||
disabled={!!topicsById[topicId]}
|
||||
checked={!!selected[topicId]}
|
||||
on:change={(event) => onTopicSelection(event, topic)}>
|
||||
<svelte:fragment slot="description">
|
||||
<span class="title"
|
||||
><span class="u-line-height-1-5">
|
||||
<span class="body-text-2 u-bold" data-private>
|
||||
{topic.name}
|
||||
</span><span class="collapsible-button-optional"
|
||||
>({topic.total} subscribers)</span>
|
||||
</span></span>
|
||||
</svelte:fragment>
|
||||
</InputCheckbox>
|
||||
{/each}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {totalResults}</p>
|
||||
<PaginationInline limit={5} bind:offset sum={totalResults} hidePages />
|
||||
</div>
|
||||
{:else if search}
|
||||
<EmptySearch hidePages>
|
||||
<div class="common-section">
|
||||
<div class="u-text-center common-section">
|
||||
<b class="body-text-2 u-bold">Sorry we couldn't find "{search}"</b>
|
||||
<p>There are no topics that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16 common-section u-main-center">
|
||||
<Button external href="https://appwrite.io/docs/products/auth/accounts" text
|
||||
>Documentation</Button>
|
||||
<Button secondary on:click={() => (search = '')}>Clear search</Button>
|
||||
</div>
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<EmptySearch hidePages>
|
||||
<div class="common-section">
|
||||
<div class="u-text-center common-section">
|
||||
<p class="text u-line-height-1-5">
|
||||
You have no topics. Create a topic to see them here.
|
||||
</p>
|
||||
<!-- TODO: link to topics docs -->
|
||||
<p class="text u-line-height-1-5">
|
||||
Need a hand? Learn more in our <a
|
||||
href="https://appwrite.io/docs/products/auth/quick-start"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer">
|
||||
documentation</a
|
||||
>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit disabled={!hasSelection}>Add</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
Loaded 100 of 109 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user