WIP: Reworked input module for the terminal front-end
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { config } from '$lib/server/db/schema';
|
||||
import { PASSWD } from '$lib/stores/bash/etc/userData';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import type { Actions, PageServerLoad } from './$types';
|
||||
|
||||
@@ -22,11 +23,16 @@ export const actions = {
|
||||
} satisfies Actions;
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
return {
|
||||
config: await db
|
||||
.select({ config: config.value })
|
||||
try {
|
||||
const rows = await db
|
||||
.select({ value: config.value })
|
||||
.from(config)
|
||||
.where(eq(config.value, 'maintenance'))
|
||||
.limit(1)
|
||||
};
|
||||
.limit(1);
|
||||
return { config: rows };
|
||||
} catch (err) {
|
||||
console.error('Full error:', err);
|
||||
// Optionally, throw a user-friendly error
|
||||
throw error(500, 'Database query failed');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
let { form, data } = $props();
|
||||
|
||||
const MAINTENANCE = $derived(Boolean(data.config[0]));
|
||||
let username = $state('');
|
||||
|
||||
function welcomeSequence() {
|
||||
//isWelcomeSequence = true;
|
||||
@@ -16,12 +17,16 @@
|
||||
function initializer(formData: FormData) {
|
||||
console.log(formData);
|
||||
|
||||
username = formData.get('username')?.toString() ?? 'foo';
|
||||
|
||||
if (form?.error) return;
|
||||
/* const password = formData.get('password')?.toString();
|
||||
const username = formData.get('username')?.toString();
|
||||
if (!password || !username) throw new Error('password or username is null or undefined');
|
||||
terminalComponent.init(username, password); */
|
||||
}
|
||||
|
||||
console.log(username);
|
||||
</script>
|
||||
|
||||
{#if MAINTENANCE}
|
||||
@@ -37,7 +42,7 @@
|
||||
<Login init={initializer} {form} />
|
||||
</div>
|
||||
<div id="wrapper2" class=" absolute z-4 size-4/5 opacity-0 {form?.success ? 'intro' : ''}">
|
||||
<Terminal></Terminal>
|
||||
<Terminal {username}></Terminal>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user