HUUUGE dump of code, toast system in a svelte module, new reworked tailwing color palette, WIP cms, WIP API and probably much more that i forgot about.
This commit is contained in:
Executable → Regular
+2
-4
@@ -40,7 +40,7 @@
|
||||
</svelte:head>
|
||||
|
||||
<main
|
||||
class="text-text m-auto flex min-h-dvh w-full flex-col items-center justify-center overflow-hidden bg-dots-bg bg-size-[20px_20px]"
|
||||
class="text-text m-auto flex min-h-dvh w-full flex-col items-center justify-center overflow-hidden bg-bg-base"
|
||||
class:dark={$theme === 'dark'}
|
||||
class:light={$theme === 'light'}
|
||||
>
|
||||
@@ -49,8 +49,6 @@
|
||||
|
||||
<style>
|
||||
main {
|
||||
transition:
|
||||
--dots-bg-2 0.2s ease-in,
|
||||
--dots-bg-1 0.2s ease-in;
|
||||
transition: all 0.2s ease-in;
|
||||
}
|
||||
</style>
|
||||
|
||||
+23
-21
@@ -1,30 +1,32 @@
|
||||
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";
|
||||
import { db } from '$lib/server/db';
|
||||
import { config } from '$lib/server/db/schema';
|
||||
import { PASSWD } from '$lib/stores/bash/etc/userData';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import type { Actions, PageServerLoad } from './$types';
|
||||
|
||||
export const actions = {
|
||||
login: async ({request}) => {
|
||||
const user = PASSWD.find((object) => object.username == "gornodox");
|
||||
let data = await request.formData();
|
||||
let out = data.get("password")?.toString();
|
||||
let error = false;
|
||||
let success = true
|
||||
login: async ({ request }) => {
|
||||
const user = PASSWD.find((object) => object.username == 'gornodox');
|
||||
let data = await request.formData();
|
||||
let out = data.get('password')?.toString();
|
||||
let error = false;
|
||||
let success = true;
|
||||
|
||||
if(out != user?.passwd || out == undefined) {
|
||||
error = true;
|
||||
success = false;
|
||||
}
|
||||
if (out != user?.passwd || out == undefined) {
|
||||
error = true;
|
||||
success = false;
|
||||
}
|
||||
|
||||
return { error, success, data: out };
|
||||
}
|
||||
} satisfies Actions
|
||||
return { error, success, data: out };
|
||||
}
|
||||
} satisfies Actions;
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
return {
|
||||
settings: await db.select({setting: settings.state}).from(settings).where(eq(settings.var, 'maintenance')).limit(1)
|
||||
config: await db
|
||||
.select({ config: config.value })
|
||||
.from(config)
|
||||
.where(eq(config.value, 'maintenance'))
|
||||
.limit(1)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
Executable → Regular
+34
-40
@@ -1,35 +1,26 @@
|
||||
<script lang="ts">
|
||||
import Settings from '../modules/Settings.svelte';
|
||||
import { isInitializing } from '$lib/stores/terminal/init.svelte';
|
||||
import Login from '../modules/Login.svelte';
|
||||
import { mount } from 'svelte';
|
||||
import Terminal from '../modules/Terminal.svelte';
|
||||
import { CircleAlert } from '@lucide/svelte';
|
||||
import Maintenence from '../modules/Maintenence.svelte';
|
||||
|
||||
import Settings from '../modules/Settings.svelte';
|
||||
import Terminal from '../modules/Terminal.svelte';
|
||||
|
||||
let { form, data } = $props();
|
||||
|
||||
const MAINTENANCE = $derived(Boolean(data.settings[0].setting));
|
||||
|
||||
//export let isWelcomeSequence = false;
|
||||
|
||||
// svelte-ignore non_reactive_update
|
||||
let terminalComponent: Terminal;
|
||||
const MAINTENANCE = $derived(Boolean(data.config[0]));
|
||||
|
||||
function welcomeSequence() {
|
||||
//isWelcomeSequence = true;
|
||||
|
||||
//TODO: do magic :)
|
||||
}
|
||||
|
||||
function initializer(formData: FormData) {
|
||||
console.log(formData);
|
||||
|
||||
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)
|
||||
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); */
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -38,36 +29,39 @@
|
||||
<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-35 flex flex-col items-center {form?.success ? 'outro' : ''}">
|
||||
<Login init={initializer} form={form}/>
|
||||
<div id="main" class="relative flex h-dvh w-full items-center justify-center p-24">
|
||||
<div
|
||||
id="wrapper1"
|
||||
class=" absolute z-35 flex flex-col items-center {form?.success ? 'outro' : ''}"
|
||||
>
|
||||
<Login init={initializer} {form} />
|
||||
</div>
|
||||
<div id="wrapper2" class=" opacity-0 size-4/5 absolute z-4 {form?.success ? 'intro' : ''}">
|
||||
<Terminal bind:this={terminalComponent} />
|
||||
<div id="wrapper2" class=" absolute z-4 size-4/5 opacity-0 {form?.success ? 'intro' : ''}">
|
||||
<Terminal></Terminal>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.intro {
|
||||
animation: fadeIn 0.5s forwards cubic-bezier(.4,.7,0,.99) 1s;
|
||||
}
|
||||
|
||||
.outro {
|
||||
animation: fadeOut 0.5s forwards cubic-bezier(.4,.7,0,.99) 1s;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
to {
|
||||
opacity: 1;
|
||||
display: block;
|
||||
.intro {
|
||||
animation: fadeIn 0.5s forwards cubic-bezier(0.4, 0.7, 0, 0.99) 1s;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
.outro {
|
||||
animation: fadeOut 0.5s forwards cubic-bezier(0.4, 0.7, 0, 0.99) 1s;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
to {
|
||||
opacity: 1;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeOut {
|
||||
to {
|
||||
opacity: 0;
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import type { Tween } from 'svelte/motion';
|
||||
|
||||
export interface UserData {
|
||||
uid: number;
|
||||
username: string;
|
||||
homeDir: number;
|
||||
homePath: string;
|
||||
gid: number;
|
||||
group: string;
|
||||
accessible: boolean;
|
||||
avatarUrl: string;
|
||||
supplementaryGroups: string[];
|
||||
}
|
||||
|
||||
export interface GroupData {
|
||||
gid: number;
|
||||
groupname: string;
|
||||
members: number[];
|
||||
}
|
||||
|
||||
export interface UserFormData {
|
||||
uid?: number;
|
||||
username: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
homeDir: number;
|
||||
gid: number;
|
||||
supplementaryGroups: number[];
|
||||
accessible: boolean;
|
||||
avatarFile?: File;
|
||||
avatarUrl?: string;
|
||||
}
|
||||
|
||||
export interface GroupFormData {
|
||||
gid: number;
|
||||
groupname: string;
|
||||
members: number[];
|
||||
}
|
||||
|
||||
export interface ToastMessage {
|
||||
id: number;
|
||||
type: 'success' | 'error' | 'info' | 'warn';
|
||||
title: string;
|
||||
message: string;
|
||||
duration: number;
|
||||
tween?: Tween<number>;
|
||||
initial: number;
|
||||
target: number;
|
||||
hideProgress: boolean;
|
||||
hideDismiss: boolean;
|
||||
onClose?: (tm: ToastMessage) => void;
|
||||
onClick?: (tm: ToastMessage) => void;
|
||||
}
|
||||
|
||||
export interface Keybind {
|
||||
action: string;
|
||||
combo: string;
|
||||
handler: () => void;
|
||||
}
|
||||
|
||||
export function capitalize(word: string): string {
|
||||
if (!word) '';
|
||||
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
||||
}
|
||||
|
||||
export async function request(
|
||||
endpoint: string,
|
||||
options?: {
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
||||
body?: any;
|
||||
headers?: Record<string, string>;
|
||||
}
|
||||
) {
|
||||
const config: RequestInit = {
|
||||
method: options?.method || 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...options?.headers
|
||||
}
|
||||
};
|
||||
|
||||
if (options?.body) {
|
||||
config.body = JSON.stringify(options.body);
|
||||
}
|
||||
|
||||
const response = await fetch(`/api/v1/${endpoint}`, config);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Request failed: ${response.status} ${errorText}`);
|
||||
}
|
||||
|
||||
const text = await response.text();
|
||||
return text ? JSON.parse(text) : null;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { config } from '$lib/server/db/schema';
|
||||
|
||||
export async function GET() {
|
||||
const rows = await db.select().from(config);
|
||||
const result: Record<string, string> = {};
|
||||
for (const row of rows) {
|
||||
result[row.key] = row.value;
|
||||
}
|
||||
return new Response(JSON.stringify(result), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
|
||||
export async function POST({ request, getClientAddress }) {
|
||||
const body = await request.json();
|
||||
for (const [key, value] of Object.entries(body)) {
|
||||
await db
|
||||
.insert(config)
|
||||
.values({ key, value: String(value) })
|
||||
.onDuplicateKeyUpdate({ set: { value: String(value) } });
|
||||
}
|
||||
return new Response(JSON.stringify({ success: true }), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { fileContents } from '$lib/server/db/schema';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function GET(event: RequestEvent): Promise<Response> {
|
||||
if (event.params.guid === undefined)
|
||||
return new Response(`Bad request - no guid specified`, { status: 400 });
|
||||
|
||||
const row = await db
|
||||
.select()
|
||||
.from(fileContents)
|
||||
.where(eq(fileContents.guid, event.params.guid))
|
||||
.limit(1);
|
||||
if (!row.length) {
|
||||
return new Response(`File not found`, { status: 404 });
|
||||
}
|
||||
|
||||
return new Response(new Uint8Array(row[0].data), {
|
||||
headers: {
|
||||
'Content-Type': row[0].mimeType || 'application/octet-stream',
|
||||
'Cache-Control': 'public, max-age=86400'
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2,8 +2,9 @@ import { db } from '$lib/server/db';
|
||||
import { filesystem } from '$lib/server/db/schema';
|
||||
import { MD5 } from '$lib/termos/util/hash';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import type { RequestEvent } from './$types';
|
||||
|
||||
export async function GET({ request }): Promise<Response> {
|
||||
export async function GET(event: RequestEvent): Promise<Response> {
|
||||
const row = await db
|
||||
.select({
|
||||
data: filesystem.data,
|
||||
@@ -18,7 +19,7 @@ export async function GET({ request }): Promise<Response> {
|
||||
}
|
||||
|
||||
const { data, checksum } = row[0];
|
||||
const clientETag = request.headers.get('if-none-match');
|
||||
const clientETag = event.request.headers.get('if-none-match');
|
||||
|
||||
if (clientETag === `"${checksum}"`) {
|
||||
return new Response(null, {
|
||||
@@ -37,15 +38,15 @@ export async function GET({ request }): Promise<Response> {
|
||||
});
|
||||
}
|
||||
|
||||
export async function POST({ request }) {
|
||||
const newData = await request.text();
|
||||
export async function POST(event: RequestEvent) {
|
||||
const newData = await event.request.text();
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(newData);
|
||||
JSON.parse(newData);
|
||||
//TODO: Schema validation
|
||||
} catch {
|
||||
//TODO: Change that to a proper http headers error
|
||||
return new Response(null, {
|
||||
return new Response('Invalid JSON', {
|
||||
status: 400
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { groups } from '$lib/server/db/schema';
|
||||
|
||||
export async function GET() {
|
||||
const rows = await db.select().from(groups);
|
||||
|
||||
if (!rows.length) {
|
||||
return new Response('No groups stored on the database', { status: 500 });
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify(rows), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { groups } from '$lib/server/db/schema';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function GET(event: RequestEvent): Promise<Response> {
|
||||
if (event.params.gid === undefined)
|
||||
return new Response(`Bad request - no gid specified`, { status: 400 });
|
||||
|
||||
const row = await db
|
||||
.select()
|
||||
.from(groups)
|
||||
.where(eq(groups.gid, Number(event.params.gid)))
|
||||
.limit(1);
|
||||
if (!row.length) {
|
||||
return new Response(`Group not found`, { status: 404 });
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify(row), {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { users } from '$lib/server/db/schema';
|
||||
import { json } from '@sveltejs/kit';
|
||||
import { json, type RequestEvent } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function GET({ request }): Promise<Response> {
|
||||
export async function GET(): Promise<Response> {
|
||||
const rows = await db
|
||||
.select({
|
||||
uid: users.uid,
|
||||
@@ -15,7 +16,7 @@ export async function GET({ request }): Promise<Response> {
|
||||
.from(users);
|
||||
|
||||
if (!rows.length) {
|
||||
return new Response('Filesystem is not initialized on the database', { status: 500 });
|
||||
return new Response('No users stored on the database', { status: 500 });
|
||||
}
|
||||
|
||||
const result: {}[] = rows.map((u) => ({
|
||||
@@ -25,3 +26,65 @@ export async function GET({ request }): Promise<Response> {
|
||||
|
||||
return json(result);
|
||||
}
|
||||
|
||||
export async function POST(event: RequestEvent) {
|
||||
const formData = await event.request.formData();
|
||||
const uid = formData.get('uid');
|
||||
const username = formData.get('username')?.toString();
|
||||
const password = formData.get('password')?.toString();
|
||||
const home = Number(formData.get('home'));
|
||||
const gid = Number(formData.get('gid'));
|
||||
const accessible = Boolean(formData.get('accessible'));
|
||||
const avatarFile = formData.get('avatar') as File | null;
|
||||
|
||||
if (!username || !password || !home || !gid || accessible === undefined) {
|
||||
return new Response('Missing fields', { status: 400 });
|
||||
}
|
||||
|
||||
let avatarBuffer: Buffer | null = null;
|
||||
if (avatarFile && avatarFile.size > 0) {
|
||||
avatarBuffer = Buffer.from(await avatarFile.arrayBuffer());
|
||||
}
|
||||
|
||||
if (uid) {
|
||||
// Update existing user
|
||||
await db
|
||||
.update(users)
|
||||
.set({
|
||||
username,
|
||||
password,
|
||||
home,
|
||||
gid,
|
||||
...(avatarBuffer && { avatar: avatarBuffer })
|
||||
})
|
||||
.where(eq(users.uid, Number(uid)));
|
||||
} else {
|
||||
// Create new user
|
||||
await db.insert(users).values({
|
||||
gid,
|
||||
username,
|
||||
password,
|
||||
home,
|
||||
accessible,
|
||||
face: avatarBuffer
|
||||
});
|
||||
}
|
||||
|
||||
const targetUid = uid
|
||||
? Number(uid)
|
||||
: (
|
||||
await db
|
||||
.select({ uid: users.uid })
|
||||
.from(users)
|
||||
.where(eq(users.username, username!))
|
||||
.limit(1)
|
||||
)[0]?.uid;
|
||||
|
||||
if (!targetUid) {
|
||||
return new Response('Failed to retrieve user after save', { status: 500 });
|
||||
}
|
||||
|
||||
return new Response(JSON.stringify({ targetUid, success: true }), {
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { db } from '$lib/server/db';
|
||||
import { users } from '$lib/server/db/schema';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function GET({ params, request }): Promise<Response> {
|
||||
export async function GET(event: RequestEvent): Promise<Response> {
|
||||
const row = await db
|
||||
.select({
|
||||
uid: users.uid,
|
||||
@@ -13,7 +14,7 @@ export async function GET({ params, request }): Promise<Response> {
|
||||
accessible: users.accessible
|
||||
})
|
||||
.from(users)
|
||||
.where(eq(users.uid, Number(params.uid)))
|
||||
.where(eq(users.uid, Number(event.params.uid)))
|
||||
.limit(1);
|
||||
|
||||
if (!row.length) {
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
// src/routes/api/users/[uid]/avatar/+server.ts
|
||||
import { db } from '$lib/server/db';
|
||||
import { users } from '$lib/server/db/schema';
|
||||
import type { RequestEvent } from '@sveltejs/kit';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export async function PUT({ params, request }) {
|
||||
const uid = Number(params.uid);
|
||||
const arrayBuffer = await request.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
await db.update(users).set({ face: buffer }).where(eq(users.uid, uid));
|
||||
return new Response(null, { status: 204 });
|
||||
export async function GET(event: RequestEvent) {
|
||||
const row = await db
|
||||
.select({ avatar: users.face })
|
||||
.from(users)
|
||||
.where(eq(users.uid, Number(event.params.uid)))
|
||||
.limit(1);
|
||||
|
||||
if (!row.length || !row[0].avatar) {
|
||||
return new Response('Not found', { status: 404 });
|
||||
}
|
||||
|
||||
const buffer = row[0].avatar;
|
||||
|
||||
return new Response(new Uint8Array(buffer), {
|
||||
headers: {
|
||||
'Content-Type': 'image/png',
|
||||
'Cache-Control': 'public, max-age=3600'
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
+42
-20
@@ -1,49 +1,71 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { BookA, ChartLine, ChartNoAxesColumn, FolderArchive, Plus } from '@lucide/svelte';
|
||||
import { type Snippet } from 'svelte';
|
||||
import { fetchAllData } from '$lib/stores/panel-state.svelte';
|
||||
import { FileSystem } from '$lib/termos/filesystem/filesystem';
|
||||
import {
|
||||
BookA,
|
||||
ChartLine,
|
||||
ChartNoAxesColumn,
|
||||
FolderArchive,
|
||||
Plus,
|
||||
Settings2,
|
||||
UserRoundCog
|
||||
} from '@lucide/svelte';
|
||||
import { onMount, type Snippet } from 'svelte';
|
||||
import '../../app.css';
|
||||
import SidebarButton from '../../modules/panel/SidebarButton.svelte';
|
||||
import ToastsModule from '../../modules/ToastsModule.svelte';
|
||||
import { capitalize } from '../admin/util';
|
||||
let { children, data }: { children: Snippet; data: any } = $props();
|
||||
|
||||
// Get last word of pathname (full url) filter if no empty array indexes exist and capitalize it
|
||||
let site: string = $derived(capitalize(page.url.pathname.split('/').filter(Boolean).pop() ?? ''));
|
||||
|
||||
onMount(async () => {
|
||||
await FileSystem.init();
|
||||
await fetchAllData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<link rel="icon" href={favicon} />
|
||||
</svelte:head>
|
||||
|
||||
<div class="flex h-dvh w-full flex-row text-text-dark light:text-text-light">
|
||||
<div class="flex h-full w-fit flex-col items-center bg-bg-dark light:bg-bg-light">
|
||||
<ToastsModule></ToastsModule>
|
||||
<div class="flex h-dvh w-full flex-row text-text-primary">
|
||||
<div class="flex h-full w-fit flex-col items-center bg-surface-1">
|
||||
<img class="m-3 mb-8" alt="Logo" src={favicon} height="32" width="32" />
|
||||
<form class="flex h-full w-fit flex-col items-center gap-3">
|
||||
<label
|
||||
class="m-0 mb-4 flex size-12 items-center justify-center rounded-xl bg-bg-lighter-dark shadow-subtle hover:text-primary-hover-dark has-checked:text-primary-dark has-checked:hover:text-primary-hover-dark light:bg-bg-light-light light:hover:text-primary-hover-light light:has-checked:text-primary-light light:has-checked:hover:text-primary-hover-light"
|
||||
class="m-0 mb-4 flex size-12 items-center justify-center rounded-xl bg-surface-2 shadow-subtle duration-100 transition-standard hover:text-primary has-checked:text-primary has-checked:hover:text-primary-variant has-active:button-click"
|
||||
>
|
||||
<input name="langs" type="radio" class="hidden" id="pl" autocomplete="off" />
|
||||
<Plus strokeWidth={1} />
|
||||
<Plus strokeWidth={1.25} />
|
||||
</label>
|
||||
<SidebarButton checked path="/panel/projects">
|
||||
<FolderArchive strokeWidth={1} />
|
||||
<!-- prettier-ignore -->
|
||||
<SidebarButton /*checked*/ path="/panel/projects">
|
||||
<FolderArchive strokeWidth={1.25} />
|
||||
</SidebarButton>
|
||||
<SidebarButton path="/panel/users">
|
||||
<UserRoundCog strokeWidth={1.25} />
|
||||
</SidebarButton>
|
||||
<SidebarButton path="/panel/langs">
|
||||
<BookA strokeWidth={1} />
|
||||
<BookA strokeWidth={1.25} />
|
||||
</SidebarButton>
|
||||
<SidebarButton path="/panel/metrics">
|
||||
<ChartLine strokeWidth={1} />
|
||||
<ChartLine strokeWidth={1.25} />
|
||||
</SidebarButton>
|
||||
<SidebarButton path="/panel/stats">
|
||||
<ChartNoAxesColumn strokeWidth={1} />
|
||||
<ChartNoAxesColumn strokeWidth={1.25} />
|
||||
</SidebarButton>
|
||||
<SidebarButton path="/panel/global">
|
||||
<Settings2 strokeWidth={1.25} />
|
||||
</SidebarButton>
|
||||
</form>
|
||||
</div>
|
||||
<div class=" w-full">
|
||||
<div class=" m-8 w-full">
|
||||
<h2 class=" m-8 ml-0 font-primary text-3xl font-black text-primary">{site}</h2>
|
||||
{@render children()}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
main {
|
||||
transition:
|
||||
--dots-bg-2 0.2s ease-in,
|
||||
--dots-bg-1 0.2s ease-in;
|
||||
}
|
||||
</style>
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
@@ -1,25 +1,14 @@
|
||||
import fsData from '$lib/assets/fs/fs.json';
|
||||
import { db } from '$lib/server/db';
|
||||
import { projects, settings } from '$lib/server/db/schema';
|
||||
import { FileSystem } from '$lib/termos/filesystem/filesystem';
|
||||
import { Sort, SortNodeBy } from '$lib/termos/util/sort';
|
||||
import { config, projects } from '$lib/server/db/schema';
|
||||
import { eq } from 'drizzle-orm';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
export const load: PageServerLoad = async () => {
|
||||
FileSystem.Init(fsData as any);
|
||||
|
||||
const fs = FileSystem.instance;
|
||||
|
||||
const node = fs.getNodeByInode(13); //Gordonox home dir
|
||||
let nodes = node.children.map((child) => fs.getNodeByInode(child));
|
||||
nodes = Sort.nodeArraySort(nodes, false, SortNodeBy.NAME);
|
||||
|
||||
return {
|
||||
settings: await db
|
||||
.select({ setting: settings.state })
|
||||
.from(settings)
|
||||
.where(eq(settings.var, 'maintenance'))
|
||||
.select({ value: config.value })
|
||||
.from(config)
|
||||
.where(eq(config.key, 'maintenance'))
|
||||
.limit(1),
|
||||
projects: await db
|
||||
.select({
|
||||
@@ -28,7 +17,6 @@ export const load: PageServerLoad = async () => {
|
||||
data: projects.data,
|
||||
enabled: projects.enabled
|
||||
})
|
||||
.from(projects),
|
||||
nodes: nodes
|
||||
.from(projects)
|
||||
};
|
||||
};
|
||||
|
||||
Executable → Regular
+30
-27
@@ -2,6 +2,7 @@
|
||||
import { Construction, Eye, EyeOff } from '@lucide/svelte';
|
||||
import NodeModule from '../../../modules/panel/NodeModule.svelte';
|
||||
import ProjectModule from '../../../modules/panel/ProjectModule.svelte';
|
||||
import ToggleSwitchModule from '../../../modules/panel/ToggleSwitchModule.svelte';
|
||||
import { setMaintenanceState } from '../settings.remote';
|
||||
|
||||
let { data }: { data: any } = $props();
|
||||
@@ -11,6 +12,10 @@
|
||||
|
||||
console.log(data.projects[0].name);
|
||||
|
||||
function testModule() {
|
||||
console.log('it works!');
|
||||
}
|
||||
|
||||
function handleToggle() {
|
||||
console.log(maintenance);
|
||||
maintenance = !maintenance;
|
||||
@@ -24,6 +29,17 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class=" flex items-start">
|
||||
<ToggleSwitchModule
|
||||
callback={async () => await setMaintenanceState(Number(!maintenance))}
|
||||
id="maintenence"
|
||||
sync={maintenance}
|
||||
>
|
||||
{#snippet icon()}
|
||||
<Construction strokeWidth={1} />
|
||||
{/snippet}
|
||||
</ToggleSwitchModule>
|
||||
</div>
|
||||
<div
|
||||
class=" grid-cols-[1.5fr, 1fr] grid w-full"
|
||||
style="grid-template-areas:
|
||||
@@ -46,33 +62,20 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class=" flex flex-col gap-1">
|
||||
{#each data.nodes as node}
|
||||
{#if showHidden}
|
||||
<NodeModule nodeName={node.name} nodeType={node.type} isProject={false} />
|
||||
{/if}
|
||||
{#if !node.name.startsWith('.') && !showHidden}
|
||||
<NodeModule nodeName={node.name} nodeType={node.type} isProject={false} />
|
||||
{/if}
|
||||
{/each}
|
||||
<form>
|
||||
{#each data.nodes as node}
|
||||
{#if showHidden}
|
||||
<label>
|
||||
<NodeModule nodeName={node.name} nodeType={node.type} isProject={false} />
|
||||
</label>
|
||||
{/if}
|
||||
{#if !node.name.startsWith('.') && !showHidden}
|
||||
<label>
|
||||
<NodeModule nodeName={node.name} nodeType={node.type} isProject={false} />
|
||||
</label>
|
||||
{/if}
|
||||
{/each}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
Executable → Regular
@@ -0,0 +1,54 @@
|
||||
<script lang="ts">
|
||||
import { Plus, Search, SquarePen } from '@lucide/svelte';
|
||||
import Button from '../../../modules/Button.svelte';
|
||||
import UsersTable from '../../../modules/panel/users/UsersTable.svelte';
|
||||
|
||||
function log2() {
|
||||
console.log('test');
|
||||
}
|
||||
|
||||
let searchPrompt = $state();
|
||||
|
||||
$inspect(searchPrompt);
|
||||
|
||||
function log(newValue: any) {
|
||||
console.log(newValue);
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <ContextMenu items={[{ label: 'test123', action: log2 }]} onClose={() => {}}></ContextMenu> -->
|
||||
<div class="mb-4 flex flex-row justify-between">
|
||||
<div
|
||||
class="
|
||||
flex flex-row items-center justify-between
|
||||
overflow-clip rounded-md border border-border
|
||||
bg-surface-1 has-focus:border-focus-ring
|
||||
"
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
class=" w-full px-3 py-2 outline-none placeholder:text-muted"
|
||||
placeholder="Search..."
|
||||
bind:value={searchPrompt}
|
||||
/>
|
||||
<Search strokeWidth={2} size={20} class="mx-3"></Search>
|
||||
</div>
|
||||
<Button class="flex flex-row items-center bg-primary text-text-on-primary">
|
||||
<Plus class="ml-1" size={20}></Plus>
|
||||
<span class="mx-2">Add User</span>
|
||||
</Button>
|
||||
</div>
|
||||
<div style="grid-template-areas: 'a b';" class=" grid-cols-[2fr 1fr] grid size-full shadow-subtle">
|
||||
<div style="grid-area: a;" class=" size-full">
|
||||
<UsersTable></UsersTable>
|
||||
</div>
|
||||
<div style="grid-area: b;" class=" p-4">
|
||||
<div class="bg-bg-dark rounded-2xl">
|
||||
<div class="flex h-full flex-col items-center justify-center">
|
||||
<SquarePen size={128} strokeWidth={1} class="text-gray-800" />
|
||||
<p class="text-2xl font-bold text-gray-800">Nothing here but us chickens...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="w-full"></div>
|
||||
Executable → Regular
+22
-5
@@ -1,10 +1,27 @@
|
||||
<script lang="ts">
|
||||
import { MD5 } from '$lib/termos/util/hash';
|
||||
import { addToast } from '$lib/stores/toasts';
|
||||
import { FileSystem } from '$lib/termos/filesystem/filesystem';
|
||||
import { onMount } from 'svelte';
|
||||
import UsersTable from '../../modules/panel/users/UsersTable.svelte';
|
||||
import Settings from '../../modules/Settings.svelte';
|
||||
import type { ToastMessage } from '../admin/util';
|
||||
|
||||
console.log(MD5.hash(''));
|
||||
console.log(MD5.hash('a'));
|
||||
console.log(MD5.hash('abc'));
|
||||
function bye(tm: ToastMessage): void {
|
||||
console.log('Funkcja wywolana');
|
||||
}
|
||||
|
||||
onMount(() => {});
|
||||
onMount(async () => {
|
||||
await FileSystem.init();
|
||||
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
addToast('success', 'Hi~', '', 5000, undefined, undefined, true, false, bye, bye);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<Settings></Settings>
|
||||
<div class="size-full p-16">
|
||||
<UsersTable></UsersTable>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user