WIP: Reworked input module for the terminal front-end

This commit is contained in:
2026-06-23 06:05:58 +02:00
parent 8682de7d17
commit 8cb42f07a2
6 changed files with 107 additions and 50 deletions
+11 -5
View File
@@ -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');
}
};
+6 -1
View File
@@ -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}