mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
8 files changed
+120
-97
No files matched your search
@@ -5,9 +5,9 @@
|
||||
|
||||
<li class="drop-tabs-item">
|
||||
{#if disabled}
|
||||
<span class="drop-tabs-button is-disabled">
|
||||
<button class="drop-tabs-button" disabled>
|
||||
<span class="text"><slot /></span>
|
||||
</span>
|
||||
</button>
|
||||
{:else}
|
||||
<a class="drop-tabs-button" {href}>
|
||||
<span class="text"><slot /></span>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher, onMount } from 'svelte';
|
||||
import { createEventDispatcher, onDestroy, onMount } from 'svelte';
|
||||
import { Alert } from '$lib/components';
|
||||
|
||||
export let show = false;
|
||||
@@ -17,6 +17,10 @@
|
||||
if (show) openModal();
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
if (show) closeModal();
|
||||
});
|
||||
|
||||
function handleBLur(event: MouseEvent) {
|
||||
if (event.target === dialog) {
|
||||
closeModal();
|
||||
@@ -65,50 +69,52 @@
|
||||
class:is-small={size === 'small'}
|
||||
class:is-big={size === 'big'}
|
||||
bind:this={dialog}>
|
||||
<!-- svelte-ignore a11y-no-redundant-roles -->
|
||||
<form class="modal-form" role="form" on:submit|preventDefault>
|
||||
<header class="modal-header">
|
||||
{#if warning}
|
||||
<div class="avatar is-color-orange is-medium">
|
||||
<span class="icon-exclamation" aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
<h4 class="modal-title heading-level-5">
|
||||
<slot name="header" />
|
||||
</h4>
|
||||
{#if closable}
|
||||
<button
|
||||
type="button"
|
||||
class="x-button"
|
||||
aria-label="Close Modal"
|
||||
title="Close Modal"
|
||||
on:click={closeModal}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
</header>
|
||||
<div class="modal-content">
|
||||
{#if error}
|
||||
<div bind:this={alert}>
|
||||
<Alert
|
||||
dismissible
|
||||
type="warning"
|
||||
on:dismiss={() => {
|
||||
error = null;
|
||||
}}>
|
||||
{error}
|
||||
</Alert>
|
||||
</div>
|
||||
{/if}
|
||||
<slot />
|
||||
</div>
|
||||
|
||||
{#if $$slots.footer}
|
||||
<div class="modal-footer">
|
||||
<div class="u-flex u-main-end u-gap-16">
|
||||
<slot name="footer" />
|
||||
</div>
|
||||
{#if show}
|
||||
<!-- svelte-ignore a11y-no-redundant-roles -->
|
||||
<form class="modal-form" role="form" on:submit|preventDefault>
|
||||
<header class="modal-header">
|
||||
{#if warning}
|
||||
<div class="avatar is-color-orange is-medium">
|
||||
<span class="icon-exclamation" aria-hidden="true" />
|
||||
</div>
|
||||
{/if}
|
||||
<h4 class="modal-title heading-level-5">
|
||||
<slot name="header" />
|
||||
</h4>
|
||||
{#if closable}
|
||||
<button
|
||||
type="button"
|
||||
class="x-button"
|
||||
aria-label="Close Modal"
|
||||
title="Close Modal"
|
||||
on:click={closeModal}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</button>
|
||||
{/if}
|
||||
</header>
|
||||
<div class="modal-content">
|
||||
{#if error}
|
||||
<div bind:this={alert}>
|
||||
<Alert
|
||||
dismissible
|
||||
type="warning"
|
||||
on:dismiss={() => {
|
||||
error = null;
|
||||
}}>
|
||||
{error}
|
||||
</Alert>
|
||||
</div>
|
||||
{/if}
|
||||
<slot />
|
||||
</div>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
{#if $$slots.footer}
|
||||
<div class="modal-footer">
|
||||
<div class="u-flex u-main-end u-gap-16">
|
||||
<slot name="footer" />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</form>
|
||||
{/if}
|
||||
</dialog>
|
||||
@@ -42,12 +42,17 @@
|
||||
<div class="u-flex u-main-space-between common-section">
|
||||
<Heading tag="h2" size="5">{title}</Heading>
|
||||
<DropTabs>
|
||||
<DropTabsLink href={`${path}/24h`} disabled={$page.params.period === '24h'}
|
||||
>24h</DropTabsLink>
|
||||
<DropTabsLink href={`${path}/30d`} disabled={$page.params.period === '30d'}
|
||||
>30d</DropTabsLink>
|
||||
<DropTabsLink href={`${path}/90d`} disabled={$page.params.period === '90d'}
|
||||
>90d</DropTabsLink>
|
||||
<DropTabsLink href={`${path}/24h`} disabled={$page.params.period === '24h'}>
|
||||
24
|
||||
</DropTabsLink>
|
||||
<DropTabsLink
|
||||
href={`${path}/30d`}
|
||||
disabled={!$page.params.period || $page.params.period === '30d'}>
|
||||
30d
|
||||
</DropTabsLink>
|
||||
<DropTabsLink href={`${path}/90d`} disabled={$page.params.period === '90d'}>
|
||||
90d
|
||||
</DropTabsLink>
|
||||
</DropTabs>
|
||||
</div>
|
||||
<Card>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { GridItem1, Heading, Empty, CardContainer, Pagination } from '$lib/components';
|
||||
@@ -8,7 +7,6 @@
|
||||
import CreateProject from '../createProject.svelte';
|
||||
import CreateOrganization from '../../createOrganization.svelte';
|
||||
import type { PageData } from './$types';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
@@ -17,10 +15,6 @@
|
||||
let showCreate = false;
|
||||
let addOrganization = false;
|
||||
|
||||
const projectCreated = async (event: CustomEvent<Models.Project>) => {
|
||||
await goto(`${base}/console/project-${event.detail.$id}`);
|
||||
};
|
||||
|
||||
const getPlatformInfo = (platform: string) => {
|
||||
let name: string, icon: string;
|
||||
if (platform.includes('flutter')) {
|
||||
@@ -112,7 +106,4 @@
|
||||
|
||||
<CreateOrganization bind:show={addOrganization} />
|
||||
|
||||
<CreateProject
|
||||
bind:show={showCreate}
|
||||
teamId={$page.params.organization}
|
||||
on:created={projectCreated} />
|
||||
<CreateProject bind:show={showCreate} teamId={$page.params.organization} />
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { Modal, CustomId } from '$lib/components';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, Button, FormList } from '$lib/elements/forms';
|
||||
@@ -15,9 +16,11 @@
|
||||
let name: string;
|
||||
let showCustomId = false;
|
||||
let error: string;
|
||||
let isCreating = false;
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
isCreating = true;
|
||||
const project = await sdkForConsole.projects.create(
|
||||
id ?? 'unique()',
|
||||
name,
|
||||
@@ -29,11 +32,11 @@
|
||||
type: 'success',
|
||||
message: `${name} has been created`
|
||||
});
|
||||
id = name = null;
|
||||
showCustomId = false;
|
||||
show = false;
|
||||
await goto(`/console/project-${project.$id}`);
|
||||
} catch ({ message }) {
|
||||
error = message;
|
||||
} finally {
|
||||
isCreating = false;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -41,7 +44,13 @@
|
||||
<Modal {error} on:submit={create} size="big" bind:show>
|
||||
<svelte:fragment slot="header">Create Project</svelte:fragment>
|
||||
<FormList>
|
||||
<InputText id="name" label="Name" bind:value={name} required autofocus={true} />
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
bind:value={name}
|
||||
required
|
||||
autofocus={true}
|
||||
disabled={isCreating} />
|
||||
{#if !showCustomId}
|
||||
<div>
|
||||
<Pill button on:click={() => (showCustomId = !showCustomId)}>
|
||||
@@ -56,6 +65,6 @@
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button secondary on:click={() => (show = false)}>Cancel</Button>
|
||||
<Button submit>Create</Button>
|
||||
<Button submit disabled={isCreating}>Create</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
+1
-1
@@ -23,7 +23,7 @@
|
||||
async function handleCreate(event: CustomEvent<Models.Collection>) {
|
||||
showCreate = false;
|
||||
await goto(
|
||||
`${base}/console/project-${project}/databases/database-${databaseId}/collection/${event.detail.$id}`
|
||||
`${base}/console/project-${project}/databases/database-${databaseId}/collection-${event.detail.$id}`
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { Heading } from '$lib/components';
|
||||
import { Empty, Heading } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
@@ -26,29 +26,42 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Name</TableCellHead>
|
||||
<TableCellHead>last accessed</TableCellHead>
|
||||
<TableCellHead>expiration date</TableCellHead>
|
||||
<TableCellHead>clients</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.keys.keys as key}
|
||||
<TableRowLink href={`keys/${key.$id}`}>
|
||||
<TableCellText title="Name">
|
||||
{key.name}
|
||||
</TableCellText>
|
||||
<TableCellText title="Last Accessed">
|
||||
{key.accessedAt ? toLocaleDateTime(key.accessedAt) : 'never'}
|
||||
</TableCellText>
|
||||
<TableCellText title="Expiration Date">
|
||||
{toLocaleDateTime(key.$updatedAt)}
|
||||
</TableCellText>
|
||||
<TableCellText title="Clients" />
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{#if data.keys.total}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Name</TableCellHead>
|
||||
<TableCellHead>last accessed</TableCellHead>
|
||||
<TableCellHead>expiration date</TableCellHead>
|
||||
<TableCellHead>clients</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each data.keys.keys as key}
|
||||
<TableRowLink href={`keys/${key.$id}`}>
|
||||
<TableCellText title="Name">
|
||||
{key.name}
|
||||
</TableCellText>
|
||||
<TableCellText title="Last Accessed">
|
||||
{key.accessedAt ? toLocaleDateTime(key.accessedAt) : 'never'}
|
||||
</TableCellText>
|
||||
<TableCellText title="Expiration Date">
|
||||
{toLocaleDateTime(key.$updatedAt)}
|
||||
</TableCellText>
|
||||
<TableCellText title="Clients" />
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{:else}
|
||||
<Empty isButton single on:click={() => (show = true)}>
|
||||
<div class="u-text-center">
|
||||
<p class="text u-line-height-1-5">Create your first API Key to get started</p>
|
||||
<p class="text u-line-height-1-5">Need a hand? Check out our documentation.</p>
|
||||
</div>
|
||||
<div class="u-flex u-gap-12">
|
||||
<Button external href="#/" text>Documentation</Button>
|
||||
<Button secondary>Create API Key</Button>
|
||||
</div>
|
||||
</Empty>
|
||||
{/if}
|
||||
|
||||
<Create bind:show />
|
||||
@@ -5,8 +5,7 @@ import Modal from '../../../src/lib/mock/modal.test.svelte';
|
||||
afterEach(() => cleanup());
|
||||
|
||||
test('renders modal', async () => {
|
||||
const { queryByText, container } = render(Modal);
|
||||
const { container } = render(Modal);
|
||||
|
||||
expect(queryByText('Content')).toBeInTheDocument();
|
||||
expect(container.querySelector('dialog')).toBeInTheDocument();
|
||||
});
|
||||
Reference in new issue
Block a user