Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export enum Dependencies {
FUNCTIONS = 'functions',
VARIABLES = 'variables',
DEPLOYMENTS = 'deployments',
EXECUTIONS = 'executions',
PLATFORM = 'platform',
PLATFORMS = 'platforms',
KEY = 'key',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Dependencies } from '$lib/constants';
import { sdkForConsole } from '$lib/stores/sdk';
import { onDestroy, onMount } from 'svelte';
import { collection } from './store';

let unsubscribe: { (): void };

onMount(() => {
unsubscribe = sdkForConsole.client.subscribe('console', (response) => {
if (
response.events.includes('databases.*.collections.*.attributes.*') ||
response.events.includes('databases.*.collections.*.indexes.*')
) {
invalidate(Dependencies.COLLECTION);
}
});
});

onDestroy(() => {
if (unsubscribe) {
unsubscribe();
}
});
</script>

<svelte:head>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { Empty, DropList, DropListItem } from '$lib/components';
import { Empty, DropList, DropListItem, Heading } from '$lib/components';
import { Pill } from '$lib/elements';
import {
Table,
Expand All @@ -19,6 +19,7 @@
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;

Expand All @@ -34,6 +35,14 @@
</script>

<Container>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<Heading tag="h2" size="5">Indexes</Heading>

<Button on:click={() => (showCreateIndex = true)}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">Create index</span>
</Button>
</div>
{#if data.indexes.total}
<Table>
<TableHeader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { Modal } from '$lib/components';
import { Button, InputText, FormList, InputSelect } from '$lib/elements/forms';
import { collection } from '../store';
import { onMount } from 'svelte';
import { sdkForProject } from '$lib/stores/sdk';
import { addNotification } from '$lib/stores/notifications';
import { page } from '$app/stores';
Expand All @@ -11,7 +10,6 @@
import { Dependencies } from '$lib/constants';

export let showCreateIndex = false;
export let externalAttribute: Attributes = null;

const databaseId = $page.params.database;

Expand All @@ -23,7 +21,7 @@
];
let newAttr = false;
let selectedType = '';
let attributeOptions = $collection.attributes.map((attribute: Attributes) => ({
$: attributeOptions = $collection.attributes.map((attribute: Attributes) => ({
value: attribute.key,
label: attribute.key
}));
Expand All @@ -32,12 +30,6 @@
let selectedAttribute = '';
let selectedOrder = '';

onMount(() => {
if (externalAttribute) {
attributeList = [{ value: externalAttribute.key, order: 'ASC' }];
}
});

$: if (showCreateIndex) {
attributeList = [];
selectedType = selectedOrder = selectedAttribute = '';
Expand Down Expand Up @@ -130,7 +122,7 @@
<div class="form-item-part u-cross-child-end">
<Button
text
disabled={externalAttribute && i === 0}
disabled={i === 0}
on:click={() => {
if (i === 0) attributeList = [];
attributeList = attributeList.splice(i, 1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
<script lang="ts">
import { execute } from './store';
import Execute from './execute.svelte';
import { onDestroy, onMount } from 'svelte';
import { sdkForConsole } from '$lib/stores/sdk';
import { Dependencies } from '$lib/constants';
import { invalidate } from '$app/navigation';

let unsubscribe: { (): void };

onMount(() => {
unsubscribe = sdkForConsole.client.subscribe('console', (response) => {
if (response.events.includes('functions.*.deployments.*')) {
invalidate(Dependencies.DEPLOYMENTS);
}
});
});

onDestroy(() => {
if (unsubscribe) {
unsubscribe();
}
});
</script>

<slot />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,29 @@
import { log } from '$lib/stores/logs';
import { func } from '../../store';
import type { PageData } from './$types';
import { PAGE_LIMIT } from '$lib/constants';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import { page } from '$app/stores';
import { onDestroy, onMount } from 'svelte';
import { sdkForConsole } from '$lib/stores/sdk';
import { invalidate } from '$app/navigation';

export let data: PageData;

//TODO: add optional hover state to rows
let unsubscribe: { (): void };

onMount(() => {
unsubscribe = sdkForConsole.client.subscribe('console', (response) => {
if (response.events.includes('functions.*.executions.*')) {
invalidate(Dependencies.EXECUTIONS);
}
});
});

onDestroy(() => {
if (unsubscribe) {
unsubscribe();
}
});
</script>

<Container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdkForProject } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';

export const load: PageLoad = async ({ params, parent }) => {
export const load: PageLoad = async ({ params, parent, depends }) => {
await parent();
depends(Dependencies.EXECUTIONS);
const page = Number(params.page);
const offset = pageToOffset(page, PAGE_LIMIT);

Expand Down