mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
Merge branch 'main' of github.com:appwrite/appwrite-console-poc into miscellaneous-v3
This commit is contained in:
commit
558ef3d9b9
41 files changed
+419
-613
No files matched your search
@@ -86,5 +86,6 @@
|
||||
.echart {
|
||||
width: 100%;
|
||||
min-height: 12rem;
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
@@ -10,7 +10,6 @@
|
||||
import 'prismjs/plugins/autoloader/prism-autoloader';
|
||||
import 'prismjs/plugins/custom-class/prism-custom-class';
|
||||
import 'prismjs/plugins/line-numbers/prism-line-numbers';
|
||||
import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
|
||||
import { afterUpdate } from 'svelte';
|
||||
import { Copy } from '.';
|
||||
|
||||
@@ -49,16 +48,16 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<pre class={`language-${language}`} class:line-numbers={withLineNumbers}>
|
||||
<code>{code}</code>
|
||||
</pre>
|
||||
<pre class={`language-${language}`} class:line-numbers={withLineNumbers}><code
|
||||
>{code}</code></pre>
|
||||
</section>
|
||||
|
||||
<style lang="scss" global>
|
||||
@import 'prismjs/themes/prism.css';
|
||||
@import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
|
||||
|
||||
.box {
|
||||
--p-box-background-color: var(--color-neutral-300) !important;
|
||||
--p-box-background-color: var(--color-neutral-400) !important;
|
||||
|
||||
body.theme-light & {
|
||||
--p-box-background-color: var(--color-neutral-5) !important;
|
||||
|
||||
@@ -15,8 +15,6 @@ export enum Dependencies {
|
||||
COLLECTION = 'collection',
|
||||
DOCUMENT = 'document',
|
||||
DOCUMENTS = 'documents',
|
||||
ATTRIBUTES = 'attributes',
|
||||
INDEXES = 'indexes',
|
||||
BUCKET = 'bucket',
|
||||
FILE = 'file',
|
||||
FILES = 'files',
|
||||
@@ -24,6 +22,7 @@ export enum Dependencies {
|
||||
FUNCTIONS = 'functions',
|
||||
VARIABLES = 'variables',
|
||||
DEPLOYMENTS = 'deployments',
|
||||
EXECUTIONS = 'executions',
|
||||
PLATFORM = 'platform',
|
||||
PLATFORMS = 'platforms',
|
||||
KEY = 'key',
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Pagination, Trim } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
|
||||
export let logs: Models.LogList;
|
||||
export let path: string;
|
||||
export let offset = 0;
|
||||
|
||||
const getBrowser = (clientCode: string) => {
|
||||
return sdkForConsole.avatars.getBrowser(clientCode, 40, 40);
|
||||
};
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if logs.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Client</TableCellHead>
|
||||
<TableCellHead>Event</TableCellHead>
|
||||
<TableCellHead>Location</TableCellHead>
|
||||
<TableCellHead>IP</TableCellHead>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
</div>
|
||||
<Trim>
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</Trim>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<span class="avatar is-color-empty" />
|
||||
<p class="text u-trim">Unknown</p>
|
||||
</div>
|
||||
{/if}
|
||||
</TableCell>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
|
||||
<TableCellText title="Location">
|
||||
{#if log.countryCode !== '--'}
|
||||
{log.countryName}
|
||||
{:else}
|
||||
Unknown
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="IP">{log.ip}</TableCellText>
|
||||
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty>
|
||||
<div class="u-flex u-flex-vertical u-cross-center">
|
||||
<div class="common-section">
|
||||
<p>No logs available</p>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<Button
|
||||
external
|
||||
secondary
|
||||
href="https://appwrite.io/docs/server/authentication?sdk=nodejs-default#usersGetLogs">
|
||||
Documentation
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {logs.total}</p>
|
||||
<Pagination limit={PAGE_LIMIT} {path} {offset} sum={logs.total} />
|
||||
</div>
|
||||
</Container>
|
||||
@@ -13,3 +13,4 @@ export { default as WizardStep } from './wizardStep.svelte';
|
||||
export { default as Breadcrumbs } from './breadcrumbs.svelte';
|
||||
export { default as Unauthenticated } from './unauthenticated.svelte';
|
||||
export { default as Usage, type UsagePeriods } from './usage.svelte';
|
||||
export { default as Activity } from './activity.svelte';
|
||||
+40
-32
@@ -75,14 +75,16 @@
|
||||
<Heading tag="h6" size="6">{total(created)}</Heading>
|
||||
<p>{createdMetadata.title}</p>
|
||||
<div class="u-margin-block-start-16" />
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: createdMetadata.legend,
|
||||
data: [...created.map((e) => [e.date, e.value])],
|
||||
color: Colors.Secondary
|
||||
}
|
||||
]} />
|
||||
<div style="height: 12rem;">
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: createdMetadata.legend,
|
||||
data: [...created.map((e) => [e.date, e.value])],
|
||||
color: Colors.Secondary
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
{/if}
|
||||
</Card>
|
||||
<Card isTile>
|
||||
@@ -90,14 +92,16 @@
|
||||
<Heading tag="h6" size="6">{total(read)}</Heading>
|
||||
<p>{readMetadata.title}</p>
|
||||
<div class="u-margin-block-start-16" />
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: readMetadata.legend,
|
||||
data: [...read.map((e) => [e.date, e.value])],
|
||||
color: Colors.Tertiary
|
||||
}
|
||||
]} />
|
||||
<div style="height: 12rem;">
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: readMetadata.legend,
|
||||
data: [...read.map((e) => [e.date, e.value])],
|
||||
color: Colors.Tertiary
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
{/if}
|
||||
</Card>
|
||||
<Card isTile>
|
||||
@@ -105,14 +109,16 @@
|
||||
<Heading tag="h6" size="6">{total(updated)}</Heading>
|
||||
<p>{updatedMetadata.title}</p>
|
||||
<div class="u-margin-block-start-16" />
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: updatedMetadata.legend,
|
||||
data: [...updated.map((e) => [e.date, e.value])],
|
||||
color: Colors.Quaternary
|
||||
}
|
||||
]} />
|
||||
<div style="height: 12rem;">
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: updatedMetadata.legend,
|
||||
data: [...updated.map((e) => [e.date, e.value])],
|
||||
color: Colors.Quaternary
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
{/if}
|
||||
</Card>
|
||||
<Card isTile>
|
||||
@@ -120,14 +126,16 @@
|
||||
<Heading tag="h6" size="6">{total(deleted)}</Heading>
|
||||
<p>{deletedMetadata.title}</p>
|
||||
<div class="u-margin-block-start-16" />
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: deletedMetadata.legend,
|
||||
data: [...deleted.map((e) => [e.date, e.value])],
|
||||
color: Colors.Quinary
|
||||
}
|
||||
]} />
|
||||
<div style="height: 12rem;">
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: deletedMetadata.legend,
|
||||
data: [...deleted.map((e) => [e.date, e.value])],
|
||||
color: Colors.Quinary
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
{/if}
|
||||
</Card>
|
||||
</Tiles>
|
||||
|
||||
@@ -1,105 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Pagination } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { Activity } from '$lib/layout';
|
||||
import type { PageData } from './$types';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const getBrowser = (clientCode: string) => {
|
||||
return sdkForConsole.avatars.getBrowser(clientCode, 40, 40);
|
||||
};
|
||||
const path = '/console/account/activity';
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.logs.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
<TableCellHead>Event</TableCellHead>
|
||||
<TableCellHead>Client</TableCellHead>
|
||||
<TableCellHead>Location</TableCellHead>
|
||||
<TableCellHead>IP</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
</div>
|
||||
<p
|
||||
class="text u-trim"
|
||||
title={`${log.clientName} ${log.clientVersion} on ${log.osName} ${log.osVersion}`}>
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<span class="avatar is-color-empty" />
|
||||
<p class="text u-trim">Unknown</p>
|
||||
</div>
|
||||
{/if}
|
||||
</TableCell>
|
||||
|
||||
<TableCellText title="Location">
|
||||
{#if log.countryCode !== '--'}
|
||||
{log.countryName}
|
||||
{:else}
|
||||
Unknown
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="IP">{log.ip}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty>
|
||||
<div class="u-flex u-flex-vertical u-cross-center">
|
||||
<div class="common-section">
|
||||
<p>No logs available</p>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<Button
|
||||
external
|
||||
secondary
|
||||
href="https://appwrite.io/docs/server/authentication?sdk=nodejs-default#usersGetLogs"
|
||||
>Documentation</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {data.logs.total}</p>
|
||||
<Pagination
|
||||
limit={PAGE_LIMIT}
|
||||
path="/console/account/activity"
|
||||
offset={data.offset}
|
||||
sum={data.logs.total} />
|
||||
</div>
|
||||
</Container>
|
||||
<Activity {path} logs={data.logs} offset={data.offset} />
|
||||
@@ -1,5 +1,26 @@
|
||||
<script lang="ts">
|
||||
import { UploadBox } from '$lib/components';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onDestroy, onMount } from 'svelte';
|
||||
import { stats } from './store';
|
||||
|
||||
let unsubscribe: { (): void };
|
||||
|
||||
onMount(() => {
|
||||
unsubscribe = sdkForConsole.client.subscribe(['project', 'console'], (response) => {
|
||||
if (response.events.includes('stats.connections')) {
|
||||
for (const [projectId, value] of Object.entries(response.payload)) {
|
||||
stats.add(projectId, [new Date(response.timestamp).toISOString(), value]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (unsubscribe) {
|
||||
unsubscribe();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<slot />
|
||||
|
||||
+3
-93
@@ -1,100 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Pagination } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import type { PageData } from './$types';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { page } from '$app/stores';
|
||||
import { Activity } from '$lib/layout';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
|
||||
const path = `/console/project-${$page.params.project}/authentication/teams/team-${$page.params.team}/activity`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.logs.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Client</TableCellHead>
|
||||
<TableCellHead>Event</TableCellHead>
|
||||
<TableCellHead>Location</TableCellHead>
|
||||
<TableCellHead>IP</TableCellHead>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
</div>
|
||||
<p class="text u-trim">
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<p class="text u-trim">
|
||||
<span class="avatar is-color-empty" />
|
||||
Unknown
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</TableCell>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
<TableCellText title="Location">
|
||||
{#if log.countryCode !== '--'}
|
||||
{log.countryName}
|
||||
{:else}
|
||||
Unknown
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="IP">{log.ip}</TableCellText>
|
||||
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty>
|
||||
<div class="u-flex u-flex-vertical u-cross-center">
|
||||
<div class="common-section">
|
||||
<p>No logs available</p>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<Button external secondary href="https://appwrite.io/docs/server/teams">
|
||||
Documentation
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {data.logs.total}</p>
|
||||
<Pagination
|
||||
limit={PAGE_LIMIT}
|
||||
path={`/console/project-${$page.params.project}/authentication/teams/team-${$page.params.team}/activity`}
|
||||
offset={data.offset}
|
||||
sum={data.logs.total} />
|
||||
</div>
|
||||
</Container>
|
||||
<Activity {path} logs={data.logs} offset={data.offset} />
|
||||
+3
-91
@@ -1,98 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Pagination } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import type { PageData } from './$types';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { page } from '$app/stores';
|
||||
import { Activity } from '$lib/layout';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
|
||||
const path = `/console/project-${$page.params.project}/authentication/user-${$page.params.user}/activity`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.logs.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Client</TableCellHead>
|
||||
<TableCellHead>Event</TableCellHead>
|
||||
<TableCellHead>Location</TableCellHead>
|
||||
<TableCellHead>IP</TableCellHead>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
</div>
|
||||
<p class="text u-trim">
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<p class="text u-trim">
|
||||
<span class="avatar is-color-empty" />
|
||||
|
||||
Unknown
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</TableCell>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
|
||||
<TableCellText title="Location">
|
||||
{#if log.countryCode !== '--'}
|
||||
{log.countryName}
|
||||
{:else}
|
||||
Unknown
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="IP">{log.ip}</TableCellText>
|
||||
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty single>
|
||||
<p>No logs available</p>
|
||||
<Button
|
||||
external
|
||||
secondary
|
||||
href="https://appwrite.io/docs/server/authentication?sdk=nodejs-default#usersGetLogs"
|
||||
>Documentation</Button>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {data.logs.total}</p>
|
||||
<Pagination
|
||||
limit={PAGE_LIMIT}
|
||||
path={`/console/project-${$page.params.project}/authentication/user-${$page.params.user}/activity`}
|
||||
offset={data.offset}
|
||||
sum={data.logs.total} />
|
||||
</div>
|
||||
</Container>
|
||||
<Activity {path} logs={data.logs} offset={data.offset} />
|
||||
@@ -17,9 +17,13 @@
|
||||
const create = async () => {
|
||||
try {
|
||||
const database = await sdkForProject.databases.create(id ? id : 'unique()', name);
|
||||
name = id = null;
|
||||
showCreate = false;
|
||||
dispatch('created', database);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
name = id = null;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
+23
@@ -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>
|
||||
|
||||
+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 {
|
||||
|
||||
+3
-93
@@ -1,100 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Pagination } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import type { PageData } from './$types';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { page } from '$app/stores';
|
||||
import { Activity } from '$lib/layout';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
|
||||
const path = `/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.logs.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Client</TableCellHead>
|
||||
<TableCellHead>Event</TableCellHead>
|
||||
<TableCellHead>Location</TableCellHead>
|
||||
<TableCellHead>IP</TableCellHead>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
</div>
|
||||
<p class="text u-trim">
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<p class="text u-trim">
|
||||
<span class="avatar is-color-empty" />
|
||||
Unknown
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</TableCell>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
<TableCellText title="Location">
|
||||
{#if log.countryCode !== '--'}
|
||||
{log.countryName}
|
||||
{:else}
|
||||
Unknown
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="IP">{log.ip}</TableCellText>
|
||||
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty>
|
||||
<div class="u-flex u-flex-vertical u-cross-center">
|
||||
<div class="common-section">
|
||||
<p>No logs available</p>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<Button external secondary href="https://appwrite.io/docs/server/database">
|
||||
Documentation
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {data.logs.total}</p>
|
||||
<Pagination
|
||||
limit={PAGE_LIMIT}
|
||||
path={`/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`}
|
||||
offset={data.offset}
|
||||
sum={data.logs.total} />
|
||||
</div>
|
||||
</Container>
|
||||
<Activity {path} logs={data.logs} offset={data.offset} />
|
||||
+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[];
|
||||
}
|
||||
};
|
||||
};
|
||||
+6
-1
@@ -4,6 +4,7 @@
|
||||
import { Button, InputText, FormList, InputSelect } from '$lib/elements/forms';
|
||||
import { invalidate } from '$app/navigation';
|
||||
import { Dependencies } from '$lib/constants';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
|
||||
export let showCreate = false;
|
||||
|
||||
@@ -12,8 +13,12 @@
|
||||
let submitted = false;
|
||||
|
||||
const created = async () => {
|
||||
invalidate(Dependencies.ATTRIBUTES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
showCreate = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Attribute has been created`
|
||||
});
|
||||
};
|
||||
|
||||
$: if (selectedOption) {
|
||||
|
||||
+5
-1
@@ -21,8 +21,12 @@
|
||||
$collection.$id,
|
||||
selectedAttribute.key
|
||||
);
|
||||
invalidate(Dependencies.ATTRIBUTES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Attribute has been deleted`
|
||||
});
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/databases/database-${databaseId}/collection-${$page.params.collection}/attributes`
|
||||
);
|
||||
|
||||
+3
-93
@@ -1,100 +1,10 @@
|
||||
<script lang="ts">
|
||||
import { Empty, Pagination } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
TableCellHead,
|
||||
TableCell,
|
||||
TableCellText
|
||||
} from '$lib/elements/table';
|
||||
import { Container } from '$lib/layout';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import type { PageData } from './$types';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { page } from '$app/stores';
|
||||
import { Activity } from '$lib/layout';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
const getBrowser = (clientCode: string) => sdkForProject.avatars.getBrowser(clientCode, 80, 80);
|
||||
const path = `/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`;
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.logs.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Client</TableCellHead>
|
||||
<TableCellHead>Event</TableCellHead>
|
||||
<TableCellHead>Location</TableCellHead>
|
||||
<TableCellHead>IP</TableCellHead>
|
||||
<TableCellHead>Date</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.logs.logs as log}
|
||||
<TableRow>
|
||||
<TableCell title="Client">
|
||||
{#if log.clientName}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<div class="avatar is-small">
|
||||
<img
|
||||
height="20"
|
||||
width="20"
|
||||
src={getBrowser(log.clientCode).toString()}
|
||||
alt={log.clientName} />
|
||||
</div>
|
||||
<p class="text u-trim">
|
||||
{log.clientName}
|
||||
{log.clientVersion}
|
||||
on {log.osName}
|
||||
{log.osVersion}
|
||||
</p>
|
||||
</div>
|
||||
{:else}
|
||||
<div class="u-flex u-cross-center u-gap-12">
|
||||
<p class="text u-trim">
|
||||
<span class="avatar is-color-empty" />
|
||||
Unknown
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
</TableCell>
|
||||
<TableCellText title="Event">{log.event}</TableCellText>
|
||||
<TableCellText title="Location">
|
||||
{#if log.countryCode !== '--'}
|
||||
{log.countryName}
|
||||
{:else}
|
||||
Unknown
|
||||
{/if}
|
||||
</TableCellText>
|
||||
<TableCellText title="IP">{log.ip}</TableCellText>
|
||||
<TableCellText title="Date">{toLocaleDateTime(log.time)}</TableCellText>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty>
|
||||
<div class="u-flex u-flex-vertical u-cross-center">
|
||||
<div class="common-section">
|
||||
<p>No logs available</p>
|
||||
</div>
|
||||
<div class="common-section">
|
||||
<Button external secondary href="https://appwrite.io/docs/server/database">
|
||||
Documentation
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
<div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {data.logs.total}</p>
|
||||
<Pagination
|
||||
limit={PAGE_LIMIT}
|
||||
path={`/console/project-${$page.params.project}/authentication/databases/database-${$page.params.team}/collection-${$page.params.collection}/document-${$page.params.document}/activity`}
|
||||
offset={data.offset}
|
||||
sum={data.logs.total} />
|
||||
</div>
|
||||
</Container>
|
||||
<Activity {path} logs={data.logs} offset={data.offset} />
|
||||
+4
@@ -20,6 +20,10 @@
|
||||
$page.params.document
|
||||
);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Document has been deleted`
|
||||
});
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/databases/database-${$page.params.database}/collection-${$page.params.collection}`
|
||||
);
|
||||
|
||||
+17
-10
@@ -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,
|
||||
@@ -11,16 +11,14 @@
|
||||
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';
|
||||
|
||||
export let data: PageData;
|
||||
import { Button } from '$lib/elements/forms';
|
||||
|
||||
let showDropdown = [];
|
||||
let selectedIndex: Models.Index = null;
|
||||
@@ -29,12 +27,20 @@
|
||||
let showDelete = false;
|
||||
|
||||
const handleDelete = async () => {
|
||||
invalidate(Dependencies.INDEXES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
};
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if data.indexes.total}
|
||||
<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 $indexes.length}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Key</TableCellHead>
|
||||
@@ -44,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">
|
||||
@@ -99,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>
|
||||
@@ -113,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)
|
||||
};
|
||||
};
|
||||
+3
-3
@@ -23,7 +23,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
|
||||
}));
|
||||
@@ -57,9 +57,9 @@
|
||||
attributeList.map((a) => a.value),
|
||||
attributeList.map((a) => a.order)
|
||||
);
|
||||
invalidate(Dependencies.INDEXES);
|
||||
invalidate(Dependencies.COLLECTION);
|
||||
addNotification({
|
||||
message: 'Index created!',
|
||||
message: 'Index has been created',
|
||||
type: 'success'
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
+4
@@ -22,6 +22,10 @@
|
||||
selectedIndex.key
|
||||
);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `Index has been deleted`
|
||||
});
|
||||
dispatch('deleted');
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
+4
@@ -16,6 +16,10 @@
|
||||
try {
|
||||
await sdkForProject.databases.deleteCollection(databaseId, $collection.$id);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$collection.name} has been deleted`
|
||||
});
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/databases/database/${$page.params.database}`
|
||||
);
|
||||
|
||||
+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[]);
|
||||
@@ -15,6 +15,10 @@
|
||||
try {
|
||||
await sdkForProject.databases.delete(databaseId);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$database.name} has been deleted`
|
||||
});
|
||||
await goto(`${base}/console/project-${$page.params.project}/databases`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
goto(`${base}/console/project-${projectId}/functions/function-${response.$id}`);
|
||||
|
||||
addNotification({
|
||||
message: 'Function has been created',
|
||||
message: `${$createFunction.name} has been created`,
|
||||
type: 'success'
|
||||
});
|
||||
wizard.hide();
|
||||
|
||||
@@ -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 />
|
||||
|
||||
+1
@@ -62,6 +62,7 @@
|
||||
}
|
||||
if (message.events.includes('functions.*.deployments.*.update')) {
|
||||
invalidate(Dependencies.DEPLOYMENTS);
|
||||
invalidate(Dependencies.FUNCTION);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,8 +5,8 @@ import { Dependencies, PAGE_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent, depends }) => {
|
||||
await parent();
|
||||
depends(Dependencies.DEPLOYMENTS);
|
||||
await parent();
|
||||
const page = Number(params.page);
|
||||
const offset = pageToOffset(page, PAGE_LIMIT);
|
||||
|
||||
|
||||
+20
-3
@@ -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>
|
||||
@@ -37,7 +54,7 @@
|
||||
<TableCellHead width={110}>Status</TableCellHead>
|
||||
<TableCellHead width={90}>Trigger</TableCellHead>
|
||||
<TableCellHead width={70}>Type</TableCellHead>
|
||||
<TableCellHead width={100}>Execution Time</TableCellHead>
|
||||
<TableCellHead width={100}>Duration</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.executions.executions as execution}
|
||||
|
||||
+3
-2
@@ -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);
|
||||
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { Container, type UsagePeriods } from '$lib/layout';
|
||||
import { page } from '$app/stores';
|
||||
import { browser } from '$app/environment';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from '../store';
|
||||
import { project, stats } from '../store';
|
||||
import { usage } from './store';
|
||||
import { onMount } from 'svelte';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
@@ -15,7 +13,7 @@
|
||||
|
||||
$: projectId = $page.params.project;
|
||||
$: path = `/console/project-${projectId}/overview`;
|
||||
|
||||
$: console.log($stats.get(projectId));
|
||||
let period: UsagePeriods = '30d';
|
||||
let showPeriodBandwidth = false;
|
||||
let showPeriodRequests = false;
|
||||
@@ -56,15 +54,6 @@
|
||||
showPeriodRequests = false;
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
sdkForConsole.client.subscribe<unknown>('console', (message) => {
|
||||
if (message.events.includes('stats.connections')) {
|
||||
// TODO: take care of realtime connections
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//TODO: workaround for broken types
|
||||
$: network = $usage?.network as unknown as Array<{
|
||||
date: number;
|
||||
@@ -120,13 +109,15 @@
|
||||
</DropList>
|
||||
</div>
|
||||
{#if network.length}
|
||||
<BarChart
|
||||
series={[
|
||||
{
|
||||
name: 'Bandwidth',
|
||||
data: [...network.map((e) => [e.date, e.value])]
|
||||
}
|
||||
]} />
|
||||
<div style="height: 12rem;">
|
||||
<BarChart
|
||||
series={[
|
||||
{
|
||||
name: 'Bandwidth',
|
||||
data: [...network.map((e) => [e.date, e.value])]
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="card is-2-columns-medium-screen is-3-columns-large-screen">
|
||||
@@ -161,13 +152,15 @@
|
||||
</DropList>
|
||||
</div>
|
||||
{#if network.length}
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: 'Requests',
|
||||
data: [...requests.map((e) => [e.date, e.value])]
|
||||
}
|
||||
]} />
|
||||
<div style="height: 12rem;">
|
||||
<LineChart
|
||||
series={[
|
||||
{
|
||||
name: 'Requests',
|
||||
data: [...requests.map((e) => [e.date, e.value])]
|
||||
}
|
||||
]} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<a
|
||||
@@ -271,8 +264,21 @@
|
||||
</a>
|
||||
<div
|
||||
class="card is-2-columns-medium-screen is-2-columns-large-screen is-2-rows-large-screen is-location-row-2-end-large-screen">
|
||||
<div class="heading-level-4">XX</div>
|
||||
<div>Realtime Connections</div>
|
||||
{#if $stats.get(projectId)}
|
||||
<div class="heading-level-4">
|
||||
{format($stats.get(projectId)[11][1])}
|
||||
</div>
|
||||
<div>Realtime Connections</div>
|
||||
<BarChart
|
||||
series={[
|
||||
{
|
||||
name: 'Realtime connection',
|
||||
data: $stats.get(projectId)
|
||||
}
|
||||
]} />
|
||||
{:else}
|
||||
<div>waiting for realtime connections</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
try {
|
||||
await sdkForProject.storage.deleteBucket($bucket.$id);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$bucket.name} has been deleted`
|
||||
});
|
||||
await goto(`${base}/console/project-${$page.params.project}/storage`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
|
||||
@@ -16,6 +16,10 @@
|
||||
await sdkForProject.storage.deleteFile(file.bucketId, file.$id);
|
||||
showDelete = false;
|
||||
dispatch('deleted', file);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${file.name} has been deleted`
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
import { bucket } from './store';
|
||||
import { calculateSize } from '$lib/helpers/sizeConvertion';
|
||||
import { Permissions } from '$lib/components/permissions';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
|
||||
export let showCreate = false;
|
||||
|
||||
@@ -34,6 +35,10 @@
|
||||
showCustomId = false;
|
||||
uploader.addFile(file);
|
||||
dispatch('created');
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${file.name} has been created`
|
||||
});
|
||||
} catch ({ message }) {
|
||||
error = message;
|
||||
}
|
||||
|
||||
+4
@@ -17,6 +17,10 @@
|
||||
await goto(
|
||||
`${base}/console/project-${$page.params.project}/storage/bucket-${$file.bucketId}`
|
||||
);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$file.name} has been deleted`
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
+16
-13
@@ -9,7 +9,8 @@
|
||||
InputTags,
|
||||
InputNumber,
|
||||
InputSelect,
|
||||
InputSwitch
|
||||
InputSwitch,
|
||||
FormList
|
||||
} from '$lib/elements/forms';
|
||||
import { bucket } from '../store';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
@@ -208,14 +209,16 @@
|
||||
<Heading tag="h2" size="7">{$bucket.name}</Heading>
|
||||
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<InputSwitch
|
||||
label={enabled ? 'Enabled' : 'Disabled'}
|
||||
id="toggle"
|
||||
bind:value={enabled} />
|
||||
</ul>
|
||||
<p>Created: {toLocaleDateTime($bucket.$createdAt)}</p>
|
||||
<p>Last Updated: {toLocaleDateTime($bucket.$updatedAt)}</p>
|
||||
<div>
|
||||
<FormList>
|
||||
<InputSwitch
|
||||
label={enabled ? 'Enabled' : 'Disabled'}
|
||||
id="toggle"
|
||||
bind:value={enabled} />
|
||||
</FormList>
|
||||
<p>Created: {toLocaleDateTime($bucket.$createdAt)}</p>
|
||||
<p>Last Updated: {toLocaleDateTime($bucket.$updatedAt)}</p>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
@@ -228,14 +231,14 @@
|
||||
<CardGrid>
|
||||
<Heading tag="h6" size="7">Update Name</Heading>
|
||||
<svelte:fragment slot="aside">
|
||||
<ul>
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
placeholder="Enter name"
|
||||
autocomplete={false}
|
||||
bind:value={bucketName} />
|
||||
</ul>
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
@@ -296,7 +299,7 @@
|
||||
and <b>Antivirus scanning.</b>
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<ul class="form-list">
|
||||
<FormList>
|
||||
<li class="form-item">
|
||||
<label class="choice-item" for="encryption">
|
||||
<div class="input-text-wrapper">
|
||||
@@ -345,7 +348,7 @@
|
||||
</li>
|
||||
|
||||
<li />
|
||||
</ul>
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { Modal, CustomId } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { Button, InputText, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
|
||||
@@ -20,6 +21,10 @@
|
||||
name = null;
|
||||
showCreate = false;
|
||||
dispatch('created', bucket);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
} catch ({ message }) {
|
||||
error = message;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,39 @@
|
||||
import { derived } from 'svelte/store';
|
||||
import { derived, writable } from 'svelte/store';
|
||||
import { page } from '$app/stores';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import type { BarSeriesOption } from 'echarts/charts';
|
||||
|
||||
export const project = derived(page, ($page) => $page.data.project as Models.Project);
|
||||
|
||||
function createStats() {
|
||||
const { subscribe, set, update } = writable<Map<string, BarSeriesOption['data']>>(new Map());
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
add: (projectId: string, data: BarSeriesOption['data'][number]) =>
|
||||
update((n) => {
|
||||
let series = n.get(projectId) ?? [];
|
||||
|
||||
if (series.length === 0) {
|
||||
const date = new Date(data[0]);
|
||||
for (let i = 0; i < 12; i++) {
|
||||
series.push([date.toISOString(), 0]);
|
||||
date.setSeconds(date.getSeconds() - 5);
|
||||
}
|
||||
}
|
||||
|
||||
series.push(data);
|
||||
|
||||
if (series.length > 12) {
|
||||
series = series.slice(-12);
|
||||
}
|
||||
|
||||
n.set(projectId, series);
|
||||
|
||||
return n;
|
||||
}),
|
||||
reset: () => set(new Map())
|
||||
};
|
||||
}
|
||||
|
||||
export const stats = createStats();
|
||||
Reference in new issue
Block a user