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
2c57014736
82 files changed
+995
-514
No files matched your search
Generated
+4
-4
@@ -8,7 +8,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.7",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
@@ -155,9 +155,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@appwrite.io/pink": {
|
||||
"version": "0.0.6-rc.6",
|
||||
"resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.6.tgz",
|
||||
"integrity": "sha512-mSOUI2UxRqO3MS4ZXz9bdyAt0VFGRhOwWYGXw+oFfYPjmu6GSKnLEQwjF37DeuArEGRNriTiOFrKqXO0HW0odA==",
|
||||
"version": "0.0.6-rc.7",
|
||||
"resolved": "https://registry.npmjs.org/@appwrite.io/pink/-/pink-0.0.6-rc.7.tgz",
|
||||
"integrity": "sha512-3I+DG4HiysIRJF9ksr+aWMmazUtZ6KrivISu3k+pIX7MjyDhN5la6LVNKgU3d8WWstbHCHoEq5+FYyjsYWWIpA==",
|
||||
"dependencies": {
|
||||
"@appwrite.io/pink-icons": "*",
|
||||
"normalize.css": "^8.0.1",
|
||||
|
||||
+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.7",
|
||||
"@popperjs/core": "^2.11.6",
|
||||
"@sentry/svelte": "^7.44.2",
|
||||
"@sentry/tracing": "^7.44.2",
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<ul class="clickable-list">
|
||||
<slot />
|
||||
</ul>
|
||||
@@ -0,0 +1,14 @@
|
||||
<script lang="ts">
|
||||
export let href: string;
|
||||
</script>
|
||||
|
||||
<li class="clickable-list-item">
|
||||
<a {href} class="clickable-list-button" on:click>
|
||||
<h5 class="clickable-list-title u-trim-1">
|
||||
<slot />
|
||||
</h5>
|
||||
<div class="clickable-list-desc">
|
||||
<p class="text u-margin-block-start-8"><slot name="desc" /></p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
@@ -41,7 +41,7 @@
|
||||
<slot>
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2">Create your first {target} to get started.</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
<section class="drop-section">
|
||||
<header class="u-flex u-main-space-between u-gap-16">
|
||||
<h4 class="body-text-1">How can we improve?</h4>
|
||||
<h4 class="body-text-1 u-bold">How can we improve?</h4>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon u-margin-inline-start-auto"
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
<section class="drop-section">
|
||||
<header class="u-flex u-main-space-between u-gap-16">
|
||||
<h4 class="body-text-1">How are we doing?</h4>
|
||||
<h4 class="body-text-1 u-bold">How are we doing?</h4>
|
||||
<button
|
||||
type="button"
|
||||
class="button is-text is-only-icon u-margin-inline-start-auto"
|
||||
|
||||
@@ -51,3 +51,5 @@ 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';
|
||||
export { default as ClickableList } from './clickableList.svelte';
|
||||
export { default as ClickableListItem } from './clickableListItem.svelte';
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="modal-form">
|
||||
<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">
|
||||
<h4 class="modal-title body-text-1 u-bold">
|
||||
<slot name="title" />
|
||||
</h4>
|
||||
{#if closable}
|
||||
|
||||
@@ -3,19 +3,34 @@
|
||||
export let group: string;
|
||||
export let value: string | number | boolean;
|
||||
export let disabled = false;
|
||||
export let padding: number = 0.5;
|
||||
export let padding = 1;
|
||||
export let icon: string = null;
|
||||
export let fullHeight = true;
|
||||
export let borderRadius: 'xsmall' | 'small' | 'medium' | 'large' = 'small';
|
||||
|
||||
enum Radius {
|
||||
xsmall = '--border-radius-xsmall',
|
||||
small = '--border-radius-small',
|
||||
medium = '--border-radius-medium',
|
||||
large = '--border-radius-large'
|
||||
}
|
||||
</script>
|
||||
|
||||
<label
|
||||
class="card is-allow-focus u-cursor-pointer"
|
||||
class:u-height-100-percent={fullHeight}
|
||||
style={`--card-padding:${padding}rem`}>
|
||||
style={`--card-padding:${padding}rem; --card-border-radius:var(${Radius[borderRadius]});`}>
|
||||
<div class="u-flex u-gap-16">
|
||||
<input type="radio" {name} {disabled} {value} bind:group on:click />
|
||||
<input
|
||||
class="is-small u-margin-block-start-2"
|
||||
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>
|
||||
<h4 class="body-text-2 u-bold"><slot name="title" /></h4>
|
||||
<p class="u-color-text-gray u-small">
|
||||
<slot />
|
||||
</p>
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
<label class="u-flex u-cross-center u-gap-8" for={team.$id}>
|
||||
<AvatarInitials size={32} name={team.name} />
|
||||
<div class="u-line-height-1-5">
|
||||
<div class="body-text-2">{team.name}</div>
|
||||
<div class="body-text-2 u-bold">{team.name}</div>
|
||||
<div class="u-x-small">{team.$id}</div>
|
||||
</div>
|
||||
</label>
|
||||
@@ -116,7 +116,7 @@
|
||||
<EmptySearch hidePages>
|
||||
<div class="common-section">
|
||||
<div class="u-text-center common-section">
|
||||
<b class="body-text-2">Sorry we couldn't find "{search}"</b>
|
||||
<b class="body-text-2 u-bold">Sorry we couldn't find "{search}"</b>
|
||||
<p>There are no teams that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16 common-section u-main-center">
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
{#if user.name}
|
||||
<AvatarInitials size={32} name={user.name} />
|
||||
<div class="u-line-height-1-5">
|
||||
<div class="body-text-2">
|
||||
<div class="body-text-2 u-bold">
|
||||
{user.name}
|
||||
</div>
|
||||
<div class="u-x-small">{user.$id}</div>
|
||||
@@ -103,7 +103,7 @@
|
||||
<span class="icon-minus-sm" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="u-line-height-1-5">
|
||||
<div class="body-text-2">
|
||||
<div class="body-text-2 u-bold">
|
||||
{user.email ? user.email : user.phone}
|
||||
</div>
|
||||
<div class="u-x-small">{user.$id}</div>
|
||||
@@ -114,7 +114,7 @@
|
||||
<span class="icon-anonymous" aria-hidden="true" />
|
||||
</div>
|
||||
<div class="u-line-height-1-5">
|
||||
<div class="body-text-2">
|
||||
<div class="body-text-2 u-bold">
|
||||
{user.name ? user.name : '-'}
|
||||
</div>
|
||||
<div class="u-x-small">{user.$id}</div>
|
||||
@@ -135,7 +135,7 @@
|
||||
<EmptySearch hidePages>
|
||||
<div class="common-section">
|
||||
<div class="u-text-center common-section">
|
||||
<b class="body-text-2">Sorry we couldn't find "{search}"</b>
|
||||
<b class="body-text-2 u-bold">Sorry we couldn't find "{search}"</b>
|
||||
<p>There are no Users that match your search.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-16 common-section u-main-center">
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
export let isCustomCollection = false;
|
||||
export let hideView = false;
|
||||
export let hideColumns = false;
|
||||
export let allowNoColumns = false;
|
||||
|
||||
let showSelectColumns = false;
|
||||
|
||||
@@ -74,32 +75,36 @@
|
||||
}, 0);
|
||||
</script>
|
||||
|
||||
{#if !hideColumns && view === View.Table}
|
||||
{#if $columns?.length}
|
||||
<DropList bind:show={showSelectColumns} scrollable={true}>
|
||||
<Button secondary on:click={() => (showSelectColumns = !showSelectColumns)}>
|
||||
<span
|
||||
class="icon-view-boards u-opacity-50"
|
||||
aria-hidden="true"
|
||||
aria-label="columns" />
|
||||
<span class="text is-only-desktop">Columns</span>
|
||||
<span class="inline-tag">{selectedColumnsNumber}</span>
|
||||
</Button>
|
||||
<svelte:fragment slot="list">
|
||||
{#each $columns as column}
|
||||
<InputChoice
|
||||
id={column.id}
|
||||
label={column.title}
|
||||
bind:value={column.show}
|
||||
disabled={selectedColumnsNumber <= 1 && column.show} />
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
<div class="grid-header-col-4">
|
||||
{#if !hideColumns && view === View.Table}
|
||||
{#if $columns?.length}
|
||||
<DropList bind:show={showSelectColumns} scrollable={true}>
|
||||
<Button secondary on:click={() => (showSelectColumns = !showSelectColumns)}>
|
||||
<span
|
||||
class="icon-view-boards u-opacity-50"
|
||||
aria-hidden="true"
|
||||
aria-label="columns" />
|
||||
<span class="text is-only-desktop">Columns</span>
|
||||
<span class="inline-tag">{selectedColumnsNumber}</span>
|
||||
</Button>
|
||||
<svelte:fragment slot="list">
|
||||
{#each $columns as column}
|
||||
<InputChoice
|
||||
id={column.id}
|
||||
label={column.title}
|
||||
bind:value={column.show}
|
||||
disabled={allowNoColumns
|
||||
? false
|
||||
: selectedColumnsNumber <= 1 && column.show} />
|
||||
{/each}
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if !hideView}
|
||||
<div class="toggle-button">
|
||||
<div class="grid-header-col-3 toggle-button">
|
||||
<ul class="toggle-button-list">
|
||||
{#key $page.url}
|
||||
<li class="toggle-button-item">
|
||||
@@ -111,7 +116,7 @@
|
||||
type="button"
|
||||
class:is-selected={view === View.Table}
|
||||
use:tooltip={{
|
||||
content: 'Column View'
|
||||
content: 'List View'
|
||||
}}>
|
||||
<span class="icon-view-list" aria-hidden="true" />
|
||||
</a>
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
<div class="u-flex u-main-center u-cross-center u-gap-16 u-flex-vertical-mobile">
|
||||
{#if maxSize}
|
||||
{@const readableMaxSize = humanFileSize(maxSize)}
|
||||
<p class="upload-file-box-info body-text-2 u-normal">
|
||||
<p class="upload-file-box-info body-text-2">
|
||||
Max file size: {readableMaxSize.value + readableMaxSize.unit}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
</div>
|
||||
</FormItem>
|
||||
<div
|
||||
class="u-flex u-gap-4 u-margin-block-start-8 u-small"
|
||||
class="u-flex u-gap-4 u-margin-block-start-8 u-small u-cross-center"
|
||||
class:u-color-text-warning={icon === 'exclamation'}>
|
||||
<span
|
||||
class:icon-info={icon === 'info'}
|
||||
|
||||
@@ -1,29 +1,34 @@
|
||||
<script lang="ts">
|
||||
import { DropList } from '$lib/components';
|
||||
import { onMount } from 'svelte';
|
||||
import { clickOnEnter } from '$lib/helpers/a11y';
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { Label } from '.';
|
||||
|
||||
type Option = $$Generic<{
|
||||
value: string | boolean | number;
|
||||
label: string;
|
||||
data?: string[];
|
||||
}>;
|
||||
type OptionArray = Option[];
|
||||
|
||||
export let options: OptionArray;
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let name: string = 'elements';
|
||||
export let name = '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;
|
||||
}[];
|
||||
export let interactiveOutput = false;
|
||||
// Input value
|
||||
export let search: string = null;
|
||||
export let search = '';
|
||||
// The actual selected value
|
||||
export let value: string | number | boolean;
|
||||
export let value: Option['value'];
|
||||
$: selectedOption = options.find((option) => option.value === value);
|
||||
|
||||
let element: HTMLInputElement;
|
||||
let timer: ReturnType<typeof setTimeout>;
|
||||
let hasFocus = false;
|
||||
let selected: number = null;
|
||||
|
||||
@@ -31,19 +36,16 @@
|
||||
selected = null;
|
||||
}
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
onMount(() => {
|
||||
if (element && autofocus) {
|
||||
element.focus();
|
||||
}
|
||||
});
|
||||
|
||||
function handleInput(event: Event) {
|
||||
function handleInput() {
|
||||
hasFocus = true;
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
const target = event.target as HTMLInputElement;
|
||||
search = target.value;
|
||||
}, debounce);
|
||||
}
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
@@ -70,13 +72,31 @@
|
||||
case 'Enter':
|
||||
if (selected !== null) {
|
||||
event.preventDefault();
|
||||
value = options[selected].value;
|
||||
search = options[selected].label;
|
||||
hasFocus = false;
|
||||
selectOption(options[selected]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function selectOption(option: Option) {
|
||||
value = option.value;
|
||||
search = option.label;
|
||||
// It's not working without this line.
|
||||
!$$slots.output && (element.value = search);
|
||||
hasFocus = false;
|
||||
search = '';
|
||||
dispatch('select', option);
|
||||
}
|
||||
|
||||
function clearOption() {
|
||||
search = '';
|
||||
value = null;
|
||||
!$$slots.output && (element.value = search);
|
||||
hasFocus = false;
|
||||
dispatch('reset');
|
||||
}
|
||||
|
||||
$: showClearBtn = (hasFocus && search) || value;
|
||||
</script>
|
||||
|
||||
<li class="u-position-relative form-item u-stretch">
|
||||
@@ -95,33 +115,44 @@
|
||||
|
||||
<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} />
|
||||
{#if $$slots.output && selectedOption}
|
||||
<div
|
||||
on:keyup={clickOnEnter}
|
||||
on:click={() => {
|
||||
if (interactiveOutput) hasFocus = !hasFocus;
|
||||
}}>
|
||||
<slot name="output" option={selectedOption} />
|
||||
</div>
|
||||
{:else}
|
||||
<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} />
|
||||
{/if}
|
||||
|
||||
<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>
|
||||
{#if showClearBtn}
|
||||
<button
|
||||
class="options-list-button"
|
||||
aria-label="clear field"
|
||||
type="button"
|
||||
disabled={!interactiveOutput}
|
||||
on:click|preventDefault={clearOption}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
<button
|
||||
class="options-list-button"
|
||||
type="button"
|
||||
disabled={!interactiveOutput}
|
||||
on:click={() => (hasFocus = !hasFocus)}>
|
||||
<span class="icon-cheveron-down" aria-hidden="true" />
|
||||
</button>
|
||||
@@ -136,11 +167,11 @@
|
||||
class:is-selected={selected === i}
|
||||
type="button"
|
||||
on:click|preventDefault={() => {
|
||||
value = option.value;
|
||||
search = option.label;
|
||||
hasFocus = false;
|
||||
selectOption(option);
|
||||
}}>
|
||||
<span class="text">{option.label}</span>
|
||||
<slot {option}>
|
||||
<span class="text" data-private>{option.label}</span>
|
||||
</slot>
|
||||
</button>
|
||||
</li>
|
||||
{:else}
|
||||
|
||||
@@ -65,6 +65,8 @@
|
||||
{required}
|
||||
{maxlength}
|
||||
class="input-text"
|
||||
class:u-padding-block-end-32={maxlength}
|
||||
style={maxlength ? '--amount-of-buttons: 0.25' : ''}
|
||||
bind:value
|
||||
bind:this={element}
|
||||
on:invalid={handleInvalid}
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export { default as Pill } from './pill.svelte';
|
||||
export { default as SelectSearchItem } from './selectSearchItem.svelte';
|
||||
@@ -0,0 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
|
||||
export let data: 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 u-font-code"
|
||||
data-private>
|
||||
<slot />
|
||||
</span>
|
||||
{#if data?.length}
|
||||
<span
|
||||
class="u-flex u-flex-1 u-trim-1 u-gap-4"
|
||||
use:tooltip={{
|
||||
content: data.map((e) => e ?? 'null').join(' | ')
|
||||
}}>
|
||||
{#each data as item, i}
|
||||
{#if i}
|
||||
<span class="u-text-color-gray">|</span>
|
||||
{/if}
|
||||
<span class="text" style="white-space: nowrap" data-private>{item}</span>
|
||||
{/each}
|
||||
</span>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -9,7 +9,7 @@
|
||||
class:is-only-desktop={onlyDesktop}
|
||||
class="table-thead-col"
|
||||
role="columnheader">
|
||||
<span class={eyebrow ? 'eyebrow-heading-3' : 'body-text-2'}>
|
||||
<span class={eyebrow ? 'eyebrow-heading-3' : 'body-text-2 u-bold'}>
|
||||
<slot />
|
||||
</span>
|
||||
</div>
|
||||
@@ -5,6 +5,9 @@ export function intersection(arr1: unknown[], arr2: unknown[]) {
|
||||
}
|
||||
|
||||
export function difference(arr1: unknown[], arr2: unknown[]) {
|
||||
if (!Array.isArray(arr1) || !Array.isArray(arr2)) {
|
||||
return Array.isArray(arr1) ? arr1 : Array.isArray(arr2) ? arr2 : [];
|
||||
}
|
||||
const set = new Set(arr2);
|
||||
const difference = new Set(arr1.filter((elem) => !set.has(elem)));
|
||||
return Array.from(difference);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { Heading, ViewSelector } from '$lib/components';
|
||||
import type { View } from '$lib/helpers/load';
|
||||
import type { Column } from '$lib/components/viewSelector.svelte';
|
||||
import type { Writable } from 'svelte/store';
|
||||
|
||||
export let title: string;
|
||||
export let columns: Writable<Column[]>;
|
||||
export let view: View;
|
||||
export let isCustomCollection = false;
|
||||
export let hideView = false;
|
||||
export let hideColumns = false;
|
||||
export let allowNoColumns = false;
|
||||
</script>
|
||||
|
||||
<header class="grid-header">
|
||||
<Heading tag="h2" size="5">{title}</Heading>
|
||||
<div class="u-flex u-gap-16 u-contents-mobile">
|
||||
<ViewSelector
|
||||
{view}
|
||||
{columns}
|
||||
{isCustomCollection}
|
||||
{hideView}
|
||||
{hideColumns}
|
||||
{allowNoColumns} />
|
||||
<div class="grid-header-col-2">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
@@ -15,3 +15,4 @@ export { default as Unauthenticated } from './unauthenticated.svelte';
|
||||
export { default as Usage, type UsagePeriods } from './usage.svelte';
|
||||
export { default as Activity } from './activity.svelte';
|
||||
export { default as Progress } from './progress.svelte';
|
||||
export { default as GridHeader } from './gridHeader.svelte';
|
||||
@@ -49,7 +49,7 @@
|
||||
{#if $log.data}
|
||||
<section class="cover-frame" data-private>
|
||||
<header class="cover-frame-header u-flex u-gap-16 u-main-space-between u-cross-center">
|
||||
<h1 class="body-text-1">Function ID: {$log.func.$id}</h1>
|
||||
<h1 class="body-text-1 u-bold">Function ID: {$log.func.$id}</h1>
|
||||
<button
|
||||
on:click={() => ($log.show = false)}
|
||||
class="button is-text is-only-icon"
|
||||
@@ -73,7 +73,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<div class="u-flex u-gap-12 u-cross-center">
|
||||
<h2 class="body-text-2">Deployment ID:</h2>
|
||||
<h2 class="body-text-2 u-bold">Deployment ID:</h2>
|
||||
<Output value={$log.data.$id}>
|
||||
{$log.data.$id}
|
||||
</Output>
|
||||
@@ -145,7 +145,7 @@
|
||||
</div>
|
||||
<div>
|
||||
<div class="u-flex u-gap-12 u-cross-center">
|
||||
<h2 class="body-text-2">Execution ID:</h2>
|
||||
<h2 class="body-text-2 u-bold">Execution ID:</h2>
|
||||
<Output value={$log.data.$id}>
|
||||
{$log.data.$id}
|
||||
</Output>
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
<div class="wizard-end-bg" />
|
||||
|
||||
<header class="wizard-header">
|
||||
<div class="body-text-1">{title}</div>
|
||||
<div class="body-text-1 u-bold">{title}</div>
|
||||
|
||||
<slot name="header" />
|
||||
<button
|
||||
|
||||
@@ -29,7 +29,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteAccount} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteAccount}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Account</svelte:fragment>
|
||||
<p>Are you sure you want to delete your account?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -43,7 +43,12 @@
|
||||
$: isUser = selectedMember?.userId === $user?.$id;
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteMembership}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">
|
||||
{isUser ? 'Leave Organization' : 'Delete Member'}
|
||||
</svelte:fragment>
|
||||
|
||||
@@ -36,7 +36,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal onSubmit={deleteOrg} bind:show={showDelete} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
onSubmit={deleteOrg}
|
||||
bind:show={showDelete}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Organization</svelte:fragment>
|
||||
<p>
|
||||
Are you sure you want to delete <b>{$organization.name}</b>? All projects ({$organization.total})
|
||||
|
||||
@@ -6,5 +6,5 @@
|
||||
|
||||
<Container>
|
||||
<Heading size="1" tag="h3">{$page.status}</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">{$page.error.message}</p>
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">{$page.error.message}</p>
|
||||
</Container>
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
<Form onSubmit={updatePasswordDictionary}>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Password Dictionary</Heading>
|
||||
<Heading tag="h2" size="7">Password Dictionary</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputSwitch
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
<Form onSubmit={updatePasswordHistoryLimit}>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Password History</Heading>
|
||||
<Heading tag="h2" size="7">Password History</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputSwitch
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Session Length</Heading>
|
||||
<Heading tag="h2" size="7">Session Length</Heading>
|
||||
|
||||
<p>
|
||||
If you reduce the limit, users who are currently logged in will be logged out of the
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
<Form onSubmit={updateSessionsLimit}>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Sessions Limit</Heading>
|
||||
<Heading tag="h2" size="7">Sessions Limit</Heading>
|
||||
<p>Maximum number of active sessions allowed per user.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
|
||||
@@ -46,11 +46,10 @@
|
||||
</script>
|
||||
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Users Limit</Heading>
|
||||
<Heading tag="h2" size="7">Users Limit</Heading>
|
||||
<p>
|
||||
Limit new users from signing up for your project, regardless of authentication method. You
|
||||
can still create users and team memberships from your Appwrite console.
|
||||
<b>The maximum limit is 10,000 users.</b>
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
|
||||
@@ -37,7 +37,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteMembership}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<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,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteTeam} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteTeam}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Team</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>{team.name}</b>?
|
||||
|
||||
@@ -31,7 +31,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDeleteAll} onSubmit={deleteAllSessions} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDeleteAll}
|
||||
onSubmit={deleteAllSessions}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<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,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteMembership} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteMembership}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Member</svelte:fragment>
|
||||
{#if selectedMembership}
|
||||
<p data-private>
|
||||
|
||||
@@ -30,7 +30,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteSession} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteSession}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Sessions</svelte:fragment>
|
||||
|
||||
<p>Are you sure you want to delete this session?</p>
|
||||
|
||||
@@ -32,7 +32,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteUser} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteUser}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<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">
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Empty, Heading, ViewSelector, PaginationWithLimit } from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Empty, PaginationWithLimit } from '$lib/components';
|
||||
import { Container, GridHeader } from '$lib/layout';
|
||||
import { base } from '$app/paths';
|
||||
import Create from './create.svelte';
|
||||
import Grid from './grid.svelte';
|
||||
@@ -24,18 +24,12 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<Heading tag="h2" size="5">Databases</Heading>
|
||||
|
||||
<div class="u-flex u-gap-16">
|
||||
<ViewSelector view={data.view} {columns} />
|
||||
|
||||
<Button on:click={() => (showCreate = true)} event="create_database">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text is-only-desktop">Create database</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<GridHeader title="Databases" {columns} view={data.view}>
|
||||
<Button on:click={() => (showCreate = true)} event="create_database">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create database</span>
|
||||
</Button>
|
||||
</GridHeader>
|
||||
|
||||
{#if data.databases.total}
|
||||
{#if data.view === 'grid'}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Heading, PaginationWithLimit, ViewSelector } from '$lib/components';
|
||||
import { Empty, PaginationWithLimit } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Container, GridHeader } from '$lib/layout';
|
||||
import { columns, showCreate } from './store';
|
||||
import Table from './table.svelte';
|
||||
import Grid from './grid.svelte';
|
||||
@@ -11,17 +11,12 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<Heading tag="h2" size="5">Collections</Heading>
|
||||
<div class="u-flex u-gap-16">
|
||||
<ViewSelector view={data.view} {columns} />
|
||||
|
||||
<Button on:click={() => ($showCreate = true)} event="create_collection">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text is-only-desktop">Create collection</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<GridHeader title="Collections" {columns} view={data.view}>
|
||||
<Button on:click={() => ($showCreate = true)} event="create_collection">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create collection</span>
|
||||
</Button>
|
||||
</GridHeader>
|
||||
|
||||
{#if data.collections.total}
|
||||
{#if data.view === 'grid'}
|
||||
|
||||
+18
-16
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Heading, ViewSelector, PaginationWithLimit } from '$lib/components';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Empty, Heading, PaginationWithLimit } from '$lib/components';
|
||||
import { Container, GridHeader } from '$lib/layout';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import Create from './createDocument.svelte';
|
||||
@@ -38,19 +38,21 @@
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
<div class="u-flex u-gap-12 common-section u-main-space-between">
|
||||
<Heading tag="h2" size="5">Documents</Heading>
|
||||
<div class="u-flex u-gap-16">
|
||||
<ViewSelector view={data.view} {columns} hideView isCustomCollection />
|
||||
<Button
|
||||
disabled={!(hasAttributes && hasValidAttributes)}
|
||||
on:click={openWizard}
|
||||
event="create_document">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text is-only-desktop">Create document</span>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<GridHeader
|
||||
title="Documents"
|
||||
{columns}
|
||||
view={data.view}
|
||||
hideView
|
||||
isCustomCollection
|
||||
allowNoColumns>
|
||||
<Button
|
||||
disabled={!(hasAttributes && hasValidAttributes)}
|
||||
on:click={openWizard}
|
||||
event="create_document">
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create document</span>
|
||||
</Button>
|
||||
</GridHeader>
|
||||
|
||||
{#if hasAttributes && hasValidAttributes}
|
||||
{#if data.documents.total}
|
||||
@@ -72,7 +74,7 @@
|
||||
<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">
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+45
-14
@@ -1,4 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { DropList, DropListItem, Empty, Heading } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
@@ -13,6 +15,7 @@
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import Create from '../createAttribute.svelte';
|
||||
import { isRelationship } from '../document-[document]/attributes/store';
|
||||
import CreateIndex from '../indexes/createIndex.svelte';
|
||||
import { attributes, type Attributes } from '../store';
|
||||
import CreateAttributeDropdown from './createAttributeDropdown.svelte';
|
||||
@@ -20,6 +23,9 @@
|
||||
import Edit from './edit.svelte';
|
||||
import { options } from './store';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const databaseId = $page.params.database;
|
||||
|
||||
let showCreateDropdown = false;
|
||||
let showEmptyCreateDropdown = false;
|
||||
let showDropdown = [];
|
||||
@@ -29,6 +35,13 @@
|
||||
let showDelete = false;
|
||||
let showEdit = false;
|
||||
let showCreateIndex = false;
|
||||
|
||||
enum attributeStringIcon {
|
||||
ip = 'location-marker',
|
||||
url = 'link',
|
||||
email = 'mail',
|
||||
enum = 'list'
|
||||
}
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
@@ -54,7 +67,7 @@
|
||||
<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'}
|
||||
{#if isRelationship(attribute)}
|
||||
<span
|
||||
class={`icon-${
|
||||
attribute?.twoWay
|
||||
@@ -62,13 +75,16 @@
|
||||
: 'arrow-sm-right'
|
||||
}`}
|
||||
aria-hidden="true" />
|
||||
{:else if 'format' in attribute}
|
||||
{@const icon = attributeStringIcon[attribute?.format]}
|
||||
<span class={`icon-${icon}`} aria-hidden="true" />
|
||||
{:else}
|
||||
<span
|
||||
class={`icon-${option.icon}`}
|
||||
aria-hidden="true" />
|
||||
{/if}
|
||||
</div>
|
||||
<span class="text u-trim">{attribute.key}</span>
|
||||
<span class="text u-trim" data-private>{attribute.key}</span>
|
||||
</div>
|
||||
{#if attribute.status !== 'available'}
|
||||
<Pill
|
||||
@@ -84,7 +100,21 @@
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCellText onlyDesktop title="Type">
|
||||
{`${attribute.type}${attribute.array ? '[]' : ''}`}
|
||||
{#if 'format' in attribute}
|
||||
<span class="u-capitalize">{attribute.format}</span>
|
||||
{:else}
|
||||
<span class="u-capitalize">{attribute.type}</span>
|
||||
{#if isRelationship(attribute)}
|
||||
<span>
|
||||
with <a
|
||||
href={`${base}/console/project-${projectId}/databases/database-${databaseId}/collection-${attribute?.relatedCollection}`}
|
||||
><b data-private>{attribute?.key}</b></a>
|
||||
</span>
|
||||
{/if}
|
||||
{/if}
|
||||
<span>
|
||||
{attribute.array ? '[]' : ''}
|
||||
</span>
|
||||
</TableCellText>
|
||||
<TableCellText onlyDesktop title="Default Value">
|
||||
{attribute?.default !== null && attribute?.default !== undefined
|
||||
@@ -114,16 +144,17 @@
|
||||
}}>
|
||||
Edit
|
||||
</DropListItem>
|
||||
|
||||
<DropListItem
|
||||
icon="plus"
|
||||
on:click={() => {
|
||||
selectedAttribute = attribute;
|
||||
showCreateIndex = true;
|
||||
showDropdown[index] = false;
|
||||
}}>
|
||||
Create Index
|
||||
</DropListItem>
|
||||
{#if !isRelationship(attribute)}
|
||||
<DropListItem
|
||||
icon="plus"
|
||||
on:click={() => {
|
||||
selectedAttribute = attribute;
|
||||
showCreateIndex = true;
|
||||
showDropdown[index] = false;
|
||||
}}>
|
||||
Create Index
|
||||
</DropListItem>
|
||||
{/if}
|
||||
<DropListItem
|
||||
icon="trash"
|
||||
on:click={() => {
|
||||
@@ -146,7 +177,7 @@
|
||||
<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">
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+10
-8
@@ -10,12 +10,12 @@
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { isRelationship } from '../document-[document]/attributes/store';
|
||||
|
||||
export let showDelete = false;
|
||||
export let selectedAttribute: Attributes;
|
||||
const databaseId = $page.params.database;
|
||||
let checked = selectedAttribute?.type !== 'relationship';
|
||||
|
||||
let checked = false;
|
||||
async function handleDelete() {
|
||||
try {
|
||||
await sdk.forProject.databases.deleteAttribute(
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
|
||||
$: isDeleteBtnDisabled =
|
||||
selectedAttribute?.type === 'relationship' && selectedAttribute?.twoWay && !checked;
|
||||
isRelationship(selectedAttribute) && selectedAttribute?.twoWay && !checked;
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
@@ -54,17 +54,19 @@
|
||||
onSubmit={handleDelete}>
|
||||
<svelte:fragment slot="header">Delete Attribute</svelte:fragment>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to delete <b>'{selectedAttribute?.key}' from {$collection?.name}</b>?
|
||||
Are you sure you want to delete <b data-private>{selectedAttribute?.key}</b> from
|
||||
<b data-private>{$collection?.name}</b>?
|
||||
</p>
|
||||
{#if selectedAttribute?.type === 'relationship' && selectedAttribute?.twoWay}
|
||||
{#if isRelationship(selectedAttribute) && 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.
|
||||
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}
|
||||
Delete relationship between <b data-private>{selectedAttribute.key}</b> to
|
||||
<b data-private>{selectedAttribute.twoWayKey}</b>
|
||||
</InputChoice>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
+28
-15
@@ -16,11 +16,18 @@
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
|
||||
let updateButtonDisabled = true;
|
||||
let error: string;
|
||||
let currentAttr: string;
|
||||
let currentAttr: Attributes;
|
||||
|
||||
$: option = options.find((option) => option?.type === selectedAttribute?.type) as Option;
|
||||
$: option = options.find((option) => {
|
||||
if (selectedAttribute) {
|
||||
if ('format' in selectedAttribute) {
|
||||
return option?.format === selectedAttribute?.format;
|
||||
} else {
|
||||
return option?.type === selectedAttribute?.type;
|
||||
}
|
||||
}
|
||||
}) as Option;
|
||||
|
||||
async function submit() {
|
||||
try {
|
||||
@@ -33,7 +40,7 @@
|
||||
}
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Attribute ${selectedAttribute.key} has been created`
|
||||
message: `Attribute ${selectedAttribute.key} has been updated`
|
||||
});
|
||||
showEdit = false;
|
||||
trackEvent(Submit.AttributeUpdate);
|
||||
@@ -43,12 +50,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: updateButtonDisabled = JSON.stringify(selectedAttribute) === currentAttr;
|
||||
|
||||
$: if (showEdit) {
|
||||
currentAttr ??= JSON.stringify(selectedAttribute);
|
||||
currentAttr ??= { ...selectedAttribute };
|
||||
error = null;
|
||||
}
|
||||
|
||||
function shouldBeDisabled(oldAttr: Attributes, newAttr: Attributes) {
|
||||
return JSON.stringify(oldAttr) === JSON.stringify(newAttr);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if selectedAttribute}
|
||||
@@ -56,7 +65,7 @@
|
||||
<svelte:fragment slot="header">
|
||||
<div class="u-flex u-cross-center u-gap-8">
|
||||
{option?.name}
|
||||
{#if option.type === 'relationship'}
|
||||
{#if option?.type === 'relationship'}
|
||||
<div class="tag eyebrow-heading-3">
|
||||
<span class="text u-x-small">Beta</span>
|
||||
</div>
|
||||
@@ -73,7 +82,7 @@
|
||||
bind:value={selectedAttribute.key}
|
||||
autofocus
|
||||
required
|
||||
disabled />
|
||||
readonly />
|
||||
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
|
||||
<span
|
||||
@@ -85,15 +94,19 @@
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
<svelte:component
|
||||
this={option.component}
|
||||
bind:data={selectedAttribute}
|
||||
editing
|
||||
on:close={() => (option = null)} />
|
||||
{#if option}
|
||||
<svelte:component
|
||||
this={option.component}
|
||||
bind:data={selectedAttribute}
|
||||
editing
|
||||
on:close={() => (option = null)} />
|
||||
{/if}
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (showEdit = false)}>Cancel</Button>
|
||||
<Button submit disabled={updateButtonDisabled}>Update</Button>
|
||||
<Button submit disabled={shouldBeDisabled(currentAttr, selectedAttribute)}>
|
||||
Update
|
||||
</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
{/if}
|
||||
+76
-47
@@ -44,27 +44,26 @@
|
||||
import arrowOne from './arrow-one.svg';
|
||||
import arrowTwo from './arrow-two.svg';
|
||||
import { camelize } from '$lib/helpers/string';
|
||||
import { SelectSearchItem } from '$lib/elements';
|
||||
import { isRelationshipToMany } from '../document-[document]/attributes/store';
|
||||
|
||||
// Props
|
||||
export let data: Partial<Models.AttributeRelationship>;
|
||||
export let data: Models.AttributeRelationship & { side: string };
|
||||
export let editing = false;
|
||||
|
||||
// Constants
|
||||
const databaseId = $page.params.database;
|
||||
const oneWay = [
|
||||
const relationshipType = [
|
||||
{ value: 'oneToOne', label: 'One to one' },
|
||||
{ value: 'oneToMany', label: 'One to many' }
|
||||
];
|
||||
const twoWay = [
|
||||
...oneWay,
|
||||
{ value: 'oneToMany', label: 'One to many' },
|
||||
{ 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' }
|
||||
{ value: 'setNull', label: 'Set NULL - set document ID as NULL in all related documents' },
|
||||
{ value: 'cascade', label: 'Cascade - delete all related documents' },
|
||||
{ value: 'restrict', label: 'Restrict - document can not be deleted' }
|
||||
];
|
||||
|
||||
// Variables
|
||||
@@ -87,32 +86,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
function updateKeyName() {
|
||||
if (!editing) {
|
||||
const collection = collectionList.collections.find(
|
||||
(n) => n.$id === data.relatedCollection
|
||||
);
|
||||
data.key = camelize(collection.name);
|
||||
}
|
||||
}
|
||||
|
||||
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) ?? [];
|
||||
$: isToMany = isRelationshipToMany(data);
|
||||
|
||||
$: 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;
|
||||
$: if (editing) {
|
||||
way = data.twoWay ? 'two' : 'one';
|
||||
} else {
|
||||
data.twoWay = false;
|
||||
if (way === 'two') {
|
||||
data.twoWay = true;
|
||||
if (!data.twoWayKey) {
|
||||
data.twoWayKey = camelize($collection.name);
|
||||
}
|
||||
} else {
|
||||
data.twoWay = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -121,13 +124,23 @@
|
||||
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">
|
||||
<LabelCard
|
||||
name="relationship"
|
||||
bind:group={way}
|
||||
value="one"
|
||||
icon="arrow-sm-right"
|
||||
disabled={editing}>
|
||||
<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">
|
||||
<LabelCard
|
||||
name="relationship"
|
||||
bind:group={way}
|
||||
value="two"
|
||||
icon="switch-horizontal"
|
||||
disabled={editing}>
|
||||
<svelte:fragment slot="title">Two-way relationship</svelte:fragment>
|
||||
One Relation attribute within this collection and another within the related collection
|
||||
</LabelCard>
|
||||
@@ -142,9 +155,23 @@
|
||||
bind:search
|
||||
bind:value={data.relatedCollection}
|
||||
required
|
||||
interactiveOutput={!editing}
|
||||
placeholder="Select a collection"
|
||||
disabled={editing}
|
||||
options={collections?.map((n) => ({ value: n.$id, label: n.name })) ?? []} />
|
||||
options={collections?.map((n) => ({ value: n.$id, label: n.$id, data: [n.name] })) ?? []}
|
||||
on:select={updateKeyName}
|
||||
let:option={o}>
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
<svelte:fragment slot="output">
|
||||
<output class="input-text" class:is-read-only={editing}>
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
</output>
|
||||
</svelte:fragment>
|
||||
</InputSelectSearch>
|
||||
|
||||
{#if data?.relatedCollection}
|
||||
<div>
|
||||
@@ -154,9 +181,10 @@
|
||||
placeholder="Enter Key"
|
||||
bind:value={data.key}
|
||||
autofocus
|
||||
readonly={editing}
|
||||
required />
|
||||
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small u-cross-center">
|
||||
<span
|
||||
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
|
||||
aria-hidden="true" />
|
||||
@@ -169,13 +197,13 @@
|
||||
<div>
|
||||
<InputText
|
||||
id="keyRelated"
|
||||
label="Attribute Key "
|
||||
label="Attribute Key (related collection)"
|
||||
placeholder="Enter Key"
|
||||
bind:value={data.twoWayKey}
|
||||
required
|
||||
disabled={editing} />
|
||||
readonly={editing} />
|
||||
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small u-cross-center">
|
||||
<span
|
||||
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
|
||||
aria-hidden="true" />
|
||||
@@ -192,25 +220,26 @@
|
||||
bind:value={data.relationType}
|
||||
required
|
||||
placeholder="Select a relation"
|
||||
options={data?.twoWay ? twoWay : oneWay}
|
||||
options={relationshipType}
|
||||
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 class="u-flex u-flex-vertical u-gap-16">
|
||||
<div class="box">
|
||||
<div class="u-flex u-align u-cross-center u-main-center u-gap-32">
|
||||
<span data-private>{camelize($collection.name)}</span>
|
||||
{#if data.twoWay}
|
||||
<img src={arrowTwo} alt={'Two way relationship'} />
|
||||
{:else}
|
||||
<img src={arrowOne} alt={'One way realationship'} />
|
||||
{/if}
|
||||
<span>{data.key}</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="u-text-center">
|
||||
<b data-private>{camelize($collection.name)}</b> has {isToMany ? 'many' : 'one'}
|
||||
<b data-private>{data.key}</b>
|
||||
</p>
|
||||
</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"
|
||||
|
||||
+1
-2
@@ -23,7 +23,7 @@ export type Option = {
|
||||
data: Partial<Attributes>
|
||||
) => Promise<void>;
|
||||
update: (databaseId: string, collectionId: string, data: Partial<Attributes>) => Promise<void>;
|
||||
format?: 'email' | 'ip' | 'url' | 'enum' | 'relationship';
|
||||
format?: 'email' | 'ip' | 'url' | 'enum';
|
||||
icon: string;
|
||||
};
|
||||
|
||||
@@ -108,7 +108,6 @@ export const options: Option[] = [
|
||||
name: 'Relationship',
|
||||
component: Relationship,
|
||||
type: 'relationship',
|
||||
format: 'relationship',
|
||||
create: submitRelationship,
|
||||
update: updateRelationship,
|
||||
icon: 'relationship'
|
||||
|
||||
+6
-3
@@ -9,11 +9,12 @@
|
||||
import { base } from '$app/paths';
|
||||
import type { Attributes } from './store';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { preferences } from '$lib/stores/preferences';
|
||||
|
||||
export let showCreate = false;
|
||||
export let selectedOption: string = null;
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
$: collectionId = $page.params.collection;
|
||||
|
||||
let key: string = null;
|
||||
let data: Partial<Attributes> = {
|
||||
@@ -26,8 +27,10 @@
|
||||
async function submit() {
|
||||
try {
|
||||
await $option.create(databaseId, collectionId, key, data);
|
||||
let selected = preferences.getCustomCollectionColumns(collectionId);
|
||||
selected.push(key ?? data?.key);
|
||||
preferences.setCustomCollectionColumns(selected);
|
||||
await invalidate(Dependencies.COLLECTION);
|
||||
// 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`
|
||||
@@ -86,7 +89,7 @@
|
||||
autofocus
|
||||
required />
|
||||
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small">
|
||||
<div class="u-flex u-gap-4 u-margin-block-start-8 u-small u-cross-center">
|
||||
<span
|
||||
class="icon-info u-cross-center u-margin-block-start-2 u-line-height-1 u-icon-small"
|
||||
aria-hidden="true" />
|
||||
|
||||
+3
-1
@@ -11,7 +11,8 @@
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let value: string | number | boolean | null;
|
||||
export let value: string | number | boolean | null | string[];
|
||||
export let editing = false;
|
||||
export let attribute:
|
||||
| Models.AttributeBoolean
|
||||
| Models.AttributeEmail
|
||||
@@ -53,6 +54,7 @@
|
||||
<svelte:component
|
||||
this={attributesTypeMap[attribute.type]}
|
||||
{id}
|
||||
{editing}
|
||||
{label}
|
||||
{attribute}
|
||||
{optionalText}
|
||||
|
||||
+3
-6
@@ -7,6 +7,7 @@
|
||||
export let attribute: Attributes;
|
||||
export let formValues: object = {};
|
||||
export let label: string;
|
||||
export let editing = false;
|
||||
|
||||
function removeArrayItem(key: string, index: number) {
|
||||
formValues = {
|
||||
@@ -26,14 +27,9 @@
|
||||
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 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">
|
||||
@@ -80,6 +76,7 @@
|
||||
{:else}
|
||||
<FormList>
|
||||
<Attribute
|
||||
{editing}
|
||||
{attribute}
|
||||
{label}
|
||||
optionalText={getAttributeType(attribute)}
|
||||
|
||||
+227
-19
@@ -1,28 +1,51 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { InputSelectSearch } from '$lib/elements/forms';
|
||||
import { PaginationInline } from '$lib/components';
|
||||
import { SelectSearchItem } from '$lib/elements';
|
||||
import { Button, InputSelectSearch, Label } 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';
|
||||
import { doc } from '../store';
|
||||
import { isRelationshipToMany } from './store';
|
||||
|
||||
export let id: string;
|
||||
export let label: string;
|
||||
export let value: string;
|
||||
export let attribute: Models.AttributeRelationship;
|
||||
|
||||
export let value: string | string[];
|
||||
//TODO: remove `side` after SDK update
|
||||
export let attribute: Models.AttributeRelationship & { side: string };
|
||||
export let optionalText: string | undefined = undefined;
|
||||
export let editing = false;
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
|
||||
let documentList: Models.DocumentList<Models.Document>;
|
||||
let search: string = null;
|
||||
let displayNames = ['$id'];
|
||||
let relatedList: string[] = [];
|
||||
let singleRel: string;
|
||||
let showInput = false;
|
||||
let limit = 10;
|
||||
let offset = 0;
|
||||
|
||||
onMount(async () => {
|
||||
teamPrefs.load($organization.$id);
|
||||
await teamPrefs.load($organization.$id);
|
||||
documentList = await getDocuments();
|
||||
|
||||
if (editing && $doc?.[attribute.key]) {
|
||||
if ($doc[attribute.key]?.length) {
|
||||
relatedList =
|
||||
$doc[attribute.key]?.map((d: Record<string, unknown>) => {
|
||||
return d?.$id;
|
||||
}) ?? [];
|
||||
} else {
|
||||
singleRel = $doc[attribute.key]?.$id;
|
||||
}
|
||||
}
|
||||
|
||||
displayNames = $teamPrefs?.displayNames?.[attribute?.relatedCollection] ?? ['$id'];
|
||||
if (!displayNames?.includes('$id')) {
|
||||
displayNames.unshift('$id');
|
||||
@@ -34,7 +57,7 @@
|
||||
const documents = await sdk.forProject.databases.listDocuments(
|
||||
databaseId,
|
||||
attribute.relatedCollection,
|
||||
[Query.search(displayNames[0], search), Query.orderDesc('$createdAt')]
|
||||
[Query.search('$id', search), Query.orderDesc('$createdAt')]
|
||||
);
|
||||
return documents;
|
||||
} else {
|
||||
@@ -45,20 +68,205 @@
|
||||
return documents;
|
||||
}
|
||||
}
|
||||
// Reactive statements
|
||||
|
||||
//Reactive statements
|
||||
$: getDocuments(search).then((res) => (documentList = res));
|
||||
|
||||
$: paginatedItems = editing
|
||||
? relatedList
|
||||
.slice()
|
||||
.reverse()
|
||||
.slice(offset, offset + limit)
|
||||
: [];
|
||||
$: total = relatedList?.length ?? 0;
|
||||
$: options =
|
||||
documentList?.documents?.map((n) => {
|
||||
const data = displayNames.filter((name) => name !== '$id').map((name) => n?.[name]);
|
||||
return {
|
||||
value: n.$id,
|
||||
label: n.$id,
|
||||
data
|
||||
};
|
||||
}) ?? [];
|
||||
</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]]
|
||||
})) ?? []} />
|
||||
{#if isRelationshipToMany(attribute)}
|
||||
<div class="u-width-full-line">
|
||||
<div class="u-flex u-cross-center u-main-space-between">
|
||||
<div>
|
||||
<Label required={attribute.required} {optionalText} for={id}>
|
||||
{label}
|
||||
</Label>
|
||||
</div>
|
||||
{#if editing || total === 0}
|
||||
<Button
|
||||
text
|
||||
noMargin
|
||||
on:click={() => {
|
||||
showInput = true;
|
||||
}}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add item</span>
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<ul class="u-flex-vertical u-gap-4 u-margin-block-start-4">
|
||||
{#if !editing && relatedList?.length}
|
||||
{#each relatedList as item, i}
|
||||
<li class="u-flex u-gap-16">
|
||||
<InputSelectSearch
|
||||
{id}
|
||||
label="Rel"
|
||||
showLabel={false}
|
||||
required
|
||||
bind:search
|
||||
bind:value={item}
|
||||
{options}
|
||||
let:option={o}>
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
<svelte:fragment slot="output">
|
||||
<output class="input-text is-read-only">
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
</output>
|
||||
</svelte:fragment>
|
||||
</InputSelectSearch>
|
||||
<Button
|
||||
text
|
||||
noMargin
|
||||
ariaLabel={`Delete item ${i}`}
|
||||
on:click={() => {
|
||||
relatedList.splice(i, 1);
|
||||
relatedList = relatedList;
|
||||
value = relatedList;
|
||||
}}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</li>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
{#if showInput}
|
||||
<li class="u-flex u-gap-16">
|
||||
<InputSelectSearch
|
||||
{id}
|
||||
label="Rel"
|
||||
showLabel={false}
|
||||
required
|
||||
placeholder={`Select ${attribute.key}`}
|
||||
bind:search
|
||||
bind:value={relatedList[total]}
|
||||
options={options?.filter((n) => !relatedList.includes(n.value))}
|
||||
on:select={() => {
|
||||
value = relatedList;
|
||||
showInput = false;
|
||||
}}
|
||||
let:option={o}>
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
<svelte:fragment slot="output">
|
||||
<output class="input-text is-read-only">
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
</output>
|
||||
</svelte:fragment>
|
||||
</InputSelectSearch>
|
||||
<Button
|
||||
text
|
||||
noMargin
|
||||
ariaLabel={`Hide input`}
|
||||
on:click={() => (showInput = false)}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
{#if paginatedItems && editing}
|
||||
{#each paginatedItems as item, i}
|
||||
<li class="u-flex u-gap-16">
|
||||
<InputSelectSearch
|
||||
{id}
|
||||
label="Rel"
|
||||
showLabel={false}
|
||||
required
|
||||
bind:search
|
||||
bind:value={item}
|
||||
{options}
|
||||
let:option={o}>
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
<svelte:fragment slot="output">
|
||||
<output class="input-text is-read-only">
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
</output>
|
||||
</svelte:fragment>
|
||||
</InputSelectSearch>
|
||||
<Button
|
||||
text
|
||||
noMargin
|
||||
ariaLabel={`Delete item ${i}`}
|
||||
on:click={() => {
|
||||
relatedList.splice(i, 1);
|
||||
relatedList = relatedList;
|
||||
value = relatedList;
|
||||
}}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</li>
|
||||
{/each}
|
||||
{/if}
|
||||
</ul>
|
||||
{#if editing}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {total}</p>
|
||||
<PaginationInline {limit} bind:offset sum={total} hidePages />
|
||||
</div>
|
||||
{/if}
|
||||
{#if total > 0 && !editing}
|
||||
<Button
|
||||
text
|
||||
noMargin
|
||||
disabled={showInput}
|
||||
on:click={() => {
|
||||
showInput = true;
|
||||
}}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add item</span>
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<InputSelectSearch
|
||||
{id}
|
||||
{label}
|
||||
{optionalText}
|
||||
required={attribute.required}
|
||||
name="documents"
|
||||
placeholder={`Select ${attribute.key}`}
|
||||
interactiveOutput
|
||||
bind:search
|
||||
bind:value={singleRel}
|
||||
{options}
|
||||
let:option={o}
|
||||
on:reset={() => (value = null)}
|
||||
on:select={() => (value = singleRel)}>
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
<svelte:fragment slot="output">
|
||||
<output class="input-text">
|
||||
<SelectSearchItem data={o.data}>
|
||||
{o.label}
|
||||
</SelectSearchItem>
|
||||
</output>
|
||||
</svelte:fragment>
|
||||
</InputSelectSearch>
|
||||
{/if}
|
||||
-112
@@ -1,112 +0,0 @@
|
||||
<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>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import type { Attributes } from '../../store';
|
||||
|
||||
//TODO: remove `side` after SDK update
|
||||
export function isRelationshipToMany(attribute: Models.AttributeRelationship & { side: string }) {
|
||||
if (!attribute) return false;
|
||||
if (!attribute?.relationType) return false;
|
||||
if (attribute?.side === 'child') {
|
||||
return !['oneToOne', 'oneToMany'].includes(attribute?.relationType);
|
||||
} else {
|
||||
return !['oneToOne', 'manyToOne'].includes(attribute?.relationType);
|
||||
}
|
||||
}
|
||||
|
||||
export function isRelationship(attribute: Attributes): attribute is Models.AttributeRelationship {
|
||||
if (!attribute) return false;
|
||||
return attribute?.type === 'relationship';
|
||||
}
|
||||
+47
-9
@@ -10,14 +10,16 @@
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
|
||||
import { doc } from '../store';
|
||||
import { collection } from '../../store';
|
||||
import { collection, type Attributes } from '../../store';
|
||||
import { Container } from '$lib/layout';
|
||||
import AttributeItem from '../attributeItem.svelte';
|
||||
import { difference } from '$lib/helpers/array';
|
||||
import { difference, symmetricDifference } from '$lib/helpers/array';
|
||||
import { isRelationship, isRelationshipToMany } from '../attributes/store';
|
||||
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
const documentId = $page.params.document;
|
||||
const editing = true;
|
||||
|
||||
const work = writable(
|
||||
Object.keys($doc)
|
||||
@@ -61,6 +63,47 @@
|
||||
trackError(error, Submit.DocumentUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
function compareAttributes(
|
||||
attribute: Attributes,
|
||||
$work: Models.Document,
|
||||
$doc: Models.Document
|
||||
) {
|
||||
if (!attribute) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const workAttribute = $work?.[attribute.key];
|
||||
const docAttribute = $doc?.[attribute.key];
|
||||
|
||||
if (attribute.array) {
|
||||
return !difference(Array.from(workAttribute), Array.from(docAttribute)).length;
|
||||
}
|
||||
|
||||
if (isRelationship(attribute)) {
|
||||
//TODO: remove `side` after SDK update
|
||||
if (
|
||||
isRelationshipToMany(attribute as Models.AttributeRelationship & { side: string })
|
||||
) {
|
||||
const workIds = workAttribute.map((doc: string | Record<string, unknown>) =>
|
||||
typeof doc === 'string' ? doc : doc.$id
|
||||
);
|
||||
|
||||
const relatedIds = docAttribute.map((doc: string | Record<string, unknown>) =>
|
||||
typeof doc === 'string' ? doc : doc.$id
|
||||
);
|
||||
return !symmetricDifference(workIds, relatedIds).length;
|
||||
} else {
|
||||
const workId =
|
||||
typeof workAttribute === 'string' ? workAttribute : workAttribute?.$id;
|
||||
const relatedId =
|
||||
typeof docAttribute === 'string' ? docAttribute : docAttribute?.$id;
|
||||
|
||||
return workId === relatedId;
|
||||
}
|
||||
}
|
||||
return workAttribute === docAttribute;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -74,17 +117,12 @@
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">{label}</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<AttributeItem {attribute} bind:formValues={$work} {label} />
|
||||
<AttributeItem {attribute} bind:formValues={$work} {label} {editing} />
|
||||
</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]}
|
||||
disabled={compareAttributes(attribute, $work, $doc)}
|
||||
on:click={() => updateData()}>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
|
||||
+10
-4
@@ -17,6 +17,8 @@
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { attributes, collection } from '../store';
|
||||
import { isRelationship } from './attributes/store';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let showDelete = false;
|
||||
const databaseId = $page.params.database;
|
||||
@@ -53,7 +55,9 @@
|
||||
'restrict' = 'Document can not be deleted'
|
||||
}
|
||||
|
||||
$: relAttributes = [$attributes?.find((attribute) => attribute.type === 'relationship')];
|
||||
$: relAttributes = $attributes?.filter((attribute) =>
|
||||
isRelationship(attribute)
|
||||
) as Models.AttributeRelationship[];
|
||||
</script>
|
||||
|
||||
<Modal
|
||||
@@ -65,7 +69,9 @@
|
||||
<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>?
|
||||
Are you sure you want to delete <b
|
||||
>the document from <span data-private>{$collection.name}</span></b
|
||||
>?
|
||||
</p>
|
||||
|
||||
{#if relAttributes?.length}
|
||||
@@ -85,7 +91,7 @@
|
||||
{:else}
|
||||
<span class="icon-arrow-sm-right" />
|
||||
{/if}
|
||||
{attr?.key}
|
||||
<span data-private>{attr?.key}</span>
|
||||
</span>
|
||||
</TableCell>
|
||||
<TableCellText title="Settings">
|
||||
@@ -102,7 +108,7 @@
|
||||
<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}
|
||||
Delete document from <span data-private>{$collection.name}</span>
|
||||
</InputChoice>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@
|
||||
<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">
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
+7
-4
@@ -9,6 +9,7 @@
|
||||
import { remove } from '$lib/helpers/array';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { isRelationship } from '../document-[document]/attributes/store';
|
||||
import { indexes, type Attributes } from '../store';
|
||||
import { collection } from '../store';
|
||||
import Select from './select.svelte';
|
||||
@@ -27,10 +28,12 @@
|
||||
];
|
||||
let selectedType = 'key';
|
||||
|
||||
let attributeOptions = $collection.attributes.map((attribute: Attributes) => ({
|
||||
value: attribute.key,
|
||||
label: attribute.key
|
||||
}));
|
||||
let attributeOptions = $collection.attributes
|
||||
.filter((attribute) => !isRelationship(attribute))
|
||||
.map((attribute) => ({
|
||||
value: attribute.key,
|
||||
label: attribute.key
|
||||
}));
|
||||
|
||||
let attributeList = [{ value: '', order: '' }];
|
||||
|
||||
|
||||
+6
-1
@@ -39,7 +39,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal icon="exclamation" state="warning" onSubmit={handleDelete} bind:show={showDelete}>
|
||||
<Modal
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
onSubmit={handleDelete}
|
||||
bind:show={showDelete}
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Index</svelte:fragment>
|
||||
|
||||
<p data-private>
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
<script lang="ts">
|
||||
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
|
||||
import { collection } from './store';
|
||||
|
||||
// svelte-ignore unused-export-let
|
||||
export let queries: string[] = [];
|
||||
|
||||
let selectedOption: string;
|
||||
|
||||
$: currentIndex = $collection.indexes.find((i) => i.key === selectedOption);
|
||||
|
||||
const options = $collection.indexes.map((i) => {
|
||||
return {
|
||||
value: i.key,
|
||||
label: i.key
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<InputSelect id="currentIndex" label="Index" {options} bind:value={selectedOption} />
|
||||
|
||||
{#if currentIndex}
|
||||
{#each currentIndex.attributes as a}
|
||||
<p>{a}</p>
|
||||
{/each}
|
||||
{/if}
|
||||
+40
-18
@@ -1,32 +1,54 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { ClickableList, ClickableListItem, Modal, Paginator } from '$lib/components';
|
||||
import { teamPrefs } from '$lib/stores/team';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
|
||||
export let show = false;
|
||||
export let selectedRelationship: string = null;
|
||||
export let data: [];
|
||||
export let selectedRelationship: Models.AttributeRelationship = null;
|
||||
const projectId = $page.params.project;
|
||||
const databaseId = $page.params.database;
|
||||
const limit = 10;
|
||||
let offset = 0;
|
||||
|
||||
$: args = $teamPrefs?.displayNames?.[selectedRelationship?.relatedCollection];
|
||||
|
||||
$: if (!show) {
|
||||
data = null;
|
||||
selectedRelationship = null;
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal size="big" bind:show icon="relationship">
|
||||
<Modal size="big" bind:show icon="relationship" headerDivider={false}>
|
||||
<svelte:fragment slot="header">
|
||||
{selectedRelationship}
|
||||
<span data-private>
|
||||
{selectedRelationship.key}
|
||||
</span>
|
||||
</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>
|
||||
{#if data?.length}
|
||||
<Paginator items={data} {limit} let:paginatedItems>
|
||||
<ClickableList>
|
||||
{#each paginatedItems as doc}
|
||||
<ClickableListItem
|
||||
href={`${base}/console/project-${projectId}/databases/database-${databaseId}/collection-${selectedRelationship.relatedCollection}/document-${doc.$id}`}
|
||||
on:click={() => (show = false)}>
|
||||
{#if args?.length}
|
||||
{#each args as arg, i}
|
||||
{#if i}
|
||||
<span class="clickable-list-title-sep">|</span>
|
||||
{/if}
|
||||
<span data-private>{doc[arg]}</span>
|
||||
{/each}
|
||||
{/if}
|
||||
<svelte:fragment slot="desc">
|
||||
{doc.$id}
|
||||
</svelte:fragment>
|
||||
</ClickableListItem>
|
||||
{/each}
|
||||
</ClickableList>
|
||||
</Paginator>
|
||||
{/if}
|
||||
<svelte:fragment slot="footer" />
|
||||
</Modal>
|
||||
+6
-1
@@ -37,7 +37,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal icon="exclamation" state="warning" bind:show={showDelete} onSubmit={handleDelete}>
|
||||
<Modal
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Collection</svelte:fragment>
|
||||
|
||||
<p data-private>
|
||||
|
||||
+10
-10
@@ -3,11 +3,12 @@
|
||||
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 { Button, Form, 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 type { Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import { attributes, collection } from '../store';
|
||||
|
||||
@@ -31,10 +32,10 @@
|
||||
[$collection.$id]: displayNames
|
||||
}
|
||||
};
|
||||
teamPrefs.updatePrefs($organization.$id, pref);
|
||||
invalidate(Dependencies.TEAM);
|
||||
await teamPrefs.updatePrefs($organization.$id, pref);
|
||||
await invalidate(Dependencies.TEAM);
|
||||
addNotification({
|
||||
message: 'Name has been updated',
|
||||
message: 'Display names has been updated',
|
||||
type: 'success'
|
||||
});
|
||||
trackEvent(Submit.CollectionUpdateName);
|
||||
@@ -47,7 +48,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
$: options = $attributes
|
||||
$: options = ($attributes as Models.AttributeString[])
|
||||
.filter(
|
||||
(attr) =>
|
||||
attr.type === 'string' &&
|
||||
@@ -70,8 +71,6 @@
|
||||
displayNames,
|
||||
$teamPrefs?.displayNames?.[$collection.$id] ?? []
|
||||
)?.length;
|
||||
|
||||
$: console.log(displayNames, $teamPrefs?.displayNames[$collection.$id]);
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateDisplayName}>
|
||||
@@ -83,8 +82,8 @@
|
||||
</p>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="u-flex u-flex-vertical u-gap-8">
|
||||
<FormList>
|
||||
<div class="u-flex u-flex-vertical u-gap-4">
|
||||
<ul class="u-flex-vertical u-gap-4 u-margin-block-start-4">
|
||||
<InputText
|
||||
id="id"
|
||||
label="Document ID"
|
||||
@@ -99,6 +98,7 @@
|
||||
id={name}
|
||||
label={name}
|
||||
showLabel={false}
|
||||
interactiveOutput
|
||||
placeholder="Select attribute"
|
||||
bind:value={displayNames[i]}
|
||||
bind:search={displayNames[i]}
|
||||
@@ -130,7 +130,7 @@
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
</FormList>
|
||||
</ul>
|
||||
<Button
|
||||
noMargin
|
||||
text
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ import { page } from '$app/stores';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { derived, writable } from 'svelte/store';
|
||||
|
||||
//TODO: remove `side` after SDK update
|
||||
export type Attributes =
|
||||
| Models.AttributeBoolean
|
||||
| Models.AttributeEmail
|
||||
@@ -11,7 +12,7 @@ export type Attributes =
|
||||
| Models.AttributeIp
|
||||
| Models.AttributeString
|
||||
| Models.AttributeUrl
|
||||
| Models.AttributeRelationship;
|
||||
| (Models.AttributeRelationship & { side: string; default?: never });
|
||||
|
||||
type Collection = Omit<Models.Collection, 'attributes'> & {
|
||||
attributes: Array<Attributes>;
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@
|
||||
{@const isSelected = collectionId === collection.$id}
|
||||
<li class="drop-list-item">
|
||||
<a class="drop-button" class:is-selected={isSelected} {href}>
|
||||
<span class="text">{collection.name}</span>
|
||||
<span class="text" data-private>{collection.name}</span>
|
||||
</a>
|
||||
</li>
|
||||
{/each}
|
||||
|
||||
+54
-41
@@ -5,7 +5,6 @@
|
||||
import { tooltip } from '$lib/actions/tooltip';
|
||||
import { Copy } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
TableBody,
|
||||
TableCell,
|
||||
@@ -15,9 +14,12 @@
|
||||
TableScroll
|
||||
} from '$lib/elements/table';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
import { preferences } from '$lib/stores/preferences';
|
||||
import { teamPrefs } from '$lib/stores/team';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import { onMount } from 'svelte';
|
||||
import type { PageData } from './$types';
|
||||
import { isRelationship, isRelationshipToMany } from './document-[document]/attributes/store';
|
||||
import RelationshipsModal from './relationshipsModal.svelte';
|
||||
import { attributes, collection, columns } from './store';
|
||||
|
||||
@@ -25,20 +27,12 @@
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const databaseId = $page.params.database;
|
||||
const collectionId = $page.params.collection;
|
||||
let showRelationships = false;
|
||||
let selectedRelationship: string = null;
|
||||
let selectedRelationship: Models.AttributeRelationship = null;
|
||||
let relationshipData: [];
|
||||
|
||||
onMount(() => {
|
||||
teamPrefs.load($organization.$id);
|
||||
columns.set([
|
||||
...$collection.attributes.map((attribute) => ({
|
||||
id: attribute.key,
|
||||
title: attribute.key,
|
||||
type: attribute.type,
|
||||
show: true
|
||||
}))
|
||||
]);
|
||||
});
|
||||
|
||||
function formatArray(array: unknown[]) {
|
||||
@@ -78,6 +72,17 @@
|
||||
whole: formattedColumn
|
||||
};
|
||||
}
|
||||
|
||||
$: selected = preferences.getCustomCollectionColumns($page.params.collection);
|
||||
|
||||
$: columns.set(
|
||||
$collection.attributes.map((attribute) => ({
|
||||
id: attribute.key,
|
||||
title: attribute.key,
|
||||
type: attribute.type,
|
||||
show: selected?.includes(attribute.key) ?? true
|
||||
}))
|
||||
);
|
||||
</script>
|
||||
|
||||
<TableScroll isSticky>
|
||||
@@ -104,41 +109,48 @@
|
||||
|
||||
{#each $columns as column}
|
||||
{#if column.show}
|
||||
{#if column.type === 'relationship'}
|
||||
<!-- {JSON.stringify(document[column.id])} -->
|
||||
{@const attr = $attributes.find((n) => n.key === column.id)}
|
||||
{@const attr = $attributes.find((n) => n.key === column.id)}
|
||||
{#if isRelationship(attr)}
|
||||
{@const args = $teamPrefs?.displayNames?.[attr.relatedCollection] ?? [
|
||||
'$id'
|
||||
]}
|
||||
|
||||
{#if !column.twoWay}
|
||||
<TableCell title={column.title}>
|
||||
<TableCell title={column.title}>
|
||||
{#if !isRelationshipToMany(attr)}
|
||||
{#if document[column.id]}
|
||||
{@const related = document[column.id]}
|
||||
<button
|
||||
class="link u-flex u-gap-4 u-padding-block-8"
|
||||
type="button"
|
||||
on:click|preventDefault|stopPropagation={() =>
|
||||
goto(
|
||||
`${base}/console/project-${projectId}/databases/database-${databaseId}/collection-${attr.relatedCollection}/document-${related.$id}`
|
||||
)}>
|
||||
{#each args as arg, i}
|
||||
{#if arg !== undefined}
|
||||
{i ? '|' : ''}
|
||||
<span class="text" data-private>
|
||||
{related?.[arg]}
|
||||
</span>
|
||||
{/if}
|
||||
{/each}
|
||||
</button>
|
||||
{:else}
|
||||
<span class="text">n/a</span>
|
||||
{/if}
|
||||
{:else}
|
||||
{@const itemsNum = document[column.id]?.length}
|
||||
<button
|
||||
class="button is-text link"
|
||||
type="button"
|
||||
on:click|preventDefault|stopPropagation={() =>
|
||||
goto(
|
||||
`${base}/console/project-${projectId}/databases/database-${databaseId}/collection-${attr.relatedCollection}`
|
||||
)}>
|
||||
{#each args as arg, i}
|
||||
{i ? '|' : ''}
|
||||
<span class="text">{document[column.id]?.[arg]}</span>
|
||||
{/each}
|
||||
</button>
|
||||
</TableCell>
|
||||
{:else}
|
||||
<TableCell>
|
||||
{@const itemsNum = column?.data?.lenght}
|
||||
<Button
|
||||
on:click={() => {
|
||||
class="button is-text"
|
||||
on:click|preventDefault|stopPropagation={() => {
|
||||
relationshipData = document[column.id];
|
||||
showRelationships = true;
|
||||
selectedRelationship = document;
|
||||
selectedRelationship = attr;
|
||||
}}
|
||||
disabled={!itemsNum}>
|
||||
Items <span class="inline-tag">{itemsNum}</span>
|
||||
</Button>
|
||||
</TableCell>
|
||||
{/if}
|
||||
Items <span class="inline-tag">{itemsNum ?? 0}</span>
|
||||
</button>
|
||||
{/if}
|
||||
</TableCell>
|
||||
{:else}
|
||||
{@const formatted = formatColumn(document[column.id])}
|
||||
<TableCell>
|
||||
@@ -146,7 +158,8 @@
|
||||
use:tooltip={{
|
||||
content: formatted.whole,
|
||||
disabled: !formatted.truncated
|
||||
}}>
|
||||
}}
|
||||
data-private>
|
||||
{formatted.value}
|
||||
</div>
|
||||
</TableCell>
|
||||
@@ -158,4 +171,4 @@
|
||||
</TableBody>
|
||||
</TableScroll>
|
||||
|
||||
<RelationshipsModal bind:show={showRelationships} {selectedRelationship} />
|
||||
<RelationshipsModal bind:show={showRelationships} {selectedRelationship} data={relationshipData} />
|
||||
@@ -32,7 +32,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal icon="exclamation" state="warning" bind:show={showDelete} onSubmit={handleDelete}>
|
||||
<Modal
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Database</svelte:fragment>
|
||||
<p class="text" data-private>
|
||||
Are you sure you want to delete <b>{$database.name}</b>?
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h2"
|
||||
>You have no inactive deployments. Create one to see it here.</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Learn more about deployments in our Documentation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -187,7 +187,7 @@
|
||||
<img src={GithubLight} alt="github" />
|
||||
{/if}
|
||||
<div class="u-flex u-flex-vertical u-gap-24">
|
||||
<h3 class="body-text-1">Coming Soon!</h3>
|
||||
<h3 class="body-text-1 u-bold">Coming Soon!</h3>
|
||||
<p>
|
||||
Creating deployments will be easier than ever with our upcoming Git Integration.
|
||||
Just set up a repository and we'll do the rest.
|
||||
|
||||
@@ -34,7 +34,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={handleSubmit} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleSubmit}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Deployment</svelte:fragment>
|
||||
<p data-private>Are you sure you want to delete this deployment?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
+6
-1
@@ -31,7 +31,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={handleSubmit} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleSubmit}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Function</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to delete this function and all associated deployments from your
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
<div class="grid-item-1-end-start">
|
||||
<div class="heading-level-4">
|
||||
{storage.value}
|
||||
<span class="body-text-2">{storage.unit}</span>
|
||||
<span class="body-text-2 u-bold">{storage.unit}</span>
|
||||
</div>
|
||||
<div>Storage</div>
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div>
|
||||
<div class="heading-level-4">
|
||||
{bandwith.value}
|
||||
<span class="body-text-2">{bandwith.unit}</span>
|
||||
<span class="body-text-2 u-bold">{bandwith.unit}</span>
|
||||
</div>
|
||||
<div>Bandwidth</div>
|
||||
</div>
|
||||
|
||||
@@ -33,7 +33,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={handleDelete} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete API Key</svelte:fragment>
|
||||
<p>The API Key will be permanently deleted. This action is irreversible.</p>
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@
|
||||
<slot>
|
||||
<div class="u-text-center">
|
||||
<Heading size="7" tag="h4">Create your first platform to get started.</Heading>
|
||||
<p class="body-text-2 u-margin-block-start-4">
|
||||
<p class="body-text-2 u-bold u-margin-block-start-4">
|
||||
Need a hand? Check out our documentation.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -33,7 +33,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={handleDelete} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Platform</svelte:fragment>
|
||||
<p>The Platform will be permanently deleted. This action is irreversible.</p>
|
||||
|
||||
|
||||
@@ -33,7 +33,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={handleDelete} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Project</svelte:fragment>
|
||||
<p>
|
||||
<b>This project will be deleted</b>, along with all of its metadata, stats, and other
|
||||
|
||||
@@ -32,7 +32,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteDomain} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteDomain}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Domain</svelte:fragment>
|
||||
{#if selectedDomain}
|
||||
<p data-private>
|
||||
|
||||
@@ -33,7 +33,12 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={handleDelete} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={handleDelete}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Webhook</svelte:fragment>
|
||||
<p data-private>
|
||||
Are you sure you want to delete <b>{$webhook.name}</b> from '{$project.name}'?
|
||||
|
||||
@@ -31,7 +31,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteUser} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteUser}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete Bucket</svelte:fragment>
|
||||
<p data-private>Are you sure you want to delete <b>{$bucket.name}</b>?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
@@ -32,7 +32,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteFile} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteFile}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete File</svelte:fragment>
|
||||
<p data-private>Are you sure you want to delete <b>{file.name}</b>?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
+6
-1
@@ -33,7 +33,12 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<Modal bind:show={showDelete} onSubmit={deleteFile} icon="exclamation" state="warning">
|
||||
<Modal
|
||||
bind:show={showDelete}
|
||||
onSubmit={deleteFile}
|
||||
icon="exclamation"
|
||||
state="warning"
|
||||
headerDivider={false}>
|
||||
<svelte:fragment slot="header">Delete File</svelte:fragment>
|
||||
<p data-private>Are you sure you want to delete <b>{$file.name}</b>?</p>
|
||||
<svelte:fragment slot="footer">
|
||||
|
||||
Reference in new issue
Block a user