mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-22 11:25:56 +00:00
Phase 8: game client integration (read-only detection, backed-up realmlist change, isolated addon install, START & PLAY)
Verified in the native UI with a stub client: realmlist pointed and backed up, addon installed without touching other addons, START & PLAY starts the server, waits for ready, then launches the client. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7b1942e6a1
commit
d85050ff95
8 files changed
+505
-2
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { api, asUiError, type Human, type Population, type ServerSummary, type ServiceStatus, type StatusView } from "@/lib/api";
|
||||
import { api, asUiError, type ClientInfo, type Human, type Population, type ServerSummary, type ServiceStatus, type StatusView } from "@/lib/api";
|
||||
import { cn, formatUptime } from "@/lib/utils";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
@@ -37,6 +37,8 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
|
||||
const [failure, setFailure] = useState<Failure | null>(null);
|
||||
const [showDetails, setShowDetails] = useState(false);
|
||||
const [pop, setPop] = useState<Population | null>(null);
|
||||
const [client, setClient] = useState<ClientInfo | null>(null);
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const alive = useRef(true);
|
||||
|
||||
const poll = useCallback(async () => {
|
||||
@@ -54,6 +56,7 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
|
||||
|
||||
useEffect(() => {
|
||||
alive.current = true;
|
||||
void api.clientInfo(server.id).then(setClient).catch(() => setClient(null));
|
||||
void poll();
|
||||
const t = setInterval(poll, 2000);
|
||||
return () => {
|
||||
@@ -85,6 +88,22 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
|
||||
}
|
||||
}
|
||||
|
||||
async function play() {
|
||||
setFailure(null);
|
||||
setShowDetails(false);
|
||||
setPlaying(true);
|
||||
try {
|
||||
const out = await api.play(server.id);
|
||||
if (!out.ok) throw { human: out.human, technical: out.output };
|
||||
} catch (e) {
|
||||
const ui = asUiError(e);
|
||||
setFailure({ human: ui.human ?? asUiError(String(e)).human, technical: ui.technical });
|
||||
} finally {
|
||||
setPlaying(false);
|
||||
void poll();
|
||||
}
|
||||
}
|
||||
|
||||
if (!status) return <p className="text-muted">Checking your server…</p>;
|
||||
if (!status.path_exists) {
|
||||
return (
|
||||
@@ -170,6 +189,12 @@ export function Overview({ server, onForget }: { server: ServerSummary; onForget
|
||||
Stop
|
||||
</Button>
|
||||
)}
|
||||
{client && (
|
||||
<Button variant={running ? "primary" : "secondary"} size="xl" disabled={transitioning || playing} onClick={() => void play()} className="ml-auto min-w-40">
|
||||
{playing && <Loader2 className="h-5 w-5 animate-spin" aria-hidden />}
|
||||
{running ? "PLAY" : "START & PLAY"}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{anyUp && !running && !transitioning && (
|
||||
<p className="mt-3 text-sm text-muted">Some parts are running. Press Start to bring up the rest, or Stop to shut everything down.</p>
|
||||
|
||||
Reference in new issue
Block a user