diff --git a/src/lib/stores/layout.ts b/src/lib/stores/layout.ts index 74ecd4644..b6319f9a7 100644 --- a/src/lib/stores/layout.ts +++ b/src/lib/stores/layout.ts @@ -1,4 +1,4 @@ -import { writable, readable } from 'svelte/store'; +import { writable } from 'svelte/store'; import type { SvelteComponent } from 'svelte'; import { browser } from '$app/environment'; import { PAGE_LIMIT } from '$lib/constants'; diff --git a/src/routes/console/project-[project]/databases/[[page]]/store.ts b/src/routes/console/project-[project]/databases/[[page]]/store.ts new file mode 100644 index 000000000..868cd0c4d --- /dev/null +++ b/src/routes/console/project-[project]/databases/[[page]]/store.ts @@ -0,0 +1,15 @@ +import { writable } from 'svelte/store'; + +export type Column = { + id: string; + name: string; + show: boolean; + width?: number; +}; + +export const columns = writable([ + { id: '$id', name: 'Database ID', show: true, width: 50 }, + { id: 'name', name: 'Name', show: true, width: 120 }, + { id: '$createdAt', name: 'Created', show: true, width: 120 }, + { id: '$updatedAt', name: 'Updated', show: true, width: 120 } +]); diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/[[page]]/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/[[page]]/+page.svelte index 39594fb9a..14e3aa5c3 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/[[page]]/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/[[page]]/+page.svelte @@ -18,9 +18,11 @@ import { collection } from '../store'; import { page } from '$app/stores'; import { PAGE_LIMIT } from '$lib/constants'; + import CreateAttribute from '../createAttribute.svelte'; import { tooltip } from '$lib/actions/tooltip'; export let data: PageData; + let showCreateAttribute = false; function openWizard() { wizard.start(Create); @@ -85,56 +87,66 @@ - {#if data.documents.total} - - - Document ID - {#each columns as column} - {column.title} - {/each} - - - {#each data.documents.documents as document} - - - - - - - - {#each columns as column} - {@const formatted = formatColumn(document[column.key])} - -
- {formatted.value} -
+ {#if $collection?.attributes?.length} + {#if data.documents.total} + + + Document ID + {#each columns as column} + {column.title} + {/each} + + + {#each data.documents.documents as document} + + + + + + - {/each} - - {/each} - - + {#each columns as column} + {@const formatted = formatColumn(document[column.key])} + +
+ {formatted.value} +
+
+ {/each} +
+ {/each} +
+
-
-

Total results: {data.documents.total}

- -
+
+

Total results: {data.documents.total}

+ +
+ {:else} + + {/if} {:else} + href="https://appwrite.io/docs/databases#attributes" + target="attribute" + on:click={() => (showCreateAttribute = true)} /> {/if} + + diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte index d84d742f4..2031838b7 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/+page.svelte @@ -17,6 +17,7 @@ import CreateIndex from '../indexes/createIndex.svelte'; import Delete from './deleteAttribute.svelte'; import Overview from './overview.svelte'; + import { options } from './store'; let showCreateDropdown = false; let showDropdown = []; @@ -26,19 +27,6 @@ let showDelete = false; let showOverview = false; let showCreateIndex = false; - - const attributesList = [ - { name: 'String', icon: 'text' }, - { name: 'Integer', icon: 'hashtag' }, - { name: 'Float', icon: 'hashtag' }, - { name: 'Boolean', icon: 'toggle' }, - { name: 'Datetime', icon: 'calendar' }, - { name: 'Email', icon: 'mail' }, - { name: 'IP', icon: 'location-marker' }, - { name: 'URL', icon: 'link' }, - { name: 'Enum', icon: 'list' }, - { name: 'Relationship', icon: 'relationship' } - ]; @@ -53,7 +41,7 @@ Create attribute - {#each attributesList as attribute} + {#each options as attribute} { diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte index 80006224e..df9dd7df1 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/relationship.svelte @@ -21,7 +21,9 @@ - - - - Indicate whether this is a required attribute - - - Indicate whether this attribute should act as an array - +{#if isOneWay} + + +
+ + +
+
+
+{:else} + 2 +{/if} diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/store.ts b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/store.ts index d276c4cfe..237d83456 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/store.ts +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/attributes/store.ts @@ -23,6 +23,7 @@ export type Option = { data: Partial ) => Promise; format?: 'email' | 'ip' | 'url' | 'enum' | 'relationship'; + icon: string; }; export const options: Option[] = [ @@ -30,66 +31,76 @@ export const options: Option[] = [ name: 'String', component: String, type: 'string', - func: submitString + func: submitString, + icon: 'text' }, { name: 'Integer', component: Integer, type: 'integer', - func: submitInteger + func: submitInteger, + icon: 'hashtag' }, { name: 'Float', component: Float, type: 'double', - func: submitFloat + func: submitFloat, + icon: 'hashtag' }, { name: 'Boolean', component: Boolean, type: 'boolean', - func: submitBoolean + func: submitBoolean, + icon: 'toggle' }, { name: 'Datetime', component: Datetime, type: 'datetime', - func: submitDatetime + func: submitDatetime, + icon: 'calendar' }, { name: 'Email', component: Email, type: 'string', format: 'email', - func: submitEmail + func: submitEmail, + icon: 'mail' }, { name: 'IP', component: Ip, type: 'string', format: 'ip', - func: submitIp + func: submitIp, + icon: 'location-marker' }, { name: 'URL', component: Url, type: 'string', format: 'url', - func: submitUrl + func: submitUrl, + icon: 'link' }, { name: 'Enum', component: Enum, type: 'string', format: 'enum', - func: submitEnum + func: submitEnum, + icon: 'list' }, { name: 'Relationship', component: Relationship, type: 'relationship', format: 'relationship', - func: submitRelationship + func: submitRelationship, + icon: 'link' } ]; diff --git a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte index fe7148b2f..620f3f9a6 100644 --- a/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte +++ b/src/routes/console/project-[project]/databases/database-[database]/collection-[collection]/createAttribute.svelte @@ -9,9 +9,10 @@ import { base } from '$app/paths'; import type { Attributes } from './store'; import { Submit, trackEvent, trackError } from '$lib/actions/analytics'; + import { Pill } from '$lib/elements'; export let showCreate = false; - export let selectedOption = null; + export let selectedOption: string = null; let key: string = null; let data: Partial = { @@ -62,28 +63,34 @@ } - - Create Attribute + + {selectedOption} + {#if selectedOption === 'Relationship'} + BETA + {/if} + -
- + {#if selectedOption !== 'Relationship'} +
+ -
-
-
- + {/if} {#if selectedOption} { invalidate(Dependencies.COLLECTION); @@ -43,79 +45,90 @@ Create index
- {#if $indexes.length} - - - Key - Type - Attributes - Asc/Desc - - - - {#each $indexes as index, i} - - -
- {index.key} - {#if index.status !== 'available'} - - {index.status} - - {/if} -
-
- {index.type} - - {index.attributes} - - - {index.orders} - - - - - - { - selectedIndex = index; - showOverview = true; - }}>Overview + {#if $collection?.attributes?.length} + {#if $indexes.length} +
+ + Key + Type + Attributes + Asc/Desc + + + + {#each $indexes as index, i} + + +
+ {index.key} + {#if index.status !== 'available'} + + {index.status} + + {/if} +
+
+ {index.type} + + {index.attributes} + + + {index.orders} + + + + + + { + selectedIndex = index; + showOverview = true; + }}>Overview - { - selectedIndex = index; - showDelete = true; - }}>Delete - - - -
- {/each} -
-
-
-

Total results: {$indexes.length}

-
+ { + selectedIndex = index; + showDelete = true; + }}>Delete +
+ + + + {/each} + + +
+

Total results: {$indexes.length}

+
+ {:else} + (showCreateIndex = true)} /> + {/if} {:else} (showCreateIndex = true)} /> + target="attribute" + href="https://appwrite.io/docs/databases#attributes" + on:click={() => (showCreateAttribute = true)} /> {/if}
@@ -125,3 +138,5 @@ {/if} + +