mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
update api requests
This commit is contained in:
1 parent
c1d083c98a
commit
ff7f87f620
16 files changed
+66
-121
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { Models } from 'src/sdk';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const user = writable<Models.User<{ [key: string]: string }>>();
|
||||
export const user = writable<Models.User<Record<string, unknown>>>();
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Models } from 'src/sdk';
|
||||
import { writable } from 'svelte/store';
|
||||
|
||||
export const user = writable<Models.User<{ [key: string]: string }>>();
|
||||
export const user = writable<Models.User<Record<string, unknown>>>();
|
||||
@@ -15,10 +15,10 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
await sdkForProject.database.createCollection(id, name, 'collection', [], []);
|
||||
const bucket = await sdkForProject.database.createCollection(id, name, 'collection', [], []);
|
||||
id = name = '';
|
||||
showCreate = false;
|
||||
dispatch('created');
|
||||
dispatch('created', bucket);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
@@ -7,11 +7,7 @@
|
||||
|
||||
let offset = 0;
|
||||
const limit = 25;
|
||||
|
||||
const project = $page.params.project;
|
||||
const getDocuments = () =>
|
||||
sdkForProject.database.listDocuments($collection.$id, [], limit, offset);
|
||||
|
||||
const columns = [
|
||||
{ key: '$id', title: '#' },
|
||||
...$collection.attributes.map((attribute) => ({
|
||||
@@ -20,7 +16,7 @@
|
||||
}))
|
||||
];
|
||||
|
||||
let request = getDocuments();
|
||||
$: request = sdkForProject.database.listDocuments($collection.$id, [], limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Documents</h1>
|
||||
@@ -49,11 +45,6 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getDocuments())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
@@ -5,19 +5,22 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Card, Pagination } from '$lib/components';
|
||||
import Create from './_create.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import type { Models } from 'src/sdk';
|
||||
|
||||
let search = '';
|
||||
let showCreate = false;
|
||||
let offset = 0;
|
||||
const limit = 25;
|
||||
|
||||
const project = $page.params.project;
|
||||
const getCollections = () => sdkForProject.database.listCollections(search, limit, offset);
|
||||
const doSearch = () => {
|
||||
offset = 0;
|
||||
request = getCollections();
|
||||
};
|
||||
let request = getCollections();
|
||||
const collectionCreated = async (event: CustomEvent<Models.Collection>) => {
|
||||
await goto(`/console/${project}/database/collection/${event.detail.$id}`);
|
||||
};
|
||||
|
||||
$: request = sdkForProject.database.listCollections(search, limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Collections</h1>
|
||||
@@ -49,14 +52,9 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getCollections())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Create Collection</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getCollections())} />
|
||||
<Create bind:showCreate on:created={collectionCreated} />
|
||||
@@ -10,17 +10,15 @@
|
||||
let search = '';
|
||||
let showCreate = false;
|
||||
let offset = 0;
|
||||
const limit = 25;
|
||||
|
||||
const limit = 25;
|
||||
const project = $page.params.project;
|
||||
const functionId = $page.params.function;
|
||||
const getDeployments = () =>
|
||||
sdkForProject.functions.listDeployments(functionId, search, limit, offset);
|
||||
// const doSearch = () => {
|
||||
// offset = 0;
|
||||
// request = getDeployments();
|
||||
// };
|
||||
let request = getDeployments();
|
||||
$: request = sdkForProject.functions.listDeployments(functionId, search, limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Overview</h1>
|
||||
@@ -63,14 +61,9 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getDeployments())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Upload</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getDeployments())} />
|
||||
<Create bind:showCreate />
|
||||
@@ -12,12 +12,10 @@
|
||||
const limit = 25;
|
||||
|
||||
const project = $page.params.project;
|
||||
const getFunctions = () => sdkForProject.functions.list(search, limit, offset);
|
||||
const doSearch = () => {
|
||||
offset = 0;
|
||||
request = getFunctions();
|
||||
};
|
||||
let request = getFunctions();
|
||||
$: request = sdkForProject.functions.list(search, limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Functions</h1>
|
||||
@@ -47,14 +45,9 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getFunctions())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Create Function</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getFunctions())} />
|
||||
<Create bind:showCreate />
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
await sdkForProject.storage.createBucket('unique()', name, 'bucket');
|
||||
const bucket = await sdkForProject.storage.createBucket('unique()', name, 'bucket');
|
||||
name = null;
|
||||
showCreate = false;
|
||||
dispatch('created');
|
||||
dispatch('created', bucket);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
@@ -13,12 +13,11 @@
|
||||
|
||||
const project = $page.params.project;
|
||||
const bucket = $page.params.bucket;
|
||||
const getBuckets = () => sdkForProject.storage.listFiles(bucket, search, limit, offset);
|
||||
const doSearch = () => {
|
||||
offset = 0;
|
||||
request = getBuckets();
|
||||
};
|
||||
let request = getBuckets();
|
||||
|
||||
$: request = sdkForProject.storage.listFiles(bucket, search, limit, offset);
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={doSearch}>
|
||||
@@ -52,14 +51,9 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getBuckets())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Upload</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getBuckets())} />
|
||||
<Create bind:showCreate />
|
||||
@@ -1,30 +1,30 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/stores';
|
||||
import { goto } from '$app/navigation';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { Table, TableRow, TableBody, TableHeader, TableCell } from '$lib/elements/table';
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Card, Pagination } from '$lib/components';
|
||||
import Create from './_create.svelte';
|
||||
import type { Models } from 'src/sdk';
|
||||
|
||||
let search = '';
|
||||
let showCreate = false;
|
||||
let offset = 0;
|
||||
const limit = 25;
|
||||
|
||||
const limit = 25;
|
||||
const project = $page.params.project;
|
||||
const getCollections = () => sdkForProject.storage.listBuckets(search, limit, offset);
|
||||
const doSearch = () => {
|
||||
offset = 0;
|
||||
request = getCollections();
|
||||
const bucketCreated = async (event: CustomEvent<Models.Bucket>) => {
|
||||
showCreate = false;
|
||||
await goto(`/console/${project}/storage/bucket/${event.detail.$id}`);
|
||||
};
|
||||
let request = getCollections();
|
||||
|
||||
$: request = sdkForProject.storage.listBuckets(search, limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Buckets</h1>
|
||||
<Card>
|
||||
<form on:submit|preventDefault={doSearch}>
|
||||
<input type="search" bind:value={search} />
|
||||
</form>
|
||||
<input type="search" bind:value={search} />
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
@@ -47,14 +47,9 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getCollections())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Create Bucket</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getCollections())} />
|
||||
<Create bind:showCreate on:created={bucketCreated} />
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
await sdkForProject.users.create('unique()', mail, pass, name);
|
||||
const user = await sdkForProject.users.create('unique()', mail, pass, name);
|
||||
mail = pass = name = '';
|
||||
showCreate = false;
|
||||
dispatch('created');
|
||||
dispatch('created', user);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Table, TableHeader, TableBody, TableRow, TableCell } from '$lib/elements/table';
|
||||
import Create from './_create.svelte';
|
||||
import type { Models } from 'src/sdk';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
let search = '';
|
||||
let showCreate = false;
|
||||
@@ -13,20 +15,15 @@
|
||||
|
||||
const project = $page.params.project;
|
||||
const getAvatar = (name: string) => sdkForProject.avatars.getInitials(name, 30, 30).toString();
|
||||
const getUsers = () =>
|
||||
sdkForProject.users.list(search, limit, offset, undefined, undefined, 'DESC');
|
||||
const doSearch = () => {
|
||||
offset = 0;
|
||||
request = getUsers();
|
||||
const userCreated = async (event: CustomEvent<Models.User<Record<string, unknown>>>) => {
|
||||
await goto(`/console/${project}/users/user/${event.detail.$id}`);
|
||||
};
|
||||
let request = getUsers();
|
||||
$: request = sdkForProject.users.list(search, limit, offset, undefined, undefined, 'DESC');
|
||||
</script>
|
||||
|
||||
<h1>Users</h1>
|
||||
<Card>
|
||||
<form on:submit|preventDefault={doSearch}>
|
||||
<input type="search" bind:value={search} />
|
||||
</form>
|
||||
<input type="search" bind:value={search} />
|
||||
</Card>
|
||||
<Card>
|
||||
{#await request}
|
||||
@@ -44,7 +41,7 @@
|
||||
{#each response.users as user}
|
||||
<TableRow>
|
||||
<TableCell>
|
||||
<img src={getAvatar(user.name)} alt={user.name} class="avatar" />
|
||||
<img src={getAvatar(user.name)} alt={user.name} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<a href={`/console/${project}/users/user/${user.$id}`}>
|
||||
@@ -58,15 +55,9 @@
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<Pagination {limit} bind:offset sum={response.total} on:change={() => (request = getUsers())} />
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Create User</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getUsers())} />
|
||||
|
||||
<style>
|
||||
.avatar {
|
||||
border-radius: 50%;
|
||||
}
|
||||
</style>
|
||||
<Create bind:showCreate on:created={userCreated} />
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
const create = async () => {
|
||||
try {
|
||||
await sdkForProject.teams.create('unique()', name);
|
||||
const team = await sdkForProject.teams.create('unique()', name);
|
||||
name = '';
|
||||
showCreate = false;
|
||||
dispatch('created');
|
||||
dispatch('created', team);
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import { Button } from '$lib/elements/forms';
|
||||
import { Card, Pagination } from '$lib/components';
|
||||
import Create from './_create.svelte';
|
||||
import { goto } from '$app/navigation';
|
||||
import type { Models } from 'src/sdk';
|
||||
|
||||
let search = '';
|
||||
let showCreate = false;
|
||||
@@ -12,19 +14,15 @@
|
||||
const limit = 25;
|
||||
|
||||
const project = $page.params.project;
|
||||
const getTeams = () => sdkForProject.teams.list(search, limit, offset);
|
||||
const doSearch = () => {
|
||||
offset = 0;
|
||||
request = getTeams();
|
||||
const teamCreated = async (event: CustomEvent<Models.Team>) => {
|
||||
await goto(`/console/${project}/users/team/${event.detail.$id}`);
|
||||
};
|
||||
let request = getTeams();
|
||||
$: request = sdkForProject.teams.list(search, limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Teams</h1>
|
||||
<Card>
|
||||
<form on:submit|preventDefault={doSearch}>
|
||||
<input type="search" bind:value={search} />
|
||||
</form>
|
||||
<input type="search" bind:value={search} />
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
@@ -52,9 +50,9 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Pagination {limit} bind:offset sum={response.total} on:change={() => (request = getTeams())} />
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
|
||||
<Button on:click={() => (showCreate = true)}>Create Team</Button>
|
||||
<Create bind:showCreate on:created={() => (request = getTeams())} />
|
||||
<Button>Create Team</Button>
|
||||
<Create bind:showCreate on:created={teamCreated} />
|
||||
@@ -4,12 +4,10 @@
|
||||
import { Table, TableBody, TableHeader, TableRow, TableCell } from '$lib/elements/table';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
|
||||
const getLogs = () => sdkForProject.users.getLogs($page.params.user);
|
||||
|
||||
let offset = 0;
|
||||
const limit = 25;
|
||||
|
||||
let request = getLogs();
|
||||
$: request = sdkForProject.users.getLogs($page.params.user, limit, offset);
|
||||
</script>
|
||||
|
||||
<h1>Activity</h1>
|
||||
@@ -49,6 +47,6 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Pagination {limit} bind:offset sum={response.total} on:change={() => (request = getLogs())} />
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
{/await}
|
||||
</Card>
|
||||
@@ -6,11 +6,9 @@
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
|
||||
const getSessions = () => sdkForProject.users.getSessions($page.params.user);
|
||||
const deleteSession = async (id: string) => {
|
||||
try {
|
||||
await sdkForProject.users.deleteSession($page.params.user, id);
|
||||
request = getSessions();
|
||||
} catch (error) {
|
||||
addNotification({
|
||||
type: 'error',
|
||||
@@ -30,10 +28,11 @@
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let offset = 0;
|
||||
const limit = 25;
|
||||
|
||||
let request = getSessions();
|
||||
$: request = sdkForProject.users.getSessions($page.params.user);
|
||||
</script>
|
||||
|
||||
<h1>Sessions</h1>
|
||||
@@ -69,12 +68,7 @@
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
<Pagination
|
||||
{limit}
|
||||
bind:offset
|
||||
sum={response.total}
|
||||
on:change={() => (request = getSessions())}
|
||||
/>
|
||||
<Pagination {limit} bind:offset sum={response.total} />
|
||||
<Button on:click={deleteAllSessions}>Logout from all sessions</Button>
|
||||
{/await}
|
||||
</Card>
|
||||
Reference in new issue
Block a user