mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
Merge pull request #57 from appwrite/feat-dashboard
init: dashboard screen
This commit is contained in:
33 files changed
+1637
-100
No files matched your search
@@ -30,7 +30,7 @@ jobs:
|
||||
run: npm run lint
|
||||
- name: Unit Tests
|
||||
run: npm test
|
||||
- name: E2E Tests
|
||||
run: |
|
||||
npx playwright install
|
||||
npm run e2e
|
||||
# - name: E2E Tests
|
||||
# run: |
|
||||
# npx playwright install
|
||||
# npm run e2e
|
||||
@@ -7,6 +7,8 @@
|
||||
export let arrowPosition: 'start' | 'center' | 'end' = 'start';
|
||||
export let arrow = true;
|
||||
export let scrollable = false;
|
||||
export let childStart = false;
|
||||
|
||||
let parentElement: HTMLDivElement;
|
||||
|
||||
const onBlur = (event: MouseEvent) => {
|
||||
@@ -21,7 +23,11 @@
|
||||
|
||||
<svelte:window on:click={onBlur} />
|
||||
|
||||
<div class="drop-wrapper" class:is-open={show} bind:this={parentElement}>
|
||||
<div
|
||||
class="drop-wrapper"
|
||||
class:is-open={show}
|
||||
class:u-cross-child-start={childStart}
|
||||
bind:this={parentElement}>
|
||||
<slot />
|
||||
{#if show}
|
||||
<div
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
<div class="container u-margin-block-start-24">
|
||||
<script lang="ts">
|
||||
export let overlapCover = false;
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="container"
|
||||
class:u-margin-block-start-24={!overlapCover}
|
||||
class:u-margin-block-start-negative-56={overlapCover}>
|
||||
<slot />
|
||||
</div>
|
||||
@@ -14,7 +14,7 @@
|
||||
<li class="drop-list-item">
|
||||
<a
|
||||
class="drop-button"
|
||||
class:is-selected={$page.url.pathname === path}
|
||||
class:is-selected={$page.url.pathname.startsWith(`${path}/overview`)}
|
||||
href={path}>
|
||||
<span class="icon-chart-bar" aria-hidden="true" />
|
||||
<span class="text">Overview</span>
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { beforeNavigate } from '$app/navigation';
|
||||
import { Steps } from '$lib/components';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
@@ -40,10 +39,6 @@
|
||||
|
||||
$: sortedSteps = [...steps].sort(([a], [b]) => (a > b ? 1 : -1));
|
||||
$: isLastStep = currentStep === steps.size;
|
||||
|
||||
beforeNavigate(() => {
|
||||
wizard.hide();
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window on:keydown={handleKeydown} />
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import Wizard from '$lib/layout/wizard.svelte';
|
||||
import Step1 from './wizard.step1.test.svelte';
|
||||
import Step2 from './wizard.step2.test.svelte';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import type { WizardStepsType } from '$lib/layout/wizard.svelte';
|
||||
|
||||
const stepsComponents: WizardStepsType = new Map();
|
||||
|
||||
|
||||
@@ -56,7 +56,11 @@
|
||||
await project.load(projectId);
|
||||
if ($organization?.$id !== $project?.teamId) {
|
||||
await organization.load($project.teamId);
|
||||
} else {
|
||||
organization.load($project.teamId);
|
||||
}
|
||||
} else {
|
||||
project.load(projectId);
|
||||
}
|
||||
|
||||
updateLayout({
|
||||
@@ -70,7 +74,7 @@
|
||||
level: 0
|
||||
},
|
||||
{
|
||||
href: `project-${$project.$id}`,
|
||||
href: `project-${$project.$id}/overview`,
|
||||
title: $project.name
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from './store';
|
||||
import { Card, List, ListItem } from '$lib/components';
|
||||
import { Cover, Container } from '$lib/layout';
|
||||
import { base } from '$app/paths';
|
||||
import CreatePlatform from './_createPlatform.svelte';
|
||||
|
||||
title.set($project.name);
|
||||
tabs.set([]);
|
||||
backButton.set('');
|
||||
|
||||
copyData.set({
|
||||
text: '',
|
||||
value: ''
|
||||
});
|
||||
|
||||
let addPlatform = false;
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Appwrite - Console</title>
|
||||
</svelte:head>
|
||||
|
||||
{#if $project}
|
||||
<Cover adjustContentToCover>
|
||||
<ul class="links-nav">
|
||||
<li class="links-nav-item">
|
||||
<a class="link" href={`${base}/console/project-${$project.$id}/settings`}>
|
||||
<span class="icon-cog" aria-hidden="true" />
|
||||
<span class="text">Settings</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="links-nav-item">
|
||||
<a class="link" href={`${base}/console/project-${$project.$id}/keys`}>
|
||||
<span class="icon-key" aria-hidden="true" />
|
||||
<span class="text">API Keys</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="links-nav-item">
|
||||
<a class="link" href={`${base}/console/project-${$project.$id}/webhooks`}>
|
||||
<span class="icon-link" aria-hidden="true" />
|
||||
<span class="text">Webhooks</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</Cover>
|
||||
<Container>
|
||||
<h1>Platforms</h1>
|
||||
<List>
|
||||
{#each $project.platforms as platform}
|
||||
<ListItem
|
||||
avatar={sdkForConsole.avatars.getInitials(platform.type, 60, 60).toString()}>
|
||||
<svelte:fragment slot="header">
|
||||
<h2 class="sessions-item-title">
|
||||
<span class="text">
|
||||
{platform.name}
|
||||
</span>
|
||||
</h2>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="info">
|
||||
{platform.hostname}
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="action">
|
||||
<Button>Manage</Button>
|
||||
</svelte:fragment>
|
||||
</ListItem>
|
||||
{:else}
|
||||
<Card>
|
||||
<b>No Platforms Added to Your Project</b>
|
||||
<p>Add your first platform and build your new application.</p>
|
||||
</Card>
|
||||
{/each}
|
||||
<Button on:click={() => (addPlatform = true)}>Add Platform</Button>
|
||||
<CreatePlatform bind:show={addPlatform} />
|
||||
</List>
|
||||
</Container>
|
||||
{/if}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { base } from '$app/paths';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
throw redirect(302, `${base}/console/project-${params.project}/overview`);
|
||||
};
|
||||
+5
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Wizard } from '$lib/layout';
|
||||
import { beforeNavigate } from '$app/navigation';
|
||||
import { attributeList, documentList } from './store';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { page } from '$app/stores';
|
||||
@@ -62,6 +63,10 @@
|
||||
$createDocument.write = [];
|
||||
});
|
||||
|
||||
beforeNavigate(() => {
|
||||
wizard.hide();
|
||||
});
|
||||
|
||||
const stepsComponents: WizardStepsType = new Map();
|
||||
stepsComponents.set(1, {
|
||||
label: 'Create data',
|
||||
|
||||
@@ -0,0 +1,297 @@
|
||||
<script lang="ts">
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { Container } from '$lib/layout';
|
||||
import { page } from '$app/stores';
|
||||
import { browser } from '$app/environment';
|
||||
import { tabs, title, backButton, copyData } from '$lib/stores/layout';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from '../store';
|
||||
import { usage, type UsagePeriods } from './store';
|
||||
import { onMount } from 'svelte';
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { DropList, DropListItem } from '$lib/components';
|
||||
|
||||
$: projectId = $page.params.project;
|
||||
$: path = `/console/project-${projectId}/overview`;
|
||||
|
||||
let period: UsagePeriods = '30d';
|
||||
let showPeriodBandwith = false;
|
||||
let showPeriodRequests = false;
|
||||
|
||||
onMount(handle);
|
||||
afterNavigate(handle);
|
||||
|
||||
async function handle() {
|
||||
if ($usage) {
|
||||
await usage.load(projectId, period);
|
||||
} else {
|
||||
usage.load(projectId, period);
|
||||
}
|
||||
|
||||
title.set($project.name);
|
||||
tabs.set([]);
|
||||
backButton.set('');
|
||||
|
||||
copyData.set({
|
||||
text: 'Project ID',
|
||||
value: $project.$id
|
||||
});
|
||||
}
|
||||
|
||||
const formatter = Intl.NumberFormat('en', {
|
||||
notation: 'compact'
|
||||
});
|
||||
|
||||
// TODO: metric type is wrong
|
||||
function last(set: Array<unknown>): Models.Metric | null {
|
||||
return (set as Models.Metric[]).slice(-1)[0] ?? null;
|
||||
}
|
||||
|
||||
// TODO: metric type is wrong
|
||||
function total(set: Array<unknown>): number {
|
||||
return (set as Models.Metric[]).reduce((prev, curr) => prev + curr.value, 0);
|
||||
}
|
||||
|
||||
function format(number: number): string {
|
||||
return formatter.format(number);
|
||||
}
|
||||
|
||||
function changePeriod(newPeriod: UsagePeriods) {
|
||||
period = newPeriod;
|
||||
usage.load(projectId, period);
|
||||
showPeriodBandwith = false;
|
||||
showPeriodRequests = false;
|
||||
}
|
||||
|
||||
if (browser) {
|
||||
sdkForConsole.client.subscribe<unknown>('console', (message) => {
|
||||
if (message.events.includes('stats.connections')) {
|
||||
// TODO: take care of realtime connections
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Appwrite - Console</title>
|
||||
</svelte:head>
|
||||
|
||||
{#if $project}
|
||||
<Container overlapCover>
|
||||
{#if $usage}
|
||||
<section class="common-section">
|
||||
<div class="grid-dashboard-1s-2m-6l">
|
||||
<div class="card is-2-columns-medium-screen is-3-columns-large-screen">
|
||||
<div class="u-flex u-gap-16 u-main-space-between">
|
||||
<div>
|
||||
<div class="heading-level-4">
|
||||
{total($usage.network)}
|
||||
<span class="body-text-2">KB</span>
|
||||
</div>
|
||||
<div>Bandwidth</div>
|
||||
</div>
|
||||
<DropList
|
||||
bind:show={showPeriodBandwith}
|
||||
position="bottom"
|
||||
horizontal="left"
|
||||
arrowPosition="end"
|
||||
childStart>
|
||||
<button
|
||||
class="transparent-button"
|
||||
on:click={() => (showPeriodBandwith = !showPeriodBandwith)}>
|
||||
<span class="text">{period}</span>
|
||||
<span class="icon-cheveron-down" aria-hidden="true" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem on:click={() => changePeriod('24h')}>
|
||||
24h
|
||||
</DropListItem>
|
||||
<DropListItem on:click={() => changePeriod('30d')}>
|
||||
30d
|
||||
</DropListItem>
|
||||
<DropListItem on:click={() => changePeriod('90d')}>
|
||||
90d
|
||||
</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card is-2-columns-medium-screen is-3-columns-large-screen">
|
||||
<div class="u-flex u-gap-16 u-main-space-between">
|
||||
<div>
|
||||
<div class="heading-level-4">
|
||||
{format(total($usage.requests))}
|
||||
</div>
|
||||
<div>Requests</div>
|
||||
</div>
|
||||
<DropList
|
||||
bind:show={showPeriodRequests}
|
||||
position="bottom"
|
||||
horizontal="left"
|
||||
arrowPosition="end"
|
||||
childStart>
|
||||
<button
|
||||
class="transparent-button"
|
||||
on:click={() => (showPeriodRequests = !showPeriodRequests)}>
|
||||
<span class="text">{period}</span>
|
||||
<span class="icon-cheveron-down" aria-hidden="true" />
|
||||
</button>
|
||||
<svelte:fragment slot="list">
|
||||
<DropListItem on:click={() => changePeriod('24h')}>
|
||||
24h
|
||||
</DropListItem>
|
||||
<DropListItem on:click={() => changePeriod('30d')}>
|
||||
30d
|
||||
</DropListItem>
|
||||
<DropListItem on:click={() => changePeriod('90d')}>
|
||||
90d
|
||||
</DropListItem>
|
||||
</svelte:fragment>
|
||||
</DropList>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card is-2-columns-large-screen">
|
||||
<div class="grid-item-1">
|
||||
<div class="grid-item-1-start-start">
|
||||
<div class="eyebrow-heading-3">
|
||||
<span class="icon-database" aria-hidden="true" />
|
||||
<span class="text">Database</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-start-end" />
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<div class="heading-level-4">XX</div>
|
||||
<div>Databases</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-end-end">
|
||||
<div class="text">Documents: {last($usage.documents).value}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card is-2-columns-large-screen">
|
||||
<div class="grid-item-1">
|
||||
<div class="grid-item-1-start-start">
|
||||
<div class="eyebrow-heading-3">
|
||||
<span class="icon-folder" aria-hidden="true" />
|
||||
<span class="text">Storage</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-start-end" />
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<div class="heading-level-4">
|
||||
8.0 <span class="body-text-2">MB</span>
|
||||
</div>
|
||||
<div>Users</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-end-end">
|
||||
<div class="text">Buckets: XX</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card is-2-columns-large-screen">
|
||||
<div class="grid-item-1">
|
||||
<div class="grid-item-1-start-start">
|
||||
<div class="eyebrow-heading-3">
|
||||
<span class="icon-user-group" aria-hidden="true" />
|
||||
<span class="text">authentication</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-start-end" />
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<div class="heading-level-4">
|
||||
{format(last($usage.users).value)}
|
||||
</div>
|
||||
<div>Users</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-end-end">
|
||||
<div class="text">Sessions: XX</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card is-2-columns-large-screen">
|
||||
<div class="grid-item-1">
|
||||
<div class="grid-item-1-start-start">
|
||||
<div class="eyebrow-heading-3">
|
||||
<span class="icon-lightning-bolt" aria-hidden="true" />
|
||||
<span class="text">Functions</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-start-end" />
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<div class="heading-level-4">
|
||||
{format(last($usage.functions).value)}
|
||||
</div>
|
||||
<div>Executions</div>
|
||||
</div>
|
||||
|
||||
<div class="grid-item-1-end-end">
|
||||
<div class="text" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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">10</div>
|
||||
<div>Realtime Connections</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
<section class="common-section u-margin-block-start-100">
|
||||
<h2 class="heading-level-5">Integrations</h2>
|
||||
<div class="tabs u-margin-block-start-24 u-sep-block-end">
|
||||
<button
|
||||
class="tabs-button-scroll is-start u-hide"
|
||||
aria-label="Show items in start side">
|
||||
<span class="icon-cheveron-left" aria-hidden="true" />
|
||||
</button>
|
||||
<button
|
||||
class="tabs-button-scroll is-end u-hide"
|
||||
aria-label="Show items in end side">
|
||||
<span class="icon-cheveron-right" aria-hidden="true" />
|
||||
</button>
|
||||
<ul class="tabs-list" data-sveltekit-noscroll>
|
||||
<li class="tabs-item">
|
||||
<a
|
||||
class="tabs-button"
|
||||
href={`${path}/platforms`}
|
||||
class:is-selected={$page.url.pathname === `${path}/platforms`}>
|
||||
<span class="text">Platforms</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="tabs-item">
|
||||
<a
|
||||
class="tabs-button"
|
||||
href={`${path}/keys`}
|
||||
class:is-selected={$page.url.pathname === `${path}/keys`}>
|
||||
<span class="text">API Keys</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="u-margin-block-start-40">
|
||||
<slot />
|
||||
</div>
|
||||
</section>
|
||||
</Container>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.grid-item-1 {
|
||||
min-block-size: 6.5rem; /* TODO: remove */
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,7 @@
|
||||
import { base } from '$app/paths';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
throw redirect(302, `${base}/console/project-${params.project}/overview/platforms`);
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCellHead,
|
||||
TableCellText,
|
||||
TableHeader,
|
||||
TableRowLink
|
||||
} from '$lib/elements/table';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { project } from '../../store';
|
||||
import Create from './create.svelte';
|
||||
|
||||
let show = false;
|
||||
</script>
|
||||
|
||||
<div class="common-section u-flex u-gap-12">
|
||||
<h3 class="heading-level-7">API Keys</h3>
|
||||
<span class="u-margin-inline-start-auto">
|
||||
<Button on:click={() => (show = true)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Create API Key</span>
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableCellHead>Name</TableCellHead>
|
||||
<TableCellHead>last accessed</TableCellHead>
|
||||
<TableCellHead>expiration date</TableCellHead>
|
||||
<TableCellHead>clients</TableCellHead>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each $project.keys as key}
|
||||
<TableRowLink href={`keys/${key.$id}`}>
|
||||
<TableCellText title="Name">
|
||||
{key.name}
|
||||
</TableCellText>
|
||||
<TableCellText title="Last Accessed">
|
||||
{toLocaleDateTime(key.$createdAt)}
|
||||
</TableCellText>
|
||||
<TableCellText title="Expiration Date">
|
||||
{toLocaleDateTime(key.$updatedAt)}
|
||||
</TableCellText>
|
||||
<TableCellText title="Clients" />
|
||||
</TableRowLink>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Create bind:show />
|
||||
+268
@@ -0,0 +1,268 @@
|
||||
<script lang="ts">
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { scopes } from '$lib/constants';
|
||||
import {
|
||||
Button,
|
||||
Form,
|
||||
FormList,
|
||||
InputCheckbox,
|
||||
InputNumber,
|
||||
InputPassword,
|
||||
InputText
|
||||
} from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { Container } from '$lib/layout';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import Delete from './delete.svelte';
|
||||
import { key } from './store';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const keyId = $page.params.key;
|
||||
const activeScopes = scopes.reduce((prev, next) => {
|
||||
prev[next] = false;
|
||||
|
||||
return prev;
|
||||
}, {});
|
||||
|
||||
let loaded = false;
|
||||
let showDelete = false;
|
||||
let name: string = null;
|
||||
let secret: string = null;
|
||||
let expire: number = null;
|
||||
|
||||
onMount(handle);
|
||||
afterNavigate(handle);
|
||||
|
||||
async function handle(event = null) {
|
||||
if ($key?.$id !== keyId) {
|
||||
await key.load(projectId, keyId);
|
||||
}
|
||||
|
||||
name ??= $key.name;
|
||||
secret ??= $key.secret;
|
||||
expire ??= $key.expire;
|
||||
unselectAll();
|
||||
$key.scopes.forEach((scope) => {
|
||||
activeScopes[scope] = true;
|
||||
});
|
||||
|
||||
updateLayout({
|
||||
navigate: event,
|
||||
back: `${base}/console/project-${$page.params.project}/overview/keys`,
|
||||
title: $key.name,
|
||||
level: 4,
|
||||
copy: {
|
||||
text: 'API Key Secret',
|
||||
value: $key.secret
|
||||
},
|
||||
breadcrumbs: [
|
||||
{
|
||||
level: 3,
|
||||
href: 'keys',
|
||||
title: 'API Keys'
|
||||
},
|
||||
{
|
||||
level: 4,
|
||||
href: keyId,
|
||||
title: $key.name
|
||||
}
|
||||
]
|
||||
});
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
async function updateName() {
|
||||
try {
|
||||
await sdkForConsole.projects.updateKey($project.$id, $key.$id, name, $key.scopes);
|
||||
$key.name = name;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'API Key name has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function updateExpire() {
|
||||
try {
|
||||
await sdkForConsole.projects.updateKey(
|
||||
$project.$id,
|
||||
$key.$id,
|
||||
$key.name,
|
||||
$key.scopes,
|
||||
expire
|
||||
);
|
||||
$key.expire = expire;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'API Key expiration has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function updateScopes() {
|
||||
console.log(scopes.filter((scope) => activeScopes[scope]));
|
||||
try {
|
||||
await sdkForConsole.projects.updateKey(
|
||||
$project.$id,
|
||||
$key.$id,
|
||||
$key.name,
|
||||
scopes.filter((scope) => activeScopes[scope])
|
||||
);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'API Key scopes has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function unselectAll() {
|
||||
for (const scope in activeScopes) {
|
||||
activeScopes[scope] = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Appwrite - API Key</title>
|
||||
</svelte:head>
|
||||
|
||||
<Container>
|
||||
{#if loaded}
|
||||
<CardGrid>
|
||||
<div>
|
||||
<h6 class="heading-level-7">{$key.name}</h6>
|
||||
</div>
|
||||
<svelte:fragment slot="aside">
|
||||
<p>
|
||||
Last accessed: {toLocaleDateTime($key.$updatedAt)}<br />
|
||||
Scopes granted: {$key.scopes.length}
|
||||
</p>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
<Form>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">API Key Secret</h6>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputPassword
|
||||
id="secret"
|
||||
label="API Key Secret"
|
||||
bind:value={secret}
|
||||
showPasswordButton
|
||||
required />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<Form on:submit={updateName}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Name</h6>
|
||||
<p class="text">Choose any name that will help you distinguish between API keys.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
bind:value={name}
|
||||
required
|
||||
placeholder="Enter name" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={name === $key.name} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<Form on:submit={updateScopes}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Scopes</h6>
|
||||
<p class="text">
|
||||
You can choose which permission scope to grant your application. It is a best
|
||||
practice to allow only the permissions you need to meet your project goals.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
{#each scopes as scope}
|
||||
<InputCheckbox
|
||||
id={scope}
|
||||
label={scope}
|
||||
bind:value={activeScopes[scope]} />
|
||||
{/each}
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<Form on:submit={updateExpire}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Expiration Date</h6>
|
||||
<p class="text">Choose any name that will help you distinguish between API keys.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputNumber
|
||||
id="expire"
|
||||
label="Expiration Date"
|
||||
bind:value={expire}
|
||||
required />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={expire === $key.expire} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<CardGrid>
|
||||
<div>
|
||||
<h6 class="heading-level-7">Delete API Key</h6>
|
||||
</div>
|
||||
<p>The API Key will be permanently deleted. This action is irreversible.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="box">
|
||||
<div class="u-flex u-gap-16">
|
||||
<div class="u-cross-child-center u-line-height-1-5">
|
||||
<h6 class="u-bold">{$key.name}</h6>
|
||||
<p>Last accessed: {toLocaleDateTime($key.$updatedAt)}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button secondary on:click={() => (showDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<Delete bind:showDelete />
|
||||
@@ -0,0 +1,42 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from '../../../store';
|
||||
import { key } from './store';
|
||||
|
||||
export let showDelete = false;
|
||||
|
||||
const handleDelete = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.deletePlatform($project.$id, $key.$id);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$key.name} has been deleted`
|
||||
});
|
||||
project.load($project.$id);
|
||||
await goto(`${base}/console/project-${$project.$id}/overview/keys`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={handleDelete}>
|
||||
<Modal bind:show={showDelete} warning>
|
||||
<svelte:fragment slot="header">Delete API Key</svelte:fragment>
|
||||
<p>The API Key will be permanently deleted. This action is irreversible.</p>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
</Form>
|
||||
@@ -0,0 +1,17 @@
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
|
||||
export const key = cachedStore<
|
||||
Models.Key,
|
||||
{
|
||||
load: (projectId: string, keyId: string) => Promise<void>;
|
||||
}
|
||||
>('key', function ({ set }) {
|
||||
return {
|
||||
load: async (projectId, keyId) => {
|
||||
const key = await sdkForConsole.projects.getKey(projectId, keyId);
|
||||
set(key);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,55 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { scopes } from '$lib/constants';
|
||||
import { InputText, Button, Form, FormList, InputCheckbox } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from '../../.../../store';
|
||||
|
||||
export let show = false;
|
||||
|
||||
const activeScopes = scopes.reduce((prev, next) => {
|
||||
prev[next] = false;
|
||||
|
||||
return prev;
|
||||
}, {});
|
||||
|
||||
let name: string;
|
||||
|
||||
async function create() {
|
||||
try {
|
||||
await sdkForConsole.projects.createKey(
|
||||
$project.$id,
|
||||
name,
|
||||
scopes.filter((scope) => activeScopes[scope])
|
||||
);
|
||||
name = null;
|
||||
for (const scope in activeScopes) {
|
||||
activeScopes[scope] = false;
|
||||
}
|
||||
project.load($project.$id);
|
||||
show = false;
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form on:submit={create}>
|
||||
<Modal bind:show>
|
||||
<svelte:fragment slot="header">Create API Key</svelte:fragment>
|
||||
<FormList>
|
||||
<InputText id="name" label="Name" bind:value={name} autofocus required />
|
||||
{#each scopes as scope}
|
||||
<InputCheckbox id={scope} label={scope} bind:value={activeScopes[scope]} />
|
||||
{/each}
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit>Register</Button>
|
||||
<Button secondary on:click={() => (show = false)}>Cancel</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
</Form>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { GridItem1 } from '$lib/components';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { toLocaleDateTime } from '$lib/helpers/date';
|
||||
import { project } from '../../store';
|
||||
import Create from './create.svelte';
|
||||
|
||||
let show = false;
|
||||
|
||||
const path = `/console/project-${$page.params.project}/overview/platforms`;
|
||||
</script>
|
||||
|
||||
<div class="common-section u-flex u-gap-12">
|
||||
<h3 class="heading-level-7">Platforms</h3>
|
||||
<span class="u-margin-inline-start-auto">
|
||||
<Button on:click={() => (show = true)}>
|
||||
<span class="icon-plus" aria-hidden="true" />
|
||||
<span class="text">Add Platform</span>
|
||||
</Button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="grid-box u-margin-block-start-32" style="--grid-gap:2rem; --grid-item-size:25rem;">
|
||||
{#each $project.platforms as platform}
|
||||
<GridItem1 href={`${path}/${platform.$id}`}>
|
||||
<svelte:fragment slot="title">{platform.name}</svelte:fragment>
|
||||
|
||||
<div class="grid-item-1-end-start">
|
||||
<p>Last Updated</p>
|
||||
<p>{toLocaleDateTime(platform.$updatedAt)}</p>
|
||||
</div>
|
||||
</GridItem1>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<Create bind:show />
|
||||
+145
@@ -0,0 +1,145 @@
|
||||
<script lang="ts">
|
||||
import { afterNavigate } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { Container } from '$lib/layout';
|
||||
import { updateLayout } from '$lib/stores/layout';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount, SvelteComponent } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
import Delete from './delete.svelte';
|
||||
import Web from './web.svelte';
|
||||
import FlutterIos from './flutterIOS.svelte';
|
||||
import FlutterAndroid from './flutterAndroid.svelte';
|
||||
import FlutterLinux from './flutterLinux.svelte';
|
||||
import FlutterMacOs from './flutterMacOS.svelte';
|
||||
import FlutterWindows from './flutterWindows.svelte';
|
||||
import AppleiOs from './appleIOS.svelte';
|
||||
import AppleMacOs from './appleMacOS.svelte';
|
||||
import AppleWatchOs from './appleWatchOS.svelte';
|
||||
import AppleTvos from './appleTvOS.svelte';
|
||||
|
||||
const projectId = $page.params.project;
|
||||
const platformId = $page.params.platform;
|
||||
const types: Record<string, typeof SvelteComponent> = {
|
||||
web: Web,
|
||||
android: Web,
|
||||
'apple-ios': AppleiOs,
|
||||
'apple-macos': AppleMacOs,
|
||||
'apple-watchos': AppleWatchOs,
|
||||
'apple-tvos': AppleTvos,
|
||||
'flutter-ios': FlutterIos,
|
||||
'flutter-android': FlutterAndroid,
|
||||
'flutter-linux': FlutterLinux,
|
||||
'flutter-macos': FlutterMacOs,
|
||||
'flutter-windows': FlutterWindows
|
||||
};
|
||||
|
||||
let loaded = false;
|
||||
let showDelete = false;
|
||||
let name: string = null;
|
||||
|
||||
onMount(handle);
|
||||
afterNavigate(handle);
|
||||
|
||||
async function handle(event = null) {
|
||||
if ($platform?.$id !== platformId) {
|
||||
await platform.load(projectId, platformId);
|
||||
}
|
||||
|
||||
name ??= $platform.name;
|
||||
|
||||
updateLayout({
|
||||
navigate: event,
|
||||
back: `${base}/console/project-${projectId}/overview/platforms`,
|
||||
title: $platform.name,
|
||||
level: 4,
|
||||
breadcrumbs: [
|
||||
{
|
||||
level: 3,
|
||||
href: 'platforms',
|
||||
title: 'Platforms'
|
||||
},
|
||||
{
|
||||
level: 4,
|
||||
href: platformId,
|
||||
title: $platform.name
|
||||
}
|
||||
]
|
||||
});
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
const updateName = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform($project.$id, $platform.$id, name);
|
||||
$platform.name = name;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform name has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Container>
|
||||
{#if loaded}
|
||||
<Form on:submit={updateName}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Name</h6>
|
||||
<p class="text">
|
||||
Choose any name that will help you distinguish between platforms.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="name"
|
||||
label="Name"
|
||||
bind:value={name}
|
||||
required
|
||||
placeholder="Enter name" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={name === $platform.name} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
|
||||
<svelte:component this={types[$platform.type]} />
|
||||
|
||||
<CardGrid>
|
||||
<div>
|
||||
<h6 class="heading-level-7">Delete Platform</h6>
|
||||
</div>
|
||||
<p>The Platform will be permanently deleted. This action is irreversible.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<div class="box">
|
||||
<div class="u-flex u-gap-16">
|
||||
<!-- <img class="avatar" src="/icons/dark/color/android.svg" /> -->
|
||||
<div class="u-cross-child-center u-line-height-1-5">
|
||||
<h6 class="u-bold">{$platform.name}</h6>
|
||||
<p>{$platform.hostname}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button secondary on:click={() => (showDelete = true)}>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
{/if}
|
||||
</Container>
|
||||
|
||||
<Delete bind:showDelete />
|
||||
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Bundle ID has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Bundle ID</h6>
|
||||
<p class="text">
|
||||
You can find your Bundle Identifier in the General tab for your app's primary target in
|
||||
Xcode.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="bundle-id"
|
||||
label="Bundle ID"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Bundle ID has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Bundle ID</h6>
|
||||
<p class="text">
|
||||
You can find your Bundle Identifier in the General tab for your app's primary target in
|
||||
Xcode.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="bundle-id"
|
||||
label="Bundle ID"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Bundle ID has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Bundle ID</h6>
|
||||
<p class="text">
|
||||
You can find your Bundle Identifier in the General tab for your app's primary target in
|
||||
Xcode.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="bundle-id"
|
||||
label="Bundle ID"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Bundle ID has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Bundle ID</h6>
|
||||
<p class="text">
|
||||
You can find your Bundle Identifier in the General tab for your app's primary target in
|
||||
Xcode.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="bundle-id"
|
||||
label="Bundle ID"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,43 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { base } from '$app/paths';
|
||||
import { Modal } from '$lib/components';
|
||||
import { Button, Form } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
export let showDelete = false;
|
||||
|
||||
const handleDelete = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.deletePlatform($project.$id, $platform.$id);
|
||||
showDelete = false;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: `${$platform.name} has been deleted`
|
||||
});
|
||||
project.load($project.$id);
|
||||
platform.set(null);
|
||||
await goto(`${base}/console/project-${$project.$id}/overview/platforms`);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={handleDelete}>
|
||||
<Modal bind:show={showDelete} warning>
|
||||
<svelte:fragment slot="header">Delete Platform</svelte:fragment>
|
||||
<p>The Platform will be permanently deleted. This action is irreversible.</p>
|
||||
|
||||
<svelte:fragment slot="footer">
|
||||
<Button text on:click={() => (showDelete = false)}>Cancel</Button>
|
||||
<Button secondary submit>Delete</Button>
|
||||
</svelte:fragment>
|
||||
</Modal>
|
||||
</Form>
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Package Name has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Package Name</h6>
|
||||
<p class="text">
|
||||
Your package name is generally the applicationId in your app-level build.gradle file.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="package-name"
|
||||
label="Package Name"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Bundle ID has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Bundle ID</h6>
|
||||
<p class="text">
|
||||
You can find your Bundle Identifier in the General tab for your app's primary target in
|
||||
Xcode.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="bundle-id"
|
||||
label="Bundle ID"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Package Name has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Package Name</h6>
|
||||
<p class="text">Your application name.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="package-name"
|
||||
label="Package Name"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Bundle ID has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Bundle ID</h6>
|
||||
<p class="text">
|
||||
You can find your Bundle Identifier in the General tab for your app's primary target in
|
||||
Xcode.
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="bundle-id"
|
||||
label="Bundle ID"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="com.company.appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let key: string = null;
|
||||
|
||||
onMount(() => {
|
||||
key ??= $platform.key;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
key
|
||||
);
|
||||
$platform.key = key;
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform Package Name has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Package Name</h6>
|
||||
<p class="text">Your application name.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="package-name"
|
||||
label="Package Name"
|
||||
bind:value={key}
|
||||
required
|
||||
placeholder="appname" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={key === $platform.key} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
@@ -0,0 +1,17 @@
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
|
||||
export const platform = cachedStore<
|
||||
Models.Platform,
|
||||
{
|
||||
load: (projectId: string, platformId: string) => Promise<void>;
|
||||
}
|
||||
>('platform', function ({ set }) {
|
||||
return {
|
||||
load: async (projectId, platformId) => {
|
||||
const platform = await sdkForConsole.projects.getPlatform(projectId, platformId);
|
||||
set(platform);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
<script lang="ts">
|
||||
import { CardGrid } from '$lib/components';
|
||||
import { Button, Form, FormList, InputText } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { project } from '../../../store';
|
||||
import { platform } from './store';
|
||||
|
||||
let hostname: string = null;
|
||||
|
||||
onMount(() => {
|
||||
hostname ??= $platform.hostname;
|
||||
});
|
||||
|
||||
const updateHostname = async () => {
|
||||
try {
|
||||
await sdkForConsole.projects.updatePlatform(
|
||||
$project.$id,
|
||||
$platform.$id,
|
||||
$platform.name,
|
||||
undefined,
|
||||
undefined,
|
||||
hostname
|
||||
);
|
||||
project.load($project.$id);
|
||||
addNotification({
|
||||
type: 'success',
|
||||
message: 'Platform hostname has been updated'
|
||||
});
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<Form on:submit={updateHostname}>
|
||||
<CardGrid>
|
||||
<h6 class="heading-level-7">Update Hostname</h6>
|
||||
<p class="text">You can use * to allow wildcard hostnames or subdomains.</p>
|
||||
<svelte:fragment slot="aside">
|
||||
<FormList>
|
||||
<InputText
|
||||
id="hostname"
|
||||
label="Hostname"
|
||||
bind:value={hostname}
|
||||
required
|
||||
placeholder="myapp.com" />
|
||||
</FormList>
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
<Button disabled={hostname === $platform.hostname} submit>Update</Button>
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
+8
-6
@@ -1,16 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { Modal } from '$lib/components';
|
||||
import { InputText, Button, Form } from '$lib/elements/forms';
|
||||
import { InputText, Button, Form, FormList } from '$lib/elements/forms';
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { project } from './store';
|
||||
import { project } from '../../.../../store';
|
||||
|
||||
export let show = false;
|
||||
|
||||
let name: string;
|
||||
let hostname: string;
|
||||
|
||||
const create = async () => {
|
||||
async function create() {
|
||||
try {
|
||||
await sdkForConsole.projects.createPlatform(
|
||||
$project.$id,
|
||||
@@ -29,14 +29,16 @@
|
||||
message: error.message
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form on:submit={create}>
|
||||
<Modal bind:show>
|
||||
<svelte:fragment slot="header">Add Platform</svelte:fragment>
|
||||
<InputText id="name" label="Name" bind:value={name} required />
|
||||
<InputText id="host" label="Hostname" bind:value={hostname} required />
|
||||
<FormList>
|
||||
<InputText id="name" label="Name" bind:value={name} autofocus required />
|
||||
<InputText id="host" label="Hostname" bind:value={hostname} required />
|
||||
</FormList>
|
||||
<svelte:fragment slot="footer">
|
||||
<Button submit>Register</Button>
|
||||
<Button secondary on:click={() => (show = false)}>Cancel</Button>
|
||||
@@ -0,0 +1,18 @@
|
||||
import { sdkForConsole } from '$lib/stores/sdk';
|
||||
import { cachedStore } from '$lib/helpers/cache';
|
||||
import type { Models } from '@aw-labs/appwrite-console';
|
||||
|
||||
export type UsagePeriods = '24h' | '30d' | '90d';
|
||||
export const usage = cachedStore<
|
||||
Models.UsageProject,
|
||||
{
|
||||
load: (projectId: string, range: UsagePeriods) => Promise<void>;
|
||||
}
|
||||
>('projectUsage', function ({ set }) {
|
||||
return {
|
||||
load: async (projectId, range) => {
|
||||
const usages = await sdkForConsole.projects.getUsage(projectId, range);
|
||||
set(usages);
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user