mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge branch 'users' of github.com:appwrite/appwrite-console-poc into storage
This commit is contained in:
commit
0b25be76c7
38 files changed
+300
-335
No files matched your search
@@ -1,10 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import type { Func } from '../stores/notifications';
|
||||
import type { Buttons } from '../stores/notifications';
|
||||
|
||||
export let dismissible = false;
|
||||
export let type: '' | 'info' | 'success' | 'warning' | 'danger' = 'info';
|
||||
export let func: Func[] = [];
|
||||
export let buttons: Buttons[] = [];
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
</script>
|
||||
@@ -25,11 +25,11 @@
|
||||
<slot name="title" />
|
||||
</h6>
|
||||
<p class="message"><slot /></p>
|
||||
{#if func?.length}
|
||||
{#if buttons?.length}
|
||||
<div class="buttons u-flex">
|
||||
{#each func as f}
|
||||
<button class="button is-text" on:click={f.method}>
|
||||
<span class="text">{f.name}</span>
|
||||
{#each buttons as button}
|
||||
<button class="button is-text" on:click={button.method}>
|
||||
<span class="text">{button.name}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<script>
|
||||
import { Card } from './';
|
||||
|
||||
let actions = {
|
||||
textContent: 'actions'
|
||||
};
|
||||
</script>
|
||||
|
||||
<Card>
|
||||
@@ -8,10 +12,12 @@
|
||||
<slot />
|
||||
</div>
|
||||
<div class="grid-1-2-col-2">
|
||||
<slot name="right" />
|
||||
<slot name="aside" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="common-section card-separator u-flex u-main-end">
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
{#if actions?.textContent}
|
||||
<div class="common-section card-separator u-flex u-main-end" bind:this={actions}>
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
{/if}
|
||||
</Card>
|
||||
@@ -3,15 +3,13 @@
|
||||
|
||||
export let value: string;
|
||||
|
||||
let showTooltip = 'none';
|
||||
|
||||
const copy = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
showTooltip = 'block';
|
||||
setTimeout(() => {
|
||||
showTooltip = 'none';
|
||||
}, 1000);
|
||||
addNotification({
|
||||
message: 'Copied to clipboard.',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
@@ -21,14 +19,6 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="input-text-wrapper is-with-end-button">
|
||||
<input {value} type="text" class="input-text" disabled />
|
||||
<button type="button" class="input-button tooltip" aria-label="Click to copy." on:click={copy}>
|
||||
<span class="icon-duplicate" aria-hidden="true" />
|
||||
<div class="tootip">
|
||||
<span class="tooltip-popup" style={`display: ${showTooltip}`} role="tooltip">
|
||||
Copied
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<span on:click={copy}>
|
||||
<slot />
|
||||
</span>
|
||||
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
|
||||
export let value: string;
|
||||
|
||||
let showTooltip = false;
|
||||
|
||||
const copy = async () => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
showTooltip = true;
|
||||
setTimeout(() => {
|
||||
showTooltip = false;
|
||||
}, 1000);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="input-text-wrapper is-with-end-button">
|
||||
<input {value} type="text" class="input-text" disabled />
|
||||
<button type="button" class="input-button tooltip" aria-label="Click to copy." on:click={copy}>
|
||||
<span class="icon-duplicate" aria-hidden="true" />
|
||||
<div class="tootip">
|
||||
{#if showTooltip}
|
||||
<span class="tooltip-popup" style={`display: block`} role="tooltip"> Copied </span>
|
||||
{/if}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
@@ -6,6 +6,7 @@ export { default as Tile } from './tile.svelte';
|
||||
export { default as Tiles } from './tiles.svelte';
|
||||
export { default as Back } from './back.svelte';
|
||||
export { default as Copy } from './copy.svelte';
|
||||
export { default as CopyInput } from './copyInput.svelte';
|
||||
export { default as UploadBox } from './uploadBox.svelte';
|
||||
export { default as List } from './list.svelte';
|
||||
export { default as ListItem } from './listItem.svelte';
|
||||
@@ -22,3 +23,4 @@ export { default as SwitchBox } from './switchBox.svelte';
|
||||
export { default as SwitchBoxes } from './switchBoxes.svelte';
|
||||
export { default as Alert } from './alert.svelte';
|
||||
export { default as Box } from './box.svelte';
|
||||
export { default as Search } from './search.svelte';
|
||||
@@ -5,7 +5,7 @@
|
||||
export let show = false;
|
||||
|
||||
let browser = false;
|
||||
|
||||
//TODO: explore other solutions compatible with testing library
|
||||
onMount(() => {
|
||||
browser = true;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<script lang="ts">
|
||||
import { InputSearch } from '$lib/elements/forms';
|
||||
|
||||
export let search: string;
|
||||
export let placeholder: string;
|
||||
</script>
|
||||
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<div class="u-flex-basis-50-percent">
|
||||
<InputSearch {placeholder} bind:value={search} />
|
||||
</div>
|
||||
<slot />
|
||||
</div>
|
||||
@@ -5,8 +5,8 @@
|
||||
export let danger = false;
|
||||
export let disabled = false;
|
||||
export let round = false;
|
||||
export let href: string = null;
|
||||
export let external = false;
|
||||
export let href: string = null;
|
||||
//TODO: add option to add aria-label to buttons that are only icons
|
||||
</script>
|
||||
|
||||
|
||||
@@ -9,15 +9,20 @@
|
||||
</script>
|
||||
|
||||
<FormItem>
|
||||
<label class="label" for={id}>{label}</label>
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
{disabled}
|
||||
{required}
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
bind:checked={value} />
|
||||
</div>
|
||||
<label class="choice-item" for={id}>
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
{id}
|
||||
{disabled}
|
||||
{required}
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
bind:checked={value}
|
||||
on:change />
|
||||
</div>
|
||||
<div class="choice-item-content">
|
||||
<div class="choice-item-title">{label}</div>
|
||||
</div>
|
||||
</label>
|
||||
</FormItem>
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
export let type: Notification['type'] = 'info';
|
||||
export let title: Notification['title'];
|
||||
export let func: Notification['func'];
|
||||
export let buttons: Notification['buttons'];
|
||||
|
||||
let icon: string;
|
||||
switch (type) {
|
||||
@@ -44,11 +44,11 @@
|
||||
{/if}
|
||||
<p><slot /></p>
|
||||
</div>
|
||||
{#if func}
|
||||
{#if buttons}
|
||||
<div class="buttons u-flex">
|
||||
{#each func as f}
|
||||
<button class="button is-text is-small" on:click={f.method}>
|
||||
<span class="text">{f.name}</span>
|
||||
{#each buttons as button}
|
||||
<button class="button is-text is-small" on:click={button.method}>
|
||||
<span class="text">{button.name}</span>
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
type={notification.type}
|
||||
title={notification.title}
|
||||
on:dismiss={() => dismissNotification(notification.id)}
|
||||
func={notification?.func}>
|
||||
buttons={notification?.buttons}>
|
||||
{notification.message}
|
||||
</Notification>
|
||||
{/each}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
|
||||
import { fade } from 'svelte/transition';
|
||||
import { Cover } from '.';
|
||||
import { Copy } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
|
||||
export let isOpen = false;
|
||||
|
||||
@@ -52,21 +52,6 @@
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const copy = async (value: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
addNotification({
|
||||
message: 'Copied to clipboard.',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<svelte:window on:resize={throttle(onScroll, 25)} />
|
||||
@@ -93,16 +78,16 @@
|
||||
</a>
|
||||
<span class="text"> {$title}</span>
|
||||
{#if $copyData?.value}
|
||||
<Pill button on:click={() => copy($copyData.value)}
|
||||
><i class="icon-duplicate" />{$copyData.text}
|
||||
</Pill>
|
||||
<Copy value={$copyData.value}>
|
||||
<Pill button><i class="icon-duplicate" />{$copyData.text}</Pill>
|
||||
</Copy>
|
||||
{/if}
|
||||
{:else}
|
||||
<span class="text"> {$title}</span>
|
||||
{#if $copyData?.value}
|
||||
<Pill button on:click={() => copy($copyData.value)}
|
||||
><i class="icon-duplicate" />{$copyData.text}
|
||||
</Pill>
|
||||
<Copy value={$copyData.value}>
|
||||
<Pill button><i class="icon-duplicate" />{$copyData.text}</Pill>
|
||||
</Copy>
|
||||
{/if}
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -7,11 +7,11 @@ export type Notification = {
|
||||
timeout?: number;
|
||||
message: string;
|
||||
title?: string;
|
||||
func?: Func[];
|
||||
buttons?: Buttons[];
|
||||
};
|
||||
|
||||
export type Func = {
|
||||
method: () => void; //TODO Check if promise is needed rather tha () => void
|
||||
export type Buttons = {
|
||||
method: () => void | Promise<void>;
|
||||
name: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,11 +9,7 @@ function createUserStore() {
|
||||
subscribe,
|
||||
set,
|
||||
fetchUser: async () => {
|
||||
try {
|
||||
set(await sdkForConsole.account.get());
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
set(await sdkForConsole.account.get());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -15,11 +15,7 @@
|
||||
onMount(async () => {
|
||||
try {
|
||||
if (!$user) {
|
||||
//TODO: find out if it's the correct implementation
|
||||
await user.fetchUser();
|
||||
if (!$user) {
|
||||
throw 'No user found';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$page.url.pathname.startsWith('/console')) {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Card, Copy } from '$lib/components';
|
||||
import { Card, CopyInput } from '$lib/components';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
@@ -45,7 +45,7 @@
|
||||
<Card>
|
||||
{#if $doc}
|
||||
<Form on:submit={updateDocument}>
|
||||
<Copy value={$doc.$id} />
|
||||
<CopyInput value={$doc.$id} />
|
||||
<Document />
|
||||
<Button submit>Update</Button>
|
||||
</Form>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
TableCellHead,
|
||||
TableCellLink
|
||||
} from '$lib/elements/table';
|
||||
import { Empty, Pagination } from '$lib/components';
|
||||
import { Empty, Pagination, Search } from '$lib/components';
|
||||
import { collection } from './store';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
@@ -35,20 +35,12 @@
|
||||
{#await request}
|
||||
<div aria-busy="true" />
|
||||
{:then response}
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<div class="input-text-wrapper u-stretch">
|
||||
<input
|
||||
type="search"
|
||||
placeholder="Search by ID"
|
||||
class="input-text"
|
||||
bind:value={search} />
|
||||
<span class="icon-search" aria-hidden="true" />
|
||||
</div>
|
||||
<Search bind:search placeholder="Search by ID">
|
||||
<Button on:click={() => console.log('showCreate = true')}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create Document</span>
|
||||
</Button>
|
||||
</div>
|
||||
</Search>
|
||||
{#if response.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
import { project } from './store';
|
||||
import { Card, List, ListItem } from '$lib/components';
|
||||
import { Cover, Container } from '$lib/layout';
|
||||
// import { Line } from '$lib/charts';
|
||||
// import { page } from '$app/stores';
|
||||
import { base } from '$app/paths';
|
||||
import CreatePlatform from './_createPlatform.svelte';
|
||||
|
||||
@@ -20,9 +18,6 @@
|
||||
});
|
||||
|
||||
let addPlatform = false;
|
||||
// let range: '24h' | '30d' | '90d' = '30d';
|
||||
|
||||
// $: requestUsage = sdkForConsole.projects.getUsage($page.params.project, range);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -53,9 +48,6 @@
|
||||
</ul>
|
||||
</Cover>
|
||||
<Container>
|
||||
<Card>
|
||||
<!-- <Line /> -->
|
||||
</Card>
|
||||
<h1>Platforms</h1>
|
||||
<List>
|
||||
{#each $project.platforms as platform}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, Copy, Alert } from '$lib/components';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import {
|
||||
Button,
|
||||
InputText,
|
||||
@@ -79,7 +79,7 @@
|
||||
</Alert>
|
||||
<div>
|
||||
<p>URI</p>
|
||||
<Copy
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.config.endpoint
|
||||
}/account/session/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, Copy, Alert } from '$lib/components';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import {
|
||||
Button,
|
||||
InputPassword,
|
||||
@@ -78,7 +78,7 @@
|
||||
</Alert>
|
||||
<div>
|
||||
<p>URI</p>
|
||||
<Copy
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.config.endpoint
|
||||
}/account/session/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, Copy, Alert } from '$lib/components';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import {
|
||||
Button,
|
||||
InputPassword,
|
||||
@@ -69,7 +69,7 @@
|
||||
</Alert>
|
||||
<div>
|
||||
<p>URI</p>
|
||||
<Copy
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.config.endpoint
|
||||
}/account/session/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, Copy, Alert } from '$lib/components';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import {
|
||||
Button,
|
||||
InputPassword,
|
||||
@@ -78,7 +78,7 @@
|
||||
</Alert>
|
||||
<div>
|
||||
<p>URI</p>
|
||||
<Copy
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.config.endpoint
|
||||
}/account/session/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Modal, Copy, Alert } from '$lib/components';
|
||||
import { Modal, CopyInput, Alert } from '$lib/components';
|
||||
import {
|
||||
Button,
|
||||
InputPassword,
|
||||
@@ -86,7 +86,7 @@
|
||||
</Alert>
|
||||
<div>
|
||||
<p>URI</p>
|
||||
<Copy
|
||||
<CopyInput
|
||||
value={`${
|
||||
sdkForConsole.config.endpoint
|
||||
}/account/session/oauth2/callback/${provider.name.toLocaleLowerCase()}/${projectId}`} />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Card } from '$lib/components';
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputSwitch } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
@@ -34,54 +35,40 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<Card>
|
||||
<div class="common-section grid-1-2">
|
||||
<div class="grid-1-2-col-1">
|
||||
<h2 class="heading-level-7">Auth Methods</h2>
|
||||
<p>Enable the auth methods you wish to use.</p>
|
||||
</div>
|
||||
<div class="grid-1-2-col-2">
|
||||
<form class="form">
|
||||
<ul class="form-list is-multiple">
|
||||
{#each $authMethods.list as box}
|
||||
<li class="form-item ">
|
||||
<label class="choice-item" for={box.method}>
|
||||
<input
|
||||
label={box.label}
|
||||
id={box.method}
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
bind:checked={box.value}
|
||||
on:change={() => {
|
||||
authUpdate(box.method, box.value);
|
||||
}} />
|
||||
<div class="choice-item-content">
|
||||
<div class="choice-item-title">{box.label}</div>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
{/each}
|
||||
<li class="form-item ">
|
||||
<label class="choice-item" for="phone">
|
||||
<input
|
||||
label="Phone"
|
||||
id="phone"
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
disabled />
|
||||
<div class="choice-item-content">
|
||||
<div class="choice-item-title">Phone</div>
|
||||
<span class="choice-item-paragraph">(soon)</span>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
<CardGrid>
|
||||
<h2 class="heading-level-7">Auth Methods</h2>
|
||||
<p>Enable the auth methods you wish to use.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<form class="form">
|
||||
<ul class="form-list is-multiple">
|
||||
{#each $authMethods.list as box}
|
||||
<InputSwitch
|
||||
label={box.label}
|
||||
id={box.method}
|
||||
bind:value={box.value}
|
||||
on:change={() => {
|
||||
authUpdate(box.method, box.value);
|
||||
}} />
|
||||
{/each}
|
||||
<li class="form-item ">
|
||||
<label class="choice-item" for="phone">
|
||||
<input
|
||||
label="Phone"
|
||||
id="phone"
|
||||
type="checkbox"
|
||||
class="switch"
|
||||
role="switch"
|
||||
disabled />
|
||||
<div class="choice-item-content">
|
||||
<div class="choice-item-title">Phone</div>
|
||||
<span class="choice-item-paragraph">(soon)</span>
|
||||
</div>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
<section class="common-section">
|
||||
<h2 class="heading-level-6 common-section">OAuth2 Providers</h2>
|
||||
<ul class="grid-box common-section">
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { Empty, Pagination, Avatar } from '$lib/components';
|
||||
import { Empty, Pagination, Avatar, Copy, Search } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -50,38 +49,14 @@
|
||||
offset = queryOffset;
|
||||
}
|
||||
});
|
||||
|
||||
const copy = async (value: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value);
|
||||
addNotification({
|
||||
message: 'Copied to clipboard.',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<div class="input-text-wrapper u-flex-basis-50-percent">
|
||||
<input
|
||||
type="search"
|
||||
placeholder="Search Name, Email, or ID"
|
||||
class="input-text"
|
||||
bind:value={search} />
|
||||
<span class="icon-search" aria-hidden="true" />
|
||||
</div>
|
||||
|
||||
<Search bind:search placeholder="Search Name, Email, or ID">
|
||||
<Button on:click={() => (showCreate = true)}>
|
||||
<span class="icon-plus" aria-hidden="true" /> <span class="text">Create User</span>
|
||||
</Button>
|
||||
</div>
|
||||
</Search>
|
||||
{#if $usersList?.response?.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
@@ -113,9 +88,9 @@
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="ID">
|
||||
<Pill button on:click={() => copy(user.$id)}
|
||||
><i class="icon-duplicate" />User ID
|
||||
</Pill>
|
||||
<Copy value={user.$id}>
|
||||
<Pill button><i class="icon-duplicate" />User ID</Pill>
|
||||
</Copy>
|
||||
</TableCellText>
|
||||
<TableCellText title="Joined">
|
||||
{toLocaleDateTime(user.registration)}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
method. You can still create users from your Appwrite console.
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<ul class="u-flex u-gap-12">
|
||||
<li>
|
||||
<div class="input-text-wrapper">
|
||||
@@ -126,7 +126,7 @@
|
||||
If you reduce the limit, users who are currently logged in will be logged out of the
|
||||
application.
|
||||
</p>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<form class="form u-grid u-gap-16">
|
||||
<ul class="form-list is-multiple">
|
||||
<InputNumber id="length" label="Length" value={1} />
|
||||
|
||||
@@ -23,22 +23,18 @@ function createUsersListStore() {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (search: string, limit: number, offset: number) => {
|
||||
try {
|
||||
const response = await sdkForProject.users.list(
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
undefined,
|
||||
undefined,
|
||||
'DESC'
|
||||
);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
const response = await sdkForProject.users.list(
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
undefined,
|
||||
undefined,
|
||||
'DESC'
|
||||
);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -53,22 +49,18 @@ function createTeamsListStore() {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (search: string, limit: number, offset: number) => {
|
||||
try {
|
||||
const response = await sdkForProject.teams.list(
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
undefined,
|
||||
undefined,
|
||||
'DESC'
|
||||
);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
const response = await sdkForProject.teams.list(
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
undefined,
|
||||
undefined,
|
||||
'DESC'
|
||||
);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -82,15 +74,11 @@ function createUsersUsageStore() {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (range: string) => {
|
||||
try {
|
||||
const response = await sdkForProject.users.getUsage(range);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
const response = await sdkForProject.users.getUsage(range);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Empty, Pagination, Avatar } from '$lib/components';
|
||||
import { Empty, Pagination, Avatar, Search } from '$lib/components';
|
||||
import Create from './_createTeam.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
@@ -47,20 +47,11 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<div class="input-text-wrapper u-flex-basis-50-percent">
|
||||
<input
|
||||
type="search"
|
||||
placeholder="Search by Name"
|
||||
class="input-text"
|
||||
bind:value={search} />
|
||||
<span class="icon-search" aria-hidden="true" />
|
||||
</div>
|
||||
|
||||
<Search bind:search placeholder="Search by Name">
|
||||
<Button on:click={() => (showCreate = true)}>
|
||||
<span class="icon-plus" aria-hidden="true" /> <span class="text">Create Team</span>
|
||||
</Button>
|
||||
</div>
|
||||
</Search>
|
||||
{#if $teamsList?.response?.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
let name: string, email: string, roles: [];
|
||||
|
||||
const create = async () => {
|
||||
const url = `${$page.url.origin}/console/${$page.params.project}/users/teams/${$page.params.team}/members`;
|
||||
|
||||
try {
|
||||
//TODO update url to correct one?
|
||||
const user = await sdkForProject.teams.createMembership(
|
||||
teamId,
|
||||
email,
|
||||
roles,
|
||||
$page.url.origin,
|
||||
url,
|
||||
name
|
||||
);
|
||||
addNotification({
|
||||
|
||||
@@ -15,15 +15,12 @@
|
||||
let showError: false | 'name' | 'email' | 'password' = false;
|
||||
let errorMessage = 'Something went wrong';
|
||||
let errorType: 'error' | 'warning' | 'success' = 'error';
|
||||
let teamName = null;
|
||||
let teamName: string = null;
|
||||
|
||||
function addError(location: typeof showError, message: string, type: typeof errorType) {
|
||||
showError = location;
|
||||
errorMessage = message;
|
||||
errorType = type;
|
||||
setTimeout(() => {
|
||||
showError = false;
|
||||
}, 6000);
|
||||
}
|
||||
|
||||
async function updateName() {
|
||||
@@ -66,7 +63,7 @@
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Name</h6>
|
||||
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<InputText
|
||||
id="name"
|
||||
@@ -98,7 +95,7 @@
|
||||
The team will be permanently deleted, including all data associated with this team.
|
||||
This action is irreversible.
|
||||
</p>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<Box>
|
||||
<svelte:fragment slot="image">
|
||||
<Avatar
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Pagination, Empty, Avatar } from '$lib/components';
|
||||
import { Pagination, Empty, Avatar, Search } from '$lib/components';
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
@@ -44,20 +44,11 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<div class="input-text-wrapper u-flex-basis-50-percent">
|
||||
<input
|
||||
type="search"
|
||||
placeholder="Search by ID"
|
||||
class="input-text"
|
||||
bind:value={search} />
|
||||
<span class="icon-search" aria-hidden="true" />
|
||||
</div>
|
||||
|
||||
<Search bind:search placeholder="Search by ID">
|
||||
<Button on:click={() => (showCreate = true)}>
|
||||
<span class="icon-plus" aria-hidden="true" /> <span class="text">Add Member</span>
|
||||
</Button>
|
||||
</div>
|
||||
</Search>
|
||||
{#if $memberships.response?.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
|
||||
@@ -22,15 +22,11 @@ function createTeamStore() {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (teamId: string) => {
|
||||
try {
|
||||
const response = await sdkForProject.teams.get(teamId);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
const response = await sdkForProject.teams.get(teamId);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -44,23 +40,19 @@ function createMembershipStore() {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (teamId: string, search: string, limit: number, offset: number) => {
|
||||
try {
|
||||
const response = await sdkForProject.teams.getMemberships(
|
||||
teamId,
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
undefined,
|
||||
undefined,
|
||||
'DESC'
|
||||
);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
const response = await sdkForProject.teams.getMemberships(
|
||||
teamId,
|
||||
search,
|
||||
limit,
|
||||
offset,
|
||||
undefined,
|
||||
undefined,
|
||||
'DESC'
|
||||
);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,14 +22,14 @@
|
||||
let showError: false | 'name' | 'email' | 'password' = false;
|
||||
let errorMessage = 'Something went wrong';
|
||||
let errorType: 'error' | 'warning' | 'success' = 'error';
|
||||
let userName = null,
|
||||
userEmail = null,
|
||||
newPassword = null,
|
||||
let userName: string = null,
|
||||
userEmail: string = null,
|
||||
newPassword: string = null,
|
||||
newPref = false,
|
||||
newKey = null,
|
||||
newValue = null;
|
||||
newKey: string = null,
|
||||
newValue: string = null;
|
||||
let showVerifcationDropdown = false;
|
||||
let prefs = null;
|
||||
let prefs = Object.entries($user.response.prefs);
|
||||
let arePrefsDisabled = true;
|
||||
|
||||
onMount(async () => {
|
||||
@@ -154,7 +154,12 @@
|
||||
async function deletePref(selectedKey: string) {
|
||||
try {
|
||||
let updatedPrefs = Object.fromEntries(prefs);
|
||||
delete updatedPrefs[selectedKey];
|
||||
updatedPrefs = Object.keys(updatedPrefs).reduce((acc, key) => {
|
||||
if (key !== selectedKey) {
|
||||
acc[key] = updatedPrefs[key];
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
await sdkForProject.users.updatePrefs($user.response.$id, updatedPrefs);
|
||||
prefs = Object.entries(updatedPrefs);
|
||||
$user.response.prefs = updatedPrefs;
|
||||
@@ -188,7 +193,7 @@
|
||||
>{$user.response.emailVerification ? 'Verified' : 'Unverified'}</Pill>
|
||||
{/if}
|
||||
</div>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<div>
|
||||
<span class="title">{$user.response.email}</span>
|
||||
<p>Joined: {toLocaleDate($user.response.registration)}</p>
|
||||
@@ -239,7 +244,7 @@
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Name</h6>
|
||||
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<InputText
|
||||
id="name"
|
||||
@@ -263,7 +268,7 @@
|
||||
</CardGrid>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Email</h6>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<InputEmail
|
||||
id="email"
|
||||
@@ -293,7 +298,7 @@
|
||||
<p>
|
||||
Enter a new password. A password must contain <b> at least 8 characters.</b>
|
||||
</p>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<InputPassword
|
||||
id="newPassword"
|
||||
@@ -323,7 +328,7 @@
|
||||
You can update your user preferences by storing information on the user's objects so
|
||||
they can easily be shared across devices and sessions.
|
||||
</p>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<form class="form u-grid u-gap-16">
|
||||
<ul class="form-list">
|
||||
{#if prefs}
|
||||
@@ -361,10 +366,10 @@
|
||||
{#if prefs.length === 0 || newPref}
|
||||
<li class="form-item is-multiple">
|
||||
<div class="form-item-part u-stretch">
|
||||
<label class="label" for={`value-${newKey}`}>Key</label>
|
||||
<label class="label" for="newKey">Key</label>
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
id={`value-${newKey}`}
|
||||
id="newKey"
|
||||
placeholder="Enter Key"
|
||||
type="text"
|
||||
class="input-text"
|
||||
@@ -372,10 +377,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-item-part u-stretch">
|
||||
<label class="label" for={`value-${newValue}`}>Value</label>
|
||||
<label class="label" for="newValue">Value</label>
|
||||
<div class="input-text-wrapper">
|
||||
<input
|
||||
id={`value-${newValue}`}
|
||||
id="newValue"
|
||||
placeholder="Enter Value"
|
||||
type="text"
|
||||
class="input-text"
|
||||
@@ -413,7 +418,7 @@
|
||||
The user will be permanently deleted, including all data associated with this user.
|
||||
This action is irreversible.
|
||||
</p>
|
||||
<svelte:fragment slot="right">
|
||||
<svelte:fragment slot="aside">
|
||||
<Box>
|
||||
<svelte:fragment slot="image">
|
||||
<Avatar
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
src={`/icons/color/${session?.clientName.toLocaleLowerCase()}.svg`}
|
||||
alt={session.clientName} />
|
||||
</div>
|
||||
<span class="">
|
||||
<span>
|
||||
<p>
|
||||
{session.clientName}
|
||||
</p>
|
||||
|
||||
@@ -11,22 +11,18 @@ export type SelectedUser = {
|
||||
function createUserStore() {
|
||||
const { subscribe, set } = writable<SelectedUser>({
|
||||
loading: true,
|
||||
response: browser ? JSON.parse(sessionStorage.getItem('user')) : null
|
||||
response: browser ? JSON.parse(sessionStorage.getItem('selectedUser')) : null
|
||||
});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
set,
|
||||
load: async (userId: string) => {
|
||||
try {
|
||||
const response = await sdkForProject.users.get(userId);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
} catch (error) {
|
||||
//TODO: take care what happens here
|
||||
}
|
||||
const response = await sdkForProject.users.get(userId);
|
||||
set({
|
||||
loading: false,
|
||||
response
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -34,5 +30,7 @@ function createUserStore() {
|
||||
export const user = createUserStore();
|
||||
|
||||
if (browser) {
|
||||
user.subscribe((n) => sessionStorage?.setItem('user', JSON.stringify(n.response ?? '')));
|
||||
user.subscribe((n) =>
|
||||
sessionStorage?.setItem('selectedUser', JSON.stringify(n.response ?? ''))
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import { Copy } from '../../../src/lib/components';
|
||||
|
||||
export let value = false;
|
||||
</script>
|
||||
|
||||
<Copy {value}>
|
||||
<span data-testid="copy-content">Content</span>
|
||||
</Copy>
|
||||
@@ -1,22 +1,11 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import { render, fireEvent } from '@testing-library/svelte';
|
||||
import { Copy } from '../../../src/lib/components';
|
||||
import Copy from './copy.test.svelte';
|
||||
|
||||
const value = 'This is a test';
|
||||
|
||||
test('shows copy component', () => {
|
||||
const { getByRole } = render(Copy, { value });
|
||||
const input = document.querySelector('input');
|
||||
const button = getByRole('button');
|
||||
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(button).toBeInTheDocument();
|
||||
expect(input).toHaveAttribute('type', 'text');
|
||||
expect(input).toBeDisabled();
|
||||
});
|
||||
|
||||
test('copy to clipboard function called on click', async () => {
|
||||
const { getByRole } = render(Copy, { value });
|
||||
const { getByTestId } = render(Copy, { value });
|
||||
|
||||
Object.assign(window.navigator, {
|
||||
clipboard: {
|
||||
@@ -24,7 +13,7 @@ test('copy to clipboard function called on click', async () => {
|
||||
}
|
||||
});
|
||||
|
||||
const button = getByRole('button');
|
||||
const button = getByTestId('copy-content');
|
||||
await fireEvent.click(button);
|
||||
|
||||
expect(window.navigator.clipboard.writeText).toHaveBeenCalledWith('This is a test');
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import { render, fireEvent } from '@testing-library/svelte';
|
||||
import { CopyInput } from '../../../src/lib/components';
|
||||
|
||||
const value = 'This is a test';
|
||||
|
||||
test('shows CopyInput component', () => {
|
||||
const { getByRole } = render(CopyInput, { value });
|
||||
const input = document.querySelector('input');
|
||||
const button = getByRole('button');
|
||||
|
||||
expect(input).toBeInTheDocument();
|
||||
expect(button).toBeInTheDocument();
|
||||
expect(input).toHaveAttribute('type', 'text');
|
||||
expect(input).toBeDisabled();
|
||||
});
|
||||
|
||||
test('copy to clipboard function called on click', async () => {
|
||||
const { getByRole } = render(CopyInput, { value });
|
||||
|
||||
Object.assign(window.navigator, {
|
||||
clipboard: {
|
||||
writeText: jest.fn().mockImplementation(() => Promise.resolve())
|
||||
}
|
||||
});
|
||||
|
||||
const button = getByRole('button');
|
||||
await fireEvent.click(button);
|
||||
|
||||
expect(window.navigator.clipboard.writeText).toHaveBeenCalledWith('This is a test');
|
||||
});
|
||||
Reference in new issue
Block a user