mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 19:25:56 +00:00
Phase 1/2: Tauri shell, React UI (welcome, read-only import, overview with start/stop), e2e driver
Verified in the native window against a disposable fixture: import writes only <folder>.manager + registry; start surfaces a human 'database update required' message; stop returns to Offline. Live install untouched throughout. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bbf06793ba
commit
2e8803a067
50 files changed
+7331
-9
No files matched your search
@@ -0,0 +1,93 @@
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
|
||||
export type Classification = "healthy" | "partial" | "unknown-custom" | "incompatible";
|
||||
export type ItemStatus = "found" | "missing" | "attention";
|
||||
|
||||
export interface ScanItem {
|
||||
key: string;
|
||||
label: string;
|
||||
status: ItemStatus;
|
||||
detail: string | null;
|
||||
}
|
||||
|
||||
export interface ExeInfo {
|
||||
size: number;
|
||||
sha256: string;
|
||||
matches_release: boolean | null;
|
||||
}
|
||||
|
||||
export interface ScanReport {
|
||||
path: string;
|
||||
classification: Classification;
|
||||
items: ScanItem[];
|
||||
worldserver: ExeInfo | null;
|
||||
authserver: ExeInfo | null;
|
||||
banner_revision: string | null;
|
||||
bot_config_keys: number;
|
||||
client: { path: string; executable: string } | null;
|
||||
notes: string[];
|
||||
modifies_files: boolean;
|
||||
}
|
||||
|
||||
export type ServiceState = "stopped" | "starting" | "running" | "stopping" | "crashed" | "updating" | "unknown";
|
||||
|
||||
export interface ServiceStatus {
|
||||
name: string;
|
||||
state: ServiceState;
|
||||
pid: number | null;
|
||||
port: number;
|
||||
port_ready: boolean;
|
||||
conflict: { port: number; pid: number; exe: string | null } | null;
|
||||
uptime_secs: number | null;
|
||||
}
|
||||
|
||||
export interface StatusView {
|
||||
observed: { mysql: ServiceStatus; auth: ServiceStatus; world: ServiceStatus };
|
||||
busy: boolean;
|
||||
path_exists: boolean;
|
||||
}
|
||||
|
||||
export interface Human {
|
||||
code: string;
|
||||
title: string;
|
||||
message: string;
|
||||
actions: string[];
|
||||
}
|
||||
|
||||
export interface DriverOutcome {
|
||||
ok: boolean;
|
||||
exit_code: number | null;
|
||||
code: string | null;
|
||||
human: Human | null;
|
||||
output: string;
|
||||
}
|
||||
|
||||
export interface ServerSummary {
|
||||
id: string;
|
||||
name: string;
|
||||
path: string;
|
||||
}
|
||||
|
||||
export interface UiError {
|
||||
human: Human;
|
||||
technical: string;
|
||||
}
|
||||
|
||||
export const api = {
|
||||
defaultInstallDir: () => invoke<string>("default_install_dir"),
|
||||
scan: (path: string) => invoke<ScanReport>("scan_server", { path }),
|
||||
add: (path: string) => invoke<ServerSummary>("add_server", { path }),
|
||||
list: () => invoke<ServerSummary[]>("list_servers"),
|
||||
forget: (id: string) => invoke<void>("forget_server", { id }),
|
||||
status: (id: string) => invoke<StatusView>("server_status", { id }),
|
||||
start: (id: string) => invoke<DriverOutcome>("start_server", { id }),
|
||||
stop: (id: string) => invoke<DriverOutcome>("stop_server", { id }),
|
||||
};
|
||||
|
||||
export function asUiError(e: unknown): UiError {
|
||||
if (e && typeof e === "object" && "human" in e) return e as UiError;
|
||||
return {
|
||||
human: { code: "unknown", title: "Something went wrong", message: "See the technical details.", actions: ["show_details"] },
|
||||
technical: String(e),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import { clsx, type ClassValue } from "clsx";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs));
|
||||
}
|
||||
|
||||
export function formatUptime(secs: number | null | undefined): string {
|
||||
if (secs == null) return "—";
|
||||
const d = Math.floor(secs / 86400);
|
||||
const h = Math.floor((secs % 86400) / 3600);
|
||||
const m = Math.floor((secs % 3600) / 60);
|
||||
if (d > 0) return `${d}d ${h}h`;
|
||||
if (h > 0) return `${h}h ${m}m`;
|
||||
return `${m}m ${secs % 60}s`;
|
||||
}
|
||||
Reference in new issue
Block a user