This commit is contained in:
Hamcha 2024-04-14 00:50:53 +02:00
commit baedd0ea87
Signed by: hamcha
GPG Key ID: 1669C533B8CF6D89
22 changed files with 329 additions and 0 deletions

13
.eslintignore Normal file
View File

@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

31
.eslintrc.cjs Normal file
View File

@ -0,0 +1,31 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

1
.npmrc Normal file
View File

@ -0,0 +1 @@
engine-strict=true

4
.prettierignore Normal file
View File

@ -0,0 +1,4 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

8
.prettierrc Normal file
View File

@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# webman
Web dashboard for staxman! Talks to serverman and do your business with our (sigh) SPA.

36
package.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "webman",
"version": "0.1.0",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.0",
"@sveltejs/kit": "^2.5.5",
"@sveltejs/vite-plugin-svelte": "^3.1.0",
"@types/eslint": "^8.56.9",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.37.0",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.3",
"svelte": "^4.2.14",
"svelte-check": "^3.6.9",
"tslib": "^2.6.2",
"typescript": "^5.4.5",
"vite": "^5.2.8"
},
"type": "module",
"dependencies": {
"@fontsource-variable/inter": "^5.0.17",
"@fontsource/iosevka": "^5.0.7"
}
}

13
src/app.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
declare global {
namespace App {
// interface Error {}
// interface Locals {}
// interface PageData {}
// interface PageState {}
// interface Platform {}
}
}
export {};

12
src/app.html Normal file
View File

@ -0,0 +1,12 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

0
src/lib/index.ts Normal file
View File

5
src/lib/server/api.ts Normal file
View File

@ -0,0 +1,5 @@
import { SERVERMAN_BASE_URL } from '$env/static/private';
export function fetchAPI(input: RequestInfo | URL, init?: RequestInit | undefined) {
return fetch(SERVERMAN_BASE_URL + input, init);
}

40
src/lib/server/system.ts Normal file
View File

@ -0,0 +1,40 @@
import { fetchAPI } from './api';
interface NetworkInterface {
name: string;
received: number;
transmitted: number;
}
interface DiskInfo {
device_name: string;
mount_point: string;
total_space: number;
available_space: number;
}
export interface SystemInfo {
// Node info
name: string;
host_name: string;
os_version: string;
kernel_version: string;
// RAM usage
total_memory: number;
used_memory: number;
total_swap: number;
used_swap: number;
// Multi-elem resources
networks: NetworkInterface[];
disks: DiskInfo[];
// CPU
load_average: [number, number, number];
}
export async function getSystemInfo(): Promise<SystemInfo> {
const res = await fetchAPI('/system-info');
return res.json();
}

24
src/lib/ui/Panel.svelte Normal file
View File

@ -0,0 +1,24 @@
<script lang="ts">
export let title: string | undefined = undefined;
</script>
<section class="panel">
{#if title}
<header>
{title}
</header>
{/if}
<slot />
</section>
<style scoped>
.panel {
background-color: var(--neutral-raised);
border-radius: 3px;
padding: var(--padding-normal);
& header {
margin-bottom: var(--padding-normal);
}
}
</style>

60
src/routes/+layout.svelte Normal file
View File

@ -0,0 +1,60 @@
<script>
import '@fontsource-variable/inter';
</script>
<svelte:head>
<title>staxman</title>
</svelte:head>
<main>
<slot />
</main>
<style>
:global(:root) {
/* Radix color: Iris */
--parpol-dark: #13131e;
--parpol-raised: #171625;
--parpol-text: #e0dffe;
/* Radix color: Mauve */
--neutral-dark: #121113;
--neutral-raised: #1a191b;
--neutral-text: #eeeef0;
--text-bright: #f9eaff;
--text-accent: #e796f3;
--table-border-color: #625f69;
--table-border: 3px solid var(--table-border-color);
--table-bg: #232225;
--link: #ffc53d;
--link-hover: #e28d0e;
--button-color: #b1a9ff;
--button-bg: #202248;
--button-border: #5b5bd6;
--button-bg-hover: #7e451d;
--success-bright: #46a758;
--success-bg: #113b29;
--success-text: #3dd68c;
--danger-bright: #e5484d;
--danger-bg: #500f1c;
--danger-text: #ff9592;
--font-monospace: 'Iosevka', monospace;
--font-sans: 'Inter Variable', sans-serif;
--padding-narrow: 0.25rem;
--padding-normal: 0.5rem;
--padding-wide: 1rem;
background-color: var(--neutral-dark);
color: var(--neutral-text);
font-family: var(--font-sans);
scrollbar-width: thin;
}
</style>

View File

@ -0,0 +1,8 @@
import { getSystemInfo } from '$lib/server/system';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params }) => {
return {
systemInfo: await getSystemInfo()
};
};

8
src/routes/+page.svelte Normal file
View File

@ -0,0 +1,8 @@
<script lang="ts">
import type { PageData } from './$types';
import HardwareInfo from './HardwareInfo.svelte';
export let data: PageData;
</script>
<HardwareInfo data={data.systemInfo} />

View File

@ -0,0 +1,15 @@
<script lang="ts">
import type { SystemInfo } from '$lib/server/system';
import Panel from '$lib/ui/Panel.svelte';
export let data: SystemInfo;
</script>
<Panel title="Hardware Info">
{data.host_name}
</Panel>
<style>
.hardware-info {
}
</style>

BIN
static/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

13
svelte.config.js Normal file
View File

@ -0,0 +1,13 @@
import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter()
}
};
export default config;

19
tsconfig.json Normal file
View File

@ -0,0 +1,19 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
// except $lib which is handled by https://kit.svelte.dev/docs/configuration#files
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

6
vite.config.ts Normal file
View File

@ -0,0 +1,6 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()]
});