mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix issues with several routes
This commit is contained in:
1 parent
8175f6ffe9
commit
c1ed6ebdba
46 files changed
+1075
-544
No files matched your search
@@ -35,7 +35,7 @@ export const load: LayoutLoad = async ({ depends, parent }) => {
|
||||
try {
|
||||
projectsCount = (
|
||||
await sdk.forConsole.projects.list([
|
||||
Query.equal('teamId', currentOrgId),
|
||||
Query.equal('teamId', currentOrgId),
|
||||
Query.limit(1)
|
||||
])
|
||||
).total;
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
import View from './view.svelte';
|
||||
|
||||
export let data;
|
||||
|
||||
const createUserUrl = (user: Models.User<{}>) => `${base}/project-${page.params.region}-${page.params.project}/auth/user-${user.$id}`;
|
||||
|
||||
const createUserUrl = (user: Models.User<{}>) =>
|
||||
`${base}/project-${page.params.region}-${page.params.project}/auth/user-${user.$id}`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -21,6 +22,5 @@
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createUserUrl}
|
||||
/>
|
||||
{createUserUrl} />
|
||||
</Container>
|
||||
@@ -21,8 +21,15 @@
|
||||
|
||||
async function authUpdate(box: AuthMethod) {
|
||||
try {
|
||||
await sdk.forConsole.projects.updateAuthStatus({ projectId, method: box.method, status: box.value });
|
||||
addNotification({ type: 'success', message: `${box.label} authentication has been updated` });
|
||||
await sdk.forConsole.projects.updateAuthStatus({
|
||||
projectId,
|
||||
method: box.method,
|
||||
status: box.value
|
||||
});
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${box.label} authentication has been updated`
|
||||
});
|
||||
trackEvent(Submit.AuthStatusUpdate, { method: box.method, value: box.value });
|
||||
invalidate(Dependencies.PROJECT);
|
||||
} catch (error) {
|
||||
@@ -45,7 +52,11 @@
|
||||
<Layout.Stack gap="l" direction="row" wrap="wrap">
|
||||
{#each $authMethods.list as box}
|
||||
<div style="flex-basis: 45%;">
|
||||
<InputSwitch label={box.label} id={box.method} bind:value={box.value} on:change={() => authUpdate(box)} />
|
||||
<InputSwitch
|
||||
label={box.label}
|
||||
id={box.method}
|
||||
bind:value={box.value}
|
||||
on:change={() => authUpdate(box)} />
|
||||
</div>
|
||||
{/each}
|
||||
</Layout.Stack>
|
||||
@@ -54,18 +65,38 @@
|
||||
<Layout.Stack>
|
||||
<Typography.Title size="s">OAuth2 Providers</Typography.Title>
|
||||
<ul class="grid-box" style:--grid-gap="1rem" style:--grid-item-size="15rem">
|
||||
{#each $project.oAuthProviders.filter((p) => p.name !== 'Mock').sort((a, b) => (a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1)) as provider}
|
||||
{#each $project.oAuthProviders
|
||||
.filter((p) => p.name !== 'Mock')
|
||||
.sort( (a, b) => (a.enabled === b.enabled ? 0 : a.enabled ? -1 : 1) ) as provider}
|
||||
{@const oAuthProvider = oAuthProviders[provider.key]}
|
||||
{#if oAuthProvider}
|
||||
<Card.Button padding="s" on:click={() => { selectedProvider = provider; showProvider = true; trackEvent(`click_select_provider`, { provider: provider.key.toLowerCase() }); }}>
|
||||
<Card.Button
|
||||
padding="s"
|
||||
on:click={() => {
|
||||
selectedProvider = provider;
|
||||
showProvider = true;
|
||||
trackEvent(`click_select_provider`, {
|
||||
provider: provider.key.toLowerCase()
|
||||
});
|
||||
}}>
|
||||
<Layout.Stack alignItems="flex-start" gap="xxl">
|
||||
<Layout.Stack direction="row" justifyContent="flex-start" alignItems="center">
|
||||
<Layout.Stack
|
||||
direction="row"
|
||||
justifyContent="flex-start"
|
||||
alignItems="center">
|
||||
<Avatar size="s">
|
||||
<img height="20" width="20" src={`${base}/icons/${$app.themeInUse}/color/${oAuthProvider.icon}.svg`} alt={provider.name} />
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={`${base}/icons/${$app.themeInUse}/color/${oAuthProvider.icon}.svg`}
|
||||
alt={provider.name} />
|
||||
</Avatar>
|
||||
<Typography.Text>{provider.name}</Typography.Text>
|
||||
</Layout.Stack>
|
||||
<Badge type={provider.enabled ? 'success' : undefined} variant="secondary" content={provider.enabled ? 'enabled' : 'disabled'} />
|
||||
<Badge
|
||||
type={provider.enabled ? 'success' : undefined}
|
||||
variant="secondary"
|
||||
content={provider.enabled ? 'enabled' : 'disabled'} />
|
||||
</Layout.Stack>
|
||||
</Card.Button>
|
||||
{/if}
|
||||
@@ -78,5 +109,12 @@
|
||||
|
||||
{#if selectedProvider && showProvider}
|
||||
{@const oAuthProvider = oAuthProviders[selectedProvider.key]}
|
||||
<svelte:component this={oAuthProvider.component} bind:provider={selectedProvider} bind:show={showProvider} onclose={() => { selectedProvider = null; showProvider = false; }} />
|
||||
<svelte:component
|
||||
this={oAuthProvider.component}
|
||||
bind:provider={selectedProvider}
|
||||
bind:show={showProvider}
|
||||
onclose={() => {
|
||||
selectedProvider = null;
|
||||
showProvider = false;
|
||||
}} />
|
||||
{/if}
|
||||
@@ -10,8 +10,9 @@
|
||||
import { Container } from '$lib/layout';
|
||||
import View from './view.svelte';
|
||||
export let data;
|
||||
|
||||
const createTeamUrl = (team: Models.Team<Record<string, unknown>>) => `${base}/project-${page.params.region}-${page.params.project}/auth/teams/team-${team.$id}`;
|
||||
|
||||
const createTeamUrl = (team: Models.Team<Record<string, unknown>>) =>
|
||||
`${base}/project-${page.params.region}-${page.params.project}/auth/teams/team-${team.$id}`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -20,6 +21,5 @@
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createTeamUrl}
|
||||
/>
|
||||
{createTeamUrl} />
|
||||
</Container>
|
||||
@@ -3,7 +3,13 @@
|
||||
import { page } from '$app/state';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Empty, EmptySearch, AvatarInitials, SearchQuery, PaginationWithLimit } from '$lib/components';
|
||||
import {
|
||||
Empty,
|
||||
EmptySearch,
|
||||
AvatarInitials,
|
||||
SearchQuery,
|
||||
PaginationWithLimit
|
||||
} from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
|
||||
import { Icon, Layout, Table } from '@appwrite.io/pink-svelte';
|
||||
@@ -34,28 +40,28 @@
|
||||
</script>
|
||||
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<SearchQuery placeholder="Search by name" />
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<Button on:mousedown={() => (showCreateTeam = true)} event="create_user" size="s">
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create team
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<SearchQuery placeholder="Search by name" />
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<Button on:mousedown={() => (showCreateTeam = true)} event="create_user" size="s">
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create team
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
|
||||
{#if teams.total}
|
||||
<Table.Root columns={3} let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
<Table.Header.Cell {root}>Name</Table.Header.Cell>
|
||||
<Table.Header.Cell {root}>Members</Table.Header.Cell>
|
||||
<Table.Header.Cell {root}>Created</Table.Header.Cell>
|
||||
</svelte:fragment>
|
||||
{#each teams.teams as team}
|
||||
{@const href = createTeamUrl(team)}
|
||||
{#if href}
|
||||
<Table.Row.Link {root} href={href}>
|
||||
{#if teams.total}
|
||||
<Table.Root columns={3} let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
<Table.Header.Cell {root}>Name</Table.Header.Cell>
|
||||
<Table.Header.Cell {root}>Members</Table.Header.Cell>
|
||||
<Table.Header.Cell {root}>Created</Table.Header.Cell>
|
||||
</svelte:fragment>
|
||||
{#each teams.teams as team}
|
||||
{@const href = createTeamUrl(team)}
|
||||
{#if href}
|
||||
<Table.Row.Link {root} {href}>
|
||||
<Table.Cell {root}>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<AvatarInitials size="xs" name={team.name} />
|
||||
@@ -69,7 +75,7 @@
|
||||
<DualTimeView time={team.$createdAt} />
|
||||
</Table.Cell>
|
||||
</Table.Row.Link>
|
||||
{:else}
|
||||
{:else}
|
||||
<Table.Row.Base {root}>
|
||||
<Table.Cell {root}>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
@@ -84,24 +90,22 @@
|
||||
<DualTimeView time={team.$createdAt} />
|
||||
</Table.Cell>
|
||||
</Table.Row.Base>
|
||||
{/if}
|
||||
{/each}
|
||||
</Table.Root>
|
||||
{/if}
|
||||
{/each}
|
||||
</Table.Root>
|
||||
|
||||
<PaginationWithLimit name="Teams" {limit} {offset} total={teams.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="teams" search={search} hidePagination={teams.total === 0}>
|
||||
<Button secondary size="s" href={clearSearchHref}>
|
||||
Clear Search
|
||||
</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
allowCreate={true}
|
||||
on:click={() => (showCreateTeam = true)}
|
||||
href="https://appwrite.io/docs/references/cloud/client-web/teams"
|
||||
target="team" />
|
||||
{/if}
|
||||
<PaginationWithLimit name="Teams" {limit} {offset} total={teams.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="teams" {search} hidePagination={teams.total === 0}>
|
||||
<Button secondary size="s" href={clearSearchHref}>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
allowCreate={true}
|
||||
on:click={() => (showCreateTeam = true)}
|
||||
href="https://appwrite.io/docs/references/cloud/client-web/teams"
|
||||
target="team" />
|
||||
{/if}
|
||||
|
||||
<CreateTeam bind:showCreate={showCreateTeam} on:created={onTeamCreated} />
|
||||
@@ -1,16 +1,29 @@
|
||||
<script context="module" lang="ts">
|
||||
import { EmailTemplateLocale, EmailTemplateType, SmsTemplateLocale, SmsTemplateType } from '@appwrite.io/console';
|
||||
import {
|
||||
EmailTemplateLocale,
|
||||
EmailTemplateType,
|
||||
SmsTemplateLocale,
|
||||
SmsTemplateType
|
||||
} from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
|
||||
export async function loadEmailTemplate(projectId: string, type: EmailTemplateType, locale: EmailTemplateLocale) {
|
||||
export async function loadEmailTemplate(
|
||||
projectId: string,
|
||||
type: EmailTemplateType,
|
||||
locale: EmailTemplateLocale
|
||||
) {
|
||||
try {
|
||||
return await sdk.forConsole.projects.getEmailTemplate({ projectId, type, locale });
|
||||
} catch (e) {
|
||||
addNotification({ type: 'error', message: e.message });
|
||||
}
|
||||
}
|
||||
export async function loadSmsTemplate(projectId: string, type: SmsTemplateType, locale: SmsTemplateLocale) {
|
||||
export async function loadSmsTemplate(
|
||||
projectId: string,
|
||||
type: SmsTemplateType,
|
||||
locale: SmsTemplateLocale
|
||||
) {
|
||||
try {
|
||||
return await sdk.forConsole.projects.getSMSTemplate({ projectId, type, locale });
|
||||
} catch (e) {
|
||||
@@ -59,9 +72,16 @@
|
||||
|
||||
<Container>
|
||||
{#if !project.smtpEnabled}
|
||||
<Alert.Inline dismissible={false} status="info" title="Custom SMTP server is required for customizing emails">
|
||||
Configure a custom SMTP server to enable custom email templates and prevent emails from being labeled as spam.
|
||||
<Button compact slot="actions" href={`${base}/project-${page.params.region}-${page.params.project}/settings/smtp`}>
|
||||
<Alert.Inline
|
||||
dismissible={false}
|
||||
status="info"
|
||||
title="Custom SMTP server is required for customizing emails">
|
||||
Configure a custom SMTP server to enable custom email templates and prevent emails from
|
||||
being labeled as spam.
|
||||
<Button
|
||||
compact
|
||||
slot="actions"
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/settings/smtp`}>
|
||||
SMTP settings
|
||||
</Button>
|
||||
</Alert.Inline>
|
||||
@@ -72,7 +92,10 @@
|
||||
Email templates <Badge variant="secondary" content="Experimental" />
|
||||
</svelte:fragment>
|
||||
Use templates to send and process account management emails.
|
||||
<Link.Anchor target="_blank" href="https://appwrite.io/docs/advanced/platform/message-templates">Learn more</Link.Anchor>
|
||||
<Link.Anchor
|
||||
target="_blank"
|
||||
href="https://appwrite.io/docs/advanced/platform/message-templates"
|
||||
>Learn more</Link.Anchor>
|
||||
<svelte:fragment slot="aside">
|
||||
<Layout.Stack gap="s">
|
||||
{#each templates as section (section.key)}
|
||||
@@ -83,14 +106,18 @@
|
||||
on:toggle={(event) => event.detail && toggleAccordion(section.key)}>
|
||||
<Layout.Stack>
|
||||
<Typography.Text>{section.description}</Typography.Text>
|
||||
<svelte:component this={section.component} loading={isTemplateLoading} />
|
||||
<svelte:component
|
||||
this={section.component}
|
||||
loading={isTemplateLoading} />
|
||||
</Layout.Stack>
|
||||
</Accordion>
|
||||
{/each}
|
||||
</Layout.Stack>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="actions">
|
||||
<Button href={`${base}/project-${page.params.region}-${page.params.project}/settings/smtp`} secondary>
|
||||
<Button
|
||||
href={`${base}/project-${page.params.region}-${page.params.project}/settings/smtp`}
|
||||
secondary>
|
||||
SMTP settings
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -2,7 +2,14 @@
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { AvatarInitials, Copy, Empty, EmptySearch, PaginationWithLimit, SearchQuery } from '$lib/components';
|
||||
import {
|
||||
AvatarInitials,
|
||||
Copy,
|
||||
Empty,
|
||||
EmptySearch,
|
||||
PaginationWithLimit,
|
||||
SearchQuery
|
||||
} from '$lib/components';
|
||||
import { toLocaleDate, toLocaleDateTime } from '$lib/helpers/date';
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { Container } from '$lib/layout';
|
||||
@@ -43,179 +50,201 @@
|
||||
{ id: 'status', title: 'Status', type: 'string', width: { min: 140 } },
|
||||
{ id: 'labels', title: 'Labels', type: 'string', hide: true, width: { min: 140 } },
|
||||
{ id: 'joined', title: 'Joined', type: 'string', width: { min: 140 } },
|
||||
{ id: 'lastActivity', title: 'Last activity', type: 'string', hide: true, width: { min: 140 } }
|
||||
{
|
||||
id: 'lastActivity',
|
||||
title: 'Last activity',
|
||||
type: 'string',
|
||||
hide: true,
|
||||
width: { min: 140 }
|
||||
}
|
||||
]);
|
||||
</script>
|
||||
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<SearchQuery placeholder="Search by name, email, phone, or ID" />
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<ViewSelector view={View.Table} {columns} hideView />
|
||||
<Button on:click={() => (showCreateUser = true)} event="create_user" size="s">
|
||||
<Icon size="s" icon={IconPlus} slot="start" />
|
||||
<span class="text">Create user</span>
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<SearchQuery placeholder="Search by name, email, phone, or ID" />
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<ViewSelector view={View.Table} {columns} hideView />
|
||||
<Button on:click={() => (showCreateUser = true)} event="create_user" size="s">
|
||||
<Icon size="s" icon={IconPlus} slot="start" />
|
||||
<span class="text">Create user</span>
|
||||
</Button>
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
|
||||
{#if users.total}
|
||||
<Table.Root columns={$columns} let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $columns as { id, title } (id)}
|
||||
<Table.Header.Cell column={id} {root}>{title}</Table.Header.Cell>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
|
||||
{#each users.users as user}
|
||||
{@const href = createUserUrl(user)}
|
||||
{#if href}
|
||||
<Table.Row.Link href={href} {root}>
|
||||
{#each $columns as { id } (id)}
|
||||
<Table.Cell column={id} {root}>
|
||||
{#if id === '$id'}
|
||||
<Copy value={user.$id} event="user">
|
||||
<Tag size="xs" variant="code">
|
||||
<Icon size="s" icon={IconDuplicate} slot="start" />
|
||||
{user.$id}
|
||||
</Tag>
|
||||
</Copy>
|
||||
{:else if id === 'name'}
|
||||
<Layout.Stack direction="row" alignItems="center" gap="s">
|
||||
{#if user.email || user.phone}
|
||||
{#if user.name}
|
||||
<AvatarInitials size="xs" name={user.name} />
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true"></span>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true"></span>
|
||||
</div>
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
{:else if id === 'identifiers'}
|
||||
<Typography.Text truncate>
|
||||
{user.email && user.phone
|
||||
? [user.email, user.phone].join(',')
|
||||
: user.email || user.phone}
|
||||
</Typography.Text>
|
||||
{:else if id === 'status'}
|
||||
{#if user.status}
|
||||
{@const success = user.emailVerification || user.phoneVerification}
|
||||
<Badge
|
||||
size="xs"
|
||||
variant="secondary"
|
||||
type={success ? 'success' : undefined}
|
||||
content={user.emailVerification && user.phoneVerification
|
||||
? 'Verified'
|
||||
: user.emailVerification
|
||||
? 'Verified email'
|
||||
: user.phoneVerification
|
||||
? 'Verified phone'
|
||||
: 'Unverified'} />
|
||||
{:else}
|
||||
<Badge size="xs" variant="secondary" type="error" content="blocked" />
|
||||
{/if}
|
||||
{:else if id === 'labels'}
|
||||
<Typography.Text truncate>
|
||||
{user.labels.join(', ')}
|
||||
</Typography.Text>
|
||||
{:else if id === 'joined'}
|
||||
{toLocaleDateTime(user.registration)}
|
||||
{:else if id === 'lastActivity'}
|
||||
{user.accessedAt ? toLocaleDate(user.accessedAt) : 'never'}
|
||||
{:else}
|
||||
{user[id]}
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Link>
|
||||
{:else}
|
||||
<Table.Row.Base {root}>
|
||||
{#each $columns as { id } (id)}
|
||||
<Table.Cell column={id} {root}>
|
||||
{#if id === '$id'}
|
||||
<Copy value={user.$id} event="user">
|
||||
<Tag size="xs" variant="code">
|
||||
<Icon size="s" icon={IconDuplicate} slot="start" />
|
||||
{user.$id}
|
||||
</Tag>
|
||||
</Copy>
|
||||
{:else if id === 'name'}
|
||||
<Layout.Stack direction="row" alignItems="center" gap="s">
|
||||
{#if user.email || user.phone}
|
||||
{#if user.name}
|
||||
<AvatarInitials size="xs" name={user.name} />
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true"></span>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true"></span>
|
||||
</div>
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
{:else if id === 'identifiers'}
|
||||
<Typography.Text truncate>
|
||||
{user.email && user.phone
|
||||
? [user.email, user.phone].join(',')
|
||||
: user.email || user.phone}
|
||||
</Typography.Text>
|
||||
{:else if id === 'status'}
|
||||
{#if user.status}
|
||||
{@const success = user.emailVerification || user.phoneVerification}
|
||||
<Badge size="xs" variant="secondary" type={success ? "success" : "warning"} content={success ? "verified" : "unverified"} />
|
||||
{:else}
|
||||
<Badge size="xs" variant="secondary" type="error" content="blocked" />
|
||||
{/if}
|
||||
{:else if id === 'labels'}
|
||||
<Typography.Text truncate>
|
||||
{user.labels.join(', ')}
|
||||
</Typography.Text>
|
||||
{:else if id === 'joined'}
|
||||
{toLocaleDateTime(user.registration)}
|
||||
{:else if id === 'lastActivity'}
|
||||
{user.accessedAt ? toLocaleDate(user.accessedAt) : 'never'}
|
||||
{:else}
|
||||
{user[id]}
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Base>
|
||||
{/if}
|
||||
{#if users.total}
|
||||
<Table.Root columns={$columns} let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $columns as { id, title } (id)}
|
||||
<Table.Header.Cell column={id} {root}>{title}</Table.Header.Cell>
|
||||
{/each}
|
||||
</Table.Root>
|
||||
</svelte:fragment>
|
||||
|
||||
<PaginationWithLimit name="Users" {limit} {offset} total={users.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="users" hidePagination>
|
||||
<Button href={clearSearchHref} size="s" secondary>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/references/cloud/server-nodejs/users"
|
||||
target="user"
|
||||
allowCreate={true}
|
||||
on:click={() => (showCreateUser = true)} />
|
||||
{/if}
|
||||
{#each users.users as user}
|
||||
{@const href = createUserUrl(user)}
|
||||
{#if href}
|
||||
<Table.Row.Link {href} {root}>
|
||||
{#each $columns as { id } (id)}
|
||||
<Table.Cell column={id} {root}>
|
||||
{#if id === '$id'}
|
||||
<Copy value={user.$id} event="user">
|
||||
<Tag size="xs" variant="code">
|
||||
<Icon size="s" icon={IconDuplicate} slot="start" />
|
||||
{user.$id}
|
||||
</Tag>
|
||||
</Copy>
|
||||
{:else if id === 'name'}
|
||||
<Layout.Stack direction="row" alignItems="center" gap="s">
|
||||
{#if user.email || user.phone}
|
||||
{#if user.name}
|
||||
<AvatarInitials size="xs" name={user.name} />
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true"
|
||||
></span>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true"></span>
|
||||
</div>
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
{:else if id === 'identifiers'}
|
||||
<Typography.Text truncate>
|
||||
{user.email && user.phone
|
||||
? [user.email, user.phone].join(',')
|
||||
: user.email || user.phone}
|
||||
</Typography.Text>
|
||||
{:else if id === 'status'}
|
||||
{#if user.status}
|
||||
{@const success =
|
||||
user.emailVerification || user.phoneVerification}
|
||||
<Badge
|
||||
size="xs"
|
||||
variant="secondary"
|
||||
type={success ? 'success' : undefined}
|
||||
content={user.emailVerification && user.phoneVerification
|
||||
? 'Verified'
|
||||
: user.emailVerification
|
||||
? 'Verified email'
|
||||
: user.phoneVerification
|
||||
? 'Verified phone'
|
||||
: 'Unverified'} />
|
||||
{:else}
|
||||
<Badge
|
||||
size="xs"
|
||||
variant="secondary"
|
||||
type="error"
|
||||
content="blocked" />
|
||||
{/if}
|
||||
{:else if id === 'labels'}
|
||||
<Typography.Text truncate>
|
||||
{user.labels.join(', ')}
|
||||
</Typography.Text>
|
||||
{:else if id === 'joined'}
|
||||
{toLocaleDateTime(user.registration)}
|
||||
{:else if id === 'lastActivity'}
|
||||
{user.accessedAt ? toLocaleDate(user.accessedAt) : 'never'}
|
||||
{:else}
|
||||
{user[id]}
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Link>
|
||||
{:else}
|
||||
<Table.Row.Base {root}>
|
||||
{#each $columns as { id } (id)}
|
||||
<Table.Cell column={id} {root}>
|
||||
{#if id === '$id'}
|
||||
<Copy value={user.$id} event="user">
|
||||
<Tag size="xs" variant="code">
|
||||
<Icon size="s" icon={IconDuplicate} slot="start" />
|
||||
{user.$id}
|
||||
</Tag>
|
||||
</Copy>
|
||||
{:else if id === 'name'}
|
||||
<Layout.Stack direction="row" alignItems="center" gap="s">
|
||||
{#if user.email || user.phone}
|
||||
{#if user.name}
|
||||
<AvatarInitials size="xs" name={user.name} />
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true"
|
||||
></span>
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true"></span>
|
||||
</div>
|
||||
<Typography.Text truncate>
|
||||
{user.name}
|
||||
</Typography.Text>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
{:else if id === 'identifiers'}
|
||||
<Typography.Text truncate>
|
||||
{user.email && user.phone
|
||||
? [user.email, user.phone].join(',')
|
||||
: user.email || user.phone}
|
||||
</Typography.Text>
|
||||
{:else if id === 'status'}
|
||||
{#if user.status}
|
||||
{@const success =
|
||||
user.emailVerification || user.phoneVerification}
|
||||
<Badge
|
||||
size="xs"
|
||||
variant="secondary"
|
||||
type={success ? 'success' : 'warning'}
|
||||
content={success ? 'verified' : 'unverified'} />
|
||||
{:else}
|
||||
<Badge
|
||||
size="xs"
|
||||
variant="secondary"
|
||||
type="error"
|
||||
content="blocked" />
|
||||
{/if}
|
||||
{:else if id === 'labels'}
|
||||
<Typography.Text truncate>
|
||||
{user.labels.join(', ')}
|
||||
</Typography.Text>
|
||||
{:else if id === 'joined'}
|
||||
{toLocaleDateTime(user.registration)}
|
||||
{:else if id === 'lastActivity'}
|
||||
{user.accessedAt ? toLocaleDate(user.accessedAt) : 'never'}
|
||||
{:else}
|
||||
{user[id]}
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Base>
|
||||
{/if}
|
||||
{/each}
|
||||
</Table.Root>
|
||||
|
||||
<PaginationWithLimit name="Users" {limit} {offset} total={users.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="users" hidePagination>
|
||||
<Button href={clearSearchHref} size="s" secondary>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/references/cloud/server-nodejs/users"
|
||||
target="user"
|
||||
allowCreate={true}
|
||||
on:click={() => (showCreateUser = true)} />
|
||||
{/if}
|
||||
|
||||
<CreateUser bind:showCreate={showCreateUser} on:created={onUserCreated} />
|
||||
@@ -22,6 +22,5 @@
|
||||
offset={data.offset}
|
||||
view={data.view}
|
||||
search={data.search}
|
||||
{getDatabaseUrl}
|
||||
/>
|
||||
{getDatabaseUrl} />
|
||||
</Container>
|
||||
+1
-2
@@ -18,6 +18,5 @@
|
||||
offset={data.offset}
|
||||
view={data.view}
|
||||
search={data.search}
|
||||
{createTableUrl}
|
||||
/>
|
||||
{createTableUrl} />
|
||||
</Container>
|
||||
+99
-67
@@ -1,6 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { EmptySearch, PaginationWithLimit, SearchQuery, ViewSelector, Id, CardContainer, GridItem1 } from '$lib/components';
|
||||
import {
|
||||
EmptySearch,
|
||||
PaginationWithLimit,
|
||||
SearchQuery,
|
||||
ViewSelector,
|
||||
Id,
|
||||
CardContainer,
|
||||
GridItem1
|
||||
} from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { showCreate, tableViewColumns } from './store';
|
||||
import { Card, Empty, Icon, Layout, Table as PinkTable } from '@appwrite.io/pink-svelte';
|
||||
@@ -9,6 +17,7 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { base } from '$app/paths';
|
||||
|
||||
let {
|
||||
tables,
|
||||
@@ -31,74 +40,97 @@
|
||||
</script>
|
||||
|
||||
<Layout.Stack direction="row" justifyContent="space-between">
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<SearchQuery placeholder="Search by name or ID" />
|
||||
</Layout.Stack>
|
||||
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<ViewSelector view={view} columns={tableViewColumns} hideColumns={!tables.total} hideView={!tables.total} />
|
||||
|
||||
{#if $canWriteTables}
|
||||
<Button event="create_table" on:click={() => ($showCreate = true)}>
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create table
|
||||
</Button>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
<Layout.Stack direction="row" alignItems="center">
|
||||
<SearchQuery placeholder="Search by name or ID" />
|
||||
</Layout.Stack>
|
||||
|
||||
{#if tables.total}
|
||||
{#if view === 'grid'}
|
||||
<CardContainer disableEmpty={!$canWriteTables} total={tables.total} {offset} event="table" service="tables" on:click={() => ($showCreate = true)}>
|
||||
{#each tables.tables as table}
|
||||
<GridItem1 href={createTableUrl(table)}>
|
||||
<svelte:fragment slot="title">{table.name}</svelte:fragment>
|
||||
<Id value={table.$id}>{table.$id}</Id>
|
||||
</GridItem1>
|
||||
{/each}
|
||||
</CardContainer>
|
||||
{:else}
|
||||
<PinkTable.Root columns={$tableViewColumns} let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $tableViewColumns as { id, title }}
|
||||
<PinkTable.Header.Cell column={id} {root}>{title}</PinkTable.Header.Cell>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
{#each tables.tables as table (table.$id)}
|
||||
<PinkTable.Row.Link {root} href={createTableUrl(table)}>
|
||||
{#each $tableViewColumns as column}
|
||||
<PinkTable.Cell column={column.id} {root}>
|
||||
{#if column.id === '$id'}
|
||||
{#key $tableViewColumns}
|
||||
<Id value={table.$id}>{table.$id}</Id>
|
||||
{/key}
|
||||
{:else if column.id === 'name'}
|
||||
{table.name}
|
||||
{:else}
|
||||
{table[column.id]}
|
||||
{/if}
|
||||
</PinkTable.Cell>
|
||||
{/each}
|
||||
</PinkTable.Row.Link>
|
||||
{/each}
|
||||
</PinkTable.Root>
|
||||
{/if}
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<ViewSelector
|
||||
{view}
|
||||
columns={tableViewColumns}
|
||||
hideColumns={!tables.total}
|
||||
hideView={!tables.total} />
|
||||
|
||||
<PaginationWithLimit name="Tables" {limit} {offset} total={tables.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="tables" hidePagination>
|
||||
<Button size="s" secondary href={clearSearchHref}>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{#if $canWriteTables}
|
||||
<Button event="create_table" on:click={() => ($showCreate = true)}>
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create table
|
||||
</Button>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
|
||||
{#if tables.total}
|
||||
{#if view === 'grid'}
|
||||
<CardContainer
|
||||
disableEmpty={!$canWriteTables}
|
||||
total={tables.total}
|
||||
{offset}
|
||||
event="table"
|
||||
service="tables"
|
||||
on:click={() => ($showCreate = true)}>
|
||||
{#each tables.tables as table}
|
||||
<GridItem1 href={createTableUrl(table)}>
|
||||
<svelte:fragment slot="title">{table.name}</svelte:fragment>
|
||||
<Id value={table.$id}>{table.$id}</Id>
|
||||
</GridItem1>
|
||||
{/each}
|
||||
</CardContainer>
|
||||
{:else}
|
||||
<Card.Base padding="none">
|
||||
<Empty title="Create your first table" src={$app.themeInUse === 'dark' ? `${base}/images/empty-database-dark.svg` : `${base}/images/empty-database-light.svg`}>
|
||||
<span slot="description">Create, organize, and query structured data with Tables.</span>
|
||||
<span slot="actions">
|
||||
<Button external href="https://appwrite.io/docs/products/databases/databases" text event="empty_documentation" ariaLabel={`create table`}>Documentation</Button>
|
||||
{#if $canWriteTables}
|
||||
<Button secondary on:click={() => { $showCreate = true; }}>Create table</Button>
|
||||
{/if}
|
||||
</span>
|
||||
</Empty>
|
||||
</Card.Base>
|
||||
<PinkTable.Root columns={$tableViewColumns} let:root>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $tableViewColumns as { id, title }}
|
||||
<PinkTable.Header.Cell column={id} {root}>{title}</PinkTable.Header.Cell>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
{#each tables.tables as table (table.$id)}
|
||||
<PinkTable.Row.Link {root} href={createTableUrl(table)}>
|
||||
{#each $tableViewColumns as column}
|
||||
<PinkTable.Cell column={column.id} {root}>
|
||||
{#if column.id === '$id'}
|
||||
{#key $tableViewColumns}
|
||||
<Id value={table.$id}>{table.$id}</Id>
|
||||
{/key}
|
||||
{:else if column.id === 'name'}
|
||||
{table.name}
|
||||
{:else}
|
||||
{table[column.id]}
|
||||
{/if}
|
||||
</PinkTable.Cell>
|
||||
{/each}
|
||||
</PinkTable.Row.Link>
|
||||
{/each}
|
||||
</PinkTable.Root>
|
||||
{/if}
|
||||
|
||||
<PaginationWithLimit name="Tables" {limit} {offset} total={tables.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="tables" hidePagination>
|
||||
<Button size="s" secondary href={clearSearchHref}>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Card.Base padding="none">
|
||||
<Empty
|
||||
title="Create your first table"
|
||||
src={$app.themeInUse === 'dark'
|
||||
? `${base}/images/empty-database-dark.svg`
|
||||
: `${base}/images/empty-database-light.svg`}>
|
||||
<span slot="description">Create, organize, and query structured data with Tables.</span>
|
||||
<span slot="actions">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/products/databases/databases"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create table`}>Documentation</Button>
|
||||
{#if $canWriteTables}
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => {
|
||||
$showCreate = true;
|
||||
}}>Create table</Button>
|
||||
{/if}
|
||||
</span>
|
||||
</Empty>
|
||||
</Card.Base>
|
||||
{/if}
|
||||
@@ -1,9 +1,17 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import { Empty, PaginationWithLimit, SearchQuery, ViewSelector, Id, CardContainer, GridItem1 } from '$lib/components';
|
||||
import {
|
||||
Empty,
|
||||
PaginationWithLimit,
|
||||
SearchQuery,
|
||||
ViewSelector,
|
||||
Id,
|
||||
CardContainer,
|
||||
GridItem1
|
||||
} from '$lib/components';
|
||||
import { canWriteDatabases } from '$lib/stores/roles';
|
||||
import { columns } from './store';
|
||||
import { Icon, Layout, Table as PinkTable, Tooltip, Button } from '@appwrite.io/pink-svelte';
|
||||
import { Icon, Layout, Table as PinkTable, Tooltip } from '@appwrite.io/pink-svelte';
|
||||
import Create from './create.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { IconPlus, IconExclamation } from '@appwrite.io/pink-icons-svelte';
|
||||
@@ -11,6 +19,8 @@
|
||||
import EmptySearch from '$lib/components/emptySearch.svelte';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { base } from '$app/paths';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
let {
|
||||
databases,
|
||||
@@ -35,7 +45,7 @@
|
||||
} = $props();
|
||||
|
||||
let showCreate = $state(false);
|
||||
|
||||
|
||||
const clearSearchHref = page.url.pathname;
|
||||
async function onCreated(e: CustomEvent<Models.Database>) {
|
||||
showCreate = false;
|
||||
@@ -70,10 +80,16 @@
|
||||
|
||||
{#if databases.total}
|
||||
{#if view === 'grid'}
|
||||
<CardContainer disableEmpty={!$canWriteDatabases} total={databases.total} {offset} event="database" service="databases" on:click={() => (showCreate = true)}>
|
||||
<CardContainer
|
||||
disableEmpty={!$canWriteDatabases}
|
||||
total={databases.total}
|
||||
{offset}
|
||||
event="database"
|
||||
service="databases"
|
||||
on:click={() => (showCreate = true)}>
|
||||
{#each databases.databases as database}
|
||||
{@const href = getDatabaseUrl(database, tables?.[database.$id] ?? null)}
|
||||
<GridItem1 href={href}>
|
||||
<GridItem1 {href}>
|
||||
<svelte:fragment slot="title">{database.name}</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">
|
||||
{#if lastBackups && lastBackups[database.$id]}
|
||||
@@ -111,12 +127,23 @@
|
||||
{:else if column.id === 'backup'}
|
||||
{@const p = policies?.[database.$id] ?? null}
|
||||
{@const last = lastBackups?.[database.$id] ?? null}
|
||||
{@const description = p?.map((policy) => getPolicyDescription(policy.schedule)).join(', ')}
|
||||
<Tooltip placement="bottom" disabled={!p || !last} maxWidth="fit-content">
|
||||
{@const description = p
|
||||
?.map((policy) => getPolicyDescription(policy.schedule))
|
||||
.join(', ')}
|
||||
<Tooltip
|
||||
placement="bottom"
|
||||
disabled={!p || !last}
|
||||
maxWidth="fit-content">
|
||||
<span class="u-trim">
|
||||
{#if !p}
|
||||
<Layout.Stack direction="row" gap="xxs" alignItems="center">
|
||||
<Icon icon={IconExclamation} size="s" color="--bgcolor-warning" />
|
||||
<Layout.Stack
|
||||
direction="row"
|
||||
gap="xxs"
|
||||
alignItems="center">
|
||||
<Icon
|
||||
icon={IconExclamation}
|
||||
size="s"
|
||||
color="--bgcolor-warning" />
|
||||
No backup policies
|
||||
</Layout.Stack>
|
||||
{:else}
|
||||
@@ -138,15 +165,24 @@
|
||||
<PaginationWithLimit name="Databases" {limit} {offset} total={databases.total} />
|
||||
{:else if search}
|
||||
<EmptySearch target="databases" hidePagination>
|
||||
<Button href={clearSearchHref ?? `${base}/project-${page.params.region}-${page.params.project}/databases`} size="s" secondary>Clear Search</Button>
|
||||
<Button
|
||||
href={clearSearchHref ??
|
||||
`${base}/project-${page.params.region}-${page.params.project}/databases`}
|
||||
size="s"
|
||||
secondary>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty single href="https://appwrite.io/docs/products/databases/databases" target="database" allowCreate={$canWriteDatabases} />
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/products/databases/databases"
|
||||
target="database"
|
||||
allowCreate={$canWriteDatabases} />
|
||||
{/if}
|
||||
|
||||
<Create bind:showCreate on:created={onCreated} />
|
||||
|
||||
|
||||
<style>
|
||||
.icon-exclamation { color: hsl(var(--color-warning-100)) !important; }
|
||||
.icon-exclamation {
|
||||
color: hsl(var(--color-warning-100)) !important;
|
||||
}
|
||||
</style>
|
||||
@@ -4,12 +4,18 @@
|
||||
import { Container } from '$lib/layout';
|
||||
import View from './view.svelte';
|
||||
export let data;
|
||||
|
||||
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
const createMessageUrl = (message: Models.Message) => `${base}/project-${page.params.region}-${page.params.project}/messaging/message-${message.$id}`;
|
||||
|
||||
const createMessageUrl = (message: Models.Message) =>
|
||||
`${base}/project-${page.params.region}-${page.params.project}/messaging/message-${message.$id}`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<View messages={data.messages} limit={data.limit} offset={data.offset} search={data.search} {createMessageUrl} />
|
||||
<View
|
||||
messages={data.messages}
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createMessageUrl} />
|
||||
</Container>
|
||||
@@ -4,7 +4,7 @@
|
||||
import { hasPageQueries } from '$lib/components/filters';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { Container, ResponsiveContainerHeader } from '$lib/layout';
|
||||
import { ResponsiveContainerHeader } from '$lib/layout';
|
||||
import { MessagingProviderType, type Models } from '@appwrite.io/console';
|
||||
import CreateMessageDropdown from './createMessageDropdown.svelte';
|
||||
import FailedModal from './failedModal.svelte';
|
||||
@@ -19,7 +19,14 @@
|
||||
import type { Column } from '$lib/helpers/types';
|
||||
import { writable } from 'svelte/store';
|
||||
import { canWriteMessages } from '$lib/stores/roles';
|
||||
import { Badge, FloatingActionBar, Layout, Link, Table, Typography } from '@appwrite.io/pink-svelte';
|
||||
import {
|
||||
Badge,
|
||||
FloatingActionBar,
|
||||
Layout,
|
||||
Link,
|
||||
Table,
|
||||
Typography
|
||||
} from '@appwrite.io/pink-svelte';
|
||||
import { Confirm } from '$lib/components';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { stopPolling, pollMessagesStatus } from './helper';
|
||||
@@ -49,7 +56,14 @@
|
||||
|
||||
const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Message ID', type: 'string', width: 200 },
|
||||
{ id: 'message', title: 'Message', type: 'string', hide: true, filter: false, width: { min: 140 } },
|
||||
{
|
||||
id: 'message',
|
||||
title: 'Message',
|
||||
type: 'string',
|
||||
hide: true,
|
||||
filter: false,
|
||||
width: { min: 140 }
|
||||
},
|
||||
{ id: 'providerType', title: 'Type', type: 'string', width: { min: 100 } },
|
||||
{ id: 'status', title: 'Status', type: 'string', width: { min: 120 } },
|
||||
{ id: 'scheduledAt', title: 'Scheduled at', type: 'datetime', width: { min: 120 } },
|
||||
@@ -58,11 +72,16 @@
|
||||
|
||||
async function handleDelete() {
|
||||
showDelete = false;
|
||||
const promises = selected.map((id) => sdk.forProject(region, project).messaging.delete({ messageId: id }));
|
||||
const promises = selected.map((id) =>
|
||||
sdk.forProject(region, project).messaging.delete({ messageId: id })
|
||||
);
|
||||
try {
|
||||
await Promise.all(promises);
|
||||
trackEvent(Submit.MessagingMessageDelete, { total: selected.length });
|
||||
addNotification({ type: 'success', message: `${selected.length} message${selected.length > 1 ? 's' : ''} deleted` });
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${selected.length} message${selected.length > 1 ? 's' : ''} deleted`
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({ type: 'error', message: error.message });
|
||||
trackError(error, Submit.MessagingMessageDelete);
|
||||
@@ -92,88 +111,108 @@
|
||||
{/if}
|
||||
</ResponsiveContainerHeader>
|
||||
|
||||
{#if messages.total}
|
||||
<Table.Root columns={$columns} allowSelection={$canWriteMessages} let:root bind:selectedRows={selected}>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $columns as { id, title }}
|
||||
<Table.Cell column={id} {root}>{title}</Table.Cell>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
{#each messages.messages as message (message.$id)}
|
||||
<Table.Row.Link {root} id={message.$id} href={createMessageUrl(message)}>
|
||||
{#each $columns as column (column.id)}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
{#if column.id === '$id'}
|
||||
{#key $columns}<Id value={message.$id}>{message.$id}</Id>{/key}
|
||||
{:else if column.id === 'message'}
|
||||
{#if message.providerType === MessagingProviderType.Push}
|
||||
{message.data.title}
|
||||
{:else if message.providerType === MessagingProviderType.Sms}
|
||||
{message.data.content}
|
||||
{:else if message.providerType === MessagingProviderType.Email}
|
||||
{message.data.subject}
|
||||
{:else}Invalid provider{/if}
|
||||
{:else if column.id === 'providerType'}
|
||||
<ProviderType type={message.providerType} size="xs" />
|
||||
{:else if column.id === 'status'}
|
||||
<Layout.Stack direction="row" gap="s">
|
||||
<MessageStatusPill status={message.status} />
|
||||
{#if message.status === 'failed'}
|
||||
<Link.Button on:click={(e) => { e.preventDefault(); errors = message.deliveryErrors; showFailed = true; }}>Details</Link.Button>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
{:else if column.type === 'datetime'}
|
||||
{#if !message[column.id]}-{:else}{toLocaleDateTime(message[column.id])}{/if}
|
||||
{:else}
|
||||
{message[column.id]}
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Link>
|
||||
{#if messages.total}
|
||||
<Table.Root
|
||||
columns={$columns}
|
||||
allowSelection={$canWriteMessages}
|
||||
let:root
|
||||
bind:selectedRows={selected}>
|
||||
<svelte:fragment slot="header" let:root>
|
||||
{#each $columns as { id, title }}
|
||||
<Table.Cell column={id} {root}>{title}</Table.Cell>
|
||||
{/each}
|
||||
</Table.Root>
|
||||
</svelte:fragment>
|
||||
{#each messages.messages as message (message.$id)}
|
||||
<Table.Row.Link {root} id={message.$id} href={createMessageUrl(message)}>
|
||||
{#each $columns as column (column.id)}
|
||||
<Table.Cell column={column.id} {root}>
|
||||
{#if column.id === '$id'}
|
||||
{#key $columns}<Id value={message.$id}>{message.$id}</Id>{/key}
|
||||
{:else if column.id === 'message'}
|
||||
{#if message.providerType === MessagingProviderType.Push}
|
||||
{message.data.title}
|
||||
{:else if message.providerType === MessagingProviderType.Sms}
|
||||
{message.data.content}
|
||||
{:else if message.providerType === MessagingProviderType.Email}
|
||||
{message.data.subject}
|
||||
{:else}Invalid provider{/if}
|
||||
{:else if column.id === 'providerType'}
|
||||
<ProviderType type={message.providerType} size="xs" />
|
||||
{:else if column.id === 'status'}
|
||||
<Layout.Stack direction="row" gap="s">
|
||||
<MessageStatusPill status={message.status} />
|
||||
{#if message.status === 'failed'}
|
||||
<Link.Button
|
||||
on:click={(e) => {
|
||||
e.preventDefault();
|
||||
errors = message.deliveryErrors;
|
||||
showFailed = true;
|
||||
}}>Details</Link.Button>
|
||||
{/if}
|
||||
</Layout.Stack>
|
||||
{:else if column.type === 'datetime'}
|
||||
{#if !message[column.id]}-{:else}{toLocaleDateTime(
|
||||
message[column.id]
|
||||
)}{/if}
|
||||
{:else}
|
||||
{message[column.id]}
|
||||
{/if}
|
||||
</Table.Cell>
|
||||
{/each}
|
||||
</Table.Row.Link>
|
||||
{/each}
|
||||
</Table.Root>
|
||||
|
||||
{#if selected.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selected.length.toString()} />
|
||||
<span>{selected.length > 1 ? 'messages' : 'message'} selected</span>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selected = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
|
||||
<PaginationWithLimit name="Messages" {limit} {offset} total={messages.total} />
|
||||
{:else if $hasPageQueries}
|
||||
<EmptyFilter resource="messages" />
|
||||
{:else if search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{search}'</b>
|
||||
<p>There are no messages that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16">
|
||||
<Button external href="https://appwrite.io/docs/products/messaging/messages" text>Documentation</Button>
|
||||
<Button secondary href={page.url.pathname}>Clear search</Button>
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty single target="message" on:click={() => ($showCreate = true)}>
|
||||
<svelte:fragment slot="actions">
|
||||
<Button external href="https://appwrite.io/docs/products/messaging/messages" text event="empty_documentation" ariaLabel={`create message`}>Documentation</Button>
|
||||
{#if $canWriteMessages}
|
||||
<CreateMessageDropdown let:toggle>
|
||||
<Button secondary on:click={toggle} event="create_message"><span class="text">Create message</span></Button>
|
||||
</CreateMessageDropdown>
|
||||
{/if}
|
||||
{#if selected.length > 0}
|
||||
<FloatingActionBar>
|
||||
<svelte:fragment slot="start">
|
||||
<Badge content={selected.length.toString()} />
|
||||
<span>{selected.length > 1 ? 'messages' : 'message'} selected</span>
|
||||
</svelte:fragment>
|
||||
</Empty>
|
||||
<svelte:fragment slot="end">
|
||||
<Button text on:click={() => (selected = [])}>Cancel</Button>
|
||||
<Button secondary on:click={() => (showDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</FloatingActionBar>
|
||||
{/if}
|
||||
|
||||
<PaginationWithLimit name="Messages" {limit} {offset} total={messages.total} />
|
||||
{:else if $hasPageQueries}
|
||||
<EmptyFilter resource="messages" />
|
||||
{:else if search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
<b>Sorry, we couldn't find '{search}'</b>
|
||||
<p>There are no messages that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16">
|
||||
<Button external href="https://appwrite.io/docs/products/messaging/messages" text
|
||||
>Documentation</Button>
|
||||
<Button secondary href={page.url.pathname}>Clear search</Button>
|
||||
</div>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty single target="message" on:click={() => ($showCreate = true)}>
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/products/messaging/messages"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create message`}>Documentation</Button>
|
||||
{#if $canWriteMessages}
|
||||
<CreateMessageDropdown let:toggle>
|
||||
<Button secondary on:click={toggle} event="create_message"
|
||||
><span class="text">Create message</span></Button>
|
||||
</CreateMessageDropdown>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</Empty>
|
||||
{/if}
|
||||
|
||||
<FailedModal bind:show={showFailed} {errors} />
|
||||
<Confirm title="Delete messages" bind:open={showDelete} onSubmit={handleDelete} disabled={deleting}>
|
||||
<Typography.Text>Are you sure you want to delete <b>{selected.length}</b> {selected.length > 1 ? 'messages' : 'message'}?</Typography.Text>
|
||||
</Confirm>
|
||||
<Typography.Text
|
||||
>Are you sure you want to delete <b>{selected.length}</b>
|
||||
{selected.length > 1 ? 'messages' : 'message'}?</Typography.Text>
|
||||
</Confirm>
|
||||
@@ -23,6 +23,5 @@
|
||||
offset={data.offset}
|
||||
view={data.view}
|
||||
search={data.search}
|
||||
{createBucketUrl}
|
||||
/>
|
||||
{createBucketUrl} />
|
||||
</Container>
|
||||
+1
-2
@@ -17,6 +17,5 @@
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createFileUrl}
|
||||
/>
|
||||
{createFileUrl} />
|
||||
</Container>
|
||||
+35
-7
@@ -15,7 +15,12 @@
|
||||
import { Layout, Table, Icon, Popover, ActionMenu } from '@appwrite.io/pink-svelte';
|
||||
import { onMount } from 'svelte';
|
||||
import DualTimeView from '$lib/components/dualTimeView.svelte';
|
||||
import { IconDotsHorizontal, IconPencil, IconPlus, IconTrash } from '@appwrite.io/pink-icons-svelte';
|
||||
import {
|
||||
IconDotsHorizontal,
|
||||
IconPencil,
|
||||
IconPlus,
|
||||
IconTrash
|
||||
} from '@appwrite.io/pink-icons-svelte';
|
||||
|
||||
let {
|
||||
files,
|
||||
@@ -54,7 +59,9 @@
|
||||
|
||||
async function deleteFile(file: Models.File) {
|
||||
try {
|
||||
await sdk.forProject(page.params.region, page.params.project).storage.deleteFile({ bucketId: file.bucketId, fileId: file.$id });
|
||||
await sdk
|
||||
.forProject(page.params.region, page.params.project)
|
||||
.storage.deleteFile({ bucketId: file.bucketId, fileId: file.$id });
|
||||
await invalidate(Dependencies.FILES);
|
||||
await uploader.removeFile(file);
|
||||
trackEvent(Submit.FileDelete);
|
||||
@@ -152,10 +159,21 @@
|
||||
</Button>
|
||||
<svelte:fragment slot="content" let:close>
|
||||
<ActionMenu.Root>
|
||||
<ActionMenu.Item.Button icon={IconPencil} on:click={() => { close(); goto(href); }}>
|
||||
<ActionMenu.Item.Button
|
||||
icon={IconPencil}
|
||||
on:click={() => {
|
||||
close();
|
||||
goto(href);
|
||||
}}>
|
||||
Edit
|
||||
</ActionMenu.Item.Button>
|
||||
<ActionMenu.Item.Button icon={IconTrash} on:click={() => { close(); selectedFile = file; showDelete = true; }}>
|
||||
<ActionMenu.Item.Button
|
||||
icon={IconTrash}
|
||||
on:click={() => {
|
||||
close();
|
||||
selectedFile = file;
|
||||
showDelete = true;
|
||||
}}>
|
||||
Delete
|
||||
</ActionMenu.Item.Button>
|
||||
</ActionMenu.Root>
|
||||
@@ -190,7 +208,13 @@
|
||||
</Button>
|
||||
<svelte:fragment slot="content" let:close>
|
||||
<ActionMenu.Root>
|
||||
<ActionMenu.Item.Button icon={IconTrash} on:click={() => { close(); selectedFile = file; showDelete = true; }}>
|
||||
<ActionMenu.Item.Button
|
||||
icon={IconTrash}
|
||||
on:click={() => {
|
||||
close();
|
||||
selectedFile = file;
|
||||
showDelete = true;
|
||||
}}>
|
||||
Delete
|
||||
</ActionMenu.Item.Button>
|
||||
</ActionMenu.Root>
|
||||
@@ -209,9 +233,13 @@
|
||||
<Button size="s" secondary href={clearSearchHref}>Clear Search</Button>
|
||||
</EmptySearch>
|
||||
{:else}
|
||||
<Empty single target="file" href="https://appwrite.io/docs/products/storage/upload-download" on:click={() => goto("create")} />
|
||||
<Empty
|
||||
single
|
||||
target="file"
|
||||
href="https://appwrite.io/docs/products/storage/upload-download"
|
||||
on:click={() => goto('create')} />
|
||||
{/if}
|
||||
|
||||
{#if selectedFile}
|
||||
<DeleteFile file={selectedFile} bind:showDelete on:deleted={fileDeleted} />
|
||||
{/if}
|
||||
{/if}
|
||||
@@ -1,7 +1,14 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/state';
|
||||
import { Empty, PaginationWithLimit, SearchQuery, Id, CardContainer, GridItem1 } from '$lib/components';
|
||||
import {
|
||||
Empty,
|
||||
PaginationWithLimit,
|
||||
SearchQuery,
|
||||
Id,
|
||||
CardContainer,
|
||||
GridItem1
|
||||
} from '$lib/components';
|
||||
import { canWriteBuckets } from '$lib/stores/roles';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { columns } from './store';
|
||||
@@ -44,7 +51,7 @@
|
||||
<Layout.Stack direction="row" alignItems="center" justifyContent="flex-end">
|
||||
<ViewSelector {columns} {view} hideColumns={!buckets.total} hideView={!buckets.total} />
|
||||
{#if $canWriteBuckets}
|
||||
<Button on:click={() => ( $showCreateBucket = true )} event="create_bucket" size="s">
|
||||
<Button on:click={() => ($showCreateBucket = true)} event="create_bucket" size="s">
|
||||
<Icon icon={IconPlus} slot="start" size="s" />
|
||||
Create bucket
|
||||
</Button>
|
||||
@@ -54,7 +61,13 @@
|
||||
|
||||
{#if buckets.total}
|
||||
{#if view === 'grid'}
|
||||
<CardContainer disableEmpty={!$canWriteBuckets} total={buckets.total} {offset} event="bucket" service="buckets" on:click={() => ($showCreateBucket = true)}>
|
||||
<CardContainer
|
||||
disableEmpty={!$canWriteBuckets}
|
||||
total={buckets.total}
|
||||
{offset}
|
||||
event="bucket"
|
||||
service="buckets"
|
||||
on:click={() => ($showCreateBucket = true)}>
|
||||
{#each buckets.buckets as bucket}
|
||||
<GridItem1 href={createBucketUrl(bucket)}>
|
||||
<svelte:fragment slot="title">{bucket.name}</svelte:fragment>
|
||||
@@ -68,8 +81,14 @@
|
||||
<Id value={bucket.$id}>{bucket.$id}</Id>
|
||||
<svelte:fragment slot="icons">
|
||||
<Tooltip>
|
||||
<span class:u-opacity-20={!bucket.encryption} class="icon-lock-closed" aria-hidden="true"></span>
|
||||
<span slot="tooltip">{bucket.encryption ? 'Encryption enabled' : 'Encryption disabled'}</span>
|
||||
<span
|
||||
class:u-opacity-20={!bucket.encryption}
|
||||
class="icon-lock-closed"
|
||||
aria-hidden="true"></span>
|
||||
<span slot="tooltip"
|
||||
>{bucket.encryption
|
||||
? 'Encryption enabled'
|
||||
: 'Encryption disabled'}</span>
|
||||
</Tooltip>
|
||||
</svelte:fragment>
|
||||
</GridItem1>
|
||||
@@ -105,7 +124,11 @@
|
||||
|
||||
<PaginationWithLimit name="Buckets" {limit} {offset} total={buckets.total} />
|
||||
{:else}
|
||||
<Empty single href="https://appwrite.io/docs/products/storage" target="bucket" on:click={() => showCreateBucket.set(true)} />
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/products/storage"
|
||||
target="bucket"
|
||||
on:click={() => showCreateBucket.set(true)} />
|
||||
{/if}
|
||||
|
||||
<Create bind:showCreate={$showCreateBucket} on:created={bucketCreated} />
|
||||
@@ -6,4 +6,3 @@ export const load: LayoutLoad = async ({ params }) => {
|
||||
const project = await sdk.forConsole.projects.get(params.project);
|
||||
return { project } as const;
|
||||
};
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import View from '$routes/(console)/project-[region]-[project]/auth/view.svelte';
|
||||
let { data } = $props();
|
||||
|
||||
const createUserUrl = (user: Models.User<{}>) => `${base}/embed/project-${page.params.region}-${page.params.project}/auth/user-${user.$id}`;
|
||||
const createUserUrl = (user: Models.User<{}>) =>
|
||||
`${base}/embed/project-${page.params.region}-${page.params.project}/auth/user-${user.$id}`;
|
||||
</script>
|
||||
|
||||
<Layout.Stack>
|
||||
@@ -15,6 +16,5 @@
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createUserUrl}
|
||||
/>
|
||||
{createUserUrl} />
|
||||
</Layout.Stack>
|
||||
@@ -15,12 +15,13 @@ export const load: PageLoad = async ({ url, route, params }) => {
|
||||
limit,
|
||||
search,
|
||||
page,
|
||||
users: await sdk.forProject(params.region, params.project).users.list([
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...(search ? [Query.search('name', search)] : [])
|
||||
])
|
||||
users: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.users.list([
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...(search ? [Query.search('name', search)] : [])
|
||||
])
|
||||
};
|
||||
};
|
||||
|
||||
@@ -22,4 +22,3 @@
|
||||
<UpdateSessionInvalidation />
|
||||
<UpdateMembershipPrivacy />
|
||||
</Layout.Stack>
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
import View from '$routes/(console)/project-[region]-[project]/auth/teams/view.svelte';
|
||||
let { data } = $props();
|
||||
|
||||
const createTeamUrl = (team: Models.Team<Record<string, unknown>>) => `${base}/embed/project-${page.params.region}-${page.params.project}/auth/teams/team-${team.$id}`;
|
||||
const createTeamUrl = (team: Models.Team<Record<string, unknown>>) =>
|
||||
`${base}/embed/project-${page.params.region}-${page.params.project}/auth/teams/team-${team.$id}`;
|
||||
</script>
|
||||
|
||||
<Layout.Stack>
|
||||
@@ -15,6 +16,5 @@
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createTeamUrl}
|
||||
/>
|
||||
{createTeamUrl} />
|
||||
</Layout.Stack>
|
||||
@@ -15,12 +15,13 @@ export const load: PageLoad = async ({ url, route, params }) => {
|
||||
limit,
|
||||
search,
|
||||
page,
|
||||
teams: await sdk.forProject(params.region, params.project).teams.list([
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...(search ? [Query.search('name', search)] : [])
|
||||
])
|
||||
teams: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.teams.list([
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...(search ? [Query.search('name', search)] : [])
|
||||
])
|
||||
};
|
||||
};
|
||||
|
||||
-1
@@ -3,4 +3,3 @@
|
||||
</script>
|
||||
|
||||
<TeamPage />
|
||||
|
||||
@@ -9,4 +9,3 @@ export const load: PageLoad = async ({ params }) => {
|
||||
|
||||
return { user, userFactors };
|
||||
};
|
||||
|
||||
@@ -3,4 +3,4 @@ import type { LayoutLoad } from './$types';
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
const { project } = await parent();
|
||||
return { project };
|
||||
};
|
||||
};
|
||||
@@ -22,6 +22,5 @@
|
||||
offset={data?.offset || 0}
|
||||
view={data?.view || 'grid'}
|
||||
search={data?.search || null}
|
||||
{getDatabaseUrl}
|
||||
/>
|
||||
</Layout.Stack>
|
||||
{getDatabaseUrl} />
|
||||
</Layout.Stack>
|
||||
@@ -1,11 +1,142 @@
|
||||
import type { PageLoad } from './$types';
|
||||
import { CARD_LIMIT, Dependencies } from '$lib/constants';
|
||||
import { getLimit, getPage, getSearch, getView, pageToOffset, View } from '$lib/helpers/load';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { type Models, Query } from '@appwrite.io/console';
|
||||
import { timeFromNow } from '$lib/helpers/date';
|
||||
import type { PageLoad, RouteParams } from './$types';
|
||||
import type { BackupPolicy } from '$lib/sdk/backups';
|
||||
import { isSelfHosted } from '$lib/system';
|
||||
import { isCloud } from '$lib/system';
|
||||
import type { Plan } from '$lib/sdk/billing';
|
||||
|
||||
export const load: PageLoad = async ({ parent, url }) => {
|
||||
const { project } = await parent();
|
||||
|
||||
// Import the console page loader to reuse the same logic
|
||||
const consoleLoader = await import('$routes/(console)/project-[region]-[project]/databases/+page.ts');
|
||||
|
||||
// Call the console loader with the same parameters
|
||||
return await consoleLoader.load({ parent, url });
|
||||
};
|
||||
export const load: PageLoad = async ({ url, route, depends, params, parent }) => {
|
||||
depends(Dependencies.DATABASES);
|
||||
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, CARD_LIMIT);
|
||||
const view = getView(url, route, View.Grid);
|
||||
const offset = pageToOffset(page, limit);
|
||||
|
||||
// already loaded by parent.
|
||||
const { currentPlan } = await parent();
|
||||
|
||||
const { databases, tables, policies, lastBackups } = await fetchDatabasesAndBackups(
|
||||
limit,
|
||||
offset,
|
||||
params,
|
||||
search,
|
||||
currentPlan
|
||||
);
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
view,
|
||||
search,
|
||||
tables,
|
||||
policies,
|
||||
databases,
|
||||
lastBackups
|
||||
};
|
||||
};
|
||||
|
||||
async function fetchDatabasesAndBackups(
|
||||
limit: number,
|
||||
offset: number,
|
||||
params: RouteParams,
|
||||
search?: string | undefined,
|
||||
currentPlan?: Plan
|
||||
) {
|
||||
const backupsEnabled = currentPlan?.backupsEnabled ?? true;
|
||||
|
||||
const projectSDK = sdk.forProject(params.region, params.project);
|
||||
|
||||
const databases = await projectSDK.tablesDB.list({
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('$createdAt')],
|
||||
search: search || undefined
|
||||
});
|
||||
|
||||
const tables: Record<string, string | null> = {};
|
||||
|
||||
await Promise.all(
|
||||
// TODO: backend should allow `Query.select` for perf!
|
||||
databases.databases.map(async ({ $id }) => {
|
||||
const res = await projectSDK.tablesDB.listTables({
|
||||
databaseId: $id,
|
||||
queries: [Query.limit(1), Query.orderDesc('')]
|
||||
});
|
||||
|
||||
tables[$id] = res.tables?.[0]?.$id ?? null;
|
||||
})
|
||||
);
|
||||
|
||||
let lastBackups: Record<string, string>, policies: Record<string, BackupPolicy[]>;
|
||||
|
||||
if (isCloud && backupsEnabled) {
|
||||
[policies, lastBackups] = await Promise.all([
|
||||
fetchPolicies(databases, params),
|
||||
fetchLastBackups(databases, params)
|
||||
]);
|
||||
}
|
||||
|
||||
return { databases, tables, policies, lastBackups };
|
||||
}
|
||||
|
||||
async function fetchPolicies(databases: Models.DatabaseList, params: RouteParams) {
|
||||
if (isSelfHosted) return {};
|
||||
|
||||
const databasePolicies: Record<string, BackupPolicy[]> = {};
|
||||
|
||||
await Promise.all(
|
||||
databases.databases.map(async (database) => {
|
||||
try {
|
||||
const { policies } = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.backups.listPolicies([
|
||||
// TODO: are all needed!?
|
||||
// Query.limit(3),
|
||||
Query.equal('resourceType', 'database'),
|
||||
Query.equal('resourceId', database.$id)
|
||||
]);
|
||||
|
||||
if (policies.length > 0) {
|
||||
databasePolicies[database.$id] = policies;
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return databasePolicies;
|
||||
}
|
||||
|
||||
async function fetchLastBackups(databases: Models.DatabaseList, params: RouteParams) {
|
||||
if (isSelfHosted) return {};
|
||||
|
||||
const lastBackups: Record<string, string> = {};
|
||||
|
||||
await Promise.all(
|
||||
databases.databases.map(async (database) => {
|
||||
try {
|
||||
const { archives } = await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.backups.listArchives([
|
||||
Query.limit(1),
|
||||
Query.orderDesc('$createdAt'),
|
||||
Query.equal('resourceType', 'database'),
|
||||
Query.equal('resourceId', database.$id)
|
||||
]);
|
||||
|
||||
if (archives.length > 0) {
|
||||
lastBackups[database.$id] = timeFromNow(archives[0].$createdAt);
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return lastBackups;
|
||||
}
|
||||
+13
-4
@@ -1,6 +1,15 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
const { project } = await parent();
|
||||
return { project };
|
||||
};
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.DATABASE);
|
||||
|
||||
const database = await sdk.forProject(params.region, params.project).tablesDB.get({
|
||||
databaseId: params.database
|
||||
});
|
||||
|
||||
return {
|
||||
database
|
||||
};
|
||||
};
|
||||
+2
-3
@@ -17,6 +17,5 @@
|
||||
offset={data.offset}
|
||||
view={data.view}
|
||||
search={data.search}
|
||||
{createTableUrl}
|
||||
/>
|
||||
</Layout.Stack>
|
||||
{createTableUrl} />
|
||||
</Layout.Stack>
|
||||
+27
-9
@@ -1,11 +1,29 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getSearch, getView, pageToOffset, View } from '$lib/helpers/load';
|
||||
import type { PageLoad } from './$types';
|
||||
import { CARD_LIMIT, Dependencies } from '$lib/constants';
|
||||
|
||||
export const load: PageLoad = async ({ parent, url, params }) => {
|
||||
const { project } = await parent();
|
||||
|
||||
// Import the console page loader to reuse the same logic
|
||||
const consoleLoader = await import('$routes/(console)/project-[region]-[project]/databases/database-[database]/+page.ts');
|
||||
|
||||
// Call the console loader with the same parameters
|
||||
return await consoleLoader.load({ parent, url, params });
|
||||
};
|
||||
export const load: PageLoad = async ({ params, url, route, depends }) => {
|
||||
depends(Dependencies.TABLES);
|
||||
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, CARD_LIMIT);
|
||||
const view = getView(url, route, View.Grid);
|
||||
const offset = pageToOffset(page, limit);
|
||||
|
||||
const tables = await sdk.forProject(params.region, params.project).tablesDB.listTables({
|
||||
databaseId: params.database,
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search: search || undefined
|
||||
});
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
view,
|
||||
tables
|
||||
};
|
||||
};
|
||||
+12
-4
@@ -1,6 +1,14 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
const { project } = await parent();
|
||||
return { project };
|
||||
};
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.TABLE);
|
||||
|
||||
return {
|
||||
table: await sdk.forProject(params.region, params.project).tablesDB.getTable({
|
||||
databaseId: params.database,
|
||||
tableId: params.table
|
||||
})
|
||||
};
|
||||
};
|
||||
+1
-1
@@ -6,4 +6,4 @@
|
||||
|
||||
<Layout.Stack>
|
||||
<TablePage {data} />
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
+73
-9
@@ -1,11 +1,75 @@
|
||||
import { Dependencies, SPREADSHEET_PAGE_LIMIT } from '$lib/constants';
|
||||
import { getLimit, getPage, getQuery, getView, pageToOffset, View } from '$lib/helpers/load';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { type Models, Query } from '@appwrite.io/console';
|
||||
import type { PageLoad } from './$types';
|
||||
import { queries, queryParamToMap } from '$lib/components/filters';
|
||||
import { buildWildcardColumnsQuery } from '$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/rows/store';
|
||||
import type { TagValue } from '$lib/components/filters/store';
|
||||
|
||||
export const load: PageLoad = async ({ parent, url, params }) => {
|
||||
const { project } = await parent();
|
||||
|
||||
// Import the console page loader to reuse the same logic
|
||||
const consoleLoader = await import('$routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+page.ts');
|
||||
|
||||
// Call the console loader with the same parameters
|
||||
return await consoleLoader.load({ parent, url, params });
|
||||
};
|
||||
export const load: PageLoad = async ({ params, depends, url, route, parent }) => {
|
||||
const { table } = await parent();
|
||||
depends(Dependencies.ROW); /* TODO: we could just invalidate the rows maybe? */
|
||||
depends(Dependencies.ROWS);
|
||||
|
||||
const page = getPage(url);
|
||||
const limit = getLimit(url, route, SPREADSHEET_PAGE_LIMIT);
|
||||
const view = getView(url, route, View.Grid);
|
||||
const offset = pageToOffset(page, limit);
|
||||
const query = getQuery(url);
|
||||
|
||||
const paramQueries = url.searchParams.get('query');
|
||||
const parsedQueries = queryParamToMap(paramQueries || '[]');
|
||||
queries.set(parsedQueries);
|
||||
|
||||
const currentSort = extractSortFromQueries(parsedQueries);
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
view,
|
||||
query,
|
||||
currentSort,
|
||||
rows: await sdk.forProject(params.region, params.project).tablesDB.listRows({
|
||||
databaseId: params.database,
|
||||
tableId: params.table,
|
||||
queries: buildGridQueries(limit, offset, parsedQueries, table)
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
function extractSortFromQueries(parsedQueries: Map<TagValue, string>) {
|
||||
for (const [tagValue, queryString] of parsedQueries.entries()) {
|
||||
if (queryString.includes('orderAsc') || queryString.includes('orderDesc')) {
|
||||
const isAsc = queryString.includes('orderAsc');
|
||||
return {
|
||||
column: tagValue.value,
|
||||
direction: isAsc ? 'asc' : 'desc'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return { column: null, direction: 'default' };
|
||||
}
|
||||
|
||||
function buildGridQueries(
|
||||
limit: number,
|
||||
offset: number,
|
||||
parsedQueries: Map<TagValue, string>,
|
||||
table: Models.Table
|
||||
) {
|
||||
const hasOrderQuery = Array.from(parsedQueries.values()).some(
|
||||
(q) => q.includes('orderAsc') || q.includes('orderDesc')
|
||||
);
|
||||
|
||||
const queryArray = [Query.limit(limit), Query.offset(offset)];
|
||||
|
||||
// don't override if there's a user created sort!
|
||||
if (!hasOrderQuery) {
|
||||
queryArray.push(Query.orderDesc(''));
|
||||
}
|
||||
|
||||
queryArray.push(...parsedQueries.values(), ...buildWildcardColumnsQuery(table));
|
||||
|
||||
return queryArray;
|
||||
}
|
||||
@@ -6,7 +6,8 @@
|
||||
import View from '$routes/(console)/project-[region]-[project]/messaging/view.svelte';
|
||||
let { data } = $props();
|
||||
|
||||
const createMessageUrl = (message) => `${base}/embed/project-${page.params.region}-${page.params.project}/messaging/message-${message.$id}`;
|
||||
const createMessageUrl = (message) =>
|
||||
`${base}/embed/project-${page.params.region}-${page.params.project}/messaging/message-${message.$id}`;
|
||||
</script>
|
||||
|
||||
<Layout.Stack>
|
||||
@@ -15,6 +16,5 @@
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
search={data.search}
|
||||
{createMessageUrl}
|
||||
/>
|
||||
{createMessageUrl} />
|
||||
</Layout.Stack>
|
||||
@@ -1,6 +1,14 @@
|
||||
import { queries, queryParamToMap } from '$lib/components/filters';
|
||||
import { CARD_LIMIT, Dependencies } from '$lib/constants';
|
||||
import { View, getLimit, getPage, getQuery, getSearch, getView, pageToOffset } from '$lib/helpers/load';
|
||||
import {
|
||||
View,
|
||||
getLimit,
|
||||
getPage,
|
||||
getQuery,
|
||||
getSearch,
|
||||
getView,
|
||||
pageToOffset
|
||||
} from '$lib/helpers/load';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
import type { PageLoad } from './$types';
|
||||
@@ -19,7 +27,12 @@ export const load: PageLoad = async ({ depends, url, route, params }) => {
|
||||
queries.set(parsedQueries);
|
||||
|
||||
const messages = (await sdk.forProject(params.region, params.project).messaging.listMessages({
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc(''), ...parsedQueries.values()],
|
||||
queries: [
|
||||
Query.limit(limit),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc(''),
|
||||
...parsedQueries.values()
|
||||
],
|
||||
search: search || undefined
|
||||
})) as {
|
||||
total: number;
|
||||
|
||||
@@ -3,4 +3,4 @@ import type { LayoutLoad } from './$types';
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
const { project } = await parent();
|
||||
return { project };
|
||||
};
|
||||
};
|
||||
@@ -4,7 +4,7 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { Layout } from '@appwrite.io/pink-svelte';
|
||||
import View from '$routes/(console)/project-[region]-[project]/storage/view.svelte';
|
||||
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
const createBucketUrl = (bucket: Models.Bucket) => {
|
||||
@@ -19,6 +19,5 @@
|
||||
offset={data?.offset || 0}
|
||||
view={data?.view || 'grid'}
|
||||
search={data?.search || null}
|
||||
{createBucketUrl}
|
||||
/>
|
||||
</Layout.Stack>
|
||||
{createBucketUrl} />
|
||||
</Layout.Stack>
|
||||
@@ -1,11 +1,25 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getSearch, getView, pageToOffset, View } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ parent, url, params }) => {
|
||||
const { project } = await parent();
|
||||
|
||||
// Import the console page loader to reuse the same logic
|
||||
const consoleLoader = await import('$routes/(console)/project-[region]-[project]/storage/+page.ts');
|
||||
|
||||
// Call the console loader with the same parameters
|
||||
return await consoleLoader.load({ parent, url, params });
|
||||
};
|
||||
export const load: PageLoad = async ({ url, route, params }) => {
|
||||
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 buckets = await sdk.forProject(params.region, params.project).storage.listBuckets({
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search: search || undefined
|
||||
});
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
view,
|
||||
search,
|
||||
buckets
|
||||
};
|
||||
};
|
||||
+11
-4
@@ -1,6 +1,13 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
const { project } = await parent();
|
||||
return { project };
|
||||
};
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.BUCKET);
|
||||
|
||||
return {
|
||||
bucket: await sdk.forProject(params.region, params.project).storage.getBucket({
|
||||
bucketId: params.bucket
|
||||
})
|
||||
};
|
||||
};
|
||||
+3
-4
@@ -4,7 +4,7 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { Layout } from '@appwrite.io/pink-svelte';
|
||||
import View from '$routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/view.svelte';
|
||||
|
||||
|
||||
let { data } = $props();
|
||||
|
||||
const createFileUrl = (file: Models.File) => {
|
||||
@@ -18,6 +18,5 @@
|
||||
limit={data?.limit || 25}
|
||||
offset={data?.offset || 0}
|
||||
search={data?.search || null}
|
||||
{createFileUrl}
|
||||
/>
|
||||
</Layout.Stack>
|
||||
{createFileUrl} />
|
||||
</Layout.Stack>
|
||||
+24
-9
@@ -1,11 +1,26 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
|
||||
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ parent, url, params }) => {
|
||||
const { project } = await parent();
|
||||
|
||||
// Import the console page loader to reuse the same logic
|
||||
const consoleLoader = await import('$routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/+page.ts');
|
||||
|
||||
// Call the console loader with the same parameters
|
||||
return await consoleLoader.load({ parent, url, params });
|
||||
};
|
||||
export const load: PageLoad = async ({ params, depends, url, route }) => {
|
||||
depends(Dependencies.FILES);
|
||||
const page = getPage(url);
|
||||
const search = getSearch(url);
|
||||
const limit = getLimit(url, route, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, limit);
|
||||
|
||||
const files = await sdk.forProject(params.region, params.project).storage.listFiles({
|
||||
bucketId: params.bucket,
|
||||
queries: [Query.limit(limit), Query.offset(offset), Query.orderDesc('')],
|
||||
search
|
||||
});
|
||||
|
||||
return {
|
||||
offset,
|
||||
limit,
|
||||
search,
|
||||
files
|
||||
};
|
||||
};
|
||||
+15
-4
@@ -1,6 +1,17 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const load: LayoutLoad = async ({ parent }) => {
|
||||
const { project } = await parent();
|
||||
return { project };
|
||||
};
|
||||
export const load: LayoutLoad = async ({ params, depends }) => {
|
||||
depends(Dependencies.FILE);
|
||||
depends(Dependencies.FILE_TOKENS);
|
||||
|
||||
return {
|
||||
file: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.storage.getFile({ bucketId: params.bucket, fileId: params.file }),
|
||||
tokens: await sdk
|
||||
.forProject(params.region, params.project)
|
||||
.tokens.list({ bucketId: params.bucket, fileId: params.file })
|
||||
};
|
||||
};
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Layout } from '@appwrite.io/pink-svelte';
|
||||
import FilePage from '$routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/file-[file]/+page.svelte';
|
||||
|
||||
|
||||
let { data } = $props();
|
||||
</script>
|
||||
|
||||
<Layout.Stack>
|
||||
<FilePage {data} />
|
||||
</Layout.Stack>
|
||||
</Layout.Stack>
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ parent, url, params }) => {
|
||||
const { project } = await parent();
|
||||
|
||||
// Import the console page loader to reuse the same logic
|
||||
const consoleLoader = await import('$routes/(console)/project-[region]-[project]/storage/bucket-[bucket]/file-[file]/+page.ts');
|
||||
|
||||
// Call the console loader with the same parameters
|
||||
return await consoleLoader.load({ parent, url, params });
|
||||
};
|
||||
@@ -2,4 +2,4 @@
|
||||
"bgcolor-accent": "var(--neutral-1000)",
|
||||
"bgcolor-accent-secondary": "var(--neutral-900)",
|
||||
"bgcolor-accent-tertiary": "var(--neutral-850)"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user