code stable. terminal initializes, database successfully connects, reads and writes. css on maintenance page needs tweaking. terminal still displays before initialization.
This commit is contained in:
+2
-1
@@ -1 +1,2 @@
|
||||
// place files you want to import through the `$lib` alias in this folder.
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { drizzle } from 'drizzle-orm/mysql2';
|
||||
import mysql from 'mysql2/promise';
|
||||
import * as schema from './schema';
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
if (!env.DATABASE_URL) throw new Error('DATABASE_URL is not set');
|
||||
|
||||
const client = mysql.createPool(env.DATABASE_URL);
|
||||
|
||||
export const db = drizzle(client, { schema, mode: 'default', logger: true });
|
||||
@@ -0,0 +1,15 @@
|
||||
import { mysqlTable, serial, int, text, tinyint } from 'drizzle-orm/mysql-core';
|
||||
|
||||
export const task = mysqlTable('task', {
|
||||
id: serial('id').primaryKey(),
|
||||
title: text('title').notNull(),
|
||||
priority: int('priority').notNull().default(1)
|
||||
});
|
||||
|
||||
export const settings = mysqlTable('settings', {
|
||||
var: text('var').notNull().unique(),
|
||||
state: tinyint('state')
|
||||
});
|
||||
|
||||
export type Setting = typeof settings.$inferSelect;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<div class=" w-dvw h-dvh">
|
||||
<div class=" select-none font-primary m-[10%] flex flex-col items-start " id="wrapper">
|
||||
<h1 class=" text-primary-dark font-semibold text-4xl mb-7" id="">Strona w konserwacji</h1>
|
||||
<p class=" text-text-muted-dark text-2xl my-5" id="">Strona jest obecnie w konserwacji. Przepraszam za niedogodność, wkrótce będzie dostępna</p>
|
||||
<p class=" text-text-muted-dark text-2xl self-center mt-16 mb-5" id="">Jeżeli uważasz że jest to błąd, proszę skontaktuj się ze mną
|
||||
<a id="click" class="relative" href="mailto:biznes.olszewski@gmail.com?subject=Website/Portfolio under maintenance">tutaj</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
#click {
|
||||
color: var(--color-primary-dark);
|
||||
pointer-events: all;
|
||||
user-select: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
#click::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
height: 1px;
|
||||
width: calc(100% + 1vw);
|
||||
background: linear-gradient(90deg, var(--color-primary-dark) 75%, transparent 100%);
|
||||
transform: scaleX(0);
|
||||
transform-origin: left;
|
||||
transition: transform 0.1s cubic-bezier(.8,.6,.85,.7);
|
||||
}
|
||||
#click:hover::after {
|
||||
transform: scaleX(1);
|
||||
}
|
||||
</style>
|
||||
@@ -73,13 +73,13 @@
|
||||
<img class="flags mx-2" src={deFlag} alt="DE" height="26" width="26" />
|
||||
</label>
|
||||
<label
|
||||
class="border-primary-dark duration-100 hover:ml-1 hover:pl-1 has-checked:border-l-3 has-checked:hover:m-0 has-checked:hover:p-0 light:border-primary-light"
|
||||
class="border-primary-dark hover:ml-1 hover:pl-1 has-checked:border-l-3 has-checked:hover:m-0 has-checked:hover:p-0 light:border-primary-light"
|
||||
>
|
||||
<input name="langs" type="radio" class="lang hidden" id="en" autocomplete="off" />
|
||||
<img class="flags mx-2" src={jaFlag} alt="JA" height="26" width="26" />
|
||||
</label>
|
||||
<label
|
||||
class="border-primary-dark duration-100 hover:ml-1 hover:pl-1 has-checked:border-l-3 has-checked:hover:m-0 has-checked:hover:p-0 light:border-primary-light"
|
||||
class="border-primary-dark transition-none duration-100 hover:ml-1 hover:pl-1 has-checked:border-l-3 has-checked:hover:m-0 has-checked:hover:p-0 light:border-primary-light"
|
||||
>
|
||||
<input name="langs" type="radio" class="lang hidden" id="en" autocomplete="off" />
|
||||
<img class="flags mx-2" src={frFlag} alt="FR" height="26" width="26" />
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { ChevronRight, Power, SquarePen } from '@lucide/svelte';
|
||||
|
||||
let { projectName, checked = true }: { projectName: string; checked?: boolean } = $props();
|
||||
let { projectName, checked = true }: { projectName: string; checked: boolean } = $props();
|
||||
</script>
|
||||
|
||||
<div
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
class:dark={$theme === 'dark'}
|
||||
class:light={$theme === 'light'}
|
||||
>
|
||||
|
||||
{@render children()}
|
||||
</main>
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { db } from "$lib/server/db";
|
||||
import { settings } from "$lib/server/db/schema";
|
||||
import { PASSWD } from "$lib/stores/bash/etc/userData";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { Actions } from "./$types";
|
||||
import type { PageServerLoad } from "./panel/projects/$types";
|
||||
|
||||
export const actions = {
|
||||
login: async ({request}) => {
|
||||
@@ -16,4 +20,11 @@ export const actions = {
|
||||
|
||||
return { error, success, data: out };
|
||||
}
|
||||
} satisfies Actions
|
||||
} satisfies Actions
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
return {
|
||||
settings: await db.select({setting: settings.state}).from(settings).where(eq(settings.var, 'maintenance')).limit(1)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
+20
-9
@@ -5,9 +5,15 @@
|
||||
import { mount } from 'svelte';
|
||||
import Terminal from '../modules/Terminal.svelte';
|
||||
import { CircleAlert } from '@lucide/svelte';
|
||||
import Maintenence from '../modules/Maintenence.svelte';
|
||||
|
||||
let { form, data } = $props();
|
||||
|
||||
const MAINTENANCE = $state(Boolean(data.settings[0].setting));
|
||||
|
||||
let { form } = $props();
|
||||
//export let isWelcomeSequence = false;
|
||||
|
||||
// svelte-ignore non_reactive_update
|
||||
let terminalComponent: Terminal;
|
||||
|
||||
function welcomeSequence() {
|
||||
@@ -24,15 +30,20 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<Settings></Settings>
|
||||
<div id="main" class="h-dvh w-full p-24 relative flex justify-center items-center">
|
||||
<div id="wrapper1" class=" absolute z-5 flex flex-col items-center {form?.success ? 'outro' : ''}">
|
||||
<Login init={initializer} form={form}/>
|
||||
{#if MAINTENANCE}
|
||||
<Settings></Settings>
|
||||
<Maintenence />
|
||||
{:else}
|
||||
<Settings></Settings>
|
||||
<div id="main" class="h-dvh w-full p-24 relative flex justify-center items-center">
|
||||
<div id="wrapper1" class=" absolute z-5 flex flex-col items-center {form?.success ? 'outro' : ''}">
|
||||
<Login init={initializer} form={form}/>
|
||||
</div>
|
||||
<div id="wrapper2" class=" size-4/5 absolute z-4 {form?.success ? 'intro' : ''}">
|
||||
<Terminal bind:this={terminalComponent} />
|
||||
</div>
|
||||
</div>
|
||||
<div id="wrapper2" class=" size-4/5 absolute z-4 {form?.success ? 'intro' : ''}">
|
||||
<Terminal bind:this={terminalComponent} />
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.outro {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import '../../app.css';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import type { Snippet } from 'svelte';
|
||||
import { BookA, ChartLine, ChartNoAxesColumn, FolderArchive, Plus } from '@lucide/svelte';
|
||||
import { getContext, setContext, type Snippet } from 'svelte';
|
||||
import { BookA, ChartLine, ChartNoAxesColumn, Construction, FolderArchive, Plus } from '@lucide/svelte';
|
||||
import SidebarButton from '../../modules/panel/SidebarButton.svelte';
|
||||
let { children, data}: { children: Snippet, data: any } = $props();
|
||||
|
||||
let { children }: { children: Snippet } = $props();
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { db } from "$lib/server/db";
|
||||
import { settings } from "$lib/server/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { PageServerLoad } from "./$types";
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
return {
|
||||
settings: await db.select({setting: settings.state}).from(settings).where(eq(settings.var, 'maintenance')).limit(1)
|
||||
};
|
||||
};
|
||||
@@ -1,7 +1,36 @@
|
||||
<script lang="ts">
|
||||
import { Construction } from '@lucide/svelte';
|
||||
import ProjectModule from '../../../modules/panel/ProjectModule.svelte';
|
||||
import { setMaintenanceState } from '../settings.remote';
|
||||
|
||||
let { data }: { data: any } = $props();
|
||||
|
||||
let maintenance = $state(Boolean(data.settings[0].setting));
|
||||
console.log(maintenance);
|
||||
|
||||
function handleToggle() {
|
||||
console.log(maintenance);
|
||||
maintenance = !maintenance;
|
||||
console.log(maintenance);
|
||||
let result = setMaintenanceState(Number(maintenance) as 1 | 0);
|
||||
console.log(result);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class=" m-10">
|
||||
<ProjectModule projectName="ProjectName" />
|
||||
<ProjectModule projectName="ProjectName" checked={false} />
|
||||
</div>
|
||||
|
||||
<div class=" mt-4">
|
||||
<Construction strokeWidth={1} />
|
||||
<label
|
||||
for='maintenence'
|
||||
class="relative m-2 ml-auto block h-5 w-10 cursor-pointer rounded-full bg-bg-lighter-dark shadow-subtle"
|
||||
>
|
||||
<input type="checkbox" checked={maintenance} onclick={async () => await setMaintenanceState(Number(!maintenance))} id='maintenence' class=" peer sr-only" />
|
||||
<span
|
||||
class=" absolute top-0.5 left-0.5 h-4/5 w-2/5 rounded-full bg-bg-dark peer-checked:left-5.5 peer-checked:bg-primary-dark"
|
||||
>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { query } from "$app/server";
|
||||
import { db } from "$lib/server/db";
|
||||
import { settings } from "$lib/server/db/schema";
|
||||
import { eq } from "drizzle-orm";
|
||||
import z from "zod";
|
||||
|
||||
export const setMaintenanceState = query(z.number(), async (state) => {
|
||||
await db.update(settings)
|
||||
.set({ state })
|
||||
.where(eq(settings.var, 'maintenance'));
|
||||
});
|
||||
Reference in New Issue
Block a user