mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: data for attributes and indexes
This commit is contained in:
1 parent
bacdcfe973
commit
80641249f4
10 files changed
+16
-53
No files matched your search
@@ -16,8 +16,6 @@ export enum Dependencies {
|
||||
COLLECTION = 'collection',
|
||||
DOCUMENT = 'document',
|
||||
DOCUMENTS = 'documents',
|
||||
ATTRIBUTES = 'attributes',
|
||||
INDEXES = 'indexes',
|
||||
BUCKET = 'bucket',
|
||||
FILE = 'file',
|
||||
FILES = 'files',
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import Header from './header.svelte';
|
||||
import { error } from '@sveltejs/kit';
|
||||
|
||||
export const load: LayoutLoad = async ({ params, parent, depends }) => {
|
||||
await parent();
|
||||
depends(Dependencies.COLLECTION);
|
||||
await parent();
|
||||
|
||||
try {
|
||||
return {
|
||||
|
||||
+4
-7
@@ -10,16 +10,13 @@
|
||||
} from '$lib/elements/table';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { DropList, DropListItem, Empty, Heading } from '$lib/components';
|
||||
import type { Attributes } from '../store';
|
||||
import { attributes, type Attributes } from '../store';
|
||||
import { Container } from '$lib/layout';
|
||||
import { Pill } from '$lib/elements';
|
||||
import Create from './createAttribute.svelte';
|
||||
import CreateIndex from '../indexes/createIndex.svelte';
|
||||
import Delete from './deleteAttribute.svelte';
|
||||
import Overview from './overview.svelte';
|
||||
import type { PageData } from './$types';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showDropdown = [];
|
||||
let selectedAttribute: Attributes = null;
|
||||
@@ -39,7 +36,7 @@
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{#if data.attributes.total}
|
||||
{#if $attributes.length}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Key</TableCellHead>
|
||||
@@ -48,7 +45,7 @@
|
||||
<TableCellHead width={30} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.attributes.attributes as attribute, index}
|
||||
{#each $attributes as attribute, index}
|
||||
<TableRow>
|
||||
<TableCell title="Key">
|
||||
<div class="u-flex u-main-space-between">
|
||||
@@ -110,7 +107,7 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div class="u-flex common-section u-main-space-between">
|
||||
<p class="text">Total results: {data.attributes.total}</p>
|
||||
<p class="text">Total results: {$attributes.length}</p>
|
||||
</div>
|
||||
{:else}
|
||||
<Empty isButton single on:click={() => (showCreate = true)}>
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
import type { Attributes } from '../store';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent, depends }) => {
|
||||
await parent();
|
||||
depends(Dependencies.ATTRIBUTES);
|
||||
|
||||
return {
|
||||
attributes: (await sdkForProject.databases.listAttributes(
|
||||
params.database,
|
||||
params.collection
|
||||
)) as unknown as {
|
||||
total: number;
|
||||
attributes: Attributes[];
|
||||
}
|
||||
};
|
||||
};
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
let submitted = false;
|
||||
|
||||
const created = async () => {
|
||||
invalidate(Dependencies.ATTRIBUTES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
showCreate = false;
|
||||
};
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@
|
||||
$collection.$id,
|
||||
selectedAttribute.key
|
||||
);
|
||||
invalidate(Dependencies.ATTRIBUTES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
showDelete = false;
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/databases/database-${databaseId}/collection-${$page.params.collection}/attributes`
|
||||
|
||||
+7
-9
@@ -11,18 +11,15 @@
|
||||
TableRow
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { collection } from '../store';
|
||||
import { indexes } from '../store';
|
||||
import Delete from './deleteIndex.svelte';
|
||||
import Create from './createIndex.svelte';
|
||||
import Overview from './overviewIndex.svelte';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import type { PageData } from './$types';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
let showDropdown = [];
|
||||
let selectedIndex: Models.Index = null;
|
||||
let showCreateIndex = false;
|
||||
@@ -30,7 +27,7 @@
|
||||
let showDelete = false;
|
||||
|
||||
const handleDelete = async () => {
|
||||
invalidate(Dependencies.INDEXES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -43,7 +40,7 @@
|
||||
<span class="text">Create index</span>
|
||||
</Button>
|
||||
</div>
|
||||
{#if data.indexes.total}
|
||||
{#if $indexes.length}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Key</TableCellHead>
|
||||
@@ -53,7 +50,7 @@
|
||||
<TableCellHead width={30} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.indexes.indexes as index, i}
|
||||
{#each $indexes as index, i}
|
||||
<TableRow>
|
||||
<TableCell title="Key">
|
||||
<div class="u-flex u-main-space-between">
|
||||
@@ -108,9 +105,9 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {data.indexes.total}</p>
|
||||
<p class="text">Total results: {$indexes.length}</p>
|
||||
</div>
|
||||
{:else if $collection.indexes?.length}
|
||||
{:else if $indexes?.length}
|
||||
<Empty isButton single on:click={() => (showCreateIndex = true)}>
|
||||
<p>Create your first attribute to get started</p>
|
||||
</Empty>
|
||||
@@ -122,6 +119,7 @@
|
||||
</Container>
|
||||
|
||||
<Create bind:showCreateIndex />
|
||||
|
||||
{#if selectedIndex}
|
||||
<Delete bind:showDelete {selectedIndex} on:deleted={handleDelete} />
|
||||
<Overview bind:showOverview {selectedIndex} />
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent, depends }) => {
|
||||
await parent();
|
||||
depends(Dependencies.INDEXES);
|
||||
|
||||
return {
|
||||
indexes: await sdkForProject.databases.listIndexes(params.database, params.collection)
|
||||
};
|
||||
};
|
||||
+1
-1
@@ -57,7 +57,7 @@
|
||||
attributeList.map((a) => a.value),
|
||||
attributeList.map((a) => a.order)
|
||||
);
|
||||
invalidate(Dependencies.INDEXES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
addNotification({
|
||||
message: 'Index created!',
|
||||
type: 'success'
|
||||
|
||||
+1
@@ -21,3 +21,4 @@ export const attributes = derived(
|
||||
page,
|
||||
($page) => $page.data.collection.attributes as Attributes[]
|
||||
);
|
||||
export const indexes = derived(page, ($page) => $page.data.collection.indexes as Models.Index[]);
|
||||
Reference in new issue
Block a user