initial commit

This commit is contained in:
Arman committed 2023-02-27 17:31:51 +01:00
1 parent 4711621074
commit 72fbeb305d
7 files changed
+150 -37

No files matched your search

+1
View File
@@ -46,3 +46,4 @@ export { default as EventModal } from './eventModal.svelte';
export { default as Status } from './status.svelte';
export { default as Heading } from './heading.svelte';
export { default as Output } from './output.svelte';
export { default as ViewSelector } from './viewSelector.svelte';
+31
View File
@@ -0,0 +1,31 @@
<script lang="ts">
import { Button } from '$lib/elements/forms';
import { DropList } from '.';
export let view = 'grid';
let showSelectColumns = false;
</script>
<DropList bind:show={showSelectColumns} scrollable={true}>
<Button secondary on:click={() => (showSelectColumns = true)}>
<span class="icon-view-board" />
<span class="text">Columns</span>
</Button>
<svelte:fragment slot="other">
<slot />
</svelte:fragment>
</DropList>
<ul class="buttons-list">
<li class="buttons-list-item">
<Button text disabled={view === 'list'} on:click={() => (view = 'list')}>
<span class="icon-view-list" />
</Button>
</li>
<li class="buttons-list-item">
<Button text disabled={view === 'grid'} on:click={() => (view = 'grid')}>
<span class="icon-view-grid" />
</Button>
</li>
</ul>
@@ -2,18 +2,19 @@
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { Button } from '$lib/elements/forms';
import { Empty, Copy, GridItem1, CardContainer, Heading, Pagination } from '$lib/components';
import { Pill } from '$lib/elements';
import { Empty, Heading, ViewSelector } from '$lib/components';
import { Container } from '$lib/layout';
import { base } from '$app/paths';
import Create from '../create.svelte';
import type { Models } from '@aw-labs/appwrite-console';
import type { PageData } from './$types';
import { CARD_LIMIT } from '$lib/constants';
import GridView from './gridView.svelte';
import TableView from './tableView.svelte';
export let data: PageData;
let showCreate = false;
let view = 'grid';
const project = $page.params.project;
async function handleCreate(event: CustomEvent<Models.Database>) {
@@ -23,43 +24,25 @@
</script>
<Container>
<div class="u-flex u-gap-12 common-section u-main-space-between">
<div class="u-flex common-section u-main-space-between">
<Heading tag="h2" size="5">Databases</Heading>
<Button on:click={() => (showCreate = true)} event="create_database">
<span class="icon-plus" aria-hidden="true" /> <span class="text">Create database</span>
</Button>
<div class="u-flex u-gap-16">
<ViewSelector bind:view>test</ViewSelector>
<Button on:click={() => (showCreate = true)} event="create_database">
<span class="icon-plus" aria-hidden="true" />
<span class="text">Create database</span>
</Button>
</div>
</div>
{#if data.databases.total}
<CardContainer
total={data.databases.total}
on:click={() => (showCreate = true)}
event="database">
{#each data.databases.databases as database}
<GridItem1
href={`${base}/console/project-${project}/databases/database-${database.$id}`}>
<!-- <svelte:fragment slot="eyebrow">X Collections</svelte:fragment> -->
<svelte:fragment slot="title">{database.name}</svelte:fragment>
<Copy value={database.$id}>
<Pill button><i class="icon-duplicate" />Database ID</Pill>
</Copy>
</GridItem1>
{/each}
<svelte:fragment slot="empty">
<p>Create a new database</p>
</svelte:fragment>
</CardContainer>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.databases.total}</p>
<Pagination
limit={CARD_LIMIT}
path={`/console/project-${$page.params.project}/databases`}
offset={data.offset}
sum={data.databases.total} />
</div>
{#if view === 'list'}
<TableView {data} />
{:else}
<GridView {data} bind:showCreate />
{/if}
{:else}
<Empty
single
@@ -0,0 +1,38 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { CardContainer, Copy, GridItem1, Pagination } from '$lib/components';
import { CARD_LIMIT } from '$lib/constants';
import { Pill } from '$lib/elements';
import type { PageData } from './$types';
export let data: PageData;
export let showCreate = false;
const project = $page.params.project;
</script>
<CardContainer total={data.databases.total} on:click={() => (showCreate = true)} event="database">
{#each data.databases.databases as database}
<GridItem1 href={`${base}/console/project-${project}/databases/database-${database.$id}`}>
<!-- <svelte:fragment slot="eyebrow">X Collections</svelte:fragment> -->
<svelte:fragment slot="title">{database.name}</svelte:fragment>
<Copy value={database.$id}>
<Pill button><i class="icon-duplicate" />Database ID</Pill>
</Copy>
</GridItem1>
{/each}
<svelte:fragment slot="empty">
<p>Create a new database</p>
</svelte:fragment>
</CardContainer>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.databases.total}</p>
<Pagination
limit={CARD_LIMIT}
path={`/console/project-${$page.params.project}/databases`}
offset={data.offset}
sum={data.databases.total} />
</div>
@@ -0,0 +1,60 @@
<script lang="ts">
import { page } from '$app/stores';
import { Copy, Pagination } from '$lib/components';
import { PAGE_LIMIT } from '$lib/constants';
import { Pill } from '$lib/elements';
import {
TableBody,
TableCell,
TableCellHead,
TableCellText,
TableHeader,
TableRow,
TableScroll
} from '$lib/elements/table';
import { toLocaleDateTime } from '$lib/helpers/date';
import type { PageData } from './$types';
export let data: PageData;
</script>
<TableScroll>
<TableHeader>
<TableCellHead width={50}>Collection ID</TableCellHead>
<TableCellHead width={100}>Name</TableCellHead>
<TableCellHead width={100}>Updated At</TableCellHead>
<TableCellHead width={100}>Created At</TableCellHead>
</TableHeader>
<TableBody>
{#each data.databases.databases as database}
<TableRow>
<TableCell title="Deployment ID">
<Copy value={database.$id}>
<Pill button trim>
<span class="icon-duplicate" aria-hidden="true" />
<span class="text u-trim">{database.$id}</span>
</Pill>
</Copy>
</TableCell>
<TableCellText title="Name">
{database.name}
</TableCellText>
<TableCellText title="Updated">
{toLocaleDateTime(database.$updatedAt)}
</TableCellText>
<TableCellText title="Created">
{toLocaleDateTime(database.$createdAt)}
</TableCellText>
</TableRow>
{/each}
</TableBody>
</TableScroll>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.databases.total}</p>
<Pagination
offset={data.offset}
limit={PAGE_LIMIT}
sum={data.databases.total}
path={`/console/project-${$page.params.project}/databases`} />
</div>
@@ -14,7 +14,7 @@
let name = '';
let id: string = null;
let showCustomId = false;
let showCustomId = true;
const create = async () => {
try {
@@ -17,7 +17,7 @@
let name = '';
let id: string = null;
let showCustomId = false;
let showCustomId = true;
const create = async () => {
try {