Merge branch 'main' of github.com:appwrite/appwrite-console-poc into functions

This commit is contained in:
Arman committed 2022-10-06 11:13:45 +02:00
commit c4101fbc3f
53 files changed
+677 -750

No files matched your search

+14 -14
View File
@@ -9,8 +9,8 @@
"version": "0.0.1",
"dependencies": {
"@aw-labs/appwrite-console": "^6.0.0",
"@aw-labs/icons": "0.0.0-57",
"@aw-labs/ui": "0.0.0-57",
"@aw-labs/icons": "0.0.0-58",
"@aw-labs/ui": "0.0.0-58",
"echarts": "^5.4.0",
"tippy.js": "^6.3.7",
"web-vitals": "^2.1.4"
@@ -77,14 +77,14 @@
}
},
"node_modules/@aw-labs/icons": {
"version": "0.0.0-57",
"resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-57.tgz",
"integrity": "sha512-HmXSTSP3GEBi5awFk0APTTNdM10DDIBCTnxi3BJGlsXo+SXnpVikoMk6RZltNLH7MRfPQNx+VfJ2bOC+hlW8ZQ=="
"version": "0.0.0-58",
"resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-58.tgz",
"integrity": "sha512-xUD5DQcYVNiKhDSpxMO24G/4l7txgAdwochK01tJA6wXhuPAcp5Yjuofjm2bGkMzCuze4Vs+SVvhsBxzVXRPrA=="
},
"node_modules/@aw-labs/ui": {
"version": "0.0.0-57",
"resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-57.tgz",
"integrity": "sha512-a/nKqu9nHysTF7bIOLo+ZN1zKpCHfv+jHGixU0SGXchTNAmj2OXClZNk3XfMmwnPD6CiF4cG6YRdbmpx+TTXgA==",
"version": "0.0.0-58",
"resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-58.tgz",
"integrity": "sha512-W3bTvAPX4ig5qLBvGn/VpNaDk62RqO4oDa0poube2WuElkVvaGwFAR0wCwmisdi2NeXyGJqt20g3Y/Mz4K2yMA==",
"dependencies": {
"@aw-labs/icons": "*"
}
@@ -8134,14 +8134,14 @@
}
},
"@aw-labs/icons": {
"version": "0.0.0-57",
"resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-57.tgz",
"integrity": "sha512-HmXSTSP3GEBi5awFk0APTTNdM10DDIBCTnxi3BJGlsXo+SXnpVikoMk6RZltNLH7MRfPQNx+VfJ2bOC+hlW8ZQ=="
"version": "0.0.0-58",
"resolved": "https://registry.npmjs.org/@aw-labs/icons/-/icons-0.0.0-58.tgz",
"integrity": "sha512-xUD5DQcYVNiKhDSpxMO24G/4l7txgAdwochK01tJA6wXhuPAcp5Yjuofjm2bGkMzCuze4Vs+SVvhsBxzVXRPrA=="
},
"@aw-labs/ui": {
"version": "0.0.0-57",
"resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-57.tgz",
"integrity": "sha512-a/nKqu9nHysTF7bIOLo+ZN1zKpCHfv+jHGixU0SGXchTNAmj2OXClZNk3XfMmwnPD6CiF4cG6YRdbmpx+TTXgA==",
"version": "0.0.0-58",
"resolved": "https://registry.npmjs.org/@aw-labs/ui/-/ui-0.0.0-58.tgz",
"integrity": "sha512-W3bTvAPX4ig5qLBvGn/VpNaDk62RqO4oDa0poube2WuElkVvaGwFAR0wCwmisdi2NeXyGJqt20g3Y/Mz4K2yMA==",
"requires": {
"@aw-labs/icons": "*"
}
+2 -2
View File
@@ -19,8 +19,8 @@
},
"dependencies": {
"@aw-labs/appwrite-console": "^6.0.0",
"@aw-labs/icons": "0.0.0-57",
"@aw-labs/ui": "0.0.0-57",
"@aw-labs/icons": "0.0.0-58",
"@aw-labs/ui": "0.0.0-58",
"echarts": "^5.4.0",
"tippy.js": "^6.3.7",
"web-vitals": "^2.1.4"
+1 -19
View File
@@ -1,21 +1,3 @@
<ul class="collapsible">
<li class="collapsible-item">
<details class="collapsible-wrapper">
<summary class="collapsible-button">
<span class="text">
<slot name="header" />
</span>
<span class="collapsible-button-optional">
<slot name="subheader" />
</span>
<div class="icon">
<span class="icon-plus" aria-hidden="true" />
<span class="icon-minus" aria-hidden="true" />
</div>
</summary>
<p class="collapsible-content">
<slot />
</p>
</details>
</li>
<slot />
</ul>
+14
View File
@@ -0,0 +1,14 @@
<li class="collapsible-item">
<details class="collapsible-wrapper">
<summary class="collapsible-button">
<span class="text"><slot name="title" /></span>
<span class="collapsible-button-optional"><slot name="subtitle" /></span>
<div class="icon">
<span class="icon-cheveron-down" aria-hidden="true" />
</div>
</summary>
<div class="collapsible-content">
<slot />
</div>
</details>
</li>
+43
View File
@@ -0,0 +1,43 @@
<script lang="ts">
import { InnerModal } from '$lib/components';
import { InputText } from '$lib/elements/forms';
export let show = false;
export let name: string;
export let id: string;
$: if (!show) {
id = null;
}
$: if (!id?.length) {
id = null;
}
</script>
<InnerModal bind:show>
<svelte:fragment slot="title">{name} ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom {name} ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading underscore, period
</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
+7
View File
@@ -24,3 +24,10 @@
</div>
</div>
</a>
<style>
/* TODO: remove this when ui library is updated*/
.grid-item-1 {
min-block-size: calc(182 / 16 * 1rem);
}
</style>
+3
View File
@@ -16,6 +16,7 @@ export { default as DropList } from './dropList.svelte';
export { default as DropListItem } from './dropListItem.svelte';
export { default as DropListLink } from './dropListLink.svelte';
export { default as Collapsible } from './collapsible.svelte';
export { default as CollapsibleItem } from './collapsibleItem.svelte';
export { default as DropTabs } from './dropTabs.svelte';
export { default as DropTabsItem } from './dropTabsItem.svelte';
export { default as Avatar } from './avatar.svelte';
@@ -26,4 +27,6 @@ export { default as Search } from './search.svelte';
export { default as GridItem1 } from './gridItem1.svelte';
export { default as Steps } from './steps.svelte';
export { default as Step } from './step.svelte';
export { default as CustomId } from './customId.svelte';
export { default as Secret } from './secret.svelte';
export { default as EventModal } from './eventModal.svelte';
+28
View File
@@ -0,0 +1,28 @@
<script lang="ts">
import { Copy } from '.';
export let show = false;
export let value: string;
</script>
<div class="interactive-text-output" class:is-textarea={show}>
{#if show}
<span class="text u-line-height-1-5 u-break-word">{value}</span>
{:else}
<span class="text">••••••••••••</span>
{/if}
<div class="u-flex u-cross-child-start u-gap-8">
<button
class="interactive-text-output-button"
aria-label="show hidden text"
type="button"
on:click={() => (show = !show)}>
<span class:icon-eye-off={show} class:icon-eye={!show} aria-hidden="true" />
</button>
<Copy {value}>
<button class="interactive-text-output-button" aria-label="copy text" type="button">
<span class="icon-duplicate" aria-hidden="true" />
</button>
</Copy>
</div>
</div>
+128 -78
View File
@@ -1,80 +1,130 @@
export const scopes = [
'users.read',
'users.write',
'teams.read',
'teams.write',
'collections.read',
'collections.write',
'attributes.read',
'attributes.write',
'indexes.read',
'indexes.write',
'documents.read',
'documents.write',
'files.read',
'files.write',
'buckets.read',
'buckets.write',
'functions.read',
'functions.write',
'execution.read',
'execution.write',
'locale.read',
'avatars.read',
'health.read'
];
export const events = [
'account.create',
'account.update.email',
'account.update.name',
'account.update.password',
'users.update.email',
'users.update.name',
'users.update.password',
'account.update.prefs',
'account.recovery.create',
'account.recovery.update',
'account.verification.create',
'account.verification.update',
'account.delete',
'account.sessions.create',
'account.sessions.delete',
'account.sessions.update',
'database.collections.create',
'database.collections.update',
'database.collections.delete',
'database.attributes.create',
'database.attributes.delete',
'database.indexes.create',
'database.indexes.delete',
'database.documents.create',
'database.documents.update',
'database.documents.delete',
'functions.create',
'functions.update',
'functions.delete',
'functions.deployments.create',
'functions.deployments.update',
'functions.deployments.delete',
'functions.executions.create',
'functions.executions.update',
'storage.files.create',
'storage.files.update',
'storage.files.delete',
'storage.buckets.create',
'storage.buckets.update',
'storage.buckets.delete',
'users.create',
'users.update.prefs',
'users.update.status',
'users.delete',
'users.sessions.delete',
'teams.create',
'teams.update',
'teams.delete',
'teams.memberships.create',
'teams.memberships.update',
'teams.memberships.update.status',
'teams.memberships.delete'
{
scope: 'users.read',
description: "Access to read your project's users",
category: 'Authentication'
},
{
scope: 'users.write',
description: "Access to create, update, and delete your project's users",
category: 'Authentication'
},
{
scope: 'teams.read',
description: "Access to read your project's teams",
category: 'Authentication'
},
{
scope: 'teams.write',
description: "Access to create, update, and delete your project's teams",
category: 'Authentication'
},
{
scope: 'databases.read',
description: "Access to read your project's databases",
category: 'Database'
},
{
scope: 'databases.write',
description: "Access to create, update, and delete your project's databases",
category: 'Database'
},
{
scope: 'collections.read',
description: "Access to read your project's database collections",
category: 'Database'
},
{
scope: 'collections.write',
description: "Access to create, update, and delete your project's database collections",
category: 'Database'
},
{
scope: 'attributes.read',
description: "Access to read your project's database collection's attributes",
category: 'Database'
},
{
scope: 'attributes.write',
description:
"Access to create, update, and delete your project's database collection's attributes",
category: 'Database'
},
{
scope: 'indexes.read',
description: "Access to read your project's database collection's indexes",
category: 'Database'
},
{
scope: 'indexes.write',
description:
"Access to create, update, and delete your project's database collection's indexes",
category: 'Database'
},
{
scope: 'documents.read',
description: "Access to read your project's database documents",
category: 'Database'
},
{
scope: 'documents.write',
description: "Access to create, update, and delete your project's database documents",
category: 'Database'
},
{
scope: 'files.read',
description: "Access to read your project's storage files and preview images",
category: 'Storage'
},
{
scope: 'files.write',
description: "Access to create, update, and delete your project's storage files",
category: 'Storage'
},
{
scope: 'buckets.read',
description: "Access to read your project's storage buckets",
category: 'Storage'
},
{
scope: 'buckets.write',
description: "Access to create, update, and delete your project's storage buckets",
category: 'Storage'
},
{
scope: 'functions.read',
description: "Access to read your project's functions and code deployments",
category: 'Functions'
},
{
scope: 'functions.write',
description:
"Access to create, update, and delete your project's functions and code deployments",
category: 'Functions'
},
{
scope: 'execution.read',
description: "Access to read your project's execution logs",
category: 'Functions'
},
{
scope: 'execution.write',
description: "Access to execute your project's functions",
category: 'Functions'
},
{
scope: 'locale.read',
description: "Access to access your project's Locale service",
category: 'Other'
},
{
scope: 'avatars.read',
description: "Access to access your project's Avatars service",
category: 'Other'
},
{
scope: 'health.read',
description: "Access to read your project's health status",
category: 'Other'
}
];
+1
View File
@@ -10,6 +10,7 @@ export { default as InputNumber } from './inputNumber.svelte';
export { default as InputSwitch } from './inputSwitch.svelte';
export { default as InputTags } from './inputTags.svelte';
export { default as InputFile } from './inputFile.svelte';
export { default as InputDateTime } from './inputDateTime.svelte';
export { default as InputSearch } from './inputSearch.svelte';
export { default as InputRadio } from './inputRadio.svelte';
export { default as InputSelect } from './inputSelect.svelte';
@@ -0,0 +1,58 @@
<script lang="ts">
import { onMount } from 'svelte';
import { FormItem, Helper } from '.';
export let label: string;
export let showLabel = true;
export let id: string;
export let value = '';
export let required = false;
export let disabled = false;
export let readonly = false;
export let autofocus = false;
export let autocomplete = false;
let element: HTMLInputElement;
let error: string;
onMount(() => {
if (element && autofocus) {
element.focus();
}
});
const handleInvalid = (event: Event) => {
event.preventDefault();
if (element.validity.valueMissing) {
error = 'This field is required';
return;
}
error = element.validationMessage;
};
$: if (value) {
error = null;
}
</script>
<FormItem>
<label class:u-hide={!showLabel} class="label" for={id}>{label}</label>
<div class="input-text-wrapper">
<input
{id}
{disabled}
{readonly}
{required}
autocomplete={autocomplete ? 'on' : 'off'}
type="datetime-local"
class="input-text"
bind:value
bind:this={element}
on:invalid={handleInvalid} />
</div>
{#if error}
<Helper type="warning">{error}</Helper>
{/if}
</FormItem>
+1 -1
View File
@@ -1 +1 @@
<svg width="148" height="105" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#a)"><path d="M38.51 23.233a4.012 4.012 0 0 1 3.407-4.568l24.203-3.399a3.99 3.99 0 0 1 2.932.746l5.139 3.812a3.99 3.99 0 0 1 1.576 2.673l5.38 39.95a4.012 4.012 0 0 1-3.41 4.506l-28.033 3.995a3.988 3.988 0 0 1-4.508-3.355l-6.686-44.36Z" fill="#fff"/></g><path d="m43.643 23.837 23.556-3.523a3.988 3.988 0 0 1 4.549 3.445l1.943 15.343-27.278 3.888-2.77-19.153Z" fill="url(#b)"/><path d="m49.09 26.97 2.732-.358 1.666 12.379-2.73.358L49.09 26.97Z" fill="url(#c)"/><path d="m54.31 30.946 2.731-.358 1.06 7.835-2.73.359-1.06-7.836Z" fill="url(#d)"/><path d="m58.79 28.826 2.73-.359 1.148 9.366-2.73.358-1.149-9.365Z" fill="url(#e)"/><path d="m63.839 32.53 2.73-.358.688 4.966-2.73.359-.688-4.967Z" fill="url(#f)"/><path d="m68.395 22.448-.656-7.41 8.032 5.866-7.376 1.544Z" fill="#DFE1EE"/><path d="m76.953 83.571 30.488 6.946H35.578L.5 83.571h76.453Z" fill="url(#g)"/><path fill-rule="evenodd" clip-rule="evenodd" d="M54.995 53.8c-.774-.608-1.715-.94-2.63-.928l-20.301.26c-2.172.029-3.526 1.927-2.886 4.046.536 1.775 2.302 3.089 4.121 3.065l20.3-.27c3.266-.044 4.162-4.004 1.396-6.173Zm53.289 9.991c-.051-2.388-2.297-4.507-4.743-4.475l-68.852.917c-2.417.032-3.917 2.153-3.19 4.51l6.938 22.468c.604 1.959 2.559 3.401 4.567 3.371l62.391-.934c1.975-.03 3.405-1.477 3.364-3.406l-.475-22.45Z" fill="#C4C6D7"/><path d="m76.92 24.531-2.066 27.784-6.884-.926-2.754-3.705 2.634-16.48a6 6 0 0 1 5.925-5.052h2.227l.918-1.62Z" fill="url(#h)" fill-opacity=".6"/><g filter="url(#i)"><path d="M71.955 27.705a3.975 3.975 0 0 1 4.343-3.602l28.228 2.718a4.024 4.024 0 0 1 3.616 4.369l-3.97 43.59a3.976 3.976 0 0 1-4.343 3.603l-28.228-2.718a4.025 4.025 0 0 1-3.616-4.369l3.97-43.59Z" fill="#fff"/></g><rect width="26.622" height="1.389" rx=".695" transform="rotate(4.056 -376.174 1105.033) skewX(.071)" fill="#E8E9F0"/><rect width="13.33" height="1.389" rx=".695" transform="rotate(4.056 -428.89 1100.632) skewX(.071)" fill="#E8E9F0"/><path d="m106.608 47.684-36.114-1.389-.459 4.4h36.573v-3.01Z" fill="url(#j)" fill-opacity=".5"/><path d="M60.826 41.236a1.83 1.83 0 0 0-1.46-.73H37.218c-1.014 0-1.836.83-1.836 1.853l3.672 46.306c0 1.023.822 1.852 1.836 1.852h67.01c1.014 0 1.836-.83 1.836-1.852l3.672-36.119a1.844 1.844 0 0 0-1.836-1.852H68.878a1.83 1.83 0 0 1-1.46-.73l-6.592-8.728Z" fill="url(#k)"/><ellipse cx="74.166" cy="85.655" rx="11.245" ry="11.345" fill="url(#l)"/><path fill-rule="evenodd" clip-rule="evenodd" d="M74.395 81.997c.305 0 .551.249.551.556v2.778H77.7c.304 0 .55.249.55.556a.553.553 0 0 1-.55.555h-2.754v2.779a.553.553 0 0 1-.55.555.553.553 0 0 1-.551-.555v-2.779H71.09a.553.553 0 0 1-.551-.555c0-.307.247-.556.55-.556h2.755v-2.778c0-.307.246-.556.55-.556Z" fill="#FCFCFF"/><defs><linearGradient id="b" x1="44.102" y1="4.157" x2="36.884" y2="51.275" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#B4B6CA"/></linearGradient><linearGradient id="c" x1="50.491" y1="26.786" x2="52.116" y2="39.171" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="d" x1="55.7" y1="30.764" x2="56.729" y2="38.603" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="e" x1="60.125" y1="28.651" x2="61.353" y2="38.006" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="f" x1="65.227" y1="32.348" x2="65.88" y2="37.319" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="g" x1="90.689" y1="96.769" x2="24.23" y2="74.494" gradientUnits="userSpaceOnUse"><stop stop-color="#C4C6D7"/><stop offset=".992" stop-color="#C4C6D7" stop-opacity=".1"/></linearGradient><linearGradient id="h" x1="65.216" y1="47.453" x2="69.652" y2="17.597" gradientUnits="userSpaceOnUse"><stop stop-color="#A3A8BD"/><stop offset="1" stop-color="#A3A8BD" stop-opacity="0"/></linearGradient><linearGradient id="j" x1="98.951" y1="-33.583" x2="84.242" y2="51.577" gradientUnits="userSpaceOnUse"><stop stop-color="#C4C6D7"/><stop offset="1" stop-color="#C4C6D7" stop-opacity=".37"/></linearGradient><linearGradient id="k" x1="4.171" y1="9.482" x2="114.21" y2="101.365" gradientUnits="userSpaceOnUse"><stop stop-color="#C4C6D7"/><stop offset="1" stop-color="#F2F2F8"/></linearGradient><linearGradient id="l" x1="58.561" y1="78.246" x2="77.573" y2="100.538" gradientUnits="userSpaceOnUse"><stop stop-color="#A3A8BD"/><stop offset="1" stop-color="#C4C6D7"/></linearGradient><filter id="a" x="15.465" y="4.227" width="74.718" height="87.761" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127Line truncated
<svg width="215" height="124" fill="none" xmlns="http://www.w3.org/2000/svg"><g filter="url(#a)"><path d="M51.026 21.99a4 4 0 0 1 3.403-4.564l34.588-4.814a4 4 0 0 1 2.921.739l7.84 5.765a4 4 0 0 1 1.595 2.684l7.504 55.25a4 4 0 0 1-3.404 4.498l-40.516 5.724a4 4 0 0 1-4.514-3.36L51.026 21.99Z" fill="#F2F2F8"/></g><path d="m58.15 24.141 33.152-4.913a4 4 0 0 1 4.554 3.45l2.793 21.857-36.765 5.194L58.15 24.14Z" fill="url(#b)"/><path d="m65.493 28.327 3.68-.479 2.246 16.538-3.68.479-2.246-16.538Z" fill="url(#c)"/><path d="m72.528 33.64 3.681-.48 1.428 10.468-3.68.479-1.429-10.468Z" fill="url(#d)"/><path d="m78.564 30.806 3.68-.479 1.549 12.512-3.681.48-1.548-12.513Z" fill="url(#e)"/><path d="m85.37 35.755 3.681-.479.927 6.636-3.68.479-.927-6.636Z" fill="url(#f)"/><path d="m91.512 22.285-.826-9.242a.3.3 0 0 1 .475-.27l9.742 7.052a.3.3 0 0 1-.115.536l-9.276 1.924Z" fill="#B2B4C7"/><path d="m103.045 103.943 41.094 9.28h-96.86L0 103.943h103.045Z" fill="url(#g)"/><path fill-rule="evenodd" clip-rule="evenodd" d="M73.15 63.943c-.859-.667-1.897-1.03-2.906-1.018l-28.67.362c-2.41.03-3.909 2.14-3.19 4.492l1.546 5.055 11.613 37.133c.611 1.954 2.565 3.391 4.57 3.362l86.464-1.274c1.976-.029 3.404-1.477 3.36-3.407l-.747-32.656c-.054-2.387-2.303-4.506-4.749-4.474l-55.021.72c-1.01.014-2.049-.35-2.907-1.017l-9.364-7.278Z" fill="#171723"/><path d="m103 25.07-2.784 37.117-9.279-1.238L87.225 56l3.826-23.721a6 6 0 0 1 5.924-5.045h4.788L103 25.07Z" fill="url(#h)" fill-opacity=".6"/><g filter="url(#i)"><path d="M96.556 27.967a4 4 0 0 1 4.356-3.61l40.677 3.81a4 4 0 0 1 3.61 4.356l-5.715 61.019a4 4 0 0 1-4.356 3.61l-40.678-3.81a4 4 0 0 1-3.61-4.356l5.716-61.019Z" fill="#F2F2F8"/></g><rect x="103.418" y="31.546" width="35.88" height="1.856" rx=".928" transform="rotate(4.021 103.418 31.546)" fill="#C4C6D7"/><rect x="102.822" y="36.514" width="17.965" height="1.856" rx=".928" transform="rotate(4.021 102.822 36.514)" fill="#C4C6D7"/><path d="M143.015 56 94 54l-.5 6.021h49.515v-4.02Z" fill="url(#j)" fill-opacity=".5"/><path d="M81.31 47.386a2.475 2.475 0 0 0-1.969-.974H49.49a2.475 2.475 0 0 0-2.475 2.474l4.95 61.862a2.475 2.475 0 0 0 2.474 2.475h90.318a2.475 2.475 0 0 0 2.475-2.475l4.949-48.252a2.475 2.475 0 0 0-2.475-2.475H92.163c-.773 0-1.5-.36-1.968-.974l-8.885-11.66Z" fill="url(#k)"/><circle cx="99.288" cy="106.727" fill="url(#l)" r="15.156"/><path fill-rule="evenodd" clip-rule="evenodd" d="M99.597 101.84c.411 0 .743.332.743.742v3.712h3.712a.742.742 0 1 1 0 1.485h-3.712v3.711a.743.743 0 1 1-1.485 0v-3.711h-3.712a.743.743 0 0 1 0-1.485h3.712v-3.712c0-.41.333-.742.742-.742Z" fill="#282A3B"/><defs><linearGradient id="b" x1="58.768" y1="-2.15" x2="49.207" y2="60.822" gradientUnits="userSpaceOnUse"><stop offset=".151" stop-color="#171723" stop-opacity=".04"/><stop offset="1" stop-color="#171723"/></linearGradient><linearGradient id="c" x1="67.379" y1="28.082" x2="69.533" y2="44.632" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="d" x1="74.401" y1="33.396" x2="75.764" y2="43.871" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="e" x1="80.365" y1="30.572" x2="81.992" y2="43.074" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="f" x1="87.242" y1="35.512" x2="88.107" y2="42.155" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity=".31"/></linearGradient><linearGradient id="g" x1="121.559" y1="121.574" x2="32.145" y2="91.339" gradientUnits="userSpaceOnUse"><stop stop-color="#14141F"/><stop offset=".992" stop-color="#14141F" stop-opacity=".1"/></linearGradient><linearGradient id="h" x1="87.225" y1="55.691" x2="93.102" y2="15.79" gradientUnits="userSpaceOnUse"><stop stop-color="#1F202E"/><stop offset="1" stop-color="#A3A8BD" stop-opacity="0"/></linearGradient><linearGradient id="j" x1="132.648" y1="-55.334" x2="112.306" y2="61.155" gradientUnits="userSpaceOnUse"><stop stop-color="#1F202E"/><stop offset="1" stop-color="#1F202E" stop-opacity=".37"/></linearGradient><linearGradient id="k" x1="4.949" y1="4.964" x2="152.181" y2="128.997" gradientUnits="userSpaceOnUse"><stop offset=".214" stop-color="#14141F"/><stop offset="1" stop-color="#33364A"/></linearGradient><linearGradient id="l" x1="78.255" y1="96.829" x2="103.619" y2="126.832" gradientUnits="userSpaceOnUse"><stop stop-color="#3B4251"/><stop offset="1" stop-color="#778397"/></linearGradient><filter id="a" x="27.98" y="1.573" width="89.934" height="106.739" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"/><feColorMatrix in="SourceAlpha" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/><feOffset dx="-7" dy="5"/><feGaussianBlur stdDeviation="8"/><feComposite in2="haLine truncated

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

+1
View File
@@ -0,0 +1 @@
<svg width="155" height="120" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m154.216 46.099-40.998 39.146-64.143-30.217L61.476 25.49l92.74 20.609Z" fill="url(#a)"/><path d="m113.59 84.854 4.034-48.893a6 6 0 0 0-4.343-6.266L44.436 10.181a1.572 1.572 0 0 0-1.995 1.392l-.958 12.486-2.519.504-1.008 13.1 2.772 4.409-1.008 17.382-25.49 23.294a2 2 0 0 0 .572 3.32l70.627 29.809c1.66.7 3.584.204 4.698-1.212l23.463-29.811Z" fill="url(#b)"/><path d="m87.404 114.051 24.492-30.16-72.113-24.776-25.674 23.082a1 1 0 0 0 .286 1.667l5.397 2.238 7.865 3.013 28.619 12.384 31.128 12.552Z" fill="url(#c)"/><path d="m89.038 107.214 14.451-18.153-65.29-24.213-14.614 13.838a2 2 0 0 0 .61 3.301l62.515 25.829a2 2 0 0 0 2.328-.602Z" fill="#373B4D"/><path d="m111.838 83.926 3.59-47.689a5.999 5.999 0 0 0-4.356-6.226l-65.609-18.48a2 2 0 0 0-2.54 1.835l-2.056 45.749 70.971 24.811Z" fill="url(#d)"/><path d="m110.164 83.591 2.829-47.203a3.999 3.999 0 0 0-2.85-4.073L45.989 13.192a2 2 0 0 0-2.567 1.792l-.385 6.167-2.828 3.286-2.757 2.393v11.337l3.653 6.046-1.322 14.902 70.381 24.476Z" fill="url(#e)"/><path d="M101.563 95.305 35.38 69.137" stroke="url(#f)" stroke-opacity=".2"/><path d="M98.584 99.015 32.392 71.842" stroke="url(#g)" stroke-opacity=".2"/><path d="M96.616 103.384 28.751 76.227" stroke="url(#h)" stroke-opacity=".2"/><path d="M93.294 106.093 26.098 78.929" stroke="url(#i)" stroke-opacity=".2"/><path d="m91.423 84.687-14.57 17.206" stroke="url(#j)" stroke-opacity=".2"/><path d="m87.716 82.044-14.57 17.205" stroke="url(#k)" stroke-opacity=".2"/><path d="m82.336 79.415-14.57 17.206" stroke="url(#l)" stroke-opacity=".2"/><path d="m77.295 77.119-14.57 17.205" stroke="url(#m)" stroke-opacity=".2"/><path d="M71.59 75.498 57.02 92.703" stroke="url(#n)" stroke-opacity=".2"/><path d="m67.214 72.86-14.57 17.205" stroke="url(#o)" stroke-opacity=".2"/><path d="m61.843 71.236-14.57 17.205" stroke="url(#p)" stroke-opacity=".2"/><path d="m53.798 69.971-7.285 8.603-7.285 8.603" stroke="url(#q)" stroke-opacity=".2"/><path d="m47.07 66.351-7.285 8.603-7.285 8.602" stroke="url(#r)" stroke-opacity=".2"/><path d="M103.431 90.945v-1.89L90.41 104.48a6 6 0 0 1-6.872 1.676L22.301 80.914l-.075 1.468 62.284 25.616a5 5 0 0 0 5.725-1.401l13.196-15.652Z" fill="url(#s)"/><g filter="url(#t)"><mask id="v" fill="#fff"><ellipse rx="16.089" ry="22.93" transform="matrix(.82897 -.63026 .55176 .78176 51.151 39.041)"/></mask><path d="M47.909 41.507c1.501 2.127 1.72 3.893 1.709 4.378-.005.194-.033-.258.372-1.156.44-.978 1.322-2.29 2.778-3.397l22.07 31.27c10.56-8.028 14.366-19.794 14.6-29.393.236-9.673-2.885-19.14-8.37-26.913l-33.16 25.21Zm4.859-.175c1.456-1.107 2.926-1.583 3.958-1.724.947-.13 1.354.034 1.174-.02-.449-.135-2.005-.884-3.506-3.012l-33.16 25.21c5.486 7.773 13.242 13.716 22.199 16.4 8.889 2.663 20.845 2.445 31.405-5.583l-22.07-31.27Zm1.626-4.756c-1.502-2.127-1.722-3.893-1.71-4.378.005-.194.033.258-.372 1.156-.44.978-1.322 2.29-2.778 3.397L27.464 5.48c-10.56 8.028-14.366 19.794-14.6 29.393-.236 9.673 2.885 19.14 8.37 26.913l33.16-25.21Zm-4.86.175c-1.456 1.107-2.926 1.583-3.958 1.724-.947.13-1.353-.034-1.174.02.45.134 2.005.884 3.507 3.012l33.158-25.21C75.582 8.523 67.826 2.58 58.87-.104 49.981-2.766 38.024-2.548 27.464 5.48l22.07 31.27Z" fill="url(#u)" mask="url(#v)"/><ellipse rx="11.318" ry="17.605" transform="matrix(.83887 -.61593 .53659 .7931 49.982 40.058)" fill="#1E1F2B"/><path transform="matrix(.90428 .33568 -.41702 .94641 68.618 47.386)" fill="url(#w)" d="M0 0h8.086v5.306H0z"/><path transform="matrix(.90428 .33568 -.41702 .94641 74.686 48.684)" fill="url(#x)" d="M0 0h23.267v6.834H0z"/><ellipse rx="1.137" ry="2.6" transform="matrix(.91688 .30592 -.38854 .95644 67.44 49.852)" fill="url(#y)"/><ellipse rx="1.464" ry="3.348" transform="matrix(.91688 .30592 -.38854 .95644 73.168 51.86)" fill="url(#z)"/><ellipse rx="1.923" ry="3.333" transform="matrix(.91688 .30592 -.38854 .95644 94.205 59.714)" fill="url(#A)"/><g style="mix-blend-mode:lighten" opacity=".79" fill="#868EA3"><path d="M43.275 41.565c-1.877.4-3.729-2.804-1.936-3.534 1.486-.606 2.264.708 3.177 1.676.821.87.571 1.471-1.24 1.858ZM47.017 48.662c-2.118-1.52-4.834-5.283-3.515-5.337 2.927-.118 4.466-.808 6.024 2.88.469 1.109 2.893 3.643 2.588 4.409-.305.765-3.449-.77-5.097-1.952Z"/></g></g><defs><radialGradient id="f" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.1233 13.38803 -32.968 .30365 68.472 82.221)"><stop stop-color="#E8E9F0"/><stop offset="1" stop-color="#F7F7F7" stop-opacity="0"/></radialGradient><radialGradient id="g" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="rotate(89.472 -10.365 75.761) scale(13.8907 32.9694)"><stop stop-color="#E8E9F0"/><stop offset="1" stop-color="#F7F7F7" stop-opacity="0"/></radialGradient><radialGradient id="h" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="rotate(89.472 -13.976 76.535) scale(13.8907 33.8062)"><stop stop-color="#E8E9F0"/><stop offset="1" stop-color="#F7F7F7" stop-oLine truncated

After

Width:  |  Height:  |  Size: 10 KiB

+1
View File
@@ -0,0 +1 @@
<svg width="155" height="120" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="m154.22 46.099-40.998 39.146-64.144-30.217L61.48 25.49l92.74 20.609Z" fill="url(#a)"/><path d="m113.594 84.854 4.034-48.893a6 6 0 0 0-4.343-6.266L44.44 10.181a1.57 1.57 0 0 0-1.995 1.392l-.958 12.486-2.52.504-1.007 13.1 2.771 4.409-1.007 17.382-25.49 23.294a2 2 0 0 0 .571 3.32l70.627 29.809c1.66.7 3.584.204 4.7-1.212l23.462-29.811Z" fill="url(#b)"/><path d="m87.408 114.051 24.492-30.16-72.114-24.776-25.673 23.082a1 1 0 0 0 .285 1.667l5.397 2.238 7.866 3.013 28.618 12.384 31.129 12.552Z" fill="url(#c)"/><path d="m89.042 107.214 14.451-18.153-65.29-24.213-14.615 13.838a2 2 0 0 0 .612 3.301l62.514 25.829a2 2 0 0 0 2.328-.602Z" fill="#fff"/><path d="m111.842 83.926 3.59-47.689a6 6 0 0 0-4.356-6.226l-65.609-18.48a2 2 0 0 0-2.54 1.835L40.87 59.115l70.971 24.811Z" fill="url(#d)"/><path d="m110.168 83.591 2.829-47.203a4 4 0 0 0-2.85-4.073L45.993 13.192a2 2 0 0 0-2.567 1.792l-.386 6.167-2.827 3.286-2.757 2.393v11.337l3.653 6.046-1.323 14.902 70.382 24.476Z" fill="url(#e)"/><path d="M101.567 95.305 35.384 69.137" stroke="url(#f)"/><path d="M98.588 99.015 32.396 71.842" stroke="url(#g)"/><path d="M96.62 103.384 28.755 76.227" stroke="url(#h)"/><path d="M93.298 106.093 26.102 78.929" stroke="url(#i)"/><path d="m91.427 84.687-14.57 17.206" stroke="url(#j)"/><path d="M87.72 82.044 73.15 99.249" stroke="url(#k)"/><path d="M82.34 79.415 67.77 96.621" stroke="url(#l)"/><path d="m77.298 77.119-14.57 17.205" stroke="url(#m)"/><path d="m71.594 75.498-14.57 17.205" stroke="url(#n)"/><path d="m67.218 72.86-14.57 17.205" stroke="url(#o)"/><path d="m61.847 71.236-14.57 17.205" stroke="url(#p)"/><path d="m53.801 69.971-7.284 8.603-7.285 8.603" stroke="url(#q)"/><path d="m47.073 66.351-7.285 8.603-7.284 8.602" stroke="url(#r)"/><path d="M103.434 90.945v-1.89l-13.02 15.424a6 6 0 0 1-6.872 1.676L22.304 80.914l-.074 1.468 62.284 25.616a5 5 0 0 0 5.724-1.401l13.196-15.652Z" fill="url(#s)"/><path d="M53.416 15.88a1.05 1.05 0 0 1-.075 1.488l-.798.716a1.027 1.027 0 0 1-1.404-1.497l.766-.75a1.05 1.05 0 0 1 1.511.043Z" fill="url(#t)" fill-opacity=".4"/><g filter="url(#u)"><mask id="w" fill="#fff"><ellipse rx="16.089" ry="22.93" transform="matrix(.82897 -.63026 .55176 .78176 51.155 39.041)"/></mask><path d="M47.913 41.507c1.501 2.127 1.72 3.893 1.709 4.378-.005.194-.033-.258.372-1.156.44-.978 1.322-2.29 2.778-3.397l22.07 31.27c10.56-8.028 14.366-19.794 14.6-29.393.236-9.673-2.885-19.14-8.37-26.913l-33.16 25.21Zm4.859-.175c1.456-1.107 2.926-1.583 3.958-1.724.947-.13 1.353.034 1.174-.02-.45-.135-2.005-.884-3.507-3.012L21.24 61.786c5.485 7.773 13.241 13.716 22.198 16.4 8.888 2.663 20.845 2.445 31.405-5.583l-22.07-31.27Zm1.625-4.756c-1.501-2.127-1.72-3.893-1.709-4.378.005-.194.033.258-.372 1.156-.44.978-1.322 2.29-2.778 3.397L27.468 5.48c-10.56 8.028-14.366 19.794-14.6 29.393-.236 9.673 2.885 19.14 8.37 26.913l33.16-25.21Zm-4.859.175c-1.456 1.107-2.926 1.583-3.958 1.724-.947.13-1.354-.034-1.174.02.449.134 2.005.884 3.507 3.012l33.158-25.21C75.585 8.523 67.83 2.58 58.873-.104 49.984-2.766 38.028-2.548 27.468 5.48l22.07 31.27Z" fill="url(#v)" mask="url(#w)"/><ellipse rx="11.318" ry="17.605" transform="matrix(.83887 -.61593 .53659 .7931 49.985 40.058)" fill="#F6F6FD"/><path transform="matrix(.90428 .33568 -.41702 .94641 68.622 47.386)" fill="url(#x)" d="M0 0h8.086v5.306H0z"/><path transform="matrix(.90428 .33568 -.41702 .94641 74.69 48.684)" fill="url(#y)" d="M0 0h23.267v6.834H0z"/><ellipse rx="1.137" ry="2.6" transform="matrix(.91688 .30592 -.38854 .95644 67.444 49.852)" fill="url(#z)"/><ellipse rx="1.464" ry="3.348" transform="matrix(.91688 .30592 -.38854 .95644 73.172 51.86)" fill="url(#A)"/><ellipse rx="1.923" ry="3.333" transform="matrix(.91688 .30592 -.38854 .95644 94.208 59.714)" fill="url(#B)"/><g style="mix-blend-mode:lighten" opacity=".79" fill="#fff"><path d="M43.279 41.565c-1.877.4-3.729-2.804-1.936-3.534 1.486-.606 2.264.708 3.177 1.676.82.87.57 1.471-1.241 1.858ZM47.02 48.662c-2.117-1.52-4.833-5.283-3.514-5.337 2.927-.118 4.466-.808 6.024 2.88.469 1.109 2.893 3.643 2.587 4.409-.304.765-3.448-.77-5.096-1.952Z"/></g></g><defs><radialGradient id="f" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="matrix(.1233 13.38803 -32.968 .30365 68.475 82.221)"><stop stop-color="#E8E9F0"/><stop offset="1" stop-color="#F7F7F7" stop-opacity="0"/></radialGradient><radialGradient id="g" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="rotate(89.472 -10.363 75.763) scale(13.8907 32.9694)"><stop stop-color="#E8E9F0"/><stop offset="1" stop-color="#F7F7F7" stop-opacity="0"/></radialGradient><radialGradient id="h" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="rotate(89.472 -13.974 76.537) scale(13.8907 33.8062)"><stop stop-color="#E8E9F0"/><stop offset="1" stop-color="#F7F7F7" stop-opacity="0"/></radialGradient><radialGradient id="i" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="rotateLine truncated

After

Width:  |  Height:  |  Size: 10 KiB

+1 -1
View File
@@ -180,7 +180,7 @@
</div>
{:else}
<h1 class="heading-level-4">
<span class="text"> {$title}</span>
<span class="text">{$title ? $title : '-'}</span>
</h1>
{/if}
{#if $page.url.pathname.includes('/console/account')}
+1
View File
@@ -75,3 +75,4 @@ export function updateLayout(args: updateLayoutArguments) {
}
export const pageLimit = readable(12); // default page limit
export const cardLimit = readable(6); // default page limit
+5 -31
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -15,7 +15,7 @@
let name: string;
let id: string;
let showDropdown = false;
let showCustomId = false;
let error: string;
const create = async () => {
@@ -50,42 +50,16 @@
bind:value={name}
autofocus={true}
required />
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
<span class="icon-pencil" aria-hidden="true" /><span class="text">
Organization ID
</span>
</Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">Organization ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom organization ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading
underscore, period
</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="organization" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -7,6 +7,7 @@
import { organizationList } from '$lib/stores/organization';
import { onMount } from 'svelte';
import { sdkForConsole } from '$lib/stores/sdk';
import { cardLimit } from '$lib/stores/layout';
onMount(async () => {
await organizationList.load();
@@ -28,7 +29,6 @@
let addOrganization = false;
let offset = 0;
const limit = 6;
</script>
<Container>
@@ -52,7 +52,7 @@
};`}>
{#each $organizationList.teams as organization, index}
{@const avatarList = getMemberships(organization.$id)}
{#if index >= offset && index < limit + offset}
{#if index >= offset && index < $cardLimit + offset}
<GridItem1 href={`${base}/console/organization-${organization.$id}`}>
<svelte:fragment slot="eyebrow"
>{organization?.total ? organization?.total : 'No'} projects</svelte:fragment>
@@ -67,7 +67,7 @@
</GridItem1>
{/if}
{/each}
{#if $organizationList?.total < limit + offset && ($organizationList?.total % 2 !== 0 || $organizationList?.total % 4 === 0)}
{#if $organizationList?.total < $cardLimit + offset && ($organizationList?.total % 2 !== 0 || $organizationList?.total % 4 === 0)}
<Empty isButton on:click={() => (addOrganization = true)}>
<p>Create a new organization</p>
</Empty>
@@ -76,7 +76,7 @@
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$organizationList?.total}</p>
<Pagination {limit} bind:offset sum={$organizationList?.total} />
<Pagination limit={$cardLimit} bind:offset sum={$organizationList?.total} />
</div>
{:else}
<Empty isButton single on:click={() => (addOrganization = true)}>
@@ -84,7 +84,7 @@
</Empty>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$organizationList?.total}</p>
<Pagination {limit} bind:offset sum={$organizationList?.total} />
<Pagination limit={$cardLimit} bind:offset sum={$organizationList?.total} />
</div>
{/if}
</Container>
@@ -1,5 +1,5 @@
<script lang="ts">
import { updateLayout } from '$lib/stores/layout';
import { pageLimit, updateLayout } from '$lib/stores/layout';
import { onMount } from 'svelte';
import { afterNavigate } from '$app/navigation';
import {
@@ -23,7 +23,7 @@
async function handle(event = null) {
const promises = Promise.all([
organization.load(organizationId),
memberList.load(organizationId, [Query.limit(12)])
memberList.load(organizationId, [Query.limit($pageLimit)])
]);
if ($organization?.$id !== organizationId) {
@@ -12,6 +12,7 @@
import { page } from '$app/stores';
import CreateOrganization from '../_createOrganization.svelte';
import CreateProject from './_createProject.svelte';
import { cardLimit } from '$lib/stores/layout';
let projects: Models.Project[] = [];
$: organizationId = $page.params.organization;
@@ -22,7 +23,7 @@
async function handle() {
await projectList.load([
Query.offset(offset),
Query.limit(limit),
Query.limit($cardLimit),
Query.equal('teamId', organizationId)
]);
}
@@ -30,7 +31,6 @@
let showCreate = false;
let addOrganization = false;
let offset = 0;
const limit = 6;
const projectCreated = async (event: CustomEvent<Models.Project>) => {
await project.load(event.detail.$id);
@@ -84,7 +84,7 @@
projects.length > 3 ? '22rem' : '25rem'
};`}>
{#each $projectList.projects as project, index}
{#if index >= offset && index < limit + offset}
{#if index >= offset && index < $cardLimit + offset}
<GridItem1 href={`${base}/console/project-${project.$id}`}>
<svelte:fragment slot="eyebrow">
{project?.platforms?.length ? project?.platforms?.length : 'No'} apps
@@ -112,7 +112,7 @@
</GridItem1>
{/if}
{/each}
{#if projects.length < limit + offset && (projects.length % 2 !== 0 || projects.length % 4 === 0)}
{#if projects.length < $cardLimit + offset && (projects.length % 2 !== 0 || projects.length % 4 === 0)}
<Empty isButton on:click={() => (showCreate = true)}>
<p>Create a new project</p>
</Empty>
@@ -121,7 +121,7 @@
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {projects.length}</p>
<Pagination {limit} bind:offset sum={projects.length} />
<Pagination limit={$cardLimit} bind:offset sum={projects.length} />
</div>
{:else}
<Empty isButton single on:click={() => (showCreate = true)}>
@@ -129,7 +129,7 @@
</Empty>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {projects?.length}</p>
<Pagination {limit} bind:offset sum={projects?.length} />
<Pagination limit={$cardLimit} bind:offset sum={projects?.length} />
</div>
{/if}
</Container>
@@ -1,5 +1,5 @@
<script lang="ts">
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -13,7 +13,7 @@
let id: string;
let name: string;
let showDropdown = false;
let showCustomId = false;
let error: string;
const create = async () => {
@@ -25,7 +25,7 @@
message: `${name} has been created`
});
id = name = null;
showDropdown = false;
showCustomId = false;
show = false;
} catch ({ message }) {
error = message;
@@ -38,42 +38,16 @@
<svelte:fragment slot="header">Create Project</svelte:fragment>
<FormList>
<InputText id="name" label="Name" bind:value={name} required autofocus={true} />
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
<span class="icon-pencil" aria-hidden="true" /><span class="text">
Project ID
</span>
</Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">Project ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom project ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading
underscore, period
</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="Project" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -34,7 +34,10 @@
};
$: if (search) offset = 0;
$: usersList.load([Query.limit($pageLimit), Query.offset(offset)], search);
$: usersList.load(
[Query.limit($pageLimit), Query.offset(offset), Query.orderDesc('$internalId')],
search
);
</script>
<Container>
@@ -56,8 +59,8 @@
<Table>
<TableHeader>
<TableCellHead>Name</TableCellHead>
<TableCellHead>Email</TableCellHead>
<TableCellHead width={100}>Status</TableCellHead>
<TableCellHead>Identifier</TableCellHead>
<TableCellHead width={130}>Status</TableCellHead>
<TableCellHead width={100}>ID</TableCellHead>
<TableCellHead>Joined</TableCellHead>
</TableHeader>
@@ -67,16 +70,40 @@
href={`${base}/console/project-${project}/authentication/user/${user.$id}`}>
<TableCell title="Name">
<div class="u-flex u-gap-12 u-cross-center">
<Avatar size={32} src={getAvatar(user.name)} name={user.name} />
<span class="text u-trim">{user.name ? user.name : 'n/a'}</span>
{#if user.email || user.phone}
{#if user.name}
<Avatar
size={32}
src={getAvatar(user.name)}
name={user.name} />
<span class="text u-trim">{user.name}</span>
{:else}
<div class="avatar is-size-small ">
<span class="icon-minus-sm" aria-hidden="true" />
</div>
{/if}
{:else}
<div class="avatar is-size-small ">
<span class="icon-anonymous" aria-hidden="true" />
</div>
<span class="text u-trim">{user.name}</span>
{/if}
</div>
</TableCell>
<TableCellText title="Email">{user.email}</TableCellText>
<TableCellText title="Identifier">
{user.email && user.phone
? [user.email, user.phone].join(',')
: user.email || user.phone}
</TableCellText>
<TableCell title="Status">
{#if user.status}
<Pill success={user.emailVerification || user.phoneVerification}>
{user.emailVerification || user.phoneVerification
{user.emailVerification && user.phoneVerification
? 'verified'
: user.emailVerification
? 'verified email'
: user.phoneVerification
? 'verified phone'
: 'unverified'}
</Pill>
{:else}
@@ -102,7 +129,7 @@
<Pagination limit={$pageLimit} bind:offset sum={$usersList.total} />
</div>
{:else if search}
<Empty>
<Empty single>
<div class="u-flex u-flex-vertical">
<b>Sorry, we couldn’t find ‘{search}’</b>
<div class="common-section">
@@ -128,7 +155,14 @@
type: 'user'
}
}}>
<p>Add Your First User To Get Started</p>
<div class="u-text-center common-section">
<p>Create your first User to get started.</p>
<p>Need a hand? Check out our documentation.</p>
</div>
<div class="u-flex u-gap-16 common-section u-main-center">
<Button external href="#/" text>Documentation</Button>
<Button secondary>Create User</Button>
</div>
</div>
</Empty>
{/if}
@@ -1,5 +1,5 @@
<script lang="ts">
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -11,14 +11,14 @@
const dispatch = createEventDispatcher();
let name: string, id: string, error: string;
let showDropdown = false;
let showCustomId = false;
const create = async () => {
try {
const team = await sdkForProject.teams.create(id ?? 'unique()', name);
name = '';
showCreate = false;
showDropdown = false;
showCustomId = false;
addNotification({
type: 'success',
message: `${team.name} has been created`
@@ -29,11 +29,8 @@
}
};
$: if (!showDropdown) {
id = null;
}
$: if (!showCreate) {
showDropdown = false;
showCustomId = false;
error = null;
}
</script>
@@ -48,39 +45,15 @@
placeholder="Enter name"
autofocus={true}
bind:value={name} />
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}
<Pill button on:click={() => (showCustomId = !showCustomId)}
><span class="icon-pencil" aria-hidden="true" />
<span class="text"> Team ID </span>
</Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">Team ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom team ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5"
>Allowed characters: alphanumeric, hyphen, non-leading
underscore, period</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="Team" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -1,11 +1,12 @@
<script lang="ts">
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements/';
import {
Button,
InputPassword,
InputEmail,
InputText,
InputPhone,
Form,
FormList
} from '$lib/elements/forms';
@@ -18,18 +19,24 @@
const dispatch = createEventDispatcher();
let showDropdown = false;
let name: string, mail: string, pass: string, id: string;
let name: string, mail: string, pass: string, id: string, phone: string;
let error: string;
const create = async () => {
try {
const user = await sdkForProject.users.create(id ?? 'unique()', mail, pass, name);
const user = await sdkForProject.users.create(
id ?? 'unique()',
mail,
phone,
pass,
name
);
mail = pass = name = '';
showCreate = false;
showDropdown = false;
addNotification({
type: 'success',
message: `${user.name} has been created`
message: `${user.name ? user.name : 'User'} has been created`
});
dispatch('created', user);
} catch ({ message }) {
@@ -56,17 +63,12 @@
placeholder="Enter name"
autofocus={true}
bind:value={name} />
<InputEmail
id="email"
label="Email"
placeholder="Enter email"
required={true}
bind:value={mail} />
<InputEmail id="email" label="Email" placeholder="Enter email" bind:value={mail} />
<InputPhone id="phone" label="Phone" placeholder="Enter phone" bind:value={phone} />
<InputPassword
id="password"
label="Password"
placeholder="Enter password"
required={true}
showPasswordButton={true}
bind:value={pass} />
@@ -79,33 +81,7 @@
</Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">User ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom user ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading
underscore, period
</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showDropdown} name="User" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -20,12 +20,12 @@
import { base } from '$app/paths';
import { teamsList } from '../store';
import { Query, type Models } from '@aw-labs/appwrite-console';
import { pageLimit } from '$lib/stores/layout';
let search = '';
let showCreate = false;
let offset = 0;
const limit = 25;
const project = $page.params.project;
const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 32, 32).toString();
const teamCreated = async (event: CustomEvent<Models.Team>) => {
@@ -33,7 +33,10 @@
};
$: if (search) offset = 0;
$: teamsList.load([Query.limit(limit), Query.offset(offset)], search);
$: teamsList.load(
[Query.limit($pageLimit), Query.offset(offset), Query.orderDesc('$internalId')],
search
);
</script>
<Container>
@@ -78,10 +81,10 @@
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$teamsList.total}</p>
<Pagination {limit} bind:offset sum={$teamsList.total} />
<Pagination limit={$pageLimit} bind:offset sum={$teamsList.total} />
</div>
{:else if search}
<Empty>
<Empty single>
<div class="common-section ">
<b>Sorry, we couldn’t find ‘{search}’</b>
</div>
@@ -94,7 +97,7 @@
</Empty>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$teamsList.total}</p>
<Pagination {limit} bind:offset sum={$teamsList.total} />
<Pagination limit={$pageLimit} bind:offset sum={$teamsList.total} />
</div>
{:else}
<Empty isButton single on:click={() => (showCreate = true)}>
@@ -107,7 +110,14 @@
type: 'team'
}
}}>
<p>Create your first team to get started</p>
<div class="u-text-center common-section">
<p>Create your first Team to get started.</p>
<p>Need a hand? Check out our documentation.</p>
</div>
<div class="u-flex u-gap-16 common-section u-main-center">
<Button external href="#/" text>Documentation</Button>
<Button secondary>Create team</Button>
</div>
</div>
</Empty>
{/if}
@@ -1,4 +1,5 @@
<script lang="ts">
import { page } from '$app/stores';
import { toLocaleDateTime } from '$lib/helpers/date';
import { Avatar, CardGrid, Box, DropList, DropListItem } from '$lib/components';
import { Pill } from '$lib/elements';
@@ -38,6 +39,7 @@
let showVerifcationDropdown = false;
onMount(async () => {
await user.load($page.params.user);
prefs = Object.entries($user.prefs);
if (!prefs?.length) {
prefs.push(['', '']);
@@ -55,7 +57,7 @@
await sdkForProject.users.updateEmailVerification($user.$id, !$user.emailVerification);
$user.emailVerification = !$user.emailVerification;
addNotification({
message: `The account has been ${
message: `${$user.name || $user.email || $user.phone || 'The account'} has been ${
$user.emailVerification ? 'verified' : 'unverified'
}`,
type: 'success'
@@ -73,7 +75,7 @@
await sdkForProject.users.updatePhoneVerification($user.$id, !$user.phoneVerification);
$user.phoneVerification = !$user.phoneVerification;
addNotification({
message: `The account has been ${
message: `${$user.name || $user.email || $user.phone || 'The account'} has been ${
$user.phoneVerification ? 'verified' : 'unverified'
}`,
type: 'success'
@@ -90,7 +92,9 @@
await sdkForProject.users.updateStatus($user.$id, !$user.status);
$user.status = !$user.status;
addNotification({
message: `The account has been ${$user.status ? 'unblocked' : 'blocked'}`,
message: `${$user.name || $user.email || $user.phone || 'The account'} has been ${
$user.status ? 'unblocked' : 'blocked'
}`,
type: 'success'
});
} catch (error) {
@@ -189,7 +193,20 @@
<Container>
<CardGrid>
<div class="grid-1-2-col-1 u-flex u-cross-center u-gap-16">
<Avatar size={48} name={$user.name} src={getAvatar($user.name)} />
{#if $user.email || $user.phone}
{#if $user.name}
<Avatar size={48} src={getAvatar($user.name)} name={$user.name} />
<span class="text u-trim">{$user.name}</span>
{:else}
<div class="avatar">
<span class="icon-minus-sm" aria-hidden="true" />
</div>
{/if}
{:else}
<div class="avatar">
<span class="icon-anonymous" aria-hidden="true" />
</div>
{/if}
<h6 class="heading-level-7">{$user.name}</h6>
</div>
<svelte:fragment slot="aside">
@@ -281,7 +298,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={userName === $user.name || !userName} submit>Update</Button>
<Button disabled={userName === $user.name} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -301,7 +318,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={userEmail === $user.email || !userEmail} submit>Update</Button>
<Button disabled={userEmail === $user.email} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -321,7 +338,7 @@
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled={userPhone === $user.phone || !userPhone} submit>Update</Button>
<Button disabled={userPhone === $user.phone} submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -439,12 +456,31 @@
<svelte:fragment slot="aside">
<Box>
<svelte:fragment slot="image">
<Avatar size={48} name={$user.name} src={getAvatar($user.name)} />
{#if $user.email || $user.phone}
{#if $user.name}
<Avatar size={48} src={getAvatar($user.name)} name={$user.name} />
<span class="text u-trim">{$user.name}</span>
{:else}
<div class="avatar">
<span class="icon-minus-sm" aria-hidden="true" />
</div>
{/if}
{:else}
<div class="avatar">
<span class="icon-anonymous" aria-hidden="true" />
</div>
{/if}
</svelte:fragment>
<svelte:fragment slot="title">
<h6 class="u-bold">{$user.name}</h6>
<h6 class="u-bold">
{$user.name || $user.email || $user.phone || 'Anonymous'}
</h6>
</svelte:fragment>
<p>{$user.email}</p>
<p>
{$user.email && $user.phone
? [$user.email, $user.phone].join(',')
: $user.email || $user.phone}
</p>
</Box>
</svelte:fragment>
@@ -453,4 +489,5 @@
</svelte:fragment>
</CardGrid>
</Container>
<DeleteUser bind:showDelete />
@@ -14,6 +14,10 @@
try {
await sdkForProject.teams.deleteMembership('tmpstring', 'tmpstring2');
showDeleteAll = false;
addNotification({
type: 'success',
message: `All memberships have been deleted`
});
await goto(
`${base}/console/project-${$page.params.project}/authentication/${$user.$id}/membeships`
);
@@ -24,6 +28,8 @@
});
}
};
//TODO: implelment delete all memberships
</script>
<Form on:submit={deleteAllMemberships}>
@@ -22,6 +22,10 @@
);
showDelete = false;
dispatch('deleted');
addNotification({
type: 'success',
message: `Membership has been deleted`
});
await goto(
`${base}/console/project-${$page.params.project}/authentication/user/${selectedMembership.userId}/memberships`
);
@@ -17,7 +17,7 @@
showDelete = false;
addNotification({
type: 'success',
message: `${$user.name} has been deleted`
message: `${$user.name ? $user.name : 'User'} has been deleted`
});
await goto(`${base}/console/project-${$page.params.project}/authentication`);
} catch (error) {
@@ -17,6 +17,7 @@
import DeleteMembership from '../_deleteMembership.svelte';
import DeleteAllMemberships from '../_deleteAllMemberships.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import { pageLimit } from '$lib/stores/layout';
const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 32, 32).toString();
const deleted = () => (request = sdkForProject.users.listMemberships($page.params.user));
@@ -27,8 +28,6 @@
let showDelete = false;
let showDeleteAll = false;
const limit = 25;
$: request = sdkForProject.users.listMemberships($page.params.user);
</script>
@@ -97,7 +96,7 @@
class="u-flex u-margin-block-start-32
u-main-space-between">
<p class="text">Total results: {response.total}</p>
<Pagination {limit} bind:offset sum={response.total} />
<Pagination limit={$pageLimit} bind:offset sum={response.total} />
</div>
{/await}
</Container>
@@ -9,19 +9,19 @@
import { Container } from '$lib/layout';
import { base } from '$app/paths';
import { databaseList } from './store';
import { cardLimit } from '$lib/stores/layout';
let showCreate = false;
let search = '';
let offset = 0;
const limit = 6;
const project = $page.params.project;
const handleCreate = async (event: CustomEvent<Models.Database>) => {
showCreate = false;
await goto(`${base}/console/project-${project}/databases/database/${event.detail.$id}`);
};
$: databaseList.load([Query.limit(limit), Query.offset(offset)], search);
$: databaseList.load([Query.limit($cardLimit), Query.offset(offset)], search);
</script>
<Container>
@@ -48,7 +48,7 @@
</Copy>
</GridItem1>
{/each}
{#if ($databaseList.total % 2 !== 0 || $databaseList.total % 4 === 0) && $databaseList.total - offset <= limit}
{#if ($databaseList.total % 2 !== 0 || $databaseList.total % 4 === 0) && $databaseList.total - offset <= $cardLimit}
<Empty isButton on:click={() => (showCreate = true)}>
<p>Create a new database</p>
</Empty>
@@ -57,7 +57,7 @@
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$databaseList.total}</p>
<Pagination {limit} bind:offset sum={$databaseList.total} />
<Pagination limit={$cardLimit} bind:offset sum={$databaseList.total} />
</div>
{:else}
<Empty isButton single on:click={() => (showCreate = true)}>
@@ -1,5 +1,5 @@
<script lang="ts">
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { Button, InputText, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -12,7 +12,7 @@
let name = '';
let id: string = null;
let showDropdown = false;
let showCustomId = false;
const create = async () => {
try {
@@ -41,41 +41,15 @@
autofocus
required />
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}
<Pill button on:click={() => (showCustomId = !showCustomId)}
><span class="icon-pencil" aria-hidden="true" /><span class="text">
Database ID
</span></Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">Database ID</svelte:fragment>
<p>
Enter a custom database ID. Leave blank for a randomly generated database
ID.
</p>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5"
>Allowed characters: alphanumeric, hyphen, non-leading
underscore, period</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="Database" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -9,12 +9,12 @@
import { Container } from '$lib/layout';
import { base } from '$app/paths';
import { collections } from './store';
import { cardLimit } from '$lib/stores/layout';
let showCreate = false;
let search = '';
let offset = 0;
const limit = 6;
const project = $page.params.project;
const databaseId = $page.params.database;
const handleCreate = async (event: CustomEvent<Models.Collection>) => {
@@ -24,7 +24,7 @@
);
};
$: collections.load(databaseId, [Query.limit(limit), Query.offset(offset)], search);
$: collections.load(databaseId, [Query.limit($cardLimit), Query.offset(offset)], search);
$: if (search) offset = 0;
</script>
@@ -62,7 +62,7 @@
</Copy>
</GridItem1>
{/each}
{#if ($collections.total % 2 !== 0 || $collections.total % 4 === 0) && $collections.total - offset <= limit}
{#if ($collections.total % 2 !== 0 || $collections.total % 4 === 0) && $collections.total - offset <= $cardLimit}
<Empty isButton on:click={() => (showCreate = true)}>
<p>Create a new collection</p>
</Empty>
@@ -71,7 +71,7 @@
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$collections.total}</p>
<Pagination {limit} bind:offset sum={$collections.total} />
<Pagination limit={$cardLimit} bind:offset sum={$collections.total} />
</div>
{:else if search}
<Empty>
@@ -87,7 +87,7 @@
</Empty>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$collections?.total}</p>
<Pagination {limit} bind:offset sum={$collections?.total} />
<Pagination limit={$cardLimit} bind:offset sum={$collections?.total} />
</div>
{:else}
<Empty isButton single on:click={() => (showCreate = true)}>
@@ -1,7 +1,7 @@
<script lang="ts">
import { page } from '$app/stores';
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { Button, InputText, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
@@ -15,7 +15,7 @@
let name = '';
let id: string = null;
let showDropdown = false;
let showCustomId = false;
const create = async () => {
try {
@@ -48,41 +48,15 @@
autofocus
required />
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}
<Pill button on:click={() => (showCustomId = !showCustomId)}
><span class="icon-pencil" aria-hidden="true" /><span class="text">
Collection ID
</span></Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">Collection ID</svelte:fragment>
<p>
Enter a custom collection ID. Leave blank for a randomly generated
collection ID.
</p>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5"
>Allowed characters: alphanumeric, hyphen, non-leading
underscore, period</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="Collection" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -17,10 +17,10 @@
import { wizard } from '$lib/stores/wizard';
import Create from './createDocument.svelte';
import { Query } from '@aw-labs/appwrite-console';
import { pageLimit } from '$lib/stores/layout';
let offset = 0;
const limit = 5;
const projectId = $page.params.project;
const databaseId = $page.params.database;
@@ -79,7 +79,7 @@
<div class="u-flex common-section u-main-space-between">
<p class="text">Total results: {$documentList.total}</p>
<Pagination {limit} bind:offset sum={$documentList.total} />
<Pagination limit={$pageLimit} bind:offset sum={$documentList.total} />
</div>
{:else}
<Empty isButton single on:click={openWizard}>
@@ -18,9 +18,9 @@
import CreateIndex from '../indexes/createIndex.svelte';
import Delete from './deleteAttribute.svelte';
import Overview from './overview.svelte';
import { pageLimit } from '$lib/stores/layout';
let offset = 0;
const limit = 5;
let showDropdown = [];
let selectedAttribute: Attributes = null;
let showCreate = false;
@@ -112,7 +112,7 @@
</Table>
<div class="u-flex common-section u-main-space-between">
<p class="text">Total results: {$collection?.attributes?.length}</p>
<Pagination {limit} bind:offset sum={$collection?.attributes?.length} />
<Pagination limit={$pageLimit} bind:offset sum={$collection?.attributes?.length} />
</div>
{:else}
<Empty isButton single on:click={() => (showCreate = true)}>
@@ -19,6 +19,7 @@
import Create from './createIndex.svelte';
import Overview from './overviewIndex.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import { pageLimit } from '$lib/stores/layout';
let showDropdown = [];
let selectedIndex: Models.Index = null;
@@ -27,8 +28,6 @@
let showDelete = false;
let search = '';
let offset: number = null;
const limit = 5;
const collectionId = $page.params.collection;
const databaseId = $page.params.database;
@@ -138,7 +137,7 @@
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$indexList?.total}</p>
<Pagination {limit} bind:offset sum={$indexList?.total} />
<Pagination limit={$pageLimit} bind:offset sum={$indexList?.total} />
</div>
{:else if search}
<Empty>
@@ -154,7 +153,7 @@
</Empty>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$indexList?.total}</p>
<Pagination {limit} bind:offset sum={$indexList?.total} />
<Pagination limit={$pageLimit} bind:offset sum={$indexList?.total} />
</div>
{:else if $collection.indexes?.length}
<Empty isButton single on:click={() => (showCreateIndex = true)}>
@@ -1,7 +1,7 @@
<script lang="ts">
import { InnerModal } from '$lib/components';
import { CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { Button, InputText } from '$lib/elements/forms';
import { Button } from '$lib/elements/forms';
import { WizardStep } from '$lib/layout';
import { createDocument } from './store';
import Attribute from '../document/[document]/_attribute.svelte';
@@ -89,31 +89,7 @@
</Pill>
</div>
{:else}
<InnerModal bind:show={showCustomId}>
<svelte:fragment slot="title">Document ID</svelte:fragment>
Enter a custom document ID. Leave blank for a randomly generated one.
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={$createDocument.id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading
underscore, period
</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="Document" bind:id={$createDocument.id} />
{/if}
</ul>
{/if}
@@ -1,22 +0,0 @@
<script>
import { afterNavigate } from '$app/navigation';
import { updateLayout } from '$lib/stores/layout';
import { onMount } from 'svelte';
onMount(handle);
afterNavigate(handle);
function handle(event = null) {
updateLayout({
navigate: event,
title: 'API Keys',
level: 3,
breadcrumbs: {
href: 'keys',
title: 'API Keys'
}
});
}
</script>
<slot />
@@ -1,62 +0,0 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Empty } from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
Table,
TableBody,
TableCellHead,
TableCellLink,
TableCellText,
TableHeader,
TableRow
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { project } from '../store';
import Create from './_create.svelte';
const projectId = $page.params.project;
let showCreate = false;
</script>
<svelte:head>
<title>Appwrite - API Keys</title>
</svelte:head>
<Container>
{#if $project}
{#if $project.keys}
<Table>
<TableHeader>
<TableCellHead>Name</TableCellHead>
<TableCellHead>Scopes</TableCellHead>
</TableHeader>
<TableBody>
{#each $project.keys as key}
<TableRow>
<TableCellLink
href={`${base}/console/project-${projectId}/keys/key/${key.$id}`}
title="Name">
{key.name}
</TableCellLink>
<TableCellText title="Scopes">{key.scopes.length}</TableCellText>
</TableRow>
{/each}
</TableBody>
</Table>
{:else}
<Empty>
<div class="u-flex u-flex-vertical">
<div class="common-section">No API Keys Found</div>
<div class="common-section">
You haven't created any API keys for your project yet.
</div>
</div>
</Empty>
{/if}
<Button on:click={() => (showCreate = true)}>Add API Key</Button>
{/if}
</Container>
<Create bind:show={showCreate} />
@@ -1,69 +0,0 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { InputText, Button, Form, InputCheckbox } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { project } from '../store';
import { scopes } from '$lib/constants';
export let show = false;
let name: string;
const activeScopes = scopes.reduce((prev, next) => {
prev[next] = false;
return prev;
}, {});
const create = async () => {
try {
await sdkForConsole.projects.createKey(
$project.$id,
name,
scopes.filter((scope) => activeScopes[scope])
);
name = null;
for (const scope in activeScopes) {
activeScopes[scope] = false;
}
await project.load($project.$id);
show = false;
} catch (error) {
addNotification({
type: 'error',
message: error.message
});
}
};
const selectAll = () => {
for (const scope in activeScopes) {
activeScopes[scope] = true;
}
};
const unselectAll = () => {
for (const scope in activeScopes) {
activeScopes[scope] = false;
}
};
</script>
<Form on:submit={create}>
<Modal bind:show>
<svelte:fragment slot="header">Add API Key</svelte:fragment>
<p>
<span class="link" on:click={selectAll}>Select All</span><span
class="link"
on:click={unselectAll}>Unselect All</span>
</p>
<InputText id="name" label="Name" bind:value={name} required />
{#each scopes as scope}
<InputCheckbox id={scope} label={scope} bind:value={activeScopes[scope]} />
{/each}
<svelte:fragment slot="footer">
<Button submit>Create</Button>
<Button secondary on:click={() => (show = false)}>Cancel</Button>
</svelte:fragment>
</Modal>
</Form>
@@ -1,35 +0,0 @@
<script lang="ts">
import { Card } from '$lib/components';
import { Container } from '$lib/layout';
import { sdkForConsole } from '$lib/stores/sdk';
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { Button } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { project } from '../../../store';
import { base } from '$app/paths';
const projectId = $page.params.project;
const keyId = $page.params.key;
const request = sdkForConsole.projects.getKey(projectId, keyId);
const deleteKey = async () => {
await sdkForConsole.projects.deleteKey(projectId, keyId);
addNotification({
message: 'API key deleted.',
type: 'success'
});
project.load(projectId);
await goto(`${base}/console/project-${projectId}/keys`);
};
</script>
<Container>
<Card>
{#await request}
loading
{:then response}
<p>{response.name}</p>
<Button danger on:click={deleteKey}>Delete</Button>
{/await}
</Card>
</Container>
@@ -276,7 +276,7 @@
</div>
<div
class="card is-2-columns-medium-screen is-2-columns-large-screen is-2-rows-large-screen is-location-row-2-end-large-screen">
<div class="heading-level-4">10</div>
<div class="heading-level-4">XX</div>
<div>Realtime Connections</div>
</div>
</div>
@@ -39,7 +39,7 @@
{key.name}
</TableCellText>
<TableCellText title="Last Accessed">
{toLocaleDateTime(key.$createdAt)}
{key.accessedAt ? toLocaleDateTime(key.accessedAt) : 'never'}
</TableCellText>
<TableCellText title="Expiration Date">
{toLocaleDateTime(key.$updatedAt)}
@@ -2,16 +2,10 @@
import { afterNavigate } from '$app/navigation';
import { base } from '$app/paths';
import { page } from '$app/stores';
import { CardGrid } from '$lib/components';
import { scopes } from '$lib/constants';
import {
Button,
Form,
FormList,
InputCheckbox,
InputPassword,
InputText
} from '$lib/elements/forms';
import { CardGrid, Secret } from '$lib/components';
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
import InputDateTime from '$lib/elements/forms/inputDateTime.svelte';
import { difference } from '$lib/helpers/array';
import { toLocaleDateTime } from '$lib/helpers/date';
import { Container } from '$lib/layout';
import { updateLayout } from '$lib/stores/layout';
@@ -19,38 +13,30 @@
import { sdkForConsole } from '$lib/stores/sdk';
import { onMount } from 'svelte';
import { project } from '../../../store';
import Scopes from '../scopes.svelte';
import Delete from './delete.svelte';
import { key } from './store';
const projectId = $page.params.project;
const keyId = $page.params.key;
const activeScopes = scopes.reduce((prev, next) => {
prev[next] = false;
return prev;
}, {});
let loaded = false;
let showDelete = false;
let name: string = null;
let secret: string = null;
let expire: string = null;
let scopes: string[] = null;
onMount(handle);
afterNavigate(handle);
async function handle(event = null) {
if ($key?.$id !== keyId) {
await key.load(projectId, keyId);
}
await key.load(projectId, keyId);
name ??= $key.name;
secret ??= $key.secret;
expire ??= $key.expire;
unselectAll();
$key.scopes.forEach((scope) => {
activeScopes[scope] = true;
});
scopes ??= $key.scopes;
updateLayout({
navigate: event,
@@ -117,12 +103,8 @@
async function updateScopes() {
try {
await sdkForConsole.projects.updateKey(
$project.$id,
$key.$id,
$key.name,
scopes.filter((scope) => activeScopes[scope])
);
await sdkForConsole.projects.updateKey($project.$id, $key.$id, $key.name, scopes);
$key.scopes = scopes;
addNotification({
type: 'success',
message: 'API Key scopes has been updated'
@@ -134,12 +116,6 @@
});
}
}
function unselectAll() {
for (const scope in activeScopes) {
activeScopes[scope] = false;
}
}
</script>
<svelte:head>
@@ -148,13 +124,14 @@
<Container>
{#if loaded}
{@const accessedAt = $key.accessedAt ? toLocaleDateTime($key.accessedAt) : 'never'}
<CardGrid>
<div>
<h6 class="heading-level-7">{$key.name}</h6>
</div>
<svelte:fragment slot="aside">
<p>
Last accessed: {toLocaleDateTime($key.$updatedAt)}<br />
Last accessed: {accessedAt}<br />
Scopes granted: {$key.scopes.length}
</p>
</svelte:fragment>
@@ -164,18 +141,9 @@
<h6 class="heading-level-7">API Key Secret</h6>
<svelte:fragment slot="aside">
<FormList>
<InputPassword
id="secret"
label="API Key Secret"
bind:value={secret}
showPasswordButton
required />
<Secret bind:value={secret} />
</FormList>
</svelte:fragment>
<svelte:fragment slot="actions">
<Button disabled submit>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
<Form on:submit={updateName}>
@@ -206,18 +174,16 @@
practice to allow only the permissions you need to meet your project goals.
</p>
<svelte:fragment slot="aside">
<FormList>
{#each scopes as scope}
<InputCheckbox
id={scope}
label={scope}
bind:value={activeScopes[scope]} />
{/each}
</FormList>
<Scopes bind:scopes />
</svelte:fragment>
<svelte:fragment slot="actions">
<Button submit>Update</Button>
<Button
submit
disabled={!(
difference(scopes, $key.scopes).length !== 0 ||
difference($key.scopes, scopes).length !== 0
)}>Update</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -227,11 +193,7 @@
<p class="text">Choose any name that will help you distinguish between API keys.</p>
<svelte:fragment slot="aside">
<FormList>
<InputText
id="expire"
label="Expiration Date"
bind:value={expire}
required />
<InputDateTime id="expire" label="Expiration Date" bind:value={expire} />
</FormList>
</svelte:fragment>
@@ -250,7 +212,7 @@
<div class="u-flex u-gap-16">
<div class="u-cross-child-center u-line-height-1-5">
<h6 class="u-bold">{$key.name}</h6>
<p>Last accessed: {toLocaleDateTime($key.$updatedAt)}</p>
<p>Last accessed: {accessedAt}</p>
</div>
</div>
</div>
@@ -1,32 +1,21 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { scopes } from '$lib/constants';
import { InputText, Button, Form, FormList, InputCheckbox } from '$lib/elements/forms';
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
import { addNotification } from '$lib/stores/notifications';
import { sdkForConsole } from '$lib/stores/sdk';
import { project } from '../../.../../store';
import Scopes from './scopes.svelte';
export let show = false;
const activeScopes = scopes.reduce((prev, next) => {
prev[next] = false;
return prev;
}, {});
let name: string;
let scopes: string[] = [];
async function create() {
try {
await sdkForConsole.projects.createKey(
$project.$id,
name,
scopes.filter((scope) => activeScopes[scope])
);
await sdkForConsole.projects.createKey($project.$id, name, scopes);
name = null;
for (const scope in activeScopes) {
activeScopes[scope] = false;
}
scopes = [];
project.load($project.$id);
show = false;
} catch (error) {
@@ -39,13 +28,11 @@
</script>
<Form on:submit={create}>
<Modal bind:show>
<Modal bind:show size="big">
<svelte:fragment slot="header">Create API Key</svelte:fragment>
<FormList>
<InputText id="name" label="Name" bind:value={name} autofocus required />
{#each scopes as scope}
<InputCheckbox id={scope} label={scope} bind:value={activeScopes[scope]} />
{/each}
<Scopes bind:scopes />
</FormList>
<svelte:fragment slot="footer">
<Button submit>Register</Button>
@@ -0,0 +1,72 @@
<script lang="ts">
import { Collapsible, CollapsibleItem } from '$lib/components';
import { Button, FormList, InputChoice } from '$lib/elements/forms';
import { scopes as allScopes } from '$lib/constants';
import { onMount } from 'svelte';
import { difference } from '$lib/helpers/array';
export let scopes: string[];
let mounted = false;
onMount(() => {
scopes.forEach((scope) => {
activeScopes[scope] = true;
});
mounted = true;
});
function selectAll() {
for (const scope in activeScopes) {
activeScopes[scope] = true;
}
}
function unselectAll() {
for (const scope in activeScopes) {
activeScopes[scope] = false;
}
}
const activeScopes = allScopes.reduce((prev, next) => {
prev[next.scope] = false;
return prev;
}, {});
$: {
if (mounted) {
const newScopes = allScopes
.filter((scope) => activeScopes[scope.scope])
.map(({ scope }) => scope);
if (
difference(scopes, newScopes).length !== 0 ||
difference(newScopes, scopes).length !== 0
) {
scopes = newScopes;
}
}
}
</script>
<div class="u-flex u-cross-center u-main-end">
<Button text on:click={unselectAll}>Unselect all</Button>
<Button text on:click={selectAll}>Select all</Button>
</div>
<Collapsible>
{#each ['Authentication', 'Database', 'Functions', 'Storage', 'Other'] as category}
<CollapsibleItem>
<svelte:fragment slot="title">{category}</svelte:fragment>
<FormList>
{#each allScopes.filter((s) => s.category === category) as scope}
<InputChoice
id={scope.scope}
label={scope.scope}
bind:value={activeScopes[scope.scope]}>
{scope.description}
</InputChoice>
{/each}
</FormList>
</CollapsibleItem>
{/each}
</Collapsible>
@@ -21,7 +21,7 @@
</span>
</div>
<div class="grid-box u-margin-block-start-32" style="--grid-gap:2rem; --grid-item-size:25rem;">
<div class="grid-box u-margin-block-start-32" style="--grid-gap:1.5rem; --grid-item-size:25rem;">
{#each $project.platforms as platform}
<GridItem1 href={`${path}/${platform.$id}`}>
<svelte:fragment slot="title">{platform.name}</svelte:fragment>
@@ -10,7 +10,7 @@
import { base } from '$app/paths';
import { bucketList } from './store';
import { tooltip } from '$lib/actions/tooltip';
import { pageLimit } from '$lib/stores/layout';
import { cardLimit } from '$lib/stores/layout';
let showCreate = false;
let search = '';
@@ -22,7 +22,7 @@
await goto(`${base}/console/project-${project}/storage/bucket/${event.detail.$id}`);
};
$: bucketList.load([Query.limit($pageLimit), Query.offset(offset)], search);
$: bucketList.load([Query.limit($cardLimit), Query.offset(offset)], search);
$: if (search) offset = 0;
</script>
@@ -38,7 +38,7 @@
{#if $bucketList?.total}
<ul
class="grid-box common-section u-margin-block-start-32"
style={`--grid-gap:2rem; --grid-item-size:${
style={`--grid-gap:1.5rem; --grid-item-size:${
$bucketList.total > 3 ? '22rem' : '25rem'
};`}>
{#each $bucketList.buckets as bucket}
@@ -81,7 +81,7 @@
</svelte:fragment>
</GridItem1>
{/each}
{#if $bucketList.total % 2 !== 0}
{#if $bucketList?.total < $cardLimit + offset && ($bucketList?.total % 2 !== 0 || $bucketList?.total % 4 === 0)}
<Empty isButton on:click={() => (showCreate = true)}>
<p>Add a new bucket</p>
</Empty>
@@ -90,7 +90,7 @@
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$bucketList.total}</p>
<Pagination limit={$pageLimit} bind:offset sum={$bucketList.total} />
<Pagination limit={$cardLimit} bind:offset sum={$bucketList.total} />
</div>
{:else if search}
<Empty>
@@ -106,7 +106,7 @@
</Empty>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {$bucketList?.total}</p>
<Pagination limit={$pageLimit} bind:offset sum={$bucketList?.total} />
<Pagination limit={$cardLimit} bind:offset sum={$bucketList?.total} />
</div>
{:else}
<Empty isButton single on:click={() => (showCreate = true)}>
@@ -1,5 +1,5 @@
<script lang="ts">
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { Pill } from '$lib/elements';
import { Button, InputText, Form, FormList } from '$lib/elements/forms';
import { sdkForProject } from '$lib/stores/sdk';
@@ -11,7 +11,7 @@
let name = '';
let id: string = null;
let showDropdown = false;
let showCustomId = false;
let error: string;
const create = async () => {
@@ -25,11 +25,11 @@
}
};
$: if (!showDropdown) {
$: if (!showCustomId) {
id = null;
}
$: if (!showCreate) {
showDropdown = false;
showCustomId = false;
error = null;
}
</script>
@@ -46,41 +46,15 @@
autofocus
required />
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
<span class="icon-pencil" aria-hidden="true" />
<span class="text"> Bucket ID </span>
</Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">Bucket ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom bucket ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5">
Allowed characters: alphanumeric, hyphen, non-leading
underscore, period
</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="Bucket" bind:id />
{/if}
</FormList>
<svelte:fragment slot="footer">
@@ -85,9 +85,9 @@
<Table>
<TableHeader>
<TableCellHead>Filename</TableCellHead>
<TableCellHead>Type</TableCellHead>
<TableCellHead>Size</TableCellHead>
<TableCellHead>Date Created</TableCellHead>
<TableCellHead width={140}>Type</TableCellHead>
<TableCellHead width={100}>Size</TableCellHead>
<TableCellHead width={120}>Date Created</TableCellHead>
<TableCellHead width={30} />
</TableHeader>
<TableBody>
@@ -95,11 +95,13 @@
{#if file.chunksTotal / file.chunksUploaded !== 1}
<TableRow>
<TableCell title="Name">
<div class="u-flex u-gap-12">
<div class="avatar is-color-empty" />
<div class="u-flex u-gap-12 u-main-space-between">
<span class="avatar is-size-small is-color-empty" />
<span class="text u-trim"> {file.name}</span>
<Pill warning>Pending</Pill>
<div>
<Pill warning>Pending</Pill>
</div>
</div>
</TableCell>
<TableCellText title="Type">{file.mimeType}</TableCellText>
@@ -1,7 +1,7 @@
<script lang="ts">
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
import { Button, Form, FormList } from '$lib/elements/forms';
import { Pill } from '$lib/elements';
import { Modal, InnerModal } from '$lib/components';
import { Modal, CustomId } from '$lib/components';
import { sdkForProject } from '$lib/stores/sdk';
import { createEventDispatcher } from 'svelte';
import { page } from '$app/stores';
@@ -21,7 +21,7 @@
let permissions: string[] = [];
let id: string = null;
let error: string;
let showDropdown = false;
let showCustomId = false;
async function create() {
try {
@@ -33,7 +33,7 @@
);
files = null;
showCreate = false;
showDropdown = false;
showCustomId = false;
uploader.addFile(file);
dispatch('created');
} catch ({ message }) {
@@ -65,10 +65,6 @@
list = new DataTransfer();
permissions = [];
}
$: if (!showDropdown) {
id = null;
}
</script>
<input bind:files bind:this={input} type="file" style="display: none" />
@@ -112,41 +108,16 @@
<p>Max file size: {calculateSize($bucket.maximumFileSize)}</p>
</div>
{#if !showDropdown}
{#if !showCustomId}
<div>
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<Pill button on:click={() => (showCustomId = !showCustomId)}>
<span class="icon-pencil" aria-hidden="true" /><span class="text">
File ID
</span>
</Pill>
</div>
{:else}
<InnerModal bind:show={showDropdown}>
<svelte:fragment slot="title">File ID</svelte:fragment>
<svelte:fragment slot="subtitle">
Enter a custom file ID. Leave blank for a randomly generated one.
</svelte:fragment>
<svelte:fragment slot="content">
<div class="form">
<InputText
id="id"
label="Custom ID"
showLabel={false}
placeholder="Enter ID"
autofocus={true}
bind:value={id} />
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
<span
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
aria-hidden="true" />
<span class="text u-line-height-1-5"
>Allowed characters: alphanumeric, hyphen, non-leading
underscore, period</span>
</div>
</div>
</svelte:fragment>
</InnerModal>
<CustomId bind:show={showCustomId} name="File" bind:id />
{/if}
<p class="heading-level-7">Permissions</p>
<Permissions bind:permissions />
+48
View File
@@ -0,0 +1,48 @@
import '@testing-library/jest-dom';
import { vi } from 'vitest';
import { render, fireEvent } from '@testing-library/svelte';
import { Secret } from '../../../src/lib/components';
const value = 'This is a secret';
test('shows Secret component', () => {
const { container } = render(Secret, { value });
const secret = container.querySelector('span.text');
const toggle = container.querySelector('[aria-label="show hidden text"]');
const copy = container.querySelector('[aria-label="copy text"]');
expect(secret).toBeInTheDocument();
expect(toggle).toBeInTheDocument();
expect(copy).toBeInTheDocument();
});
test('toggle secret', async () => {
const { container } = render(Secret, { value });
const toggle = container.querySelector('[aria-label="show hidden text"]');
let secret = container.querySelector('span.text');
expect(secret).not.toContainEqual(value);
await fireEvent.click(toggle);
secret = container.querySelector('span.text');
expect(secret.textContent).toEqual(value);
await fireEvent.click(toggle);
secret = container.querySelector('span.text');
expect(secret.textContent).not.toEqual(value);
});
test('copy to clipboard on click', async () => {
const { container } = render(Secret, { value });
const copy = container.querySelector('[aria-label="copy text"]');
Object.assign(window.navigator, {
clipboard: {
writeText: vi.fn().mockImplementation(() => Promise.resolve())
}
});
await fireEvent.click(copy);
expect(window.navigator.clipboard.writeText).toHaveBeenCalledWith(value);
});