feat: configs

This commit is contained in:
2026-04-06 20:28:03 +02:00
parent 2994735f3b
commit d8abe311cd
4 changed files with 72 additions and 9 deletions

View File

@@ -226,13 +226,23 @@ export async function saveEnv(content: string): Promise<void> {
// Config (Reticulum + NomadNet)
// ---------------------------------------------------------------------------
export async function fetchConfig(kind: "reticulum" | "nomadnet"): Promise<string> {
export interface NodeIdentity {
name: string;
hash: string | null;
}
export async function fetchIdentity(): Promise<NodeIdentity> {
const res = await fetch("/api/browse/identity");
return json(res);
}
export async function fetchConfig(kind: "reticulum" | "reticulum-client" | "nomadnet"): Promise<string> {
const res = await fetch(`/api/browse/config/${kind}`);
const data = await json<{ content: string }>(res);
return data.content;
}
export async function saveConfig(kind: "reticulum" | "nomadnet", content: string): Promise<void> {
export async function saveConfig(kind: "reticulum" | "reticulum-client" | "nomadnet", content: string): Promise<void> {
const res = await fetch(`/api/browse/config/${kind}`, {
method: "POST",
headers: { "Content-Type": "application/json" },

View File

@@ -16,7 +16,7 @@ import type { ManagedWindow } from "@/hooks/useWindowManager";
const iniExtensions = iniHighlight();
type ConfigKind = "reticulum" | "nomadnet";
type ConfigKind = "reticulum" | "reticulum-client" | "nomadnet";
interface ConfigWinData {
kind: ConfigKind;
@@ -28,8 +28,13 @@ export default function SettingsView() {
open, update, close, focus,
} = useWindowManager<ConfigWinData>({ w: 560, h: 440 });
const [identity, setIdentity] = useState<{ name: string; hash: string | null } | null>(null);
const [restarting, setRestarting] = useState(false);
useEffect(() => {
api.fetchIdentity().then(setIdentity).catch(() => {});
}, []);
const handleRestart = useCallback(async () => {
setRestarting(true);
try {
@@ -48,6 +53,16 @@ export default function SettingsView() {
return (
<div className="flex flex-col items-center justify-center h-full gap-4">
{identity && (
<div className="flex flex-col gap-1.5 text-center">
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Identity</h2>
<span className="text-sm font-medium">{identity.name}</span>
{identity.hash && (
<span className="text-[11px] font-mono text-muted-foreground select-all">{identity.hash}</span>
)}
</div>
)}
<div className="flex flex-col gap-3 text-center">
<h2 className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">Configuration</h2>
<div className="flex gap-3">
@@ -55,7 +70,13 @@ export default function SettingsView() {
variant="outline"
onClick={() => open("reticulum", { kind: "reticulum" })}
>
Reticulum
Reticulum Server
</Button>
<Button
variant="outline"
onClick={() => open("reticulum-client", { kind: "reticulum-client" })}
>
Reticulum Client
</Button>
<Button
variant="outline"
@@ -92,7 +113,8 @@ export default function SettingsView() {
// ---------------------------------------------------------------------------
const TITLES: Record<ConfigKind, string> = {
reticulum: "Reticulum Config",
reticulum: "Reticulum Server",
"reticulum-client": "Reticulum Client",
nomadnet: "NomadNet Config",
};