fix: populate possible f2 servers

I figured out how to handle Objects in Svelte each blocks and can
therefore now pass the data through.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
André Jaenisch 2024-03-13 18:51:37 +01:00
parent fc2bb247e7
commit e00e274873
No known key found for this signature in database
GPG key ID: 5A668E771F1ED854
5 changed files with 44 additions and 18 deletions

View file

@ -14,6 +14,13 @@ You should have received a copy of the GNU Affero General Public License along w
<script lang="ts"> <script lang="ts">
import { _ } from 'svelte-i18n'; import { _ } from 'svelte-i18n';
/**
* PageData provided by SvelteKit.
*/
export let data: unknown = {
servers: {}
};
/** /**
* Form handling by SvelteKit * Form handling by SvelteKit
*/ */
@ -24,11 +31,6 @@ You should have received a copy of the GNU Affero General Public License along w
*/ */
export let i18n: null; export let i18n: null;
/**
* Available servers for signin
*/
export let servers: Array = [];
/** /**
* Allow for linking stories in Storybook. * Allow for linking stories in Storybook.
*/ */
@ -45,9 +47,9 @@ You should have received a copy of the GNU Affero General Public License along w
<label class="label"> <label class="label">
<span>{$_(i18n.fields.server.label)}</span> <span>{$_(i18n.fields.server.label)}</span>
<select class="select" name="server"> <select class="select" name="server">
<option value="1">fig.fr33domlover.site</option> {#each Object.entries(data.servers) as [value, label]}
<option value="2">grape.fr33domlover.site</option> <option {value}>{label}</option>
<option value="3">walnut.fr33domlover.site</option> {/each}
</select> </select>
</label> </label>
<label class="label"> <label class="label">

View file

@ -14,10 +14,17 @@ You should have received a copy of the GNU Affero General Public License along w
<script lang="ts"> <script lang="ts">
import LoginTemplate from '../templates/Login.svelte'; import LoginTemplate from '../templates/Login.svelte';
/**
* PageData provided by SvelteKit.
*/
export let data: unknown = {
servers: {}
};
/** /**
* Form handling by SvelteKit * Form handling by SvelteKit
*/ */
export let form: unknown = null; export let form: unknown = null;
</script> </script>
<LoginTemplate {form} /> <LoginTemplate {data} {form} />

View file

@ -16,10 +16,19 @@ You should have received a copy of the GNU Affero General Public License along w
import LoginForm from '../organisms/LoginForm.svelte'; import LoginForm from '../organisms/LoginForm.svelte';
/**
* PageData provided by SvelteKit.
*/
export let data: unknown = {
servers: {}
};
/** /**
* Form handling by SvelteKit * Form handling by SvelteKit
*/ */
export let form: unknown = null; export let form: unknown = {
servers: {}
};
/** /**
* Translation keys to enable reuse * Translation keys to enable reuse
@ -49,18 +58,12 @@ You should have received a copy of the GNU Affero General Public License along w
* Allow for linking stories in Storybook. * Allow for linking stories in Storybook.
*/ */
export let sb = ''; export let sb = '';
const servers = {
'1': 'fig.fr33domlover.site',
'2': 'grape.fr33domlover.site',
'3': 'walnut.fr33domlover.site'
};
</script> </script>
<div class="w-full max-w-md h-full mx-auto flex justify-center items-center py-10"> <div class="w-full max-w-md h-full mx-auto flex justify-center items-center py-10">
<div class="space-y-10"> <div class="space-y-10">
<h1 class="h1 font-bold">{$_('page.login.heading')}</h1> <h1 class="h1 font-bold">{$_('page.login.heading')}</h1>
<p>{$_('page.login.intro')}</p> <p>{$_('page.login.intro')}</p>
<LoginForm {form} {i18n} {sb} {servers} /> <LoginForm {data} {form} {i18n} {sb} />
</div> </div>
</div> </div>

View file

@ -45,3 +45,14 @@ export const actions = {
redirect(303, '/profile'); redirect(303, '/profile');
} }
}; };
/** @type {import('./$types').PageServerLoad} */
export async function load({ params }) {
return {
servers: {
1: 'fig.fr33domlover.site',
2: 'grape.fr33domlover.site',
3: 'walnut.fr33domlover.site'
}
};
}

View file

@ -8,8 +8,11 @@ SPDX-License-Identifier: AGPL-3.0-or-later
<script> <script>
import Login from '$lib/components/pages/Login.svelte'; import Login from '$lib/components/pages/Login.svelte';
/** @type {import('./types').PageData} */
export let data;
/** @type {import('./$types').ActionData} */ /** @type {import('./$types').ActionData} */
export let form; export let form;
</script> </script>
<Login {form} /> <Login {data} {form} />