mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge branch feat-databases-v2 into feat/null-value-fields
This commit is contained in:
commit
f1a8130db8
126 files changed
+3051
-1294
No files matched your search
Generated
+609
-586
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -20,7 +20,7 @@
|
||||
"dependencies": {
|
||||
"@analytics/google-analytics": "^1.0.5",
|
||||
"@appwrite.io/console": "0.1.0-preview-0.1",
|
||||
"@appwrite.io/pink": "0.0.6-rc.6",
|
||||
"@appwrite.io/pink": "^0.0.6-rc.6",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
|
||||
@@ -149,6 +149,7 @@ export enum Submit {
|
||||
DatabaseDelete = 'submit_database_delete',
|
||||
DatabaseUpdateName = 'submit_database_update_name',
|
||||
AttributeCreate = 'submit_attribute_create',
|
||||
AttributeUpdate = 'submit_attribute_update',
|
||||
AttributeDelete = 'submit_attribute_delete',
|
||||
DocumentCreate = 'submit_document_create',
|
||||
DocumentDelete = 'submit_document_delete',
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
class:common-section={!isTile}
|
||||
class:is-border-dashed={isDashed}
|
||||
class:is-danger={danger}
|
||||
class:is-allowed-focus={href}
|
||||
on:click
|
||||
on:keyup={clickOnEnter}
|
||||
{href}>
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { Empty } from '$lib/components';
|
||||
import { cardLimit } from '$lib/stores/layout';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import { prefs } from '$lib/stores/user';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let offset = 0;
|
||||
export let limit = $cardLimit;
|
||||
export let total = 0;
|
||||
export let event: string = null;
|
||||
|
||||
let limit = CARD_LIMIT;
|
||||
|
||||
onMount(async () => {
|
||||
await prefs.load();
|
||||
$prefs?.pageLimit && (limit = $prefs.pageLimit);
|
||||
});
|
||||
|
||||
prefs.subscribe((prefs) => {
|
||||
prefs?.pageLimit && (limit = prefs.pageLimit);
|
||||
});
|
||||
</script>
|
||||
|
||||
<ul
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
});
|
||||
</script>
|
||||
|
||||
<section class="box u-overflow-hidden " class:common-section={!noMargin}>
|
||||
<section class="box u-overflow-hidden" class:common-section={!noMargin}>
|
||||
<div
|
||||
class="controls u-position-absolute u-inset-inline-end-8 u-inset-block-start-8 u-flex u-gap-8">
|
||||
{#if label}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
export let show = false;
|
||||
export let name: string;
|
||||
export let id: string;
|
||||
export let autofocus = true;
|
||||
|
||||
$: if (!show) {
|
||||
id = null;
|
||||
@@ -27,7 +28,7 @@
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="content">
|
||||
<div class="form">
|
||||
<InputId bind:value={id} />
|
||||
<InputId bind:value={id} {autofocus} />
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</InnerModal>
|
||||
@@ -10,6 +10,9 @@
|
||||
export let noArrow = false;
|
||||
export let placement: Placement = 'bottom-start';
|
||||
export let childStart = false;
|
||||
export let noStyle = false;
|
||||
export let fullWidth = false;
|
||||
export let fixed = false;
|
||||
|
||||
let element: HTMLDivElement;
|
||||
let tooltip: HTMLDivElement;
|
||||
@@ -19,6 +22,7 @@
|
||||
onMount(() => {
|
||||
instance = createPopper(element, tooltip, {
|
||||
placement,
|
||||
strategy: fixed ? 'fixed' : 'absolute',
|
||||
modifiers: [
|
||||
{
|
||||
name: 'arrow',
|
||||
@@ -37,6 +41,20 @@
|
||||
options: {
|
||||
fallbackPlacements: ['bottom-start', 'bottom-end', 'top-start', 'top-end']
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'sameWidth',
|
||||
enabled: fixed,
|
||||
phase: 'beforeWrite',
|
||||
requires: ['computeStyles'],
|
||||
fn: ({ state }) => {
|
||||
state.styles.popper.width = `${state.rects.reference.width}px`;
|
||||
},
|
||||
effect: ({ state }) => {
|
||||
state.elements.popper.style.width = `${
|
||||
(state.elements.reference as HTMLElement)?.offsetWidth
|
||||
}px`;
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -67,11 +85,15 @@
|
||||
|
||||
<svelte:window on:click={onBlur} />
|
||||
|
||||
<div class="drop-wrapper" class:u-cross-child-start={childStart} bind:this={element}>
|
||||
<div class:drop-wrapper={!noStyle} class:u-cross-child-start={childStart} bind:this={element}>
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
<div class="drop-tooltip" bind:this={tooltip} style="z-index: 10">
|
||||
<div
|
||||
class="drop-tooltip"
|
||||
class:u-width-full-line={fullWidth}
|
||||
bind:this={tooltip}
|
||||
style:z-index="10">
|
||||
<div class="drop-arrow" class:u-hide={!show || (show && noArrow)} bind:this={arrow} />
|
||||
{#if show}
|
||||
<slot name="list" />
|
||||
|
||||
@@ -4,27 +4,30 @@
|
||||
|
||||
export let show = false;
|
||||
export let placement: Placement = 'bottom-start';
|
||||
export let fixed = false;
|
||||
export let scrollable = false;
|
||||
export let childStart = false;
|
||||
export let noArrow = false;
|
||||
export let noStyle = false;
|
||||
export let width: string = null;
|
||||
export let fullWidth = false;
|
||||
export let position: 'relative' | 'static' = 'relative';
|
||||
</script>
|
||||
|
||||
<Drop bind:show {placement} {childStart} {noArrow}>
|
||||
<Drop bind:show {placement} {childStart} {noArrow} {noStyle} {fullWidth} {fixed}>
|
||||
<slot />
|
||||
<svelte:fragment slot="list">
|
||||
<div
|
||||
class="drop is-no-arrow"
|
||||
style={`${
|
||||
width
|
||||
? `--drop-width-size-desktop:${width}rem; position:relative`
|
||||
: ' position:relative'
|
||||
class:u-max-width-100-percent={fullWidth}
|
||||
style={`${width ? `--drop-width-size-desktop:${width}rem; ` : ''} ${
|
||||
position === 'static' ? 'position:static' : 'position:relative'
|
||||
}`}>
|
||||
{#if $$slots.list}
|
||||
<section
|
||||
class:u-overflow-y-auto={scrollable}
|
||||
class:u-max-height-200={scrollable}
|
||||
class="drop-section ">
|
||||
class="drop-section">
|
||||
<ul class="drop-list">
|
||||
<slot name="list" />
|
||||
</ul>
|
||||
|
||||
@@ -53,23 +53,12 @@
|
||||
|
||||
<Form onSubmit={handleSubmit}>
|
||||
<FormList>
|
||||
<InputText
|
||||
label="name"
|
||||
id="name"
|
||||
bind:value={name}
|
||||
placeholder="Enter name"
|
||||
showLabel={false} />
|
||||
<InputEmail
|
||||
label="email"
|
||||
id="email"
|
||||
bind:value={email}
|
||||
placeholder="Enter email"
|
||||
showLabel={false} />
|
||||
<InputText label="Name" id="name" bind:value={name} placeholder="Enter name" />
|
||||
<InputEmail label="Email" id="email" bind:value={email} placeholder="Enter email" />
|
||||
<InputTextarea
|
||||
id="feedback"
|
||||
placeholder="Your message here"
|
||||
showLabel={false}
|
||||
label="Feedback"
|
||||
label="Message"
|
||||
required
|
||||
bind:value={message} />
|
||||
</FormList>
|
||||
|
||||
@@ -58,22 +58,12 @@
|
||||
<InputTextarea
|
||||
id="feedback"
|
||||
placeholder="Your message here"
|
||||
label="Feedback"
|
||||
label="Message"
|
||||
required
|
||||
bind:value={message}
|
||||
showLabel={false} />
|
||||
<InputText
|
||||
label="name"
|
||||
id="name"
|
||||
bind:value={name}
|
||||
placeholder="Enter name"
|
||||
showLabel={false} />
|
||||
<InputEmail
|
||||
label="email"
|
||||
id="email"
|
||||
bind:value={email}
|
||||
placeholder="Enter email"
|
||||
showLabel={false} />
|
||||
<InputText label="Name" id="name" bind:value={name} placeholder="Enter name" />
|
||||
<InputEmail label="Email" id="email" bind:value={email} placeholder="Enter email" />
|
||||
</FormList>
|
||||
{/if}
|
||||
<div class="u-flex u-main-end u-gap-16 u-margin-block-start-24">
|
||||
|
||||
@@ -46,5 +46,7 @@ export { default as EventModal } from './eventModal.svelte';
|
||||
export { default as Status } from './status.svelte';
|
||||
export { default as Heading } from './heading.svelte';
|
||||
export { default as Output } from './output.svelte';
|
||||
export { default as Limit } from './limit.svelte';
|
||||
export { default as ViewSelector } from './viewSelector.svelte';
|
||||
export { default as LabelCard } from './labelCard.svelte';
|
||||
export { default as Limit } from './limit.svelte';
|
||||
export { default as PaginationWithLimit } from './paginationWithLimit.svelte';
|
||||
@@ -2,29 +2,35 @@
|
||||
import { FormItem } from '$lib/elements/forms';
|
||||
|
||||
export let show = false;
|
||||
export let closable = true;
|
||||
</script>
|
||||
|
||||
{#if show}
|
||||
<FormItem>
|
||||
<section class="modal is-inner-modal">
|
||||
<div class="modal-form">
|
||||
<header class="modal-header u-flex-wrap">
|
||||
<h4 class="modal-title body-text-1">
|
||||
<slot name="title" />
|
||||
</h4>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="Close"
|
||||
title="Close"
|
||||
on:click={() => (show = false)}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
<p class="u-flex-basis-100-percent">
|
||||
<header class="modal-header">
|
||||
<div class="u-flex u-main-space-between u-cross-center u-gap-16">
|
||||
<h4 class="modal-title body-text-1">
|
||||
<slot name="title" />
|
||||
</h4>
|
||||
{#if closable}
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="Close"
|
||||
title="Close"
|
||||
on:click={() => (show = false)}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="u-flex-basis-100-percent text u-small">
|
||||
<slot name="subtitle" />
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div class="modal-content">
|
||||
<slot name="content" />
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<script lang="ts">
|
||||
export let name: string;
|
||||
export let group: string;
|
||||
export let value: string | number | boolean;
|
||||
export let disabled = false;
|
||||
export let padding: number = 0.5;
|
||||
export let icon: string = null;
|
||||
export let fullHeight = true;
|
||||
</script>
|
||||
|
||||
<label
|
||||
class="card is-allow-focus u-cursor-pointer"
|
||||
class:u-height-100-percent={fullHeight}
|
||||
style={`--card-padding:${padding}rem`}>
|
||||
<div class="u-flex u-gap-16">
|
||||
<input type="radio" {name} {disabled} {value} bind:group on:click />
|
||||
<div class="u-flex u-flex-vertical u-gap-4">
|
||||
<h4 class="body-text-2"><slot name="title" /></h4>
|
||||
<p class="u-color-text-gray u-small">
|
||||
<slot />
|
||||
</p>
|
||||
</div>
|
||||
{#if icon}
|
||||
<span class={`icon-${icon} u-margin-inline-start-auto`} aria-hidden="true" />
|
||||
{/if}
|
||||
</div>
|
||||
</label>
|
||||
@@ -6,9 +6,11 @@
|
||||
|
||||
export let show = false;
|
||||
export let size: 'small' | 'big' = null;
|
||||
export let warning = false;
|
||||
export let icon: string = null;
|
||||
export let state: 'success' | 'warning' | 'error' | 'info' = null;
|
||||
export let error: string = null;
|
||||
export let closable = true;
|
||||
export let headerDivider = true;
|
||||
export let onSubmit: () => Promise<void> | void = function () {
|
||||
return;
|
||||
};
|
||||
@@ -79,33 +81,44 @@
|
||||
class="modal"
|
||||
class:is-small={size === 'small'}
|
||||
class:is-big={size === 'big'}
|
||||
bind:this={dialog}>
|
||||
class:is-separate-header={headerDivider}
|
||||
bind:this={dialog}
|
||||
on:cancel|preventDefault>
|
||||
{#if show}
|
||||
<Form isModal {onSubmit}>
|
||||
<header class="modal-header">
|
||||
{#if warning}
|
||||
<div class="avatar is-warning is-medium">
|
||||
<span class="icon-exclamation" aria-hidden="true" />
|
||||
<div class="u-flex u-main-space-between u-cross-center u-gap-16">
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
{#if icon}
|
||||
<div
|
||||
class="avatar is-medium"
|
||||
class:is-success={state === 'success'}
|
||||
class:is-warning={state === 'warning'}
|
||||
class:is-danger={state === 'error'}
|
||||
class:is-info={state === 'info'}>
|
||||
<span class={`icon-${icon}`} aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
<h4 class="modal-title heading-level-5">
|
||||
<slot name="header" />
|
||||
</h4>
|
||||
</div>
|
||||
{/if}
|
||||
<h4 class="modal-title heading-level-5">
|
||||
<slot name="header" />
|
||||
</h4>
|
||||
{#if closable}
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="Close Modal"
|
||||
title="Close Modal"
|
||||
on:click={() =>
|
||||
trackEvent('click_close_modal', {
|
||||
from: 'button'
|
||||
})}
|
||||
on:click={closeModal}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
{#if closable}
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="Close Modal"
|
||||
title="Close Modal"
|
||||
on:click={() =>
|
||||
trackEvent('click_close_modal', {
|
||||
from: 'button'
|
||||
})}
|
||||
on:click={closeModal}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
</div>
|
||||
</header>
|
||||
<div class="modal-content">
|
||||
{#if error}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<script lang="ts">
|
||||
import Limit from './limit.svelte';
|
||||
import Pagination from './pagination.svelte';
|
||||
|
||||
export let limit: number;
|
||||
export let offset: number;
|
||||
export let total: number;
|
||||
export let name: string;
|
||||
</script>
|
||||
|
||||
<div class="u-flex u-margin-block-start-32 u-flex-wrap">
|
||||
<Limit {limit} sum={total} {name} />
|
||||
<div class="u-margin-inline-start-auto">
|
||||
<Pagination {limit} {offset} sum={total} />
|
||||
</div>
|
||||
</div>
|
||||
@@ -70,13 +70,13 @@
|
||||
{@const isAnonymous = !data.email && !data.phone && isUser}
|
||||
<div class="user-profile">
|
||||
{#if isAnonymous}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true" />
|
||||
</div>
|
||||
{:else if data.name}
|
||||
<AvatarInitials name={data.name} size={40} />
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<div class="u-x-small">{user.$id}</div>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="u-line-height-1-5">
|
||||
@@ -110,7 +110,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="u-line-height-1-5">
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
import { preferences } from '$lib/stores/preferences';
|
||||
import { onMount } from 'svelte';
|
||||
import { View } from '$lib/helpers/load';
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
export let columns: Writable<Column[]>;
|
||||
export let view: View;
|
||||
@@ -81,7 +82,7 @@
|
||||
class="icon-view-boards u-opacity-50"
|
||||
aria-hidden="true"
|
||||
aria-label="columns" />
|
||||
<span class="text">Columns</span>
|
||||
<span class="text is-only-desktop">Columns</span>
|
||||
<span class="inline-tag">{selectedColumnsNumber}</span>
|
||||
</Button>
|
||||
<svelte:fragment slot="list">
|
||||
@@ -108,7 +109,10 @@
|
||||
class="toggle-button-element"
|
||||
aria-label="List View"
|
||||
type="button"
|
||||
class:is-selected={view === View.Table}>
|
||||
class:is-selected={view === View.Table}
|
||||
use:tooltip={{
|
||||
content: 'Column View'
|
||||
}}>
|
||||
<span class="icon-view-list" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
@@ -119,7 +123,10 @@
|
||||
class="toggle-button-element"
|
||||
aria-label="Grid View"
|
||||
type="button"
|
||||
class:is-selected={view === View.Grid}>
|
||||
class:is-selected={view === View.Grid}
|
||||
use:tooltip={{
|
||||
content: 'Grid View'
|
||||
}}>
|
||||
<span class="icon-view-grid" aria-hidden="true" />
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -15,6 +15,7 @@ export enum Dependencies {
|
||||
TEAMS = 'dependency:teams',
|
||||
MEMBERSHIPS = 'dependency:memberships',
|
||||
DATABASE = 'dependency:database',
|
||||
DATABASES = 'dependency:databases',
|
||||
COLLECTION = 'dependency:collection',
|
||||
DOCUMENT = 'dependency:document',
|
||||
DOCUMENTS = 'dependency:documents',
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
<script lang="ts">
|
||||
export let isCommonSection = false;
|
||||
export let gap = 24;
|
||||
</script>
|
||||
|
||||
<ul class="form-list" class:common-section={isCommonSection}>
|
||||
<ul
|
||||
class="form-list"
|
||||
class:common-section={isCommonSection}
|
||||
style={`--form-list-gap: ${gap / 16}rem;`}>
|
||||
<slot />
|
||||
</ul>
|
||||
@@ -15,6 +15,7 @@ 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';
|
||||
export { default as InputSelectSearch } from './inputSelectSearch.svelte';
|
||||
export { default as InputCheckbox } from './inputCheckbox.svelte';
|
||||
export { default as InputChoice } from './inputChoice.svelte';
|
||||
export { default as InputPhone } from './inputPhone.svelte';
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<p class="text">{label}</p>
|
||||
{/if}
|
||||
<div
|
||||
class="box is-no-shadow u-padding-24"
|
||||
class="box is-no-shadow u-padding-24"
|
||||
style="--box-border-radius:var(--border-radius-xsmall); z-index: 1"
|
||||
class:is-border-dashed={!hovering}
|
||||
class:is-hover-with-file={hovering}
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
import TextCounter from './textCounter.svelte';
|
||||
|
||||
export let value = '';
|
||||
export let autofocus = true;
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let icon = 'info';
|
||||
const pattern = String.raw`^[a-zA-Z0-9][a-zA-Z0-9._-]*$`;
|
||||
const autofocus = true;
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
@@ -52,7 +52,7 @@
|
||||
<span
|
||||
class:icon-info={icon === 'info'}
|
||||
class:icon-exclamation={icon === 'exclamation'}
|
||||
class="u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
|
||||
class="u-cross-center u-line-height-1 u-icon-small u-color-text-gray"
|
||||
aria-hidden="true" />
|
||||
<span class="text u-line-height-1-5">
|
||||
Allowed characters: alphanumeric, non-leading hyphen, underscore, period
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
role="textbox"
|
||||
{id}
|
||||
aria-placeholder={placeholder}
|
||||
class="input-text is-resizable"
|
||||
class="input-text is-resizable"
|
||||
bind:textContent={value} />
|
||||
{:else}
|
||||
<input
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
<script lang="ts">
|
||||
import { DropList } from '$lib/components';
|
||||
import { onMount } from 'svelte';
|
||||
import { Label } from '.';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let name: string = 'elements';
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let showLabel = true;
|
||||
export let placeholder = '';
|
||||
export let required = false;
|
||||
export let disabled = false;
|
||||
export let autofocus = false;
|
||||
export let debounce = 250;
|
||||
export let options: {
|
||||
value: string | boolean | number;
|
||||
label: string;
|
||||
}[];
|
||||
// Input value
|
||||
export let search: string = null;
|
||||
// The actual selected value
|
||||
export let value: string | number | boolean;
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
let hasFocus = false;
|
||||
let selected: number = null;
|
||||
|
||||
$: if (!hasFocus) {
|
||||
selected = null;
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
element.focus();
|
||||
}
|
||||
});
|
||||
|
||||
function handleInput(event: Event) {
|
||||
hasFocus = true;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
const target = event.target as HTMLInputElement;
|
||||
search = target.value;
|
||||
}, debounce);
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
event.stopImmediatePropagation();
|
||||
|
||||
switch (event.key) {
|
||||
case 'Escape':
|
||||
hasFocus = false;
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
if (selected === null) {
|
||||
selected = 0;
|
||||
} else {
|
||||
selected = (selected + 1) % options.length;
|
||||
}
|
||||
break;
|
||||
case 'ArrowUp':
|
||||
if (selected === null) {
|
||||
selected = options.length - 1;
|
||||
} else {
|
||||
selected = (selected - 1 + options.length) % options.length;
|
||||
}
|
||||
break;
|
||||
case 'Enter':
|
||||
if (selected !== null) {
|
||||
event.preventDefault();
|
||||
value = options[selected].value;
|
||||
search = options[selected].label;
|
||||
hasFocus = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<li class="u-position-relative form-item u-stretch">
|
||||
<DropList
|
||||
bind:show={hasFocus}
|
||||
noStyle
|
||||
noArrow
|
||||
scrollable
|
||||
placement="bottom-end"
|
||||
position="static"
|
||||
fullWidth={true}
|
||||
fixed>
|
||||
<Label {required} {optionalText} hide={!showLabel} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
|
||||
<div class="custom-select">
|
||||
<div class="input-text-wrapper" style="--amount-of-buttons:2">
|
||||
<input
|
||||
type="text"
|
||||
class="input-text"
|
||||
{placeholder}
|
||||
{disabled}
|
||||
{required}
|
||||
bind:value={search}
|
||||
bind:this={element}
|
||||
on:focus={() => (hasFocus = true)}
|
||||
on:click={() => (hasFocus = true)}
|
||||
on:input={handleInput}
|
||||
on:keydown={handleKeydown} />
|
||||
|
||||
<div class="options-list">
|
||||
<button
|
||||
class="options-list-button"
|
||||
aria-label="clear field"
|
||||
type="button"
|
||||
on:click|preventDefault={() => {
|
||||
search = '';
|
||||
value = null;
|
||||
}}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
class="options-list-button"
|
||||
type="button"
|
||||
on:click={() => (hasFocus = !hasFocus)}>
|
||||
<span class="icon-cheveron-down" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<svelte:fragment slot="list">
|
||||
{#each options as option, i}
|
||||
<li class="drop-list-item">
|
||||
<button
|
||||
class="drop-button"
|
||||
class:is-selected={selected === i}
|
||||
type="button"
|
||||
on:click|preventDefault={() => {
|
||||
value = option.value;
|
||||
search = option.label;
|
||||
hasFocus = false;
|
||||
}}>
|
||||
<span class="text">{option.label}</span>
|
||||
</button>
|
||||
</li>
|
||||
{:else}
|
||||
<li class="drop-list-item">
|
||||
<span class="text">There are no {name} that match your search</span>
|
||||
</li>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</li>
|
||||
|
||||
<style>
|
||||
.form-item :global(.drop) {
|
||||
translate: 0 4px;
|
||||
}
|
||||
|
||||
.form-item :global(.drop-section) {
|
||||
width: 100%;
|
||||
margin-inline: initial;
|
||||
max-inline-size: initial;
|
||||
}
|
||||
</style>
|
||||
@@ -85,6 +85,7 @@
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{#if error}
|
||||
<Helper type="warning">{error}</Helper>
|
||||
{/if}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</label>
|
||||
|
||||
{#if optionalText}
|
||||
<span class="optional">{optionalText}</span>
|
||||
<span class="optional u-margin-inline-start-8">{optionalText}</span>
|
||||
{/if}
|
||||
|
||||
{#if tooltip}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<script lang="ts">
|
||||
export let id: string = null;
|
||||
export let text: string[] = [];
|
||||
</script>
|
||||
|
||||
<div class="u-flex u-cross-baseline u-gap-12">
|
||||
<span
|
||||
class="u-flex-basis-140 u-flex-shrink-0 u-text-start u-trim-start u-x-small u-color-text-gray"
|
||||
>{id}</span>
|
||||
<span class="u-flex-1 u-trim-1">
|
||||
{#each text as t, i}
|
||||
{t}{i < text.length - 1 ? ', ' : ''}
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
@@ -1,4 +1,3 @@
|
||||
<!-- TODO: is 100% height needed? -->
|
||||
<div class="table-with-scroll" data-private>
|
||||
<div class="table-wrapper">
|
||||
<div class="table is-remove-outer-styles">
|
||||
|
||||
@@ -6,8 +6,8 @@ export function intersection(arr1: unknown[], arr2: unknown[]) {
|
||||
|
||||
export function difference(arr1: unknown[], arr2: unknown[]) {
|
||||
const set = new Set(arr2);
|
||||
const intersection = new Set(arr1.filter((elem) => !set.has(elem)));
|
||||
return Array.from(intersection);
|
||||
const difference = new Set(arr1.filter((elem) => !set.has(elem)));
|
||||
return Array.from(difference);
|
||||
}
|
||||
|
||||
export function symmetricDifference(arr1: unknown[], arr2: unknown[]) {
|
||||
|
||||
@@ -20,3 +20,23 @@ export function capitalize(str: string): string {
|
||||
export function singular(str: string): string {
|
||||
return str.replace(/s$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a dash/underscore/space separated string to camelCase.
|
||||
*
|
||||
* @export
|
||||
* @param {string} str - The string to convert.
|
||||
* @returns {string} The camelized string.
|
||||
*/
|
||||
export function camelize(str: string): string {
|
||||
if (!str) {
|
||||
return '';
|
||||
}
|
||||
return str
|
||||
.replace(/[-_\s]+(.)?/g, (_, char: string) => {
|
||||
return char ? char.toUpperCase() : '';
|
||||
})
|
||||
.replace(/^(.)/, (firstChar) => {
|
||||
return firstChar.toLowerCase();
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { AvatarInitials, EmptySearch, Limit, Pagination, Trim } from '$lib/components';
|
||||
import { AvatarInitials, EmptySearch, PaginationWithLimit, Trim } from '$lib/components';
|
||||
import {
|
||||
TableBody,
|
||||
TableHeader,
|
||||
@@ -42,7 +42,7 @@
|
||||
<Trim>{log.userEmail}</Trim>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true" />
|
||||
</div>
|
||||
<span class="text u-trim">{log.userName ?? 'Anonymous'}</span>
|
||||
@@ -64,10 +64,8 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit {limit} sum={logs.total} name="Logs" />
|
||||
<Pagination {limit} {offset} sum={logs.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit name="Logs" {limit} {offset} total={logs.total} />
|
||||
{:else}
|
||||
<EmptySearch>
|
||||
<div class="u-flex u-flex-vertical u-cross-center">
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
<div class="pulse-notification" />
|
||||
</div>
|
||||
{/if}
|
||||
<DropList width="28" bind:show={showFeedback} scrollable={true}>
|
||||
<DropList bind:show={showFeedback} scrollable={true}>
|
||||
<button class="button is-small is-text" on:click={toggleFeedback}>
|
||||
<span class="text">Feedback</span>
|
||||
</button>
|
||||
|
||||
@@ -64,8 +64,8 @@
|
||||
{/if}
|
||||
|
||||
<slot />
|
||||
<slot name="footer" />
|
||||
</section>
|
||||
<slot name="footer" />
|
||||
</main>
|
||||
|
||||
<style lang="scss">
|
||||
@@ -92,8 +92,4 @@
|
||||
grid-template-columns: auto 1fr !important;
|
||||
}
|
||||
}
|
||||
|
||||
.main-content {
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
@@ -99,7 +99,7 @@
|
||||
|
||||
<slot name="header" />
|
||||
<button
|
||||
class="button is-text is-only-icon"
|
||||
class="button is-text is-only-icon u-margin-inline-start-auto"
|
||||
style="--button-size:1.5rem;"
|
||||
aria-label="close wizard"
|
||||
on:click={handleExit}>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show onSubmit={handleSubmit} warning>
|
||||
<Modal bind:show onSubmit={handleSubmit} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Exit Process</svelte:fragment>
|
||||
<p>
|
||||
Are you sure you want to exit from <slot />? All data will be deleted. This action is
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { writable, readable } from 'svelte/store';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { SvelteComponent } from 'svelte';
|
||||
|
||||
export type Tab = {
|
||||
@@ -11,6 +11,8 @@ export type Breadcrumb = {
|
||||
title: string;
|
||||
};
|
||||
|
||||
export type View = 'list' | 'grid';
|
||||
|
||||
export type updateLayoutArguments = {
|
||||
header?: typeof SvelteComponent;
|
||||
breadcrumb?: typeof SvelteComponent;
|
||||
@@ -23,6 +25,3 @@ export function updateLayout(args: updateLayoutArguments) {
|
||||
header.set(args.header ?? null);
|
||||
breadcrumb.set(args.breadcrumb ?? null);
|
||||
}
|
||||
|
||||
export const pageLimit = readable(12); // default page limit
|
||||
export const cardLimit = readable(6); // default card limit
|
||||
@@ -0,0 +1,20 @@
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { sdk } from './sdk';
|
||||
|
||||
export const teamPrefs = cachedStore<
|
||||
Models.Preferences,
|
||||
{
|
||||
load: (id: string) => Promise<void>;
|
||||
updatePrefs: (id: string, prefs: Models.Preferences) => Promise<void>;
|
||||
}
|
||||
>('teamPrefs', (store) => ({
|
||||
load: async (id: string) => {
|
||||
const prefs = await sdk.forConsole.teams.getPrefs(id);
|
||||
store.set(prefs);
|
||||
},
|
||||
updatePrefs: async (id: string, prefs: Models.Preferences) => {
|
||||
await sdk.forConsole.teams.updatePrefs(id, prefs);
|
||||
store.set(prefs);
|
||||
}
|
||||
}));
|
||||
@@ -1,8 +1,27 @@
|
||||
import { page } from '$app/stores';
|
||||
import { derived } from 'svelte/store';
|
||||
import { sdk } from './sdk';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export const user = derived(
|
||||
page,
|
||||
($page) => $page.data.account as Models.Account<Record<string, string>>
|
||||
);
|
||||
|
||||
export const prefs = cachedStore<
|
||||
Models.Preferences,
|
||||
{
|
||||
load: () => Promise<void>;
|
||||
updatePrefs: (prefs: Models.Preferences) => Promise<void>;
|
||||
}
|
||||
>('prefs', (store) => ({
|
||||
load: async () => {
|
||||
const prefs = await sdk.forConsole.account.getPrefs();
|
||||
store.set(prefs);
|
||||
},
|
||||
updatePrefs: async (prefs: Models.Preferences) => {
|
||||
await sdk.forConsole.account.updatePrefs(prefs);
|
||||
store.set(prefs);
|
||||
}
|
||||
}));
|
||||
@@ -10,14 +10,23 @@
|
||||
import { feedback } from '$lib/stores/app';
|
||||
import { log } from '$lib/stores/logs';
|
||||
import { newOrgModal } from '$lib/stores/organization';
|
||||
import { prefs } from '$lib/stores/user';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { onMount } from 'svelte';
|
||||
import { loading } from '../store';
|
||||
import Create from './createOrganization.svelte';
|
||||
|
||||
onMount(() => {
|
||||
onMount(async () => {
|
||||
loading.set(false);
|
||||
|
||||
await prefs.load();
|
||||
if (!$prefs?.preferredView) {
|
||||
prefs.updatePrefs({
|
||||
preferredView: 'grid',
|
||||
pageLimit: 6
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(() => {
|
||||
checkForFeedback(INTERVAL);
|
||||
}, INTERVAL);
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteAccount} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteAccount} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete Account</svelte:fragment>
|
||||
<p>Are you sure you want to delete your account?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
import {
|
||||
GridItem1,
|
||||
Empty,
|
||||
Pagination,
|
||||
AvatarGroup,
|
||||
CardContainer,
|
||||
Heading,
|
||||
Limit
|
||||
PaginationWithLimit
|
||||
} from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
@@ -51,7 +50,7 @@
|
||||
{organization.name}
|
||||
</svelte:fragment>
|
||||
{#await avatarList}
|
||||
<span class="avatar is-color-empty" />
|
||||
<span class="avatar is-color-empty" />
|
||||
{:then avatars}
|
||||
<AvatarGroup size={40} {avatars} />
|
||||
{/await}
|
||||
@@ -66,10 +65,12 @@
|
||||
<p>Create a new organization</p>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.organizations.total} name="Organizations" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.organizations.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Organizations"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.organizations.total} />
|
||||
</Container>
|
||||
|
||||
<CreateOrganization bind:show={addOrganization} />
|
||||
@@ -80,7 +80,7 @@
|
||||
{session.osVersion}
|
||||
</Trim>
|
||||
{:else}
|
||||
<span class="avatar is-color-empty" />
|
||||
<span class="avatar is-color-empty" />
|
||||
<p class="text u-trim">Unknown</p>
|
||||
{/if}
|
||||
<div class="is-only-desktop">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { GridItem1, Heading, Empty, CardContainer, Pagination, Limit } from '$lib/components';
|
||||
import { GridItem1, Heading, Empty, CardContainer, PaginationWithLimit } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import CreateProject from './createProject.svelte';
|
||||
@@ -94,10 +94,12 @@
|
||||
<p>Create a new project</p>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.projects.total} name="Projects" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.projects.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Projects"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.projects.total} />
|
||||
</Container>
|
||||
|
||||
<CreateOrganization bind:show={addOrganization} />
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
$: isUser = selectedMember?.userId === $user?.$id;
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">
|
||||
{isUser ? 'Leave Organization' : 'Delete Member'}
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal onSubmit={deleteOrg} bind:show={showDelete} warning>
|
||||
<Modal onSubmit={deleteOrg} bind:show={showDelete} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete Organization</svelte:fragment>
|
||||
<p>
|
||||
Are you sure you want to delete <b>{$organization.name}</b>? All projects ({$organization.total})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { AvatarInitials, Heading, Limit, Pagination } from '$lib/components';
|
||||
import { AvatarInitials, Heading, PaginationWithLimit } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
@@ -112,10 +112,12 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.members.total} name="Members" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.members.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Members"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.members.total} />
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
import {
|
||||
Empty,
|
||||
EmptySearch,
|
||||
Pagination,
|
||||
Copy,
|
||||
SearchQuery,
|
||||
AvatarInitials,
|
||||
Limit
|
||||
PaginationWithLimit
|
||||
} from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
@@ -63,12 +62,12 @@
|
||||
<AvatarInitials size={32} name={user.name} />
|
||||
<span class="text u-trim">{user.name}</span>
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-minus-sm" aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="avatar is-size-small ">
|
||||
<div class="avatar is-size-small">
|
||||
<span class="icon-anonymous" aria-hidden="true" />
|
||||
</div>
|
||||
<span class="text u-trim">{user.name}</span>
|
||||
@@ -110,10 +109,12 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.users.total} name="Users" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.users.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Users"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.users.total} />
|
||||
{:else if data.search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
type="radio"
|
||||
bind:group={isLimited}
|
||||
value={false} />
|
||||
<div class="choice-item-content u-cross-child-center">
|
||||
<div class="choice-item-content u-cross-child-center">
|
||||
<div class="choice-item-title">Unlimited</div>
|
||||
</div>
|
||||
<Pill>recommended</Pill>
|
||||
|
||||
@@ -14,9 +14,8 @@
|
||||
Empty,
|
||||
EmptySearch,
|
||||
AvatarInitials,
|
||||
Pagination,
|
||||
SearchQuery,
|
||||
Limit
|
||||
PaginationWithLimit
|
||||
} from '$lib/components';
|
||||
import Create from '../createTeam.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
@@ -68,10 +67,12 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.teams.total} name="Teams" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.teams.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Teams"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.teams.total} />
|
||||
{:else if data.search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete Member</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>{selectedMembership.userName}</b> from '{selectedMembership.teamName}'?
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteTeam} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteTeam} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete Team</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>{team.name}</b>?
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
Empty,
|
||||
EmptySearch,
|
||||
AvatarInitials,
|
||||
Pagination,
|
||||
SearchQuery,
|
||||
Limit
|
||||
PaginationWithLimit
|
||||
} from '$lib/components';
|
||||
import {
|
||||
Table,
|
||||
@@ -87,10 +86,12 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.memberships.total} name="Memberships" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.memberships.total} />
|
||||
</div>
|
||||
|
||||
<PaginationWithLimit
|
||||
name="Memberships"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.memberships.total} />
|
||||
{:else if data.search}
|
||||
<EmptySearch>
|
||||
<div class="u-text-center">
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDeleteAll} onSubmit={deleteAllSessions} warning>
|
||||
<Modal bind:show={showDeleteAll} onSubmit={deleteAllSessions} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete All Sessions</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>all of {$user.name}'s sessions?</b>
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete Member</svelte:fragment>
|
||||
{#if selectedMembership}
|
||||
<p data-private>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteSession} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteSession} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete Sessions</svelte:fragment>
|
||||
|
||||
<p>Are you sure you want to delete this session?</p>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteUser} warning>
|
||||
<Modal bind:show={showDelete} onSubmit={deleteUser} icon="exclamation" state="warning">
|
||||
<svelte:fragment slot="header">Delete User</svelte:fragment>
|
||||
<p data-private>Are you sure you want to delete <b>{$user.name}</b> from '{$project.name}'?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
<Container>
|
||||
{#if data.sessions.total}
|
||||
<div class="u-flex u-main-end common-section">
|
||||
<div class="u-flex u-main-end common-section">
|
||||
<Button secondary on:click={() => (showDeleteAll = true)}>
|
||||
<span class="text">Delete All</span>
|
||||
</Button>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Empty, Heading, Pagination, Limit, ViewSelector } from '$lib/components';
|
||||
import { Empty, Heading, ViewSelector, PaginationWithLimit } from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import { base } from '$app/paths';
|
||||
import Create from './create.svelte';
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
<Button on:click={() => (showCreate = true)} event="create_database">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create database</span>
|
||||
<span class="text is-only-desktop">Create database</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -44,10 +44,11 @@
|
||||
<Table {data} />
|
||||
{/if}
|
||||
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.databases.total} name="Databases" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.databases.total} />
|
||||
</div>
|
||||
<PaginationWithLimit
|
||||
name="Databases"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.databases.total} />
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
let name = '';
|
||||
let id: string = null;
|
||||
let showCustomId = false;
|
||||
let showCustomId = true;
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
@@ -58,7 +58,7 @@
|
||||
</span></Pill>
|
||||
</div>
|
||||
{:else}
|
||||
<CustomId bind:show={showCustomId} name="Database" bind:id />
|
||||
<CustomId bind:show={showCustomId} name="Database" bind:id autofocus={false} />
|
||||
{/if}
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Heading, Limit, Pagination, ViewSelector } from '$lib/components';
|
||||
import { Empty, Heading, PaginationWithLimit, ViewSelector } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { columns, showCreate } from './store';
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
<Button on:click={() => ($showCreate = true)} event="create_collection">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create collection</span>
|
||||
<span class="text is-only-desktop">Create collection</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -30,10 +30,11 @@
|
||||
<Table {data} />
|
||||
{/if}
|
||||
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.collections.total} name="Collections" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.collections.total} />
|
||||
</div>
|
||||
<PaginationWithLimit
|
||||
name="Collections"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.collections.total} />
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Query } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { getLimit, getPage, getView, pageToOffset, View } from '$lib/helpers/load';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
|
||||
export const load: PageLoad = async ({ params, url, route }) => {
|
||||
const page = getPage(url);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export type Column = {
|
||||
id: string;
|
||||
title: string;
|
||||
show: boolean;
|
||||
width?: number;
|
||||
};
|
||||
|
||||
export const columns = writable<Column[]>([
|
||||
{ id: '$id', title: 'Database ID', show: true, width: 50 },
|
||||
{ id: 'name', title: 'Name', show: true, width: 120 },
|
||||
{ id: '$createdAt', title: 'Created', show: true, width: 120 },
|
||||
{ id: '$updatedAt', title: 'Updated', show: true, width: 120 }
|
||||
]);
|
||||
+46
-14
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Heading, Pagination, Limit, ViewSelector } from '$lib/components';
|
||||
import { Empty, Heading, ViewSelector, PaginationWithLimit } from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
@@ -10,10 +10,13 @@
|
||||
import Table from './table.svelte';
|
||||
import { preferences } from '$lib/stores/preferences';
|
||||
import { page } from '$app/stores';
|
||||
import CreateAttributeDropdown from './attributes/createAttributeDropdown.svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showCreateAttribute = false;
|
||||
let showCreateDropdown = false;
|
||||
let selectedAttribute: string = null;
|
||||
|
||||
$: selected = preferences.getCustomCollectionColumns($page.params.collection);
|
||||
$: columns.set(
|
||||
@@ -28,6 +31,10 @@
|
||||
function openWizard() {
|
||||
wizard.start(Create);
|
||||
}
|
||||
|
||||
$: hasAttributes = !!$collection.attributes.length;
|
||||
|
||||
$: hasValidAttributes = $collection?.attributes?.some((attr) => attr.status === 'available');
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -36,23 +43,24 @@
|
||||
<div class="u-flex u-gap-16">
|
||||
<ViewSelector view={data.view} {columns} hideView isCustomCollection />
|
||||
<Button
|
||||
disabled={!$collection?.attributes?.length}
|
||||
disabled={!(hasAttributes && hasValidAttributes)}
|
||||
on:click={openWizard}
|
||||
event="create_document">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create document</span>
|
||||
<span class="text is-only-desktop">Create document</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{#if $collection?.attributes?.length}
|
||||
{#if hasAttributes && hasValidAttributes}
|
||||
{#if data.documents.total}
|
||||
<Table {data} />
|
||||
|
||||
<div class="u-flex common-section u-main-space-between">
|
||||
<Limit limit={data.limit} sum={data.documents.total} name="Documents" />
|
||||
<Pagination limit={data.limit} offset={data.offset} sum={data.documents.total} />
|
||||
</div>
|
||||
<PaginationWithLimit
|
||||
name="Documents"
|
||||
limit={data.limit}
|
||||
offset={data.offset}
|
||||
total={data.documents.total} />
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
@@ -61,12 +69,36 @@
|
||||
on:click={openWizard} />
|
||||
{/if}
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/databases#attributes"
|
||||
target="attribute"
|
||||
on:click={() => (showCreateAttribute = true)} />
|
||||
<Empty single target="attribute" on:click={() => (showCreateDropdown = true)}>
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2">Create your first attribute to get started.</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16 u-main-center">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/databases#attributes"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create {target}`}>Documentation</Button>
|
||||
<CreateAttributeDropdown
|
||||
bind:showCreateDropdown
|
||||
bind:showCreate={showCreateAttribute}
|
||||
bind:selectedOption={selectedAttribute}>
|
||||
<Button
|
||||
secondary
|
||||
event="create_attribute"
|
||||
on:click={() => {
|
||||
showCreateDropdown = !showCreateDropdown;
|
||||
}}>
|
||||
Create attribute
|
||||
</Button>
|
||||
</CreateAttributeDropdown>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<CreateAttribute bind:showCreate={showCreateAttribute} />
|
||||
<CreateAttribute bind:showCreate={showCreateAttribute} selectedOption={selectedAttribute} />
|
||||
+81
-28
@@ -1,28 +1,33 @@
|
||||
<script lang="ts">
|
||||
import { DropList, DropListItem, Empty, Heading } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableHeader,
|
||||
TableBody,
|
||||
TableRow,
|
||||
TableCell,
|
||||
TableCellHead,
|
||||
TableCellText,
|
||||
TableCell
|
||||
TableHeader,
|
||||
TableRow
|
||||
} from '$lib/elements/table';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { DropList, DropListItem, Empty, Heading } from '$lib/components';
|
||||
import { attributes, type Attributes } from '../store';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Pill } from '$lib/elements';
|
||||
import Create from '../createAttribute.svelte';
|
||||
import CreateIndex from '../indexes/createIndex.svelte';
|
||||
import { attributes, type Attributes } from '../store';
|
||||
import CreateAttributeDropdown from './createAttributeDropdown.svelte';
|
||||
import Delete from './deleteAttribute.svelte';
|
||||
import Overview from './overview.svelte';
|
||||
import Edit from './edit.svelte';
|
||||
import { options } from './store';
|
||||
|
||||
let showCreateDropdown = false;
|
||||
let showEmptyCreateDropdown = false;
|
||||
let showDropdown = [];
|
||||
let selectedOption: string = null;
|
||||
let selectedAttribute: Attributes = null;
|
||||
let showCreate = false;
|
||||
let showDelete = false;
|
||||
let showOverview = false;
|
||||
let showEdit = false;
|
||||
let showCreateIndex = false;
|
||||
</script>
|
||||
|
||||
@@ -30,10 +35,7 @@
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<Heading tag="h2" size="5">Attributes</Heading>
|
||||
|
||||
<Button on:click={() => (showCreate = true)} event="create_attribute">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create attribute</span>
|
||||
</Button>
|
||||
<CreateAttributeDropdown bind:showCreateDropdown bind:selectedOption bind:showCreate />
|
||||
</div>
|
||||
|
||||
{#if $attributes.length}
|
||||
@@ -46,10 +48,28 @@
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each $attributes as attribute, index}
|
||||
{@const option = options.find((option) => option.type === attribute.type)}
|
||||
<TableRow>
|
||||
<TableCell title="Key">
|
||||
<div class="u-flex u-main-space-between">
|
||||
<span class="text u-trim">{attribute.key}</span>
|
||||
<div class="u-flex u-main-space-between u-cross-center">
|
||||
<div class="u-flex u-cross-center u-gap-16">
|
||||
<div class="avatar is-size-small u-color-text-gray">
|
||||
{#if option.icon === 'relationship'}
|
||||
<span
|
||||
class={`icon-${
|
||||
attribute?.twoWay
|
||||
? 'switch-horizontal'
|
||||
: 'arrow-sm-right'
|
||||
}`}
|
||||
aria-hidden="true" />
|
||||
{:else}
|
||||
<span
|
||||
class={`icon-${option.icon}`}
|
||||
aria-hidden="true" />
|
||||
{/if}
|
||||
</div>
|
||||
<span class="text u-trim">{attribute.key}</span>
|
||||
</div>
|
||||
{#if attribute.status !== 'available'}
|
||||
<Pill
|
||||
warning={attribute.status === 'processing'}
|
||||
@@ -67,7 +87,9 @@
|
||||
{`${attribute.type}${attribute.array ? '[]' : ''}`}
|
||||
</TableCellText>
|
||||
<TableCellText onlyDesktop title="Default Value">
|
||||
{attribute.default !== null ? attribute.default : '-'}
|
||||
{attribute?.default !== null && attribute?.default !== undefined
|
||||
? attribute?.default
|
||||
: '-'}
|
||||
</TableCellText>
|
||||
<TableCell showOverflow>
|
||||
<DropList
|
||||
@@ -84,25 +106,32 @@
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem
|
||||
icon="eye"
|
||||
icon="pencil"
|
||||
on:click={() => {
|
||||
selectedAttribute = attribute;
|
||||
showOverview = true;
|
||||
showEdit = true;
|
||||
showDropdown[index] = false;
|
||||
}}>Overview</DropListItem>
|
||||
}}>
|
||||
Edit
|
||||
</DropListItem>
|
||||
|
||||
<DropListItem
|
||||
icon="plus"
|
||||
on:click={() => {
|
||||
selectedAttribute = attribute;
|
||||
showCreateIndex = true;
|
||||
showDropdown[index] = false;
|
||||
}}>Create Index</DropListItem>
|
||||
}}>
|
||||
Create Index
|
||||
</DropListItem>
|
||||
<DropListItem
|
||||
icon="trash"
|
||||
on:click={() => {
|
||||
selectedAttribute = attribute;
|
||||
showDelete = true;
|
||||
}}>Delete</DropListItem>
|
||||
}}>
|
||||
Delete
|
||||
</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</TableCell>
|
||||
@@ -114,15 +143,39 @@
|
||||
<p class="text">Total results: {$attributes.length}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
href="https://appwrite.io/docs/databases#attributes"
|
||||
target="attribute"
|
||||
on:click={() => (showCreate = true)} />
|
||||
<Empty single target="attribute" on:click={() => (showEmptyCreateDropdown = true)}>
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2">Create your first attribute to get started.</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16 u-main-center">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/databases#attributes"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create {target}`}>Documentation</Button>
|
||||
<CreateAttributeDropdown
|
||||
bind:showCreateDropdown={showEmptyCreateDropdown}
|
||||
bind:selectedOption
|
||||
bind:showCreate>
|
||||
<Button
|
||||
secondary
|
||||
event="create_attribute"
|
||||
on:click={() => {
|
||||
showEmptyCreateDropdown = !showEmptyCreateDropdown;
|
||||
}}>
|
||||
Create attribute
|
||||
</Button>
|
||||
</CreateAttributeDropdown>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<Create bind:showCreate />
|
||||
<Create bind:showCreate bind:selectedOption />
|
||||
<Delete bind:showDelete {selectedAttribute} />
|
||||
<Overview bind:showOverview {selectedAttribute} />
|
||||
<Edit bind:showEdit {selectedAttribute} />
|
||||
<CreateIndex bind:showCreateIndex externalAttribute={selectedAttribute} />
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<svg width="55" height="9" viewBox="0 0 55 9" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M54.8536 4.85355C55.0488 4.65829 55.0488 4.34171 54.8536 4.14645L51.6716 0.964466C51.4763 0.769204 51.1597 0.769204 50.9645 0.964466C50.7692 1.15973 50.7692 1.47631 50.9645 1.67157L53.7929 4.5L50.9645 7.32843C50.7692 7.52369 50.7692 7.84027 50.9645 8.03553C51.1597 8.2308 51.4763 8.2308 51.6716 8.03553L54.8536 4.85355ZM0.5 5H54.5V4H0.5V5Z" fill="#868EA3"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 468 B |
+4
@@ -0,0 +1,4 @@
|
||||
<svg width="56" height="21" viewBox="0 0 56 21" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M55.3536 4.85355C55.5488 4.65829 55.5488 4.34171 55.3536 4.14645L52.1716 0.964466C51.9763 0.769204 51.6597 0.769204 51.4645 0.964466C51.2692 1.15973 51.2692 1.47631 51.4645 1.67157L54.2929 4.5L51.4645 7.32843C51.2692 7.52369 51.2692 7.84027 51.4645 8.03553C51.6597 8.2308 51.9763 8.2308 52.1716 8.03553L55.3536 4.85355ZM1 5H55V4H1V5Z" fill="#868EA3"/>
|
||||
<path d="M0.646442 16.8536C0.45118 16.6583 0.45118 16.3417 0.646442 16.1464L3.82842 12.9645C4.02369 12.7692 4.34027 12.7692 4.53553 12.9645C4.73079 13.1597 4.73079 13.4763 4.53553 13.6716L1.7071 16.5L4.53553 19.3284C4.73079 19.5237 4.73079 19.8403 4.53553 20.0355C4.34027 20.2308 4.02369 20.2308 3.82842 20.0355L0.646442 16.8536ZM55 17H0.999996V16H55V17Z" fill="#868EA3"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 837 B |
+19
-19
@@ -17,24 +17,32 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
export async function updateBoolean(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
|
||||
data: Partial<Models.AttributeBoolean>
|
||||
) {
|
||||
await sdk.forProject.databases.updateBooleanAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputChoice, InputSelect } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeBoolean = null;
|
||||
export let editing = false;
|
||||
export let data: Partial<Models.AttributeBoolean> = {
|
||||
required: false,
|
||||
array: false,
|
||||
default: null
|
||||
};
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
data.required = selectedAttribute.required;
|
||||
data.array = selectedAttribute.array;
|
||||
data.default = selectedAttribute.default;
|
||||
}
|
||||
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -45,23 +53,15 @@
|
||||
label="Default value"
|
||||
placeholder="Select a value"
|
||||
options={[
|
||||
{ label: 'Select a value', value: null },
|
||||
{ label: 'NULL', value: null },
|
||||
{ label: 'True', value: true },
|
||||
{ label: 'False', value: false }
|
||||
]}
|
||||
bind:value={data.default}
|
||||
disabled={!!selectedAttribute || data.array || data.required} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
disabled={data.array || data.required} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { DropList, DropListItem } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { options } from './store';
|
||||
|
||||
export let showCreateDropdown = false;
|
||||
|
||||
export let selectedOption: string = null;
|
||||
export let showCreate = false;
|
||||
</script>
|
||||
|
||||
<DropList bind:show={showCreateDropdown} scrollable>
|
||||
<slot>
|
||||
<Button
|
||||
on:click={() => (showCreateDropdown = !showCreateDropdown)}
|
||||
event="create_attribute">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create attribute</span>
|
||||
</Button>
|
||||
</slot>
|
||||
<svelte:fragment slot="list">
|
||||
{#each options as attribute}
|
||||
<DropListItem
|
||||
icon={attribute.icon}
|
||||
on:click={() => {
|
||||
selectedOption = attribute.name;
|
||||
showCreateDropdown = false;
|
||||
showCreate = true;
|
||||
}}>
|
||||
{attribute.name}
|
||||
</DropListItem>
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
+18
-15
@@ -17,20 +17,28 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateDatetime(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeDatetime>
|
||||
) {
|
||||
await sdk.forProject.databases.updateDatetimeAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputChoice, InputDateTime } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeDatetime = null;
|
||||
export let editing = false;
|
||||
export let data: Partial<Models.AttributeDatetime>;
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
data.required = selectedAttribute.required;
|
||||
data.array = selectedAttribute.array;
|
||||
data.default = selectedAttribute.default;
|
||||
}
|
||||
|
||||
$: if (data.required) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -40,15 +48,10 @@
|
||||
id="default"
|
||||
label="Default value"
|
||||
bind:value={data.default}
|
||||
disabled={data.required}
|
||||
readonly={!!selectedAttribute} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute}>
|
||||
disabled={data.required} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={!!selectedAttribute}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+26
-4
@@ -3,7 +3,7 @@
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Button, InputChoice } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { collection } from '../store';
|
||||
import type { Attributes } from '../store';
|
||||
@@ -14,6 +14,7 @@
|
||||
export let showDelete = false;
|
||||
export let selectedAttribute: Attributes;
|
||||
const databaseId = $page.params.database;
|
||||
let checked = selectedAttribute?.type !== 'relationship';
|
||||
|
||||
async function handleDelete() {
|
||||
try {
|
||||
@@ -40,15 +41,36 @@
|
||||
trackError(error, Submit.AttributeDelete);
|
||||
}
|
||||
}
|
||||
|
||||
$: isDeleteBtnDisabled =
|
||||
selectedAttribute?.type === 'relationship' && selectedAttribute?.twoWay && !checked;
|
||||
</script>
|
||||
|
||||
<Modal warning={true} bind:show={showDelete} onSubmit={handleDelete}>
|
||||
<Modal
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}>
|
||||
<svelte:fragment slot="header">Delete Attribute</svelte:fragment>
|
||||
<p data-private>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to delete <b>'{selectedAttribute?.key}' from {$collection?.name}</b>?
|
||||
</p>
|
||||
{#if selectedAttribute?.type === 'relationship' && selectedAttribute?.twoWay}
|
||||
<div class="u-flex u-flex-vertical u-gap-24">
|
||||
<p class="text">
|
||||
Are you sure you want to delete reviews from Movie? This is a two way relationship
|
||||
and the corresponding relationship will also be deleted.
|
||||
</p>
|
||||
<p class="text"><b>This action is irreversible.</b></p>
|
||||
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
|
||||
Delete relationship between {selectedAttribute.key} to {selectedAttribute.twoWayKey}
|
||||
</InputChoice>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
<Button disabled={isDeleteBtnDisabled} secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<script lang="ts">
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import type { Attributes } from '../store';
|
||||
import { options, type Option } from './store';
|
||||
|
||||
export let showEdit = false;
|
||||
export let selectedAttribute: Attributes;
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
|
||||
let updateButtonDisabled = true;
|
||||
let error: string;
|
||||
let currentAttr: string;
|
||||
|
||||
$: option = options.find((option) => option?.type === selectedAttribute?.type) as Option;
|
||||
|
||||
async function submit() {
|
||||
try {
|
||||
await option.update(databaseId, collectionId, selectedAttribute);
|
||||
await Promise.allSettled([invalidate(Dependencies.COLLECTION)]);
|
||||
if (!$page.url.pathname.includes('attributes')) {
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/databases/database-${databaseId}/collection-${collectionId}/attributes`
|
||||
);
|
||||
}
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Attribute ${selectedAttribute.key} has been created`
|
||||
});
|
||||
showEdit = false;
|
||||
trackEvent(Submit.AttributeUpdate);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.AttributeUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
$: updateButtonDisabled = JSON.stringify(selectedAttribute) === currentAttr;
|
||||
|
||||
$: if (showEdit) {
|
||||
currentAttr ??= JSON.stringify(selectedAttribute);
|
||||
error = null;
|
||||
}
|
||||
|
||||
$: console.log(selectedAttribute, currentAttr);
|
||||
</script>
|
||||
|
||||
{#if selectedAttribute}
|
||||
<Modal {error} size="big" bind:show={showEdit} onSubmit={submit} icon={option?.icon}>
|
||||
<svelte:fragment slot="header">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
{option?.name}
|
||||
{#if option.type === 'relationship'}
|
||||
<div class="tag eyebrow-heading-3">
|
||||
<span class="text u-x-small">Beta</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
<FormList>
|
||||
{#if selectedAttribute?.type !== 'relationship'}
|
||||
<div>
|
||||
<InputText
|
||||
id="key"
|
||||
label="Attribute Key"
|
||||
placeholder="Enter Key"
|
||||
bind:value={selectedAttribute.key}
|
||||
autofocus
|
||||
required
|
||||
disabled />
|
||||
|
||||
<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>
|
||||
{/if}
|
||||
<svelte:component
|
||||
this={option.component}
|
||||
bind:data={selectedAttribute}
|
||||
editing
|
||||
on:close={() => (option = null)} />
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (showEdit = false)}>Cancel</Button>
|
||||
<Button submit disabled={updateButtonDisabled}>Update</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
{/if}
|
||||
+19
-19
@@ -18,20 +18,28 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateEmail(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeEmail>
|
||||
) {
|
||||
await sdk.forProject.databases.updateEmailAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputChoice, InputEmail } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeEmail = null;
|
||||
export let editing = false;
|
||||
export let data: Partial<Models.AttributeEmail>;
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
data.required = selectedAttribute.required;
|
||||
data.array = selectedAttribute.array;
|
||||
data.default = selectedAttribute.default;
|
||||
}
|
||||
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -40,20 +48,12 @@
|
||||
<InputEmail
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
bind:value={data.default}
|
||||
disabled={data.required}
|
||||
readonly={!!selectedAttribute} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
disabled={data.required} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+20
-22
@@ -18,12 +18,27 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateEnum(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeEnum>
|
||||
) {
|
||||
await sdk.forProject.databases.updateEnumAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.elements,
|
||||
data.required,
|
||||
data.default ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputChoice, InputSelect, InputTags } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeEnum;
|
||||
export let editing = false;
|
||||
export let data: Partial<Models.AttributeEnum>;
|
||||
|
||||
$: options =
|
||||
@@ -32,15 +47,6 @@
|
||||
label: e
|
||||
})) ?? [];
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
({
|
||||
required: data.required,
|
||||
array: data.array,
|
||||
elements: data.elements,
|
||||
default: data.default
|
||||
} = selectedAttribute);
|
||||
}
|
||||
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -51,25 +57,17 @@
|
||||
label="Elements"
|
||||
bind:tags={data.elements}
|
||||
placeholder="Add elements here"
|
||||
readonly={!!selectedAttribute}
|
||||
required />
|
||||
<InputSelect
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Select value"
|
||||
bind:options
|
||||
bind:value={data.default}
|
||||
disabled={!!selectedAttribute || data.required} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
disabled={data.required} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+22
-24
@@ -19,12 +19,28 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateFloat(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeFloat>
|
||||
) {
|
||||
await sdk.forProject.databases.updateFloatAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.min,
|
||||
data.max,
|
||||
typeof data.default === 'number' ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputNumber, InputChoice } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeFloat;
|
||||
export let editing = false;
|
||||
export let data: Partial<Models.AttributeFloat> = {
|
||||
required: false,
|
||||
min: 0,
|
||||
@@ -33,44 +49,26 @@
|
||||
array: false
|
||||
};
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
({
|
||||
required: data.required,
|
||||
array: data.array,
|
||||
min: data.min,
|
||||
max: data.max
|
||||
} = selectedAttribute);
|
||||
data.default = selectedAttribute.default;
|
||||
}
|
||||
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<InputNumber id="min" label="Min" bind:value={data.min} readonly={!!selectedAttribute} />
|
||||
<InputNumber id="max" label="Max" bind:value={data.max} readonly={!!selectedAttribute} />
|
||||
<InputNumber id="min" label="Min" placeholder="Enter size" bind:value={data.min} />
|
||||
<InputNumber id="max" label="Max" placeholder="Enter size" bind:value={data.max} />
|
||||
|
||||
<InputNumber
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
min={data.min}
|
||||
max={data.max}
|
||||
bind:value={data.default}
|
||||
disabled={data.required || data.array}
|
||||
readonly={!!selectedAttribute}
|
||||
step="any" />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+23
-24
@@ -19,12 +19,27 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateInteger(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeInteger>
|
||||
) {
|
||||
await sdk.forProject.databases.updateIntegerAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.min,
|
||||
data.max,
|
||||
typeof data.default === 'number' ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputNumber, InputChoice } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeInteger;
|
||||
export let data: Partial<Models.AttributeInteger> = {
|
||||
required: false,
|
||||
min: 0,
|
||||
@@ -32,43 +47,27 @@
|
||||
default: 0,
|
||||
array: false
|
||||
};
|
||||
export let editing = false;
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
({
|
||||
required: data.required,
|
||||
array: data.array,
|
||||
min: data.min,
|
||||
max: data.max,
|
||||
default: data.default
|
||||
} = selectedAttribute);
|
||||
}
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<InputNumber id="min" label="Min" bind:value={data.min} readonly={!!selectedAttribute} />
|
||||
<InputNumber id="max" label="Max" bind:value={data.max} readonly={!!selectedAttribute} />
|
||||
<InputNumber id="min" label="Min" placeholder="Enter size" bind:value={data.min} />
|
||||
<InputNumber id="max" label="Max" placeholder="Enter size" bind:value={data.max} />
|
||||
|
||||
<InputNumber
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
min={data.min}
|
||||
max={data.max}
|
||||
bind:value={data.default}
|
||||
disabled={data.required || data.array}
|
||||
readonly={!!selectedAttribute} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
disabled={data.required || data.array} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+18
-16
@@ -17,17 +17,27 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
export async function updateIp(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeIp>
|
||||
) {
|
||||
await sdk.forProject.databases.updateIpAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputText, InputChoice } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeIp;
|
||||
export let editing = false;
|
||||
export let data: Partial<Models.AttributeIp>;
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
({ required: data.required, array: data.array, default: data.default } = selectedAttribute);
|
||||
}
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -36,20 +46,12 @@
|
||||
<InputText
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
bind:value={data.default}
|
||||
disabled={data.required || data.array}
|
||||
readonly={!!selectedAttribute} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
disabled={data.required || data.array} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { InputText, FormList, InputChoice, InputTags } from '$lib/elements/forms';
|
||||
import type { Attributes } from '../store';
|
||||
|
||||
export let showOverview = false;
|
||||
export let selectedAttribute: Attributes;
|
||||
|
||||
$: attr = selectedAttribute as {
|
||||
type?: string;
|
||||
size?: string;
|
||||
format?: string;
|
||||
array?: boolean;
|
||||
required?: boolean;
|
||||
status?: string;
|
||||
key?: string;
|
||||
min?: string;
|
||||
max?: string;
|
||||
default: string;
|
||||
elements?: string[];
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal size="big" bind:show={showOverview}>
|
||||
<svelte:fragment slot="header">Overview</svelte:fragment>
|
||||
<FormList>
|
||||
{#if attr}
|
||||
<InputText
|
||||
id="ID"
|
||||
label="Attribute ID"
|
||||
placeholder="Enter ID"
|
||||
bind:value={attr.key}
|
||||
disabled />
|
||||
<InputText id="type" label="Type" value={attr.type ?? ''} readonly />
|
||||
{#if attr.size}
|
||||
<InputText id="size" label="Size" value={attr.size} readonly />
|
||||
{/if}
|
||||
{#if attr.format}
|
||||
<InputText id="format" label="Format" value={attr.format} readonly />
|
||||
{/if}
|
||||
{#if attr.min}
|
||||
<InputText id="min" label="Min" value={attr.min ?? ''} readonly />
|
||||
{/if}
|
||||
{#if attr.max}
|
||||
<InputText id="max" label="Max" value={attr.max ?? ''} readonly />
|
||||
{/if}
|
||||
{#if attr.elements}
|
||||
<InputTags id="elements" label="Elements" tags={attr.elements} readonly />
|
||||
{/if}
|
||||
<InputText id="default" label="Default value" value={attr.default} readonly />
|
||||
<InputChoice id="required" label="Required" value={attr.required} disabled>
|
||||
Indicate whether this is a required attribute</InputChoice>
|
||||
<InputChoice id="array" label="Array" value={attr.array} disabled>
|
||||
Indicate whether this attribute should act as an array</InputChoice>
|
||||
{/if}
|
||||
</FormList>
|
||||
</Modal>
|
||||
+221
@@ -0,0 +1,221 @@
|
||||
<script context="module" lang="ts">
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
|
||||
export async function submitRelationship(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
_: string,
|
||||
data: Partial<Models.AttributeRelationship>
|
||||
) {
|
||||
await sdk.forProject.databases.createRelationshipAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.relatedCollection,
|
||||
data.relationType,
|
||||
data.twoWay,
|
||||
data.key,
|
||||
data.twoWayKey,
|
||||
data.onDelete
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateRelationship(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeRelationship>
|
||||
) {
|
||||
await sdk.forProject.databases.updateRelationshipAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.twoWay,
|
||||
data.onDelete
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputText, InputSelect, InputSelectSearch } from '$lib/elements/forms';
|
||||
import { onMount } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { LabelCard } from '$lib/components';
|
||||
import { collection } from '../store';
|
||||
import arrowOne from './arrow-one.svg';
|
||||
import arrowTwo from './arrow-two.svg';
|
||||
import { camelize } from '$lib/helpers/string';
|
||||
|
||||
// Props
|
||||
export let data: Partial<Models.AttributeRelationship>;
|
||||
export let editing = false;
|
||||
|
||||
// Constants
|
||||
const databaseId = $page.params.database;
|
||||
const oneWay = [
|
||||
{ value: 'oneToOne', label: 'One to one' },
|
||||
{ value: 'oneToMany', label: 'One to many' }
|
||||
];
|
||||
const twoWay = [
|
||||
...oneWay,
|
||||
{ value: 'manyToOne', label: 'Many to one' },
|
||||
{ value: 'manyToMany', label: 'Many to many' }
|
||||
];
|
||||
|
||||
const deleteOptions = [
|
||||
{ value: 'setNull', label: 'Null' },
|
||||
{ value: 'cascade', label: 'Cascade' },
|
||||
{ value: 'restrict', label: 'Restrict' }
|
||||
];
|
||||
|
||||
// Variables
|
||||
let search: string = null;
|
||||
let collectionList: Models.CollectionList;
|
||||
let way = 'one';
|
||||
|
||||
// Lifecycle hooks
|
||||
async function getCollections(search: string = null) {
|
||||
if (search) {
|
||||
const collections = await sdk.forProject.databases.listCollections(
|
||||
databaseId,
|
||||
[Query.orderDesc('$createdAt')],
|
||||
search
|
||||
);
|
||||
return collections;
|
||||
} else {
|
||||
const collections = await sdk.forProject.databases.listCollections(databaseId);
|
||||
return collections;
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
collectionList = await getCollections();
|
||||
|
||||
if (editing) {
|
||||
way = data.twoWay ? 'two' : 'one';
|
||||
search = data.relatedCollection;
|
||||
}
|
||||
});
|
||||
|
||||
// Reactive statements
|
||||
|
||||
$: getCollections(search).then((res) => (collectionList = res));
|
||||
$: collections = collectionList?.collections?.filter((n) => n.$id !== $collection.$id) ?? [];
|
||||
|
||||
$: if (data?.relatedCollection && !data.key) {
|
||||
const collection = collectionList.collections.find((n) => n.$id === data.relatedCollection);
|
||||
data.key = camelize(collection.name);
|
||||
}
|
||||
$: if (way === 'two' && !data.twoWayKey) {
|
||||
data.twoWayKey = camelize($collection.name);
|
||||
}
|
||||
|
||||
$: if (way === 'two') {
|
||||
data.twoWay = true;
|
||||
} else {
|
||||
data.twoWay = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<li>
|
||||
<ul
|
||||
class="grid-box"
|
||||
style="--p-grid-item-size:16em; --p-grid-item-size-small-screens:16rem; --grid-gap: 0.5rem;">
|
||||
<li>
|
||||
<LabelCard name="relationship" bind:group={way} value="one" icon="arrow-sm-right">
|
||||
<svelte:fragment slot="title">One-way relationship</svelte:fragment>
|
||||
One Relation attribute within this collection
|
||||
</LabelCard>
|
||||
</li>
|
||||
<li>
|
||||
<LabelCard name="relationship" bind:group={way} value="two" icon="switch-horizontal">
|
||||
<svelte:fragment slot="title">Two-way relationship</svelte:fragment>
|
||||
One Relation attribute within this collection and another within the related collection
|
||||
</LabelCard>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
<InputSelectSearch
|
||||
id="related"
|
||||
label="Related Collection"
|
||||
name="collections"
|
||||
bind:search
|
||||
bind:value={data.relatedCollection}
|
||||
required
|
||||
placeholder="Select a collection"
|
||||
disabled={editing}
|
||||
options={collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} />
|
||||
|
||||
{#if data?.relatedCollection}
|
||||
<div>
|
||||
<InputText
|
||||
id="key"
|
||||
label="Attribute Key"
|
||||
placeholder="Enter Key"
|
||||
bind:value={data.key}
|
||||
autofocus
|
||||
required />
|
||||
|
||||
<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>
|
||||
{#if way === 'two'}
|
||||
<div>
|
||||
<InputText
|
||||
id="keyRelated"
|
||||
label="Attribute Key "
|
||||
placeholder="Enter Key"
|
||||
bind:value={data.twoWayKey}
|
||||
required
|
||||
disabled={editing} />
|
||||
|
||||
<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>
|
||||
{/if}
|
||||
|
||||
<InputSelect
|
||||
id="relationship"
|
||||
label="Relation"
|
||||
bind:value={data.relationType}
|
||||
required
|
||||
placeholder="Select a relation"
|
||||
options={data?.twoWay ? twoWay : oneWay}
|
||||
disabled={editing} />
|
||||
|
||||
<div class="box">
|
||||
<div class="u-flex u-align u-cross-center u-main-center u-gap-32">
|
||||
<span>{camelize($collection.name)}</span>
|
||||
{#if way === 'one'}
|
||||
<img src={arrowOne} alt={'One way realationship'} />
|
||||
{:else}
|
||||
<img src={arrowTwo} alt={'Two way relationship'} />
|
||||
{/if}
|
||||
<span>{data.key}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="u-text-center">
|
||||
<b> {camelize($collection.name)}</b> has {way === 'one' ? 'one' : 'many'}
|
||||
<b>{data.key}</b>
|
||||
</p>
|
||||
|
||||
<InputSelect
|
||||
id="deleting"
|
||||
label="On deleting a document"
|
||||
bind:value={data.onDelete}
|
||||
required
|
||||
placeholder="Select a deletion method"
|
||||
options={deleteOptions} />
|
||||
{/if}
|
||||
+51
-21
@@ -1,27 +1,30 @@
|
||||
import type { SvelteComponent } from 'svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import Boolean, { submitBoolean } from './boolean.svelte';
|
||||
import Email, { submitEmail } from './email.svelte';
|
||||
import Enum, { submitEnum } from './enum.svelte';
|
||||
import Float, { submitFloat } from './float.svelte';
|
||||
import Integer, { submitInteger } from './integer.svelte';
|
||||
import Ip, { submitIp } from './ip.svelte';
|
||||
import String, { submitString } from './string.svelte';
|
||||
import Url, { submitUrl } from './url.svelte';
|
||||
import Datetime, { submitDatetime } from './datetime.svelte';
|
||||
import Boolean, { submitBoolean, updateBoolean } from './boolean.svelte';
|
||||
import Email, { submitEmail, updateEmail } from './email.svelte';
|
||||
import Enum, { submitEnum, updateEnum } from './enum.svelte';
|
||||
import Float, { submitFloat, updateFloat } from './float.svelte';
|
||||
import Integer, { submitInteger, updateInteger } from './integer.svelte';
|
||||
import Ip, { submitIp, updateIp } from './ip.svelte';
|
||||
import String, { submitString, updateString } from './string.svelte';
|
||||
import Url, { submitUrl, updateUrl } from './url.svelte';
|
||||
import Datetime, { submitDatetime, updateDatetime } from './datetime.svelte';
|
||||
import type { Attributes } from '../store';
|
||||
import Relationship, { submitRelationship, updateRelationship } from './relationship.svelte';
|
||||
|
||||
export type Option = {
|
||||
name: string;
|
||||
component: typeof SvelteComponent;
|
||||
type: 'string' | 'integer' | 'double' | 'boolean' | 'datetime';
|
||||
func: (
|
||||
type: 'string' | 'integer' | 'double' | 'boolean' | 'datetime' | 'relationship';
|
||||
create: (
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
key: string,
|
||||
data: Partial<Attributes>
|
||||
) => Promise<void>;
|
||||
format?: 'email' | 'ip' | 'url' | 'enum';
|
||||
update: (databaseId: string, collectionId: string, data: Partial<Attributes>) => Promise<void>;
|
||||
format?: 'email' | 'ip' | 'url' | 'enum' | 'relationship';
|
||||
icon: string;
|
||||
};
|
||||
|
||||
export const options: Option[] = [
|
||||
@@ -29,59 +32,86 @@ export const options: Option[] = [
|
||||
name: 'String',
|
||||
component: String,
|
||||
type: 'string',
|
||||
func: submitString
|
||||
create: submitString,
|
||||
update: updateString,
|
||||
icon: 'text'
|
||||
},
|
||||
{
|
||||
name: 'Integer',
|
||||
component: Integer,
|
||||
type: 'integer',
|
||||
func: submitInteger
|
||||
create: submitInteger,
|
||||
update: updateInteger,
|
||||
icon: 'hashtag'
|
||||
},
|
||||
{
|
||||
name: 'Float',
|
||||
component: Float,
|
||||
type: 'double',
|
||||
func: submitFloat
|
||||
create: submitFloat,
|
||||
update: updateFloat,
|
||||
icon: 'hashtag'
|
||||
},
|
||||
{
|
||||
name: 'Boolean',
|
||||
component: Boolean,
|
||||
type: 'boolean',
|
||||
func: submitBoolean
|
||||
create: submitBoolean,
|
||||
update: updateBoolean,
|
||||
icon: 'toggle'
|
||||
},
|
||||
{
|
||||
name: 'Datetime',
|
||||
component: Datetime,
|
||||
type: 'datetime',
|
||||
func: submitDatetime
|
||||
create: submitDatetime,
|
||||
update: updateDatetime,
|
||||
icon: 'calendar'
|
||||
},
|
||||
{
|
||||
name: 'Email',
|
||||
component: Email,
|
||||
type: 'string',
|
||||
format: 'email',
|
||||
func: submitEmail
|
||||
create: submitEmail,
|
||||
update: updateEmail,
|
||||
icon: 'mail'
|
||||
},
|
||||
{
|
||||
name: 'IP',
|
||||
component: Ip,
|
||||
type: 'string',
|
||||
format: 'ip',
|
||||
func: submitIp
|
||||
create: submitIp,
|
||||
update: updateIp,
|
||||
icon: 'location-marker'
|
||||
},
|
||||
{
|
||||
name: 'URL',
|
||||
component: Url,
|
||||
type: 'string',
|
||||
format: 'url',
|
||||
func: submitUrl
|
||||
create: submitUrl,
|
||||
update: updateUrl,
|
||||
icon: 'link'
|
||||
},
|
||||
{
|
||||
name: 'Enum',
|
||||
component: Enum,
|
||||
type: 'string',
|
||||
format: 'enum',
|
||||
func: submitEnum
|
||||
create: submitEnum,
|
||||
update: updateEnum,
|
||||
icon: 'list'
|
||||
},
|
||||
{
|
||||
name: 'Relationship',
|
||||
component: Relationship,
|
||||
type: 'relationship',
|
||||
format: 'relationship',
|
||||
create: submitRelationship,
|
||||
update: updateRelationship,
|
||||
icon: 'relationship'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
+24
-25
@@ -18,28 +18,34 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
export async function updateString(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeString>
|
||||
) {
|
||||
console.log(data);
|
||||
await sdk.forProject.databases.updateStringAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
(data.default as string) || undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputNumber, InputText, InputChoice } from '$lib/elements/forms';
|
||||
import InputTextarea from '$lib/elements/forms/inputTextarea.svelte';
|
||||
|
||||
export let selectedAttribute: Models.AttributeString;
|
||||
export let data: Partial<Models.AttributeString> = {
|
||||
required: false,
|
||||
size: 0,
|
||||
default: null,
|
||||
array: false
|
||||
};
|
||||
export let editing = false;
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
({
|
||||
required: data.required,
|
||||
array: data.array,
|
||||
size: data.size,
|
||||
default: data.default
|
||||
} = selectedAttribute);
|
||||
}
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -48,37 +54,30 @@
|
||||
<InputNumber
|
||||
id="size"
|
||||
label="Size"
|
||||
placeholder="Enter size"
|
||||
bind:value={data.size}
|
||||
required
|
||||
readonly={!!selectedAttribute} />
|
||||
{#if data.size > 64}
|
||||
readonly={editing} />
|
||||
{#if data.size > 50}
|
||||
<InputTextarea
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
bind:value={data.default}
|
||||
maxlength={data.size}
|
||||
disabled={data.required || data.array}
|
||||
readonly={!!selectedAttribute} />
|
||||
disabled={data.required || data.array} />
|
||||
{:else}
|
||||
<InputText
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
bind:value={data.default}
|
||||
maxlength={data.size}
|
||||
disabled={data.required || data.array}
|
||||
readonly={!!selectedAttribute} />
|
||||
disabled={data.required || data.array} />
|
||||
{/if}
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+19
-16
@@ -17,17 +17,28 @@
|
||||
data.array
|
||||
);
|
||||
}
|
||||
|
||||
export async function updateUrl(
|
||||
databaseId: string,
|
||||
collectionId: string,
|
||||
data: Partial<Models.AttributeUrl>
|
||||
) {
|
||||
await sdk.forProject.databases.updateUrlAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
data.key,
|
||||
data.required,
|
||||
data.default ? data.default : undefined
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { InputText, InputChoice } from '$lib/elements/forms';
|
||||
|
||||
export let selectedAttribute: Models.AttributeUrl;
|
||||
export let data: Partial<Models.AttributeUrl>;
|
||||
export let editing = false;
|
||||
|
||||
$: if (selectedAttribute) {
|
||||
({ required: data.required, array: data.array, default: data.default } = selectedAttribute);
|
||||
}
|
||||
$: if (data.required || data.array) {
|
||||
data.default = null;
|
||||
}
|
||||
@@ -36,20 +47,12 @@
|
||||
<InputText
|
||||
id="default"
|
||||
label="Default value"
|
||||
placeholder="Enter value"
|
||||
bind:value={data.default}
|
||||
disabled={data.required || data.array}
|
||||
readonly={!!selectedAttribute} />
|
||||
<InputChoice
|
||||
id="required"
|
||||
label="Required"
|
||||
bind:value={data.required}
|
||||
disabled={!!selectedAttribute || data.array}>
|
||||
disabled={data.required || data.array} />
|
||||
<InputChoice id="required" label="Required" bind:value={data.required} disabled={data.array}>
|
||||
Indicate whether this is a required attribute
|
||||
</InputChoice>
|
||||
<InputChoice
|
||||
id="array"
|
||||
label="Array"
|
||||
bind:value={data.array}
|
||||
disabled={!!selectedAttribute || data.required}>
|
||||
<InputChoice id="array" label="Array" bind:value={data.array} disabled={data.required || editing}>
|
||||
Indicate whether this attribute should act as an array
|
||||
</InputChoice>
|
||||
+44
-39
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { option, options } from './attributes/store';
|
||||
import { Button, InputText, FormList, InputSelect } from '$lib/elements/forms';
|
||||
import { Button, InputText, FormList } from '$lib/elements/forms';
|
||||
import { goto, invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { page } from '$app/stores';
|
||||
@@ -11,38 +11,37 @@
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
|
||||
export let showCreate = false;
|
||||
export let selectedOption: string = null;
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
|
||||
let key: string = null;
|
||||
let selectedOption = null;
|
||||
let data: Partial<Attributes> = {
|
||||
required: false,
|
||||
array: false,
|
||||
default: null
|
||||
};
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
let error: string;
|
||||
|
||||
async function submit() {
|
||||
try {
|
||||
await $option.func(databaseId, collectionId, key, data);
|
||||
await $option.create(databaseId, collectionId, key, data);
|
||||
await invalidate(Dependencies.COLLECTION);
|
||||
// await Promise.allSettled([invalidate(Dependencies.COLLECTION)]);
|
||||
if (!$page.url.pathname.includes('attributes')) {
|
||||
goto(
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/databases/database-${databaseId}/collection-${collectionId}/attributes`
|
||||
);
|
||||
}
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Attribute ${key} has been created`
|
||||
message: `Attribute ${key ?? data?.key} has been created`
|
||||
});
|
||||
showCreate = false;
|
||||
trackEvent(Submit.AttributeCreate);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
trackError(error, Submit.AttributeCreate);
|
||||
} catch (e) {
|
||||
error = e.message;
|
||||
trackError(e, Submit.AttributeCreate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +50,7 @@
|
||||
}
|
||||
|
||||
$: if (!showCreate) {
|
||||
error = null;
|
||||
key = null;
|
||||
selectedOption = null;
|
||||
$option = null;
|
||||
@@ -62,35 +62,40 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal size="big" bind:show={showCreate} onSubmit={submit}>
|
||||
<svelte:fragment slot="header">Create Attribute</svelte:fragment>
|
||||
<Modal {error} size="big" bind:show={showCreate} onSubmit={submit} icon={$option?.icon}>
|
||||
<svelte:fragment slot="header">
|
||||
{#if selectedOption === 'Relationship'}
|
||||
<span class="u-flex u-gap-16 u-cross-center">
|
||||
{selectedOption}
|
||||
<div class="tag eyebrow-heading-3">
|
||||
<span class="text u-x-small">Beta</span>
|
||||
</div>
|
||||
</span>
|
||||
{:else}
|
||||
{selectedOption}
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
<FormList>
|
||||
<div>
|
||||
<InputText
|
||||
id="key"
|
||||
label="Attribute Key"
|
||||
placeholder="Enter Key"
|
||||
bind:value={key}
|
||||
autofocus
|
||||
required />
|
||||
{#if selectedOption !== 'Relationship'}
|
||||
<div>
|
||||
<InputText
|
||||
id="key"
|
||||
label="Attribute Key"
|
||||
placeholder="Enter Key"
|
||||
bind:value={key}
|
||||
autofocus
|
||||
required />
|
||||
|
||||
<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 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>
|
||||
</div>
|
||||
|
||||
<InputSelect
|
||||
options={options.map((n) => ({ value: n.name, label: n.name }))}
|
||||
id="type"
|
||||
label="Attribute type"
|
||||
placeholder="Select type"
|
||||
bind:value={selectedOption}
|
||||
required />
|
||||
{/if}
|
||||
{#if selectedOption}
|
||||
<svelte:component
|
||||
this={$option.component}
|
||||
|
||||
+1
-3
@@ -6,7 +6,6 @@
|
||||
import { doc } from './store';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import Document from './document.svelte';
|
||||
import Delete from './delete.svelte';
|
||||
import { symmetricDifference } from '$lib/helpers/array';
|
||||
import { Permissions } from '$lib/components/permissions';
|
||||
@@ -58,7 +57,7 @@
|
||||
|
||||
<Container>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="7">Document</Heading>
|
||||
<Heading tag="h2" size="7">Metadata</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<div>
|
||||
<p>Created: {toLocaleDateTime($doc.$createdAt)}</p>
|
||||
@@ -66,7 +65,6 @@
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
<Document />
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Permissions</Heading>
|
||||
<p>
|
||||
|
||||
+3
-1
@@ -4,6 +4,7 @@
|
||||
import Datetime from './attributes/datetime.svelte';
|
||||
import Enum from './attributes/enum.svelte';
|
||||
import Integer from './attributes/integer.svelte';
|
||||
import Relationship from './attributes/relationship.svelte';
|
||||
import String from './attributes/string.svelte';
|
||||
import Url from './attributes/url.svelte';
|
||||
|
||||
@@ -27,7 +28,8 @@
|
||||
integer: Integer,
|
||||
double: Integer,
|
||||
boolean: Boolean,
|
||||
datetime: Datetime
|
||||
datetime: Datetime,
|
||||
relationship: Relationship
|
||||
};
|
||||
|
||||
const attributesFormatMap = {
|
||||
|
||||
+2
-80
@@ -1,11 +1,8 @@
|
||||
<script lang="ts">
|
||||
import CustomId from '$lib/components/customId.svelte';
|
||||
import { FormList } from '$lib/elements/forms';
|
||||
import Button from '$lib/elements/forms/button.svelte';
|
||||
import Pill from '$lib/elements/pill.svelte';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import type { Attributes } from '../store';
|
||||
import Attribute from './attribute.svelte';
|
||||
import AttributeItem from './attributeItem.svelte';
|
||||
|
||||
export let attributes: Attributes[] = [];
|
||||
export let formValues: object = {};
|
||||
@@ -13,88 +10,13 @@
|
||||
export let gap: '16' | '24' | '32' = '32';
|
||||
|
||||
let showCustomId = false;
|
||||
|
||||
function removeArrayItem(key: string, index: number) {
|
||||
formValues = {
|
||||
...formValues,
|
||||
[key]: formValues[key].filter((_, i) => i !== index)
|
||||
};
|
||||
}
|
||||
|
||||
function addArrayItem(key: string) {
|
||||
formValues = {
|
||||
...formValues,
|
||||
[key]: [...formValues[key], null]
|
||||
};
|
||||
}
|
||||
|
||||
function getAttributeType(attribute: Attributes) {
|
||||
if ('format' in attribute && attribute.format === 'enum') return 'Enum';
|
||||
return `${capitalize(attribute.type)}${attribute.array ? '[]' : ''}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if attributes.length}
|
||||
<ul class={`form-list u-gap-${gap}`}>
|
||||
{#each attributes as attribute}
|
||||
{@const label = attribute.key}
|
||||
{#if attribute.array}
|
||||
{#if formValues[attribute.key].length === 0}
|
||||
<div class="u-flex u-cross-center u-main-space-between">
|
||||
<span class="label u-margin-0">
|
||||
{label}
|
||||
<span class="optional">
|
||||
{getAttributeType(attribute)}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<Button text noMargin on:click={() => addArrayItem(attribute.key)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text"> Add item</span>
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if formValues[attribute.key].length !== 0}
|
||||
<ul class="u-grid u-gap-8">
|
||||
{#each [...formValues[attribute.key].keys()] as index}
|
||||
<li class="form-item is-multiple">
|
||||
<div class="form-item-part u-stretch">
|
||||
<Attribute
|
||||
{attribute}
|
||||
id={`${attribute.key}-${index}`}
|
||||
optionalText={index === 0
|
||||
? getAttributeType(attribute)
|
||||
: undefined}
|
||||
label={index === 0 ? label : ''}
|
||||
bind:value={formValues[attribute.key][index]} />
|
||||
</div>
|
||||
<div class="form-item-part u-cross-child-end">
|
||||
<Button
|
||||
noMargin
|
||||
text
|
||||
on:click={() => removeArrayItem(attribute.key, index)}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
<Button text noMargin on:click={() => addArrayItem(attribute.key)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text"> Add item</span>
|
||||
</Button>
|
||||
</ul>
|
||||
{/if}
|
||||
{:else}
|
||||
<FormList>
|
||||
<Attribute
|
||||
{attribute}
|
||||
{label}
|
||||
optionalText={getAttributeType(attribute)}
|
||||
id={attribute.key}
|
||||
bind:value={formValues[attribute.key]} />
|
||||
</FormList>
|
||||
{/if}
|
||||
<AttributeItem {attribute} bind:formValues {label} />
|
||||
{/each}
|
||||
|
||||
{#if customId !== undefined}
|
||||
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
<script lang="ts">
|
||||
import { Button, FormList } from '$lib/elements/forms';
|
||||
import { capitalize } from '$lib/helpers/string';
|
||||
import type { Attributes } from '../store';
|
||||
import Attribute from './attribute.svelte';
|
||||
|
||||
export let attribute: Attributes;
|
||||
export let formValues: object = {};
|
||||
export let label: string;
|
||||
|
||||
function removeArrayItem(key: string, index: number) {
|
||||
formValues = {
|
||||
...formValues,
|
||||
[key]: formValues[key].filter((_, i) => i !== index)
|
||||
};
|
||||
}
|
||||
|
||||
function addArrayItem(key: string) {
|
||||
formValues = {
|
||||
...formValues,
|
||||
[key]: [...formValues[key], null]
|
||||
};
|
||||
}
|
||||
|
||||
function getAttributeType(attribute: Attributes) {
|
||||
if ('format' in attribute && attribute.format === 'enum') return 'Enum';
|
||||
return `${capitalize(attribute.type)}${attribute.array ? '[]' : ''}`;
|
||||
}
|
||||
|
||||
$: manyRelation =
|
||||
attribute?.relationType === 'manyToMany' ||
|
||||
attribute?.relationType === 'manyToOne' ||
|
||||
attribute?.relationType === 'oneToMany';
|
||||
</script>
|
||||
|
||||
{#if attribute.array || manyRelation}
|
||||
{#if formValues[attribute.key]?.length === 0}
|
||||
<div class="u-flex u-cross-center u-main-space-between">
|
||||
<span class="label u-margin-0">
|
||||
{label}
|
||||
<span class="optional u-margin-inline-start-8">
|
||||
{getAttributeType(attribute)}
|
||||
</span>
|
||||
</span>
|
||||
<Button text noMargin on:click={() => addArrayItem(attribute.key)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add item</span>
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if formValues[attribute.key].length !== 0}
|
||||
<ul class="u-grid u-gap-8">
|
||||
{#each [...formValues[attribute.key].keys()] as index}
|
||||
<li class="form-item is-multiple">
|
||||
<div class="form-item-part u-stretch">
|
||||
<Attribute
|
||||
{attribute}
|
||||
id={`${attribute.key}-${index}`}
|
||||
optionalText={index === 0 ? getAttributeType(attribute) : undefined}
|
||||
label={index === 0 ? label : ''}
|
||||
bind:value={formValues[attribute.key][index]} />
|
||||
</div>
|
||||
<div class="form-item-part u-cross-child-end">
|
||||
<Button
|
||||
noMargin
|
||||
text
|
||||
on:click={() => removeArrayItem(attribute.key, index)}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
<Button text noMargin on:click={() => addArrayItem(attribute.key)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text"> Add item</span>
|
||||
</Button>
|
||||
</ul>
|
||||
{/if}
|
||||
{:else}
|
||||
<FormList>
|
||||
<Attribute
|
||||
{attribute}
|
||||
{label}
|
||||
optionalText={getAttributeType(attribute)}
|
||||
id={attribute.key}
|
||||
bind:value={formValues[attribute.key]} />
|
||||
</FormList>
|
||||
{/if}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { InputSelectSearch } from '$lib/elements/forms';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { teamPrefs } from '$lib/stores/team';
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let value: string;
|
||||
export let attribute: Models.AttributeRelationship;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
|
||||
let documentList: Models.DocumentList<Models.Document>;
|
||||
let search: string = null;
|
||||
let displayNames = ['$id'];
|
||||
|
||||
onMount(async () => {
|
||||
teamPrefs.load($organization.$id);
|
||||
documentList = await getDocuments();
|
||||
|
||||
displayNames = $teamPrefs?.displayNames?.[attribute?.relatedCollection] ?? ['$id'];
|
||||
if (!displayNames?.includes('$id')) {
|
||||
displayNames.unshift('$id');
|
||||
}
|
||||
});
|
||||
|
||||
async function getDocuments(search: string = null) {
|
||||
if (search) {
|
||||
const documents = await sdk.forProject.databases.listDocuments(
|
||||
databaseId,
|
||||
attribute.relatedCollection,
|
||||
[Query.search(displayNames[0], search), Query.orderDesc('$createdAt')]
|
||||
);
|
||||
return documents;
|
||||
} else {
|
||||
const documents = await sdk.forProject.databases.listDocuments(
|
||||
databaseId,
|
||||
attribute.relatedCollection
|
||||
);
|
||||
return documents;
|
||||
}
|
||||
}
|
||||
// Reactive statements
|
||||
$: getDocuments(search).then((res) => (documentList = res));
|
||||
</script>
|
||||
|
||||
<InputSelectSearch
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
required={attribute.required}
|
||||
name="documents"
|
||||
placeholder={`Select ${attribute.key}`}
|
||||
bind:search
|
||||
bind:value
|
||||
options={documentList?.documents?.map((n) => ({
|
||||
value: n.$id,
|
||||
label: n?.[displayNames[0]]
|
||||
})) ?? []} />
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { Button, InputSelectSearch } from '$lib/elements/forms';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Query, type Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let value: string;
|
||||
export let attribute: Models.AttributeRelationship;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
|
||||
let documentList: Models.DocumentList<Models.Document>;
|
||||
let search: string = null;
|
||||
let searchAttribute: string = null;
|
||||
|
||||
onMount(async () => {
|
||||
documentList = await getDocuments();
|
||||
searchAttribute = 'test';
|
||||
});
|
||||
|
||||
async function getDocuments(search: string = null) {
|
||||
if (search) {
|
||||
const documents = await sdk.forProject.databases.listDocuments(
|
||||
databaseId,
|
||||
attribute.relatedCollection,
|
||||
[Query.search(searchAttribute, search), Query.orderDesc('$createdAt')]
|
||||
);
|
||||
return documents;
|
||||
} else {
|
||||
const documents = await sdk.forProject.databases.listDocuments(
|
||||
databaseId,
|
||||
attribute.relatedCollection
|
||||
);
|
||||
return documents;
|
||||
}
|
||||
}
|
||||
// Reactive statements
|
||||
$: getDocuments(search).then((res) => (documentList = res));
|
||||
</script>
|
||||
|
||||
<div class="u-width-full-line u-max-width-600">
|
||||
<div class="u-flex u-cross-baseline u-gap-16">
|
||||
<div class="u-flex u-cross-baseline u-gap-8">
|
||||
<label class="label" for="relationship">{label}</label>
|
||||
<span class="optional u-x-small">Relation</span>
|
||||
</div>
|
||||
<button
|
||||
on:click|preventDefault={() => {
|
||||
addRelationship = true;
|
||||
}}
|
||||
class="button is-text u-padding-inline-0 u-margin-inline-start-auto"
|
||||
type="button">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add item</span>
|
||||
</button>
|
||||
|
||||
<ul class="u-flex-vertical u-gap-4 u-margin-block-start-4">
|
||||
{#if addRelationship === false}
|
||||
<InputSelectSearch
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
required
|
||||
bind:value
|
||||
options={documentList?.collections?.map((n) => ({
|
||||
value: n.$id,
|
||||
label: n.name
|
||||
})) ?? []} />
|
||||
{/if}
|
||||
{#each attribute?.relationships as relationship}
|
||||
<li class="u-flex u-gap-16">
|
||||
<output class="input-text is-read-only">
|
||||
<div class="u-flex u-cross-baseline u-gap-12">
|
||||
<span
|
||||
class="u-flex-basis-140 u-flex-shrink-0 u-text-start u-trim-start u-x-small u-color-text-gray">
|
||||
{realationship.label}
|
||||
</span>
|
||||
<span class="u-flex-1 u-trim-1">
|
||||
{#each relationship.data as info}
|
||||
{info}
|
||||
{/each}
|
||||
</span>
|
||||
</div>
|
||||
</output>
|
||||
<button class="button is-text u-padding-inline-0" aria-label="delete item 1">
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
|
||||
<div class="u-flex u-cross-baseline u-gap-16 u-margin-block-start-8">
|
||||
<p class="u-small">Total results: {attribute?.relationships?.length}</p>
|
||||
|
||||
<nav class="pagination u-margin-inline-start-auto" style="--button-size: 2.5rem;">
|
||||
<Button text disabled noMargin ariaLabel="prev page">
|
||||
<span class="icon-cheveron-left" aria-hidden="true" />
|
||||
<span class="text">Prev</span>
|
||||
</Button>
|
||||
|
||||
<Button text disabled noMargin ariaLabel="next page">
|
||||
<span class="text">Next</span>
|
||||
<span class="icon-cheveron-right" aria-hidden="true" />
|
||||
</Button>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
+2
-4
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import InputText from '$lib/elements/forms/inputText.svelte';
|
||||
import InputTextarea from '$lib/elements/forms/inputTextarea.svelte';
|
||||
import { InputText, InputTextarea } from '$lib/elements/forms';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let id: string;
|
||||
@@ -10,11 +9,10 @@
|
||||
export let optionalText: string | undefined = undefined;
|
||||
</script>
|
||||
|
||||
{#if attribute.size > 64}
|
||||
{#if attribute.size >= 50}
|
||||
<InputTextarea
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
placeholder="Enter string"
|
||||
showLabel={!!label?.length}
|
||||
required={attribute.required}
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { page } from '$app/stores';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { writable } from 'svelte/store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { doc } from '../store';
|
||||
import { collection } from '../../store';
|
||||
import { Container } from '$lib/layout';
|
||||
import AttributeItem from '../attributeItem.svelte';
|
||||
import { difference } from '$lib/helpers/array';
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
const documentId = $page.params.document;
|
||||
|
||||
const work = writable(
|
||||
Object.keys($doc)
|
||||
.filter((key) => {
|
||||
return ![
|
||||
'$id',
|
||||
'$collection',
|
||||
'$collectionId',
|
||||
'$databaseId',
|
||||
'$createdAt',
|
||||
'$updatedAt'
|
||||
].includes(key);
|
||||
})
|
||||
.reduce((obj, key) => {
|
||||
obj[key] = $doc[key];
|
||||
return obj;
|
||||
}, {}) as Models.Document
|
||||
);
|
||||
|
||||
async function updateData() {
|
||||
try {
|
||||
await sdk.forProject.databases.updateDocument(
|
||||
databaseId,
|
||||
collectionId,
|
||||
documentId,
|
||||
$work,
|
||||
$work.$permissions
|
||||
);
|
||||
|
||||
invalidate(Dependencies.DOCUMENT);
|
||||
trackEvent(Submit.DocumentUpdate);
|
||||
addNotification({
|
||||
message: 'Document was updated!',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
trackError(error, Submit.DocumentUpdate);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Data - Appwrite</title>
|
||||
</svelte:head>
|
||||
|
||||
<Container>
|
||||
{#if $collection?.attributes?.length}
|
||||
{#each $collection.attributes as attribute}
|
||||
{@const label = attribute.key}
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">{label}</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<AttributeItem {attribute} bind:formValues={$work} {label} />
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button
|
||||
disabled={attribute?.array
|
||||
? !difference(
|
||||
Array.from($work?.[attribute.key]),
|
||||
Array.from($doc?.[attribute.key])
|
||||
).length
|
||||
: $work?.[attribute.key] === $doc?.[attribute.key]}
|
||||
on:click={() => updateData()}>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
{/each}
|
||||
{/if}
|
||||
</Container>
|
||||
+67
-6
@@ -3,15 +3,24 @@
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Alert, Modal } from '$lib/components';
|
||||
import { Button, InputChoice } from '$lib/elements/forms';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableCellHead,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { collection } from '../store';
|
||||
import { attributes, collection } from '../store';
|
||||
|
||||
export let showDelete = false;
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
let checked = false;
|
||||
|
||||
const handleDelete = async () => {
|
||||
try {
|
||||
@@ -37,16 +46,68 @@
|
||||
trackError(error, Submit.DocumentDelete);
|
||||
}
|
||||
};
|
||||
|
||||
enum Deletion {
|
||||
'setNull' = 'Set document ID as NULL in all related documents',
|
||||
'cascade' = 'All related documents will be deleted',
|
||||
'restrict' = 'Document can not be deleted'
|
||||
}
|
||||
|
||||
$: relAttributes = [$attributes?.find((attribute) => attribute.type === 'relationship')];
|
||||
</script>
|
||||
|
||||
<Modal warning={true} onSubmit={handleDelete} bind:show={showDelete}>
|
||||
<Modal
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
onSubmit={handleDelete}
|
||||
bind:show={showDelete}
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Document</svelte:fragment>
|
||||
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>the document from {$collection.name}</b>?
|
||||
</p>
|
||||
|
||||
{#if relAttributes?.length}
|
||||
<TableScroll>
|
||||
<TableHeader>
|
||||
<TableCellHead width={50}>Relation</TableCellHead>
|
||||
<TableCellHead width={50}>Setting</TableCellHead>
|
||||
<TableCellHead width={200} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each relAttributes as attr}
|
||||
<TableRow>
|
||||
<TableCell title="relation">
|
||||
<span class="u-flex u-cross-center u-gap-8">
|
||||
{#if attr?.twoWay}
|
||||
<span class="icon-switch-horizontal" />
|
||||
{:else}
|
||||
<span class="icon-arrow-sm-right" />
|
||||
{/if}
|
||||
{attr?.key}
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCellText title="Settings">
|
||||
{attr?.onDelete}
|
||||
</TableCellText>
|
||||
<TableCellText title="description">
|
||||
{Deletion[attr?.onDelete]}
|
||||
</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
<div class="u-flex u-flex-vertical u-gap-16">
|
||||
<Alert>To change the selection edit the relationship settings.</Alert>
|
||||
|
||||
<InputChoice id="delete" label="Delete" showLabel={false} bind:value={checked}>
|
||||
Delete document from {$collection.name}
|
||||
</InputChoice>
|
||||
</div>
|
||||
{/if}
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
<Button secondary submit disabled={relAttributes?.length && !checked}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+6
@@ -17,6 +17,12 @@
|
||||
title: 'Overview',
|
||||
event: 'overview'
|
||||
},
|
||||
{
|
||||
href: `${path}/data`,
|
||||
title: 'Data',
|
||||
event: 'data',
|
||||
hasChildren: true
|
||||
},
|
||||
{
|
||||
href: `${path}/activity`,
|
||||
title: 'Activity',
|
||||
|
||||
+33
-6
@@ -18,6 +18,7 @@
|
||||
import CreateAttribute from '../createAttribute.svelte';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import CreateAttributeDropdown from '../attributes/createAttributeDropdown.svelte';
|
||||
|
||||
let showDropdown = [];
|
||||
let selectedIndex: Models.Index = null;
|
||||
@@ -25,6 +26,8 @@
|
||||
let showOverview = false;
|
||||
let showDelete = false;
|
||||
let showCreateAttribute = false;
|
||||
let showCreateDropdown = false;
|
||||
let selectedAttribute: string = null;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -118,11 +121,35 @@
|
||||
on:click={() => (showCreateIndex = true)} />
|
||||
{/if}
|
||||
{:else}
|
||||
<Empty
|
||||
single
|
||||
target="attribute"
|
||||
href="https://appwrite.io/docs/databases#attributes"
|
||||
on:click={() => (showCreateAttribute = true)} />
|
||||
<Empty single target="attribute" on:click={() => (showCreateDropdown = true)}>
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2">Create your first attribute to get started.</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16 u-main-center">
|
||||
<Button
|
||||
external
|
||||
href="https://appwrite.io/docs/databases#attributes"
|
||||
text
|
||||
event="empty_documentation"
|
||||
ariaLabel={`create {target}`}>Documentation</Button>
|
||||
<CreateAttributeDropdown
|
||||
bind:showCreateDropdown
|
||||
bind:showCreate={showCreateAttribute}
|
||||
bind:selectedOption={selectedAttribute}>
|
||||
<Button
|
||||
secondary
|
||||
event="create_attribute"
|
||||
on:click={() => {
|
||||
showCreateDropdown = !showCreateDropdown;
|
||||
}}>
|
||||
Create attribute
|
||||
</Button>
|
||||
</CreateAttributeDropdown>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
@@ -133,4 +160,4 @@
|
||||
<Overview bind:showOverview {selectedIndex} />
|
||||
{/if}
|
||||
|
||||
<CreateAttribute bind:showCreate={showCreateAttribute} />
|
||||
<CreateAttribute bind:showCreate={showCreateAttribute} bind:selectedOption={selectedAttribute} />
|
||||
+1
-1
@@ -39,7 +39,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal warning={true} onSubmit={handleDelete} bind:show={showDelete}>
|
||||
<Modal icon="exclamation" state="warning" onSubmit={handleDelete} bind:show={showDelete}>
|
||||
<svelte:fragment slot="header">Delete Index</svelte:fragment>
|
||||
|
||||
<p data-private>
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
export let show = false;
|
||||
export let selectedRelationship: string = null;
|
||||
const limit = 10;
|
||||
let offset = 0;
|
||||
|
||||
$: if (!show) {
|
||||
selectedRelationship = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal size="big" bind:show icon="relationship">
|
||||
<svelte:fragment slot="header">
|
||||
{selectedRelationship}
|
||||
</svelte:fragment>
|
||||
{#each selectedRelationship as relationship, i}
|
||||
{#if i >= offset && i < offset + limit}
|
||||
{relationship.data} {relationship.id}
|
||||
{/if}
|
||||
{/each}
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary disabled={!!offset} on:click={() => offset - limit}>Prev</Button>
|
||||
<Button
|
||||
secondary
|
||||
disabled={selectedRelationship?.relationships?.length < offset}
|
||||
on:click={() => offset + limit}>Next</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+2
@@ -2,6 +2,7 @@
|
||||
import { Container } from '$lib/layout';
|
||||
import { collection } from '../store';
|
||||
import DangerZone from './dangerZone.svelte';
|
||||
import DisplayName from './displayName.svelte';
|
||||
import UpdateName from './updateName.svelte';
|
||||
import UpdatePermissions from './updatePermissions.svelte';
|
||||
import UpdateSecurity from './updateSecurity.svelte';
|
||||
@@ -12,6 +13,7 @@
|
||||
{#if $collection}
|
||||
<UpdateStatus />
|
||||
<UpdateName />
|
||||
<DisplayName />
|
||||
<UpdatePermissions />
|
||||
<UpdateSecurity />
|
||||
<DangerZone />
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal warning={true} bind:show={showDelete} onSubmit={handleDelete}>
|
||||
<Modal icon="exclamation" state="warning" bind:show={showDelete} onSubmit={handleDelete}>
|
||||
<svelte:fragment slot="header">Delete Collection</svelte:fragment>
|
||||
|
||||
<p data-private>
|
||||
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
<script lang="ts">
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { CardGrid, Heading } from '$lib/components';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button, Form, FormList, InputSelectSearch, InputText } from '$lib/elements/forms';
|
||||
import { symmetricDifference } from '$lib/helpers/array';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { teamPrefs } from '$lib/stores/team';
|
||||
import { onMount } from 'svelte';
|
||||
import { attributes, collection } from '../store';
|
||||
|
||||
let displayNames = [];
|
||||
let search: string;
|
||||
|
||||
onMount(async () => {
|
||||
await teamPrefs.load($organization.$id);
|
||||
|
||||
$teamPrefs.displayNames ??= {};
|
||||
$teamPrefs.displayNames[$collection.$id] ??= [];
|
||||
displayNames = [...$teamPrefs.displayNames[$collection.$id]];
|
||||
});
|
||||
|
||||
async function updateDisplayName() {
|
||||
try {
|
||||
const pref = {
|
||||
...$teamPrefs,
|
||||
displayNames: {
|
||||
...$teamPrefs.displayNames,
|
||||
[$collection.$id]: displayNames
|
||||
}
|
||||
};
|
||||
teamPrefs.updatePrefs($organization.$id, pref);
|
||||
invalidate(Dependencies.TEAM);
|
||||
addNotification({
|
||||
message: 'Name has been updated',
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.CollectionUpdateName);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
message: error.message,
|
||||
type: 'error'
|
||||
});
|
||||
trackError(error, Submit.CollectionUpdateName);
|
||||
}
|
||||
}
|
||||
|
||||
$: options = $attributes
|
||||
.filter(
|
||||
(attr) =>
|
||||
attr.type === 'string' &&
|
||||
attr?.size <= 50 &&
|
||||
!attr?.array &&
|
||||
!displayNames?.some((name) => name === attr.key)
|
||||
)
|
||||
.map((attr) => {
|
||||
return {
|
||||
value: attr.key,
|
||||
label: attr.key
|
||||
};
|
||||
});
|
||||
|
||||
$: addAttributeDisabled =
|
||||
displayNames?.length >= 5 ||
|
||||
(displayNames?.length && !displayNames[displayNames?.length - 1]);
|
||||
|
||||
$: updateBtnDisabled = !symmetricDifference(
|
||||
displayNames,
|
||||
$teamPrefs?.displayNames?.[$collection.$id] ?? []
|
||||
)?.length;
|
||||
|
||||
$: console.log(displayNames, $teamPrefs?.displayNames[$collection.$id]);
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateDisplayName}>
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Display Name</Heading>
|
||||
<p class="text">
|
||||
Set string attributes with maximum 50 characters to be used as a display name in the
|
||||
Appwrite console. Maximum 5 names.
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="u-flex u-flex-vertical u-gap-8">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="id"
|
||||
label="Document ID"
|
||||
showLabel={false}
|
||||
placeholder="Document ID"
|
||||
readonly />
|
||||
{#if displayNames?.length}
|
||||
{#each displayNames as name, i}
|
||||
<div class="u-flex u-gap-8">
|
||||
{#if displayNames[i]}
|
||||
<InputSelectSearch
|
||||
id={name}
|
||||
label={name}
|
||||
showLabel={false}
|
||||
placeholder="Select attribute"
|
||||
bind:value={displayNames[i]}
|
||||
bind:search={displayNames[i]}
|
||||
name="attributes"
|
||||
disabled
|
||||
{options} />
|
||||
{:else}
|
||||
<InputSelectSearch
|
||||
id={name}
|
||||
label={name}
|
||||
showLabel={false}
|
||||
placeholder="Select attribute"
|
||||
bind:value={displayNames[i]}
|
||||
bind:search
|
||||
name="attributes"
|
||||
{options} />
|
||||
{/if}
|
||||
<div class="form-item-part u-cross-child-end">
|
||||
<Button
|
||||
text
|
||||
noMargin
|
||||
on:click={() => {
|
||||
displayNames.splice(i, 1);
|
||||
displayNames = displayNames;
|
||||
}}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
</FormList>
|
||||
<Button
|
||||
noMargin
|
||||
text
|
||||
disabled={addAttributeDisabled}
|
||||
on:click={() => {
|
||||
displayNames[displayNames.length] = null;
|
||||
search = null;
|
||||
displayNames = displayNames;
|
||||
}}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add attribute</span>
|
||||
</Button>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={updateBtnDisabled} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user