Initial ui

This commit is contained in:
Jack Mechem 2026-03-25 23:33:09 -07:00
parent 526822335e
commit 4bfb87448f
18 changed files with 702 additions and 92 deletions

55
app/lib/getStats.ts Normal file
View file

@ -0,0 +1,55 @@
export interface Memory {
total: number;
used: number;
available: number;
percent: number;
}
export interface Cpu {
percent: number;
model: string;
cores: number;
}
export interface Disk {
total: number;
used: number;
available: number;
percent: number;
}
export interface Uptime {
seconds: number;
days: number;
hours: number;
minutes: number;
}
export interface NetworkInterface {
rx: number;
tx: number;
}
export interface LoadAvg {
"1m": number;
"5m": number;
"15m": number;
}
export interface Stats {
timestamp: string;
memory: Memory;
cpu: Cpu;
disk: Disk;
uptime: Uptime;
network: Record<string, NetworkInterface>;
services: Record<string, string>;
loadAvg: LoadAvg;
temperature: number | null;
}
export async function getStats(): Promise<Stats> {
const res = await fetch("/api/stats");
if (!res.ok) throw new Error(`Failed to fetch stats: ${res.status}`);
return res.json() as Promise<Stats>;
}

16
app/lib/links.ts Normal file
View file

@ -0,0 +1,16 @@
export interface AppLink {
name: string;
description: string;
href: string;
icon: string;
}
// Add new services here
export const LINKS: AppLink[] = [
{
name: "Syncthing",
description: "File synchronization",
href: "https://syncthing.jackmechem.dev",
icon: "⇄",
},
];

15
app/lib/utils.ts Normal file
View file

@ -0,0 +1,15 @@
export function formatBytes(bytes: number): string {
if (bytes > 1e9) return (bytes / 1e9).toFixed(1) + " GB";
if (bytes > 1e6) return (bytes / 1e6).toFixed(1) + " MB";
return (bytes / 1e3).toFixed(1) + " KB";
}
export function statColor(percent: number): string {
if (percent > 80) return "#ef4444";
if (percent > 60) return "#f59e0b";
return "#3b82f6";
}
export function pad(n: number): string {
return String(n).padStart(2, "0");
}