diff --git a/src/routes/(console)/project-[project]/functions/templates/+page.svelte b/src/routes/(console)/project-[project]/functions/templates/+page.svelte index 35331afdb..ddabd6ca5 100644 --- a/src/routes/(console)/project-[project]/functions/templates/+page.svelte +++ b/src/routes/(console)/project-[project]/functions/templates/+page.svelte @@ -2,7 +2,7 @@ import { goto } from '$app/navigation'; import { base } from '$app/paths'; import { page } from '$app/stores'; - import { EmptyFilter, EmptySearch, SearchQuery, SvgIcon } from '$lib/components'; + import { EmptyFilter, EmptySearch, Paginator, SearchQuery, SvgIcon } from '$lib/components'; import { Button } from '$lib/elements/forms'; import { Container, ContainerButton } from '$lib/layout'; import { isServiceLimited } from '$lib/stores/billing'; @@ -23,7 +23,6 @@ import Card from '$lib/components/card.svelte'; import Link from '$lib/elements/link.svelte'; import Avatar from '$lib/components/avatar.svelte'; - import PaginationWithLimit from '$lib/components/paginationWithLimit.svelte'; import { getIconFromRuntime } from '$lib/stores/runtimes'; export let data; @@ -140,86 +139,88 @@ - {#if data.templates.length > 0} - - {#each data.templates as template} - {@const baseRuntimes = getBaseRuntimes(template.runtimes)} - {@const displayed = baseRuntimes.slice(0, 2)} - {@const hidden = baseRuntimes.slice(1, -1)} - - - - - {template.name} - + {#if data.templates?.length > 0} + + + {#each paginatedItems as template} + {@const baseRuntimes = getBaseRuntimes(template.runtimes)} + {@const displayed = baseRuntimes.slice(0, 2)} + {@const hidden = baseRuntimes.slice(1, -1)} + + + + + {template.name} + - - {template.tagline} - - + + {template.tagline} + + - - - {#each displayed as runtime} - {@const icon = getIconFromRuntime(runtime.name)} - {#if icon} - - - - {/if} - {/each} - {#if hidden.length} - - - - +{hidden.length} - - - - {hidden.map((n) => n.name).join(', ')} - - - {/if} - - - {#if $canWriteFunctions} - - {/if} + justifyContent="space-between" + alignItems="center"> + + {#each displayed as runtime} + {@const icon = getIconFromRuntime(runtime.name)} + {#if icon} + + + + {/if} + {/each} + {#if hidden.length} + + + + +{hidden.length} + + + + {hidden.map((n) => n.name).join(', ')} + + + {/if} + + + + {#if $canWriteFunctions} + + {/if} + - - - {/each} - - + + {/each} + + {:else if data?.search} diff --git a/src/routes/(console)/project-[project]/functions/templates/+page.ts b/src/routes/(console)/project-[project]/functions/templates/+page.ts index 21601046f..a38841be5 100644 --- a/src/routes/(console)/project-[project]/functions/templates/+page.ts +++ b/src/routes/(console)/project-[project]/functions/templates/+page.ts @@ -6,11 +6,7 @@ import type { PageLoad } from './$types'; export const load: PageLoad = async ({ url, route, depends, parent }) => { depends(Dependencies.FUNCTIONS); - const limit = getLimit(url, route, PAGE_LIMIT); - const page = getPage(url); const search = getSearch(url); - const view = getView(url, route, View.Grid); - const offset = pageToOffset(page, limit); const filter = { useCases: url.searchParams.getAll('useCase'), runtimes: url.searchParams.getAll('runtime') @@ -51,15 +47,11 @@ export const load: PageLoad = async ({ url, route, depends, parent }) => { }); return { - offset, - limit, - view, filter, runtimes, useCases, search, - sum: templates.length, - templates: templates.splice(((page === 0 ? 1 : page) - 1) * limit, limit), + templates, functions: await sdk.forProject.functions.list() }; };