mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: database pagination
This commit is contained in:
1 parent
564ae46efc
commit
552cde0482
4 files changed
+24
-11
No files matched your search
@@ -3,21 +3,23 @@ import type { Action } from 'svelte/action';
|
||||
export type AnalyticsActionParam = {
|
||||
name: string;
|
||||
action: string;
|
||||
category?: string;
|
||||
label?: string;
|
||||
parameters?: Record<string, string>;
|
||||
event?: keyof HTMLElementEventMap;
|
||||
};
|
||||
|
||||
export const event: Action<HTMLElement, AnalyticsActionParam> = (node, param) => {
|
||||
export const event: Action<HTMLElement, Partial<AnalyticsActionParam>> = (node, param) => {
|
||||
if (!isTrackingAllowed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
node.addEventListener(param.event ?? 'click', () =>
|
||||
node.addEventListener(param.event ?? 'click', () => {
|
||||
gtag('event', param.name, {
|
||||
...param.parameters,
|
||||
action: param.action
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const isTrackingAllowed = () => {
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { base } from '$app/paths';
|
||||
import { page } from '$app/stores';
|
||||
import { event, type AnalyticsActionParam } from '$lib/actions/analytics';
|
||||
|
||||
$: project = $page.params.project;
|
||||
$: path = `${base}/console/project-${project}`;
|
||||
|
||||
const defaultEventOptions: Partial<AnalyticsActionParam> = {
|
||||
category: 'console/navigation',
|
||||
name: 'click_menu_link',
|
||||
action: 'click'
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="side-nav">
|
||||
@@ -15,7 +22,11 @@
|
||||
<a
|
||||
class="drop-button"
|
||||
class:is-selected={$page.url.pathname.startsWith(`${path}/overview`)}
|
||||
href={path}>
|
||||
href={path}
|
||||
use:event={{
|
||||
...defaultEventOptions,
|
||||
label: 'Home Link'
|
||||
}}>
|
||||
<span class="icon-chart-bar" aria-hidden="true" />
|
||||
<span class="text">Overview</span>
|
||||
</a>
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent }) => {
|
||||
await parent();
|
||||
const page = Number(params.page);
|
||||
const offset = pageToOffset(page, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, CARD_LIMIT);
|
||||
|
||||
return {
|
||||
offset,
|
||||
databases: await sdkForProject.databases.list([
|
||||
Query.limit(PAGE_LIMIT),
|
||||
Query.limit(CARD_LIMIT),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc('$createdAt')
|
||||
])
|
||||
|
||||
+3
-3
@@ -1,18 +1,18 @@
|
||||
import { Query } from '@aw-labs/appwrite-console';
|
||||
import { sdkForProject } from '$lib/stores/sdk';
|
||||
import { pageToOffset } from '$lib/helpers/load';
|
||||
import { PAGE_LIMIT } from '$lib/constants';
|
||||
import { CARD_LIMIT } from '$lib/constants';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ params, parent }) => {
|
||||
await parent();
|
||||
const page = Number(params.page);
|
||||
const offset = pageToOffset(page, PAGE_LIMIT);
|
||||
const offset = pageToOffset(page, CARD_LIMIT);
|
||||
|
||||
return {
|
||||
offset,
|
||||
collections: await sdkForProject.databases.listCollections(params.database, [
|
||||
Query.limit(PAGE_LIMIT),
|
||||
Query.limit(CARD_LIMIT),
|
||||
Query.offset(offset),
|
||||
Query.orderDesc('$createdAt')
|
||||
])
|
||||
|
||||
Reference in new issue
Block a user