feat: add limit option to all views

This commit is contained in:
Torsten Dittmann committed 2023-03-22 15:36:41 +01:00
1 parent 6c4c7750a7
commit baefe388ba
44 files changed
+297 -124

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 Limit } from './limit.svelte';
+35
View File
@@ -0,0 +1,35 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { page as pageStore } from '$app/stores';
import { InputSelect } from '$lib/elements/forms';
import { preferences } from '$lib/stores/preferences';
export let sum: number;
export let limit: number;
export let name: string;
const options = [
{ label: '6', value: 6 },
{ label: '12', value: 12 },
{ label: '24', value: 24 },
{ label: '48', value: 48 },
{ label: '96', value: 96 }
];
async function limitChange() {
const url = new URL($pageStore.url);
url.searchParams.set('limit', limit.toString());
preferences.setLimit(limit);
await goto(url.toString());
}
</script>
<div class="u-flex u-gap-12 u-cross-center">
<InputSelect
id="rows"
label="Rows per page"
showLabel={false}
{options}
bind:value={limit}
on:change={limitChange} />
<p class="text">{name} per page. Total results: {sum}</p>
</div>
+2 -1
View File
@@ -52,7 +52,8 @@
{disabled}
bind:this={element}
bind:value
on:invalid={handleInvalid}>
on:invalid={handleInvalid}
on:change>
{#if placeholder}
<option value={null} disabled selected hidden>{placeholder}</option>
{/if}
+19
View File
@@ -1,7 +1,26 @@
import { preferences } from '$lib/stores/preferences';
import type { Page } from '@sveltejs/kit';
export function pageToOffset(page: number, limit: number): number {
return page ? page * limit - limit : 0;
}
export function getPage(url: URL): number {
return Number(url.searchParams.get('page'));
}
export function getLimit(url: URL, route: Page['route'], fallback: number): number {
return Number(url.searchParams.get('limit') ?? preferences.get(route).limit ?? fallback);
}
export function getView(url: URL, route: Page['route'], fallback: 'table' | 'grid'): string {
return url.searchParams.get('view') ?? preferences.get(route).view ?? fallback;
}
export function getSearch(url: URL): string | undefined {
return url.searchParams.get('search') ?? undefined;
}
type TabElement = { href: string; title: string; hasChildren?: boolean };
export function isTabSelected(
+4 -4
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { AvatarInitials, EmptySearch, Pagination, Trim } from '$lib/components';
import { AvatarInitials, EmptySearch, Limit, Pagination, Trim } from '$lib/components';
import {
TableBody,
TableHeader,
@@ -11,11 +11,11 @@
} from '$lib/elements/table';
import { Container } from '$lib/layout';
import { toLocaleDateTime } from '$lib/helpers/date';
import { PAGE_LIMIT } from '$lib/constants';
import type { Models } from '@aw-labs/appwrite-console';
export let logs: Models.LogList;
export let offset = 0;
export let limit = 0;
</script>
<Container>
@@ -65,8 +65,8 @@
</TableBody>
</TableScroll>
<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} {offset} sum={logs.total} />
<Limit {limit} sum={logs.total} name="Logs" />
<Pagination {limit} {offset} sum={logs.total} />
</div>
{:else}
<EmptySearch>
+68
View File
@@ -0,0 +1,68 @@
import { browser } from '$app/environment';
import { page } from '$app/stores';
import type { Page } from '@sveltejs/kit';
import { get, writable } from 'svelte/store';
import { sdk } from './sdk';
type Preferences = {
limit?: number;
view?: 'table' | 'grid';
};
type PreferencesStore = {
[key: string]: {
[key: string]: Preferences;
};
};
function createPreferences() {
const { subscribe, set, update } = writable<PreferencesStore>({});
if (browser) {
set(JSON.parse(globalThis.localStorage.getItem('preferences') ?? '{}'));
}
return {
subscribe,
get: (route: Page['route']): Preferences => {
let preferences: PreferencesStore;
subscribe((n) => (preferences = n))();
return (
preferences[sdk.forProject.client.config.project]?.[route.id] ?? {
limit: null,
view: null
}
);
},
setLimit: (limit: Preferences['limit']) =>
update((n) => {
const path = get(page).route.id;
const project = sdk.forProject.client.config.project;
if (!n[project]?.[path]) {
n[project] ??= {};
n[project][path] ??= {};
}
n[project][path].limit = limit;
return n;
}),
setView: (view: Preferences['view']) =>
update((n) => {
const path = get(page).route.id;
const project = sdk.forProject.client.config.project;
if (!n[project]?.[path]) {
n[project] ??= {};
n[project][path] ??= {};
}
n[project][path].view = view;
return n;
})
};
}
export const preferences = createPreferences();
if (browser) {
preferences.subscribe((n) => globalThis.localStorage.setItem('preferences', JSON.stringify(n)));
}
@@ -5,4 +5,4 @@
export let data: PageData;
</script>
<Activity logs={data.logs} offset={data.offset} />
<Activity {...data} />
+4 -4
View File
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -6,7 +6,8 @@
Pagination,
AvatarGroup,
CardContainer,
Heading
Heading,
Limit
} from '$lib/components';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
@@ -66,7 +67,7 @@
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.organizations.total}</p>
<Limit limit={data.limit} sum={data.organizations.total} name="Organizations" />
<Pagination limit={data.limit} offset={data.offset} sum={data.organizations.total} />
</div>
</Container>
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? CARD_LIMIT);
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -1,7 +1,7 @@
<script lang="ts">
import { base } from '$app/paths';
import { Pill } from '$lib/elements';
import { GridItem1, Heading, Empty, CardContainer, Pagination } from '$lib/components';
import { GridItem1, Heading, Empty, CardContainer, Pagination, Limit } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
import CreateProject from './createProject.svelte';
@@ -95,7 +95,7 @@
</Empty>
{/if}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.projects.total}</p>
<Limit limit={data.limit} sum={data.projects.total} name="Projects" />
<Pagination limit={data.limit} offset={data.offset} sum={data.projects.total} />
</div>
</Container>
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? CARD_LIMIT);
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -2,7 +2,7 @@
import { invalidate } from '$app/navigation';
import { page } from '$app/stores';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { AvatarInitials, Heading, Pagination } from '$lib/components';
import { AvatarInitials, Heading, Limit, Pagination } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
@@ -111,7 +111,7 @@
</TableBody>
</TableScroll>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.organizationMembers.total}</p>
<Limit limit={data.limit} sum={data.members.total} name="Members" />
<Pagination offset={data.offset} limit={data.limit} sum={data.members.total} />
</div>
{/if}
@@ -1,12 +1,12 @@
import { PAGE_LIMIT } from '$lib/constants';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@aw-labs/appwrite-console';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url, params }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ url, params, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -6,7 +6,8 @@
Pagination,
Copy,
SearchQuery,
AvatarInitials
AvatarInitials,
Limit
} from '$lib/components';
import { Button } from '$lib/elements/forms';
import {
@@ -31,9 +32,9 @@
let showCreate = false;
const projectId = $page.params.project;
const userCreated = async (event: CustomEvent<Models.User<Record<string, unknown>>>) => {
async function userCreated(event: CustomEvent<Models.User<Record<string, unknown>>>) {
await goto(`${base}/console/project-${projectId}/auth/user-${event.detail.$id}`);
};
}
</script>
<Container>
@@ -110,7 +111,7 @@
</TableBody>
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.users.total}</p>
<Limit limit={data.limit} sum={data.users.total} name="Users" />
<Pagination offset={data.offset} limit={data.limit} sum={data.users.total} />
</div>
{:else if data.search}
@@ -1,14 +1,14 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const search = getSearch(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
const search = url.searchParams.get('search') ?? undefined;
return {
offset,
@@ -10,7 +10,14 @@
TableCell
} from '$lib/elements/table';
import { Button } from '$lib/elements/forms';
import { Empty, EmptySearch, AvatarInitials, Pagination, SearchQuery } from '$lib/components';
import {
Empty,
EmptySearch,
AvatarInitials,
Pagination,
SearchQuery,
Limit
} from '$lib/components';
import Create from '../createTeam.svelte';
import { goto } from '$app/navigation';
import { toLocaleDateTime } from '$lib/helpers/date';
@@ -62,7 +69,7 @@
</TableBody>
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.teams.total}</p>
<Limit limit={data.limit} sum={data.teams.total} name="Teams" />
<Pagination limit={data.limit} offset={data.offset} sum={data.teams.total} />
</div>
{:else if data.search}
@@ -1,14 +1,14 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const search = getSearch(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
const search = url.searchParams.get('search') ?? undefined;
return {
offset,
@@ -5,4 +5,4 @@
export let data: PageData;
</script>
<Activity logs={data.logs} offset={data.offset} />
<Activity {...data} />
@@ -1,16 +1,17 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
offset,
limit,
logs: await sdk.forProject.teams.listLogs(params.team, [
Query.limit(limit),
Query.offset(offset)
@@ -1,6 +1,13 @@
<script lang="ts">
import { page } from '$app/stores';
import { Empty, EmptySearch, AvatarInitials, Pagination, SearchQuery } from '$lib/components';
import {
Empty,
EmptySearch,
AvatarInitials,
Pagination,
SearchQuery,
Limit
} from '$lib/components';
import {
Table,
TableHeader,
@@ -81,7 +88,7 @@
</TableBody>
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.memberships.total}</p>
<Limit limit={data.limit} sum={data.memberships.total} name="Memberships" />
<Pagination limit={data.limit} offset={data.offset} sum={data.memberships.total} />
</div>
{:else if data.search}
@@ -1,16 +1,16 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, depends, url }) => {
export const load: PageLoad = async ({ params, depends, url, route }) => {
depends(Dependencies.MEMBERSHIPS);
const teamId = params.team;
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
const page = getPage(url);
const search = getSearch(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
const search = url.searchParams.get('search') ?? undefined;
return {
offset,
@@ -1,14 +1,13 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
offset,
limit,
@@ -2,7 +2,15 @@
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 {
Empty,
Copy,
GridItem1,
CardContainer,
Heading,
Pagination,
Limit
} from '$lib/components';
import { Pill } from '$lib/elements';
import { Container } from '$lib/layout';
import { base } from '$app/paths';
@@ -51,7 +59,7 @@
</CardContainer>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.databases.total}</p>
<Limit limit={data.limit} sum={data.databases.total} name="Databases" />
<Pagination limit={data.limit} offset={data.offset} sum={data.databases.total} />
</div>
{:else}
@@ -1,12 +1,12 @@
import { CARD_LIMIT } from '$lib/constants';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@aw-labs/appwrite-console';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? CARD_LIMIT);
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -1,7 +1,15 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { CardContainer, Copy, Empty, GridItem1, Heading, Pagination } from '$lib/components';
import {
CardContainer,
Copy,
Empty,
GridItem1,
Heading,
Limit,
Pagination
} from '$lib/components';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
import { Container } from '$lib/layout';
@@ -54,6 +62,7 @@
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.collections.total}</p>
<Limit limit={data.limit} sum={data.collections.total} name="Collections" />
<Pagination limit={data.limit} offset={data.offset} sum={data.collections.total} />
</div>
{:else}
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? CARD_LIMIT);
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -7,7 +7,7 @@
TableCellHead,
TableCell
} from '$lib/elements/table';
import { Empty, Copy, Heading, Pagination } from '$lib/components';
import { Empty, Copy, Heading, Pagination, Limit } from '$lib/components';
import { Pill } from '$lib/elements';
import { Container } from '$lib/layout';
import { Button } from '$lib/elements/forms';
@@ -125,7 +125,7 @@
</TableScroll>
<div class="u-flex common-section u-main-space-between">
<p class="text">Total results: {data.documents.total}</p>
<Limit limit={data.limit} sum={data.documents.total} name="Documents" />
<Pagination limit={data.limit} offset={data.offset} sum={data.documents.total} />
</div>
{:else}
@@ -1,13 +1,13 @@
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { sdk } from '$lib/stores/sdk';
import { Query } from '@aw-labs/appwrite-console';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, depends, url }) => {
export const load: PageLoad = async ({ params, depends, url, route }) => {
depends(Dependencies.DOCUMENTS);
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -5,4 +5,4 @@
export let data: PageData;
</script>
<Activity logs={data.logs} offset={data.offset} />
<Activity {...data} />
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -5,4 +5,4 @@
export let data: PageData;
</script>
<Activity logs={data.logs} offset={data.offset} />
<Activity {...data} />
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
export const load: PageLoad = async ({ params, url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -2,7 +2,7 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { showCreate } from '../store';
import type { PageData } from './[[page]]/$types';
import type { PageData } from './$types';
$: data = $page.data as PageData;
$: project = $page.params.project;
@@ -1,7 +1,15 @@
<script lang="ts">
import { page } from '$app/stores';
import { Button } from '$lib/elements/forms';
import { Empty, CardContainer, Copy, GridItem1, Heading, Pagination } from '$lib/components';
import {
Empty,
CardContainer,
Copy,
GridItem1,
Heading,
Pagination,
Limit
} from '$lib/components';
import { Pill } from '$lib/elements';
import { Container } from '$lib/layout';
import { base } from '$app/paths';
@@ -81,7 +89,7 @@
</svelte:fragment>
</CardContainer>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.functions.total}</p>
<Limit limit={data.limit} sum={data.functions.total} name="Functions" />
<Pagination limit={data.limit} offset={data.offset} sum={data.functions.total} />
</div>
{:else}
@@ -1,13 +1,13 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT, Dependencies } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url, depends }) => {
export const load: PageLoad = async ({ url, depends, route }) => {
depends(Dependencies.FUNCTIONS);
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? CARD_LIMIT);
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -9,7 +9,8 @@
Empty,
Status,
Heading,
Pagination
Pagination,
Limit
} from '$lib/components';
import {
TableHeader,
@@ -278,12 +279,10 @@
href="https://appwrite.io/docs/functions#createFunction"
on:click={() => (showCreate = true)} />
{/if}
{@const sum = data.deployments.total ? data.deployments.total - 1 : 0}
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.deployments.total ? data.deployments.total - 1 : 0}</p>
<Pagination
limit={data.limit}
offset={data.offset}
sum={data.deployments.total ? data.deployments.total - 1 : 0} />
<Limit limit={data.limit} {sum} name="Deployments" />
<Pagination limit={data.limit} offset={data.offset} {sum} />
</div>
</Container>
@@ -1,13 +1,13 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, depends, url }) => {
export const load: PageLoad = async ({ params, depends, url, route }) => {
depends(Dependencies.DEPLOYMENTS);
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -1,6 +1,6 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { Copy, EmptySearch, Heading, Pagination, Status } from '$lib/components';
import { Copy, EmptySearch, Heading, Limit, Pagination, Status } from '$lib/components';
import { Dependencies } from '$lib/constants';
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
@@ -104,7 +104,7 @@
</TableBody>
</TableScroll>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.executions.total}</p>
<Limit limit={data.limit} sum={data.executions.total} name="Executions" />
<Pagination limit={data.limit} offset={data.offset} sum={data.executions.total} />
</div>
{:else}
@@ -1,13 +1,13 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, depends, url }) => {
export const load: PageLoad = async ({ params, depends, url, route }) => {
depends(Dependencies.EXECUTIONS);
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
const page = getPage(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -2,7 +2,15 @@
import { page } from '$app/stores';
import { goto } from '$app/navigation';
import { Button } from '$lib/elements/forms';
import { Empty, Pagination, Copy, GridItem1, CardContainer, Heading } from '$lib/components';
import {
Empty,
Pagination,
Copy,
GridItem1,
CardContainer,
Heading,
Limit
} from '$lib/components';
import { Pill } from '$lib/elements';
import Create from './create.svelte';
import { Container } from '$lib/layout';
@@ -83,7 +91,7 @@
</CardContainer>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.buckets.total}</p>
<Limit limit={data.limit} sum={data.buckets.total} name="Buckets" />
<Pagination limit={data.limit} offset={data.offset} sum={data.buckets.total} />
</div>
{:else}
@@ -1,12 +1,12 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, pageToOffset } from '$lib/helpers/load';
import { CARD_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ url }) => {
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? CARD_LIMIT);
export const load: PageLoad = async ({ url, route }) => {
const page = getPage(url);
const limit = getLimit(url, route, CARD_LIMIT);
const offset = pageToOffset(page, limit);
return {
@@ -11,7 +11,8 @@
DropList,
DropListItem,
DropListLink,
SearchQuery
SearchQuery,
Limit
} from '$lib/components';
import Create from './create.svelte';
import Delete from './deleteFile.svelte';
@@ -184,7 +185,7 @@
</TableBody>
</Table>
<div class="u-flex u-margin-block-start-32 u-main-space-between">
<p class="text">Total results: {data.files.total}</p>
<Limit limit={data.limit} sum={data.files.total} name="Files" />
<Pagination limit={data.limit} offset={data.offset} sum={data.files.total} />
</div>
{:else if data.search}
@@ -1,15 +1,15 @@
import { Query } from '@aw-labs/appwrite-console';
import { sdk } from '$lib/stores/sdk';
import { pageToOffset } from '$lib/helpers/load';
import { getLimit, getPage, getSearch, pageToOffset } from '$lib/helpers/load';
import { Dependencies, PAGE_LIMIT } from '$lib/constants';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, depends, url }) => {
export const load: PageLoad = async ({ params, depends, url, route }) => {
depends(Dependencies.FILES);
const page = Number(url.searchParams.get('page'));
const limit = Number(url.searchParams.get('limit') ?? PAGE_LIMIT);
const page = getPage(url);
const search = getSearch(url);
const limit = getLimit(url, route, PAGE_LIMIT);
const offset = pageToOffset(page, limit);
const search = url.searchParams.get('search') ?? undefined;
return {
offset,