mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
fix: functions loading
This commit is contained in:
1 parent
729ed59098
commit
6e03fd28c0
9 files changed
+130
-127
No files matched your search
@@ -17,9 +17,6 @@
|
||||
export let hasInstallations = false;
|
||||
export let action: 'button' | 'select' = 'select';
|
||||
|
||||
let offset = 0;
|
||||
const limit = 5;
|
||||
|
||||
$: {
|
||||
hasInstallations = $installations?.total > 0;
|
||||
}
|
||||
@@ -74,8 +71,24 @@
|
||||
|
||||
{#if hasInstallations}
|
||||
{#await loadInstallations()}
|
||||
<div class="u-flex u-gap-8 u-cross-center u-main-center">
|
||||
<div class="loader u-margin-32" />
|
||||
<div class="u-flex u-gap-16">
|
||||
<div class="u-width-full-line">
|
||||
<InputSelect
|
||||
disabled
|
||||
id="installation"
|
||||
label="Select installation"
|
||||
showLabel={false}
|
||||
options={[
|
||||
{
|
||||
label: 'Loading...',
|
||||
value: null
|
||||
}
|
||||
]}
|
||||
value={null} />
|
||||
</div>
|
||||
<div class="u-width-full-line">
|
||||
<InputSearch placeholder="Search repositories" disabled />
|
||||
</div>
|
||||
</div>
|
||||
{:then installations}
|
||||
<div class="u-flex u-gap-16">
|
||||
@@ -103,86 +116,75 @@
|
||||
</div>
|
||||
</div>
|
||||
{/await}
|
||||
|
||||
<p class="text common-section">
|
||||
Manage organization configuration in your <a
|
||||
class="link"
|
||||
href={`${base}/console/project-${$page.params.project}/settings`}>project settings</a
|
||||
>.
|
||||
</p>
|
||||
{#if selectedInstallation}
|
||||
<p class="text common-section">
|
||||
Manage organization configuration in your <a
|
||||
class="link"
|
||||
href={`${base}/console/project-${$page.params.project}/settings`}
|
||||
>project settings</a
|
||||
>.
|
||||
</p>
|
||||
{#await loadRepositories(selectedInstallation, search)}
|
||||
<div class="card-git card is-border-dashed is-no-shadow common-section">
|
||||
<div class="u-flex u-gap-8 u-cross-center u-main-center">
|
||||
<div class="loader u-margin-16" />
|
||||
Loading repositories...
|
||||
</div>
|
||||
<div class="u-flex u-gap-8 u-cross-center u-main-center">
|
||||
<div class="loader u-margin-32" />
|
||||
</div>
|
||||
{:then response}
|
||||
{#if response?.length}
|
||||
<ul class="table is-remove-outer-styles common-section">
|
||||
{#each response as repo, i}
|
||||
{#if i < offset + limit && i > offset - limit}
|
||||
<li class="table-row">
|
||||
<div class="table-col">
|
||||
{#each response as repo}
|
||||
<li class="table-row">
|
||||
<div class="table-col">
|
||||
<div
|
||||
class="u-flex u-cross-center u-gap-8"
|
||||
style="margin-block: .75rem;">
|
||||
{#if action === 'select'}
|
||||
<input
|
||||
class="is-small u-margin-inline-end-8"
|
||||
type="radio"
|
||||
name="repositories"
|
||||
bind:group={selectedRepository}
|
||||
on:change={() => repository.set(repo)}
|
||||
value={repo.id} />
|
||||
{/if}
|
||||
<div
|
||||
class="u-flex u-cross-center u-gap-8"
|
||||
style="margin-block: .75rem;">
|
||||
{#if action === 'select'}
|
||||
<input
|
||||
class="is-small u-margin-inline-end-8"
|
||||
type="radio"
|
||||
name="repositories"
|
||||
bind:group={selectedRepository}
|
||||
on:change={() => repository.set(repo)}
|
||||
value={repo.id} />
|
||||
{/if}
|
||||
<div
|
||||
class="avatar is-size-x-small"
|
||||
style:--p-text-size="1.25rem"
|
||||
class:is-color-empty={!repo.runtime}>
|
||||
{#if repo.runtime}
|
||||
<img
|
||||
src={`${base}/icons/${$app.themeInUse}/color/${
|
||||
repo.runtime.split('-')[0]
|
||||
}.svg`}
|
||||
alt={repo.name} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="u-flex u-gap-8">
|
||||
<span class="text u-trim-1">{repo.name}</span>
|
||||
{#if repo.private}
|
||||
<span
|
||||
class="icon-lock-closed"
|
||||
style="font-size: var(--icon-size-small)"
|
||||
aria-hidden="true" />
|
||||
{/if}
|
||||
<time
|
||||
class="u-color-text-gray u-trim-1"
|
||||
datetime={repo.pushedAt}>
|
||||
{timeFromNow(repo.pushedAt)}
|
||||
</time>
|
||||
</div>
|
||||
{#if action === 'button'}
|
||||
<div class="u-margin-inline-start-auto">
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => dispatch('connect', repo)}>
|
||||
Connect
|
||||
</Button>
|
||||
</div>
|
||||
class="avatar is-size-x-small"
|
||||
style:--p-text-size="1.25rem"
|
||||
class:is-color-empty={!repo.runtime}>
|
||||
{#if repo.runtime}
|
||||
<img
|
||||
src={`${base}/icons/${$app.themeInUse}/color/${
|
||||
repo.runtime.split('-')[0]
|
||||
}.svg`}
|
||||
alt={repo.name} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="u-flex u-gap-8">
|
||||
<span class="text u-trim-1">{repo.name}</span>
|
||||
{#if repo.private}
|
||||
<span
|
||||
class="icon-lock-closed"
|
||||
style="font-size: var(--icon-size-small)"
|
||||
aria-hidden="true" />
|
||||
{/if}
|
||||
<time
|
||||
class="u-color-text-gray u-trim-1"
|
||||
datetime={repo.pushedAt}>
|
||||
{timeFromNow(repo.pushedAt)}
|
||||
</time>
|
||||
</div>
|
||||
{#if action === 'button'}
|
||||
<div class="u-margin-inline-start-auto">
|
||||
<Button
|
||||
secondary
|
||||
on:click={() => dispatch('connect', repo)}>
|
||||
Connect
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</li>
|
||||
{/if}
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
<!-- <div class="u-flex u-margin-block-start-32 u-main-space-between">
|
||||
<p class="text">Total results: {response?.length}</p>
|
||||
<PaginationInline {limit} bind:offset sum={response?.length} />
|
||||
</div> -->
|
||||
{:else if search}
|
||||
<EmptySearch hidePages>
|
||||
<div class="common-section">
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
import WizardCover from '$lib/layout/wizardCover.svelte';
|
||||
import { app } from '$lib/stores/app';
|
||||
import { wizard } from '$lib/stores/wizard';
|
||||
import { repository, templateConfig, template as templateStore } from './store';
|
||||
import { repository, runtimes, templateConfig, template as templateStore } from './store';
|
||||
import { marketplace, type MarketplaceTemplate } from '$lib/stores/marketplace';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import type { Models } from '@appwrite.io/console';
|
||||
import Repositories from './components/repositories.svelte';
|
||||
import CreateManual from './createManual.svelte';
|
||||
@@ -52,11 +51,6 @@
|
||||
repository.set(event.detail);
|
||||
wizard.start(CreateGit);
|
||||
}
|
||||
|
||||
async function loadRuntimes() {
|
||||
let runtimes = await sdk.forProject.functions.listRuntimes();
|
||||
return runtimes.runtimes;
|
||||
}
|
||||
</script>
|
||||
|
||||
<WizardCover>
|
||||
@@ -64,7 +58,7 @@
|
||||
<div class="wizard-container container">
|
||||
<div class="grid-1-1 u-gap-24">
|
||||
<div>
|
||||
<div class="card u-cross-child-start">
|
||||
<div class="card u-cross-child-start u-height-100-percent">
|
||||
<Heading size="6" tag="h2">Connect Git repository</Heading>
|
||||
<p class="u-margin-block-start-8">
|
||||
Create and deploy a function with a connected git repository.
|
||||
@@ -81,36 +75,34 @@
|
||||
on:connect={connect} />
|
||||
</div>
|
||||
</div>
|
||||
<p class="u-margin-block-start-16">
|
||||
You can also create a function <button
|
||||
class="link"
|
||||
on:click={() => wizard.start(CreateManual)}>manually</button>
|
||||
or using the CLI.
|
||||
<a
|
||||
href="https://appwrite.io/docs/functions-deploy"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">Learn more</a
|
||||
>.
|
||||
</p>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card u-height-100-percent">
|
||||
<section class="common-section">
|
||||
<h2 class="heading-level-6">Quick start</h2>
|
||||
<p class="u-margin-block-start-8">
|
||||
Use a starter templates to begin with the basics.
|
||||
</p>
|
||||
|
||||
{#await loadRuntimes()}
|
||||
<div class="avatar is-size-x-small">
|
||||
<div class="loader u-margin-16" />
|
||||
</div>
|
||||
{:then runtimes}
|
||||
<ul
|
||||
class="grid-box u-margin-block-start-16"
|
||||
style:--grid-item-size="8rem"
|
||||
style:--grid-item-size-small-screens="9rem"
|
||||
style:--grid-gap="1rem">
|
||||
<ul
|
||||
class="grid-box u-margin-block-start-16"
|
||||
style:--grid-item-size="8rem"
|
||||
style:--grid-item-size-small-screens="9rem"
|
||||
style:--grid-gap="1rem">
|
||||
{#await $runtimes}
|
||||
{#each Array(6) as _i}
|
||||
<li>
|
||||
<button
|
||||
disabled
|
||||
class="box u-width-full-line u-flex u-cross-center u-main-center"
|
||||
style:--box-padding="1rem"
|
||||
style:--box-border-radius="var(--border-radius-small)">
|
||||
<div class="avatar is-size-small">
|
||||
<div class="loader u-margin-16" />
|
||||
</div>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
{:then response}
|
||||
{@const runtimes = response.runtimes}
|
||||
{#each quickStart.runtimes.filter((_template, index) => index < 6) as runtime}
|
||||
{@const runtimeDetail = runtimes.find(
|
||||
(r) => r.$id === runtime.name
|
||||
@@ -150,8 +142,8 @@
|
||||
</Box>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
{/await}
|
||||
{/await}
|
||||
</ul>
|
||||
</section>
|
||||
<div class="u-sep-block-start common-section" />
|
||||
<section class="common-section">
|
||||
@@ -183,12 +175,24 @@
|
||||
</section>
|
||||
<Button
|
||||
text
|
||||
class="u-margin-inline-start-auto u-margin-block-start-16"
|
||||
class="u-margin-inline-start-auto u-margin-block-start-32"
|
||||
href={`${base}/console/project-${$page.params.project}/functions/templates`}>
|
||||
<span> All templates </span>
|
||||
<span class="icon-cheveron-right" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<p class="u-margin-block-start-16">
|
||||
You can also create a function <button
|
||||
class="link"
|
||||
on:click={() => wizard.start(CreateManual)}>manually</button>
|
||||
or using the CLI.
|
||||
<a
|
||||
href="https://appwrite.io/docs/functions-deploy"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
class="link">Learn more</a
|
||||
>.
|
||||
</p>
|
||||
</div>
|
||||
</WizardCover>
|
||||
@@ -3,17 +3,15 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, InputSelect, FormList } from '$lib/elements/forms';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { createFunction } from '../store';
|
||||
import { createFunction, runtimes } from '../store';
|
||||
|
||||
let showCustomId = false;
|
||||
|
||||
let options = [];
|
||||
|
||||
onMount(async () => {
|
||||
let runtimes = await sdk.forProject.functions.listRuntimes();
|
||||
options = runtimes.runtimes.map((runtime) => ({
|
||||
options = (await $runtimes).runtimes.map((runtime) => ({
|
||||
label: `${runtime.name} - ${runtime.version}`,
|
||||
value: runtime.$id
|
||||
}));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import { onMount } from 'svelte';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import Label from '$lib/elements/forms/label.svelte';
|
||||
import { choices, createFunction, installation, repository } from '../store';
|
||||
import { choices, createFunction, installation, repository, runtimes } from '../store';
|
||||
|
||||
let showCustomId = false;
|
||||
|
||||
@@ -29,8 +29,7 @@
|
||||
let options = [];
|
||||
|
||||
onMount(async () => {
|
||||
let runtimes = await sdk.forProject.functions.listRuntimes();
|
||||
options = runtimes.runtimes.map((runtime) => ({
|
||||
options = (await $runtimes).runtimes.map((runtime) => ({
|
||||
label: `${runtime.name} - ${runtime.version}`,
|
||||
value: runtime.$id
|
||||
}));
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { FormList, InputSelect, InputText } from '$lib/elements/forms';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { template, templateConfig } from '../store';
|
||||
import { runtimes, template, templateConfig } from '../store';
|
||||
|
||||
let showCustomId = false;
|
||||
|
||||
@@ -15,8 +14,7 @@
|
||||
}
|
||||
|
||||
async function loadRuntimes() {
|
||||
let runtimes = await sdk.forProject.functions.listRuntimes();
|
||||
const options = runtimes.runtimes
|
||||
const options = (await $runtimes).runtimes
|
||||
.map((runtime) => ({
|
||||
label: `${runtime.name} - ${runtime.version}`,
|
||||
value: runtime.$id
|
||||
|
||||
@@ -33,6 +33,11 @@ export const installations = derived(
|
||||
($page) => $page.data.installations as Models.InstallationList
|
||||
);
|
||||
|
||||
export const runtimes = derived(
|
||||
page,
|
||||
($page) => $page.data.runtimes as Promise<Models.RuntimeList>
|
||||
);
|
||||
|
||||
const initialCreateFunction: Partial<Models.Function> = {
|
||||
$id: null,
|
||||
name: null,
|
||||
|
||||
@@ -11,6 +11,7 @@ export const load: LayoutLoad = async ({ depends }) => {
|
||||
return {
|
||||
header: Header,
|
||||
breadcrumbs: Breadcrumbs,
|
||||
runtimes: sdk.forProject.functions.listRuntimes(),
|
||||
installations: sdk.forProject.vcs.listInstallations([Query.limit(100)])
|
||||
};
|
||||
};
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
onMount(async () => {
|
||||
runtime ??= $func.runtime;
|
||||
|
||||
let runtimes = await sdk.forProject.functions.listRuntimes();
|
||||
let runtimes = await $page.data.runtimes;
|
||||
options = runtimes.runtimes.map((runtime) => ({
|
||||
label: `${runtime.name} - ${runtime.version}`,
|
||||
value: runtime.$id
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
import { Pill } from '$lib/elements';
|
||||
import { InputText, InputSelect, FormList } from '$lib/elements/forms';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { createFunction } from './store';
|
||||
import { runtimes } from '$lib/wizards/functions/store';
|
||||
|
||||
let showCustomId = false;
|
||||
|
||||
let options = [];
|
||||
|
||||
onMount(async () => {
|
||||
let runtimes = await sdk.forProject.functions.listRuntimes();
|
||||
options = runtimes.runtimes.map((runtime) => ({
|
||||
options = (await $runtimes).runtimes.map((runtime) => ({
|
||||
label: `${runtime.name} - ${runtime.version}`,
|
||||
value: runtime.$id
|
||||
}));
|
||||
@@ -22,7 +21,7 @@
|
||||
|
||||
<WizardStep>
|
||||
<svelte:fragment slot="title">Create your function</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">Let’s create a function.</svelte:fragment>
|
||||
<svelte:fragment slot="subtitle">Let's create a function.</svelte:fragment>
|
||||
<FormList>
|
||||
<InputText
|
||||
label="Name"
|
||||
@@ -30,14 +29,12 @@
|
||||
placeholder="Function name"
|
||||
bind:value={$createFunction.name}
|
||||
required />
|
||||
|
||||
<InputText
|
||||
label="Entrypoint"
|
||||
id="entrypoint"
|
||||
placeholder="Entrypoint"
|
||||
bind:value={$createFunction.entrypoint}
|
||||
required />
|
||||
|
||||
<InputSelect
|
||||
label="Runtime"
|
||||
id="runtime"
|
||||
@@ -45,7 +42,6 @@
|
||||
bind:value={$createFunction.runtime}
|
||||
{options}
|
||||
required />
|
||||
|
||||
{#if !showCustomId}
|
||||
<div>
|
||||
<Pill button on:click={() => (showCustomId = !showCustomId)}>
|
||||
|
||||
Reference in new issue
Block a user