mirror of
https://github.com/Corfirean/coa-server-manager.git
synced 2026-11-18 19:25:56 +00:00
Merge feat/companions-realms: companion bots on Wildcard and Warcraft Reborn
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> # Conflicts: # crates/coa-core/src/ra.rs
This commit is contained in:
commit
326a4fe3d3
12 files changed
+2691
-327
No files matched your search
+36
-6
@@ -361,6 +361,16 @@ export interface CompanionSizes {
|
||||
sizes: { id: string; title: string; bots: number; warning: string | null }[];
|
||||
}
|
||||
|
||||
export interface WildcardArchetypeDto {
|
||||
id: string;
|
||||
name: string;
|
||||
roles: number;
|
||||
primary_stat: number;
|
||||
author: string;
|
||||
difficulty: number;
|
||||
category: number;
|
||||
}
|
||||
|
||||
export interface ClientInfo {
|
||||
path: string;
|
||||
executable: string;
|
||||
@@ -574,15 +584,35 @@ export const api = {
|
||||
invoke<{ txn: UpdateTxn; preexisting_character_count?: number }>("apply_update", { id, source: source ?? null, resolutions }),
|
||||
rollbackUpdate: (id: string, txn: string) => invoke<UpdateTxn>("rollback_update", { id, txn }),
|
||||
retryUpdateValidation: (id: string, txn: string) => invoke<UpdateTxn>("retry_update_validation", { id, txn }),
|
||||
population: (id: string) => invoke<Population | null>("get_population", { id }),
|
||||
stopSpawning: (id: string) => invoke<{ count: number }>("companions_stop_spawning", { id }),
|
||||
takeOffline: (id: string) => invoke<{ count: number }>("companions_take_offline", { id }),
|
||||
despawnSome: (id: string, count: number) => invoke<{ count: number }>("companions_despawn_some", { id, count }),
|
||||
deleteAllCompanions: (id: string) => invoke<{ count: number }>("companions_delete_all", { id }),
|
||||
population: (id: string, realm?: RealmMode) => invoke<Population | null>("get_population", { id, realm: realm ?? null }),
|
||||
stopSpawning: (id: string, realm?: RealmMode) => invoke<{ count: number }>("companions_stop_spawning", { id, realm: realm ?? null }),
|
||||
takeOffline: (id: string, realm?: RealmMode) => invoke<{ count: number }>("companions_take_offline", { id, realm: realm ?? null }),
|
||||
despawnSome: (id: string, count: number, realm?: RealmMode) => invoke<{ count: number }>("companions_despawn_some", { id, count, realm: realm ?? null }),
|
||||
deleteAllCompanions: (id: string, realm?: RealmMode) => invoke<{ count: number }>("companions_delete_all", { id, realm: realm ?? null }),
|
||||
loginAllCompanions: (id: string, realm?: RealmMode) => invoke<string>("companions_login_all", { id, realm: realm ?? null }),
|
||||
spawnBotFleet: (id: string, race: number, level: number, realm?: RealmMode) => invoke<string>("companions_spawn_fleet", { id, race, level, realm: realm ?? null }),
|
||||
openLink: (url: string) => invoke<void>("open_link", { url }),
|
||||
performance: (id: string) => invoke<Performance | null>("get_performance", { id }),
|
||||
companionSizes: () => invoke<CompanionSizes>("companion_sizes"),
|
||||
addCompanions: (id: string, count: number) => invoke<{ spawned: string | null; created: number | null; baseline: number | null }>("add_companions", { id, count }),
|
||||
addCompanions: (
|
||||
id: string,
|
||||
count: number,
|
||||
realm?: RealmMode,
|
||||
level?: number,
|
||||
classId?: number,
|
||||
specId?: number,
|
||||
archetype?: string
|
||||
) =>
|
||||
invoke<{ spawned: string | null; created: number | null; baseline: number | null }>("add_companions", {
|
||||
id,
|
||||
count,
|
||||
realm: realm ?? null,
|
||||
level: level ?? null,
|
||||
class_id: classId ?? null,
|
||||
spec_id: specId ?? null,
|
||||
archetype: archetype ?? null,
|
||||
}),
|
||||
getWildcardArchetypes: (id: string) => invoke<WildcardArchetypeDto[]>("get_wildcard_archetypes", { id }),
|
||||
clientGraphics: (id: string) => invoke<{ dxvk_disabled: boolean; enhancements_disabled: boolean }>("client_graphics", { id }),
|
||||
clientSetGraphics: (id: string, name: string, disabled: boolean) => invoke<{ dxvk_disabled: boolean; enhancements_disabled: boolean }>("client_set_graphics", { id, name, disabled }),
|
||||
clientInfo: (id: string) => invoke<ClientInfo | null>("client_info", { id }),
|
||||
|
||||
+712
-159
@@ -1,30 +1,125 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { api, asUiError, type CompanionSizes, type Population, type UiError } from "@/lib/api";
|
||||
import {
|
||||
Loader2,
|
||||
Bot,
|
||||
CheckCircle2,
|
||||
AlertCircle,
|
||||
RefreshCw,
|
||||
Power,
|
||||
Users,
|
||||
Database,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
api,
|
||||
asUiError,
|
||||
type Population,
|
||||
type RealmMode,
|
||||
type RealmProfiles,
|
||||
type UiError,
|
||||
type WildcardArchetypeDto,
|
||||
} from "@/lib/api";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card } from "@/components/ui/card";
|
||||
import { hasKey, useHuman, useT, type Key } from "@/i18n";
|
||||
import { useHuman, useT } from "@/i18n";
|
||||
|
||||
function formatRole(roles: number): string {
|
||||
const parts: string[] = [];
|
||||
if (roles & 1) parts.push("Tank");
|
||||
if (roles & 2) parts.push("Melee");
|
||||
if (roles & 4) parts.push("Ranged");
|
||||
if (roles & 8) parts.push("Healer");
|
||||
return parts.join("/") || "DPS";
|
||||
}
|
||||
|
||||
function formatStat(stat: number): string {
|
||||
switch (stat) {
|
||||
case 0: return "Strength";
|
||||
case 1: return "Agility";
|
||||
case 2: return "Stamina";
|
||||
case 3: return "Intellect";
|
||||
case 4: return "Spirit";
|
||||
default: return "All";
|
||||
}
|
||||
}
|
||||
|
||||
export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
const t = useT();
|
||||
const human = useHuman();
|
||||
const [sizes, setSizes] = useState<CompanionSizes | null>(null);
|
||||
|
||||
// Realm & Environment state
|
||||
const [profiles, setProfiles] = useState<RealmProfiles | null>(null);
|
||||
const [selectedRealm, setSelectedRealm] = useState<RealmMode>("coa");
|
||||
const [pop, setPop] = useState<Population | null>(null);
|
||||
const [running, setRunning] = useState(false);
|
||||
const [choice, setChoice] = useState<string>("small");
|
||||
const [custom, setCustom] = useState("100");
|
||||
|
||||
// Fleet Configuration state
|
||||
const [spawnMode, setSpawnMode] = useState<"population" | "fleet">("population");
|
||||
const [countChoice, setCountChoice] = useState<string>("50");
|
||||
const [customCount, setCustomCount] = useState<string>("50");
|
||||
const [targetLevel, setTargetLevel] = useState<number>(80);
|
||||
const [selectedClass, setSelectedClass] = useState<string>("all");
|
||||
const [selectedRole, setSelectedRole] = useState<string>("all");
|
||||
const [selectedArchetype, setSelectedArchetype] = useState<string>("all");
|
||||
const [wildcardArchetypes, setWildcardArchetypes] = useState<WildcardArchetypeDto[]>([]);
|
||||
|
||||
// Operational state
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<UiError | null>(null);
|
||||
const [note, setNote] = useState<string | null>(null);
|
||||
// Start-up login: how many existing bots the server brings online by itself every time it starts.
|
||||
const [job, setJob] = useState<{ baseline: number; target: number; since: number } | null>(null);
|
||||
|
||||
// Startup Auto-Login settings
|
||||
const [autoOn, setAutoOn] = useState(true);
|
||||
const [autoMax, setAutoMax] = useState("");
|
||||
// A creation that is still in progress on the running server: how many existed before and how many were asked for.
|
||||
const [job, setJob] = useState<{ baseline: number; target: number; since: number } | null>(null);
|
||||
const [startNote, setStartNote] = useState<string | null>(null);
|
||||
const [startBusy, setStartBusy] = useState(false);
|
||||
const [despawnN, setDespawnN] = useState("10");
|
||||
|
||||
const activeServerRealm = profiles?.active ?? "coa";
|
||||
const isViewingActiveRealm = selectedRealm === activeServerRealm;
|
||||
const isRealmOperational = isViewingActiveRealm || running;
|
||||
|
||||
const maxLevelForRealm = 60;
|
||||
|
||||
// Load realm profiles
|
||||
const loadProfiles = async () => {
|
||||
try {
|
||||
const r = await api.realmProfiles(serverId);
|
||||
setProfiles(r);
|
||||
if (!selectedRealm) {
|
||||
setSelectedRealm(r.active);
|
||||
}
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
void loadProfiles();
|
||||
}, [serverId]);
|
||||
|
||||
// Adjust target level if realm changed
|
||||
useEffect(() => {
|
||||
if (targetLevel > maxLevelForRealm) {
|
||||
setTargetLevel(maxLevelForRealm);
|
||||
}
|
||||
}, [selectedRealm, maxLevelForRealm, targetLevel]);
|
||||
|
||||
// Load wildcard archetypes dynamically from target characters db
|
||||
useEffect(() => {
|
||||
if (selectedRealm === "wildcard") {
|
||||
api.getWildcardArchetypes(serverId)
|
||||
.then((archs) => setWildcardArchetypes(archs))
|
||||
.catch(() => {});
|
||||
if (selectedClass === "all") {
|
||||
setSelectedClass("10");
|
||||
}
|
||||
} else {
|
||||
setSelectedArchetype("all");
|
||||
}
|
||||
}, [serverId, selectedRealm]);
|
||||
|
||||
// Load startup settings
|
||||
useEffect(() => {
|
||||
void api
|
||||
.settings(serverId, "bots")
|
||||
@@ -40,6 +135,46 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
const maxNum = Number(autoMax);
|
||||
const maxValid = autoMax.trim() !== "" && Number.isInteger(maxNum) && maxNum >= 0 && maxNum <= 5000;
|
||||
|
||||
// Polling population
|
||||
const fetchPopulation = async () => {
|
||||
const s = await api.status(serverId).catch(() => null);
|
||||
if (!s) return;
|
||||
const up = s.observed.world.state === "running";
|
||||
setRunning(up);
|
||||
if (up) {
|
||||
const p = await api.population(serverId, selectedRealm).catch(() => null);
|
||||
setPop(p);
|
||||
} else {
|
||||
setPop(null);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
const poll = async () => {
|
||||
if (!alive) return;
|
||||
await fetchPopulation();
|
||||
};
|
||||
void poll();
|
||||
const interval = setInterval(poll, job ? 1500 : 4000);
|
||||
return () => {
|
||||
alive = false;
|
||||
clearInterval(interval);
|
||||
};
|
||||
}, [serverId, selectedRealm, job !== null]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const done = job && pop ? Math.max(0, Math.min(job.target, pop.bots_total - job.baseline)) : 0;
|
||||
useEffect(() => {
|
||||
if (!job) return;
|
||||
if ((pop && done >= job.target) || !running) {
|
||||
if (pop && done >= job.target) setNote(t("comp.progressDone", { n: job.target }));
|
||||
setJob(null);
|
||||
}
|
||||
}, [done, running]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const count = countChoice === "custom" ? Number(customCount) : Number(countChoice);
|
||||
const valid = Number.isInteger(count) && count >= 1 && count <= 2000;
|
||||
|
||||
async function act(fn: () => Promise<string>) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
@@ -52,45 +187,128 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
// Primary action: Spawn bots / fleet
|
||||
const handleSpawn = async () => {
|
||||
if (!valid) return;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNote(null);
|
||||
try {
|
||||
if (spawnMode === "fleet") {
|
||||
const race = 1;
|
||||
const out = await api.spawnBotFleet(serverId, race, targetLevel, selectedRealm);
|
||||
setNote(out || `Spawned level ${targetLevel} fleet`);
|
||||
} else {
|
||||
const classNum = selectedClass !== "all" ? parseInt(selectedClass, 10) : (selectedRealm === "wildcard" ? 10 : undefined);
|
||||
let specNum: number | undefined = undefined;
|
||||
if (selectedRole === "tank") {
|
||||
if (selectedRealm === "reborn") {
|
||||
specNum = (classNum === 7 || classNum === 9 || classNum === 11) ? 4 : (classNum === 2 ? 2 : classNum === 1 ? 3 : 1);
|
||||
} else if (selectedRealm === "wildcard") {
|
||||
specNum = 1;
|
||||
}
|
||||
} else if (selectedRole === "healer") {
|
||||
if (selectedRealm === "reborn") {
|
||||
specNum = (classNum === 2 || classNum === 5) ? 1 : (classNum === 7 || classNum === 11 ? 3 : 1);
|
||||
} else if (selectedRealm === "wildcard") {
|
||||
specNum = 2;
|
||||
}
|
||||
}
|
||||
const archStr = selectedArchetype !== "all" ? selectedArchetype : undefined;
|
||||
const r = await api.addCompanions(serverId, count, selectedRealm, targetLevel, classNum, specNum, archStr);
|
||||
if (r.spawned && r.baseline !== null) {
|
||||
setJob({ baseline: r.baseline, target: count, since: Date.now() });
|
||||
}
|
||||
setNote(
|
||||
r.created
|
||||
? t("comp.offlineDone", { n: r.created })
|
||||
: r.spawned
|
||||
? t("comp.spawned", { n: count })
|
||||
: t("comp.saved", { n: count })
|
||||
);
|
||||
}
|
||||
await fetchPopulation();
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Bring offline bots online
|
||||
const handleLoginAll = () =>
|
||||
act(async () => {
|
||||
const out = await api.loginAllCompanions(serverId, selectedRealm);
|
||||
await fetchPopulation();
|
||||
return out || "All available offline bots queued for login.";
|
||||
});
|
||||
|
||||
// Stop queued creations
|
||||
const stopCreating = () =>
|
||||
act(async () => {
|
||||
const r = await api.stopSpawning(serverId);
|
||||
const r = await api.stopSpawning(serverId, selectedRealm);
|
||||
setJob(null);
|
||||
await fetchPopulation();
|
||||
return t("comp.stopped", { n: r.count });
|
||||
});
|
||||
|
||||
// Take online bots offline
|
||||
const takeOffline = () => {
|
||||
if (!window.confirm(t("comp.offlineConfirm"))) return;
|
||||
void act(async () => {
|
||||
const r = await api.takeOffline(serverId);
|
||||
const r = await api.takeOffline(serverId, selectedRealm);
|
||||
setJob(null);
|
||||
await fetchPopulation();
|
||||
return t("comp.offlineDone2", { n: r.count });
|
||||
});
|
||||
};
|
||||
|
||||
// Despawn batch
|
||||
const dn = Number(despawnN);
|
||||
const dnValid = Number.isInteger(dn) && dn >= 1 && dn <= 5000;
|
||||
const despawnSome = () =>
|
||||
act(async () => {
|
||||
const r = await api.despawnSome(serverId, dn);
|
||||
const r = await api.despawnSome(serverId, dn, selectedRealm);
|
||||
await fetchPopulation();
|
||||
return t("comp.despawnSomeDone", { n: r.count });
|
||||
});
|
||||
|
||||
// Delete all bots in realm
|
||||
const deleteAll = () => {
|
||||
if (!window.confirm(t("comp.deleteConfirm", { n: pop?.bots_total ?? 0 }))) return;
|
||||
void act(async () => {
|
||||
await api.deleteAllCompanions(serverId);
|
||||
await api.deleteAllCompanions(serverId, selectedRealm);
|
||||
setJob(null);
|
||||
await fetchPopulation();
|
||||
return t("comp.deleteDone");
|
||||
});
|
||||
};
|
||||
|
||||
// Switch server realm
|
||||
const switchServerRealm = async (mode: RealmMode) => {
|
||||
if (!window.confirm(`Switch server active realm to ${mode.toUpperCase()} and restart?`)) return;
|
||||
setBusy(true);
|
||||
try {
|
||||
await api.realmSelect(serverId, mode, true);
|
||||
await loadProfiles();
|
||||
setSelectedRealm(mode);
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Save auto startup settings
|
||||
async function saveStart() {
|
||||
setStartBusy(true);
|
||||
setError(null);
|
||||
setStartNote(null);
|
||||
try {
|
||||
await api.save(serverId, "bots", { "CoaBots.AutoLoginOnStartup": autoOn, "CoaBots.AutoLogin.MaxCount": maxNum });
|
||||
await api.save(serverId, "bots", {
|
||||
"CoaBots.AutoLoginOnStartup": autoOn,
|
||||
"CoaBots.AutoLogin.MaxCount": maxNum,
|
||||
});
|
||||
setStartNote(t("comp.startSaved"));
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
@@ -99,181 +317,516 @@ export function CompanionsCard({ serverId }: { serverId: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void api.companionSizes().then(setSizes);
|
||||
let alive = true;
|
||||
const poll = async () => {
|
||||
const s = await api.status(serverId).catch(() => null);
|
||||
if (!alive || !s) return;
|
||||
const up = s.observed.world.state === "running";
|
||||
setRunning(up);
|
||||
setPop(up ? await api.population(serverId).catch(() => null) : null);
|
||||
};
|
||||
void poll();
|
||||
// Faster while companions are being created, so the progress bar moves.
|
||||
const t = setInterval(poll, job ? 1500 : 4000);
|
||||
return () => {
|
||||
alive = false;
|
||||
clearInterval(t);
|
||||
};
|
||||
}, [serverId, job !== null]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
// Database schema name for selected realm
|
||||
const dbSchema =
|
||||
selectedRealm === "coa"
|
||||
? "acore_characters"
|
||||
: selectedRealm === "wildcard"
|
||||
? "acore_characters_wildcard"
|
||||
: "acore_characters_reborn";
|
||||
|
||||
const done = job && pop ? Math.max(0, Math.min(job.target, pop.bots_total - job.baseline)) : 0;
|
||||
useEffect(() => {
|
||||
if (!job) return;
|
||||
// Finished, or the server went away, or nothing new appeared for two minutes.
|
||||
if ((pop && done >= job.target) || !running) {
|
||||
if (pop && done >= job.target) setNote(t("comp.progressDone", { n: job.target }));
|
||||
setJob(null);
|
||||
}
|
||||
}, [done, running]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
// The backend describes a size's warning in English; show the translated text for the two known kinds.
|
||||
const warningFor = (size?: { bots: number; warning: string | null }) => {
|
||||
if (!size?.warning) return null;
|
||||
return size.warning.startsWith(`${size.bots} companions`)
|
||||
? t("comp.warnHardware", { n: size.bots, cores: sizes?.hardware.cores ?? "?", ram: sizes ? sizes.hardware.ram_gb.toFixed(0) : "?" })
|
||||
: t("comp.warnMemory");
|
||||
};
|
||||
const count = choice === "custom" ? Number(custom) : (sizes?.sizes.find((s) => s.id === choice)?.bots ?? 0);
|
||||
const warning = choice === "custom" ? (count > 500 ? t("comp.largeWarning") : null) : (warningFor(sizes?.sizes.find((s) => s.id === choice)));
|
||||
const valid = Number.isInteger(count) && count >= 1 && count <= 2000;
|
||||
|
||||
async function add() {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setNote(null);
|
||||
try {
|
||||
const r = await api.addCompanions(serverId, count);
|
||||
if (r.spawned && r.baseline !== null) setJob({ baseline: r.baseline, target: count, since: Date.now() });
|
||||
setNote(r.created ? t("comp.offlineDone", { n: r.created }) : r.spawned ? t("comp.spawned", { n: count }) : t("comp.saved", { n: count }));
|
||||
} catch (e) {
|
||||
setError(asUiError(e));
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
// Binary compatibility check
|
||||
const isBinaryCompatible =
|
||||
selectedRealm === "coa" ||
|
||||
(selectedRealm === "wildcard" && (profiles?.supported ?? true)) ||
|
||||
(selectedRealm === "reborn" && (profiles?.reborn_supported ?? true));
|
||||
|
||||
return (
|
||||
<Card className="mt-6 p-6">
|
||||
<h2 className="font-semibold">{t("comp.title")}</h2>
|
||||
<p className="mt-1 text-sm text-muted">
|
||||
{pop
|
||||
? t("comp.population", { online: pop.bots_online, total: pop.bots_total })
|
||||
: running
|
||||
? t("comp.reading")
|
||||
: t("comp.startToSee")}
|
||||
</p>
|
||||
|
||||
<fieldset className="mt-4">
|
||||
<legend className="text-sm text-muted">{t("comp.wantMore")}</legend>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{sizes?.sizes.map((s) => (
|
||||
<label key={s.id} className={`cursor-pointer rounded-md border px-3 py-2 text-sm ${choice === s.id ? "border-gold bg-gold/10" : "border-line hover:bg-white/5"}`}>
|
||||
<input type="radio" name="size" className="sr-only" checked={choice === s.id} onChange={() => setChoice(s.id)} />
|
||||
{hasKey(`comp.size.${s.id}`) ? t(`comp.size.${s.id}` as Key) : s.title} <span className="text-muted">· {s.bots}</span>
|
||||
</label>
|
||||
))}
|
||||
<label className={`cursor-pointer rounded-md border px-3 py-2 text-sm ${choice === "custom" ? "border-gold bg-gold/10" : "border-line hover:bg-white/5"}`}>
|
||||
<input type="radio" name="size" className="sr-only" checked={choice === "custom"} onChange={() => setChoice("custom")} />
|
||||
{t("comp.custom")}
|
||||
</label>
|
||||
{choice === "custom" && (
|
||||
<input aria-label={t("comp.numberLabel")} value={custom} onChange={(e) => setCustom(e.target.value)} inputMode="numeric" className="w-24 rounded-md border border-line bg-bg px-3 py-2 text-right text-sm outline-none focus:border-gold" />
|
||||
)}
|
||||
<Card className="mt-6 p-6 space-y-6">
|
||||
{/* Header & Realm Switcher */}
|
||||
<div>
|
||||
<div className="flex flex-wrap items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
<Bot className="h-6 w-6 text-gold" />
|
||||
<h2 className="text-xl font-bold tracking-tight">{t("comp.title")}</h2>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-xs text-muted flex items-center gap-1">
|
||||
<Database className="h-3.5 w-3.5" />
|
||||
DB: <code className="text-gold">{dbSchema}</code>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
{warning && <p className="mt-3 text-sm text-warn" role="status">{warning}</p>}
|
||||
{sizes && <p className="mt-2 text-xs text-muted">{t("comp.hardware", { cores: sizes.hardware.cores, ram: sizes.hardware.ram_gb.toFixed(0) })}</p>}
|
||||
|
||||
<div className="mt-4 flex items-center gap-3">
|
||||
<Button variant="primary" disabled={busy || !valid || job !== null} onClick={() => void add()}>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin" aria-hidden />}
|
||||
{valid ? t("comp.add", { n: count }) : t("comp.addPlain")}
|
||||
</Button>
|
||||
{!running && <span className="text-xs text-muted">{t("comp.stoppedHint")}</span>}
|
||||
{/* Realm Navigation Tabs */}
|
||||
<div className="mt-4 flex flex-wrap gap-2 border-b border-line pb-3">
|
||||
{(["coa", "wildcard", "reborn"] as RealmMode[]).map((mode) => {
|
||||
const isSelected = selectedRealm === mode;
|
||||
const isActive = activeServerRealm === mode;
|
||||
const label =
|
||||
mode === "coa"
|
||||
? "Conquest of Azeroth"
|
||||
: mode === "wildcard"
|
||||
? "Wildcard (Hero)"
|
||||
: "Warcraft Reborn";
|
||||
return (
|
||||
<button
|
||||
key={mode}
|
||||
type="button"
|
||||
onClick={() => setSelectedRealm(mode)}
|
||||
className={`flex items-center gap-2 rounded-lg px-4 py-2 text-sm font-medium transition-colors ${
|
||||
isSelected
|
||||
? "bg-gold/20 text-gold border border-gold/40 shadow-sm"
|
||||
: "border border-line hover:bg-white/5 text-muted hover:text-white"
|
||||
}`}
|
||||
>
|
||||
<span>{label}</span>
|
||||
{isActive && (
|
||||
<span className="rounded bg-ok/20 px-1.5 py-0.5 text-[10px] font-semibold text-ok uppercase">
|
||||
Active Server
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
{busy && !running && count >= 100 && (
|
||||
<div className="mt-3">
|
||||
<p className="text-sm text-muted" role="status">{t("comp.progressOffline", { n: count })}</p>
|
||||
<div className="mt-2 h-2 overflow-hidden rounded-full bg-white/10" role="progressbar" aria-busy="true">
|
||||
<div className="h-full w-full animate-pulse rounded-full bg-gold/70" />
|
||||
|
||||
{/* Binary Compatibility & Realm Mode Warning */}
|
||||
{!isBinaryCompatible && (
|
||||
<div className="rounded-lg border border-bad/40 bg-bad/10 p-4 text-sm text-bad flex items-start gap-3">
|
||||
<AlertCircle className="h-5 w-5 shrink-0 mt-0.5" />
|
||||
<div>
|
||||
<div className="font-semibold">Binary Compatibility Warning</div>
|
||||
<p className="mt-1 text-xs text-bad/90">
|
||||
The currently running server core binary does not have full multi-realm support enabled
|
||||
for <strong>{selectedRealm.toUpperCase()}</strong>. Automated bot features may be restricted.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{job && (
|
||||
<div className="mt-3">
|
||||
<div className="flex justify-between text-sm">
|
||||
<span role="status">{t("comp.progress", { done, target: job.target })}</span>
|
||||
<span className="text-muted">{Math.round((done / job.target) * 100)}%</span>
|
||||
</div>
|
||||
<div className="mt-2 h-2 overflow-hidden rounded-full bg-white/10" role="progressbar" aria-valuenow={done} aria-valuemin={0} aria-valuemax={job.target}>
|
||||
<div className="h-full rounded-full bg-gold transition-[width] duration-500" style={{ width: `${(done / job.target) * 100}%` }} />
|
||||
</div>
|
||||
{done === 0 && Date.now() - job.since > 20000 && <p className="mt-1 text-xs text-muted">{t("comp.progressStalled")}</p>}
|
||||
<Button className="mt-2" size="sm" variant="ghost" disabled={busy} onClick={() => void stopCreating()}>
|
||||
{t("comp.stop")}
|
||||
|
||||
{/* Active Realm Switch Helper */}
|
||||
{!isViewingActiveRealm && (
|
||||
<div className="rounded-lg border border-warn/40 bg-warn/10 p-3 text-sm flex items-center justify-between gap-3">
|
||||
<span className="text-warn text-xs">
|
||||
Viewing <strong>{selectedRealm.toUpperCase()}</strong> bots, but the worldserver is currently running in{" "}
|
||||
<strong>{activeServerRealm.toUpperCase()}</strong> mode.
|
||||
</span>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
disabled={busy}
|
||||
onClick={() => void switchServerRealm(selectedRealm)}
|
||||
>
|
||||
Switch Server to {selectedRealm.toUpperCase()}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{note && !job && <p className="mt-3 text-sm text-ok" role="status">{note}</p>}
|
||||
|
||||
{running && pop && pop.bots_total > 0 && (
|
||||
<div className="mt-5 border-t border-line pt-4">
|
||||
<h3 className="text-sm font-semibold">{t("comp.manageTitle")}</h3>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-2 text-sm">
|
||||
<label htmlFor="despawn-n" className="text-muted">{t("comp.despawnCount")}</label>
|
||||
{/* Realm Population Dashboard */}
|
||||
<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
||||
<div className="rounded-lg border border-line bg-bg/50 p-3">
|
||||
<div className="text-xs text-muted flex items-center gap-1.5">
|
||||
<Bot className="h-3.5 w-3.5 text-gold" />
|
||||
Bots Online
|
||||
</div>
|
||||
<div className="mt-1 text-2xl font-bold text-white">
|
||||
{running && pop ? pop.bots_online : "—"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-line bg-bg/50 p-3">
|
||||
<div className="text-xs text-muted flex items-center gap-1.5">
|
||||
<Users className="h-3.5 w-3.5 text-gold" />
|
||||
Total Fleet
|
||||
</div>
|
||||
<div className="mt-1 text-2xl font-bold text-white">
|
||||
{pop ? pop.bots_total : "—"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-line bg-bg/50 p-3">
|
||||
<div className="text-xs text-muted flex items-center gap-1.5">
|
||||
<CheckCircle2 className="h-3.5 w-3.5 text-ok" />
|
||||
Players Online
|
||||
</div>
|
||||
<div className="mt-1 text-2xl font-bold text-white">
|
||||
{running && pop ? pop.players_online : "—"}
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-lg border border-line bg-bg/50 p-3 flex flex-col justify-between">
|
||||
<div className="text-xs text-muted flex items-center justify-between">
|
||||
<span>Status</span>
|
||||
<button
|
||||
onClick={() => void fetchPopulation()}
|
||||
title="Refresh"
|
||||
className="text-muted hover:text-white"
|
||||
>
|
||||
<RefreshCw className="h-3 w-3" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="text-sm font-medium">
|
||||
{running ? (
|
||||
<span className="text-ok flex items-center gap-1">
|
||||
<span className="h-2 w-2 rounded-full bg-ok animate-pulse" /> Running
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-muted">Offline</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Fleet Configuration & Spawning Section */}
|
||||
<div className="border-t border-line pt-5 space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<h3 className="font-semibold text-sm tracking-wide uppercase text-muted">
|
||||
Fleet Deployment Controls
|
||||
</h3>
|
||||
<div className="flex rounded-md border border-line p-0.5 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSpawnMode("population")}
|
||||
className={`px-2.5 py-1 rounded transition-colors ${
|
||||
spawnMode === "population" ? "bg-gold/20 text-gold font-medium" : "text-muted hover:text-white"
|
||||
}`}
|
||||
>
|
||||
Batch Population
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSpawnMode("fleet")}
|
||||
className={`px-2.5 py-1 rounded transition-colors ${
|
||||
spawnMode === "fleet" ? "bg-gold/20 text-gold font-medium" : "text-muted hover:text-white"
|
||||
}`}
|
||||
>
|
||||
Synchronous Fleet
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Count Selector */}
|
||||
{spawnMode === "population" && (
|
||||
<div>
|
||||
<label className="text-xs text-muted">Fleet Size (Number of Bots)</label>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{["10", "25", "50", "100", "250", "500"].map((n) => (
|
||||
<button
|
||||
key={n}
|
||||
type="button"
|
||||
onClick={() => setCountChoice(n)}
|
||||
className={`rounded-md border px-3 py-1.5 text-sm transition-colors ${
|
||||
countChoice === n
|
||||
? "border-gold bg-gold/15 text-gold font-medium"
|
||||
: "border-line hover:bg-white/5 text-muted"
|
||||
}`}
|
||||
>
|
||||
{n}
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setCountChoice("custom")}
|
||||
className={`rounded-md border px-3 py-1.5 text-sm transition-colors ${
|
||||
countChoice === "custom"
|
||||
? "border-gold bg-gold/15 text-gold font-medium"
|
||||
: "border-line hover:bg-white/5 text-muted"
|
||||
}`}
|
||||
>
|
||||
Custom
|
||||
</button>
|
||||
{countChoice === "custom" && (
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max="2000"
|
||||
value={customCount}
|
||||
onChange={(e) => setCustomCount(e.target.value)}
|
||||
className="w-24 rounded-md border border-line bg-bg px-3 py-1.5 text-right text-sm outline-none focus:border-gold"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Fleet Specific Settings: Level, Class, Role, Archetype */}
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3">
|
||||
{/* Target Level */}
|
||||
<div>
|
||||
<label className="text-xs text-muted">
|
||||
{spawnMode === "fleet" ? "Fleet Level" : "Max Level Cap"} (1 - {maxLevelForRealm})
|
||||
</label>
|
||||
<input
|
||||
type="number"
|
||||
min="1"
|
||||
max={maxLevelForRealm}
|
||||
value={targetLevel}
|
||||
onChange={(e) => setTargetLevel(Math.max(1, Math.min(maxLevelForRealm, Number(e.target.value))))}
|
||||
className="mt-1.5 w-full rounded-md border border-line bg-bg px-3 py-1.5 text-sm outline-none focus:border-gold"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Class Filter */}
|
||||
<div>
|
||||
<label className="text-xs text-muted">Class Focus</label>
|
||||
<select
|
||||
value={selectedClass}
|
||||
onChange={(e) => setSelectedClass(e.target.value)}
|
||||
className="mt-1.5 w-full rounded-md border border-line bg-bg px-3 py-1.5 text-sm outline-none focus:border-gold"
|
||||
>
|
||||
<option value="all">All Realm Classes</option>
|
||||
{selectedRealm === "coa" && (
|
||||
<>
|
||||
<option value="12">Barbarian</option>
|
||||
<option value="13">Witch Doctor</option>
|
||||
<option value="14">Felsworn</option>
|
||||
<option value="15">Witch Hunter</option>
|
||||
<option value="16">Stormbringer</option>
|
||||
<option value="17">Knight of Xoroth</option>
|
||||
<option value="18">Guardian</option>
|
||||
<option value="19">Templar</option>
|
||||
<option value="20">Bloodmage</option>
|
||||
<option value="21">Ranger</option>
|
||||
<option value="22">Chronomancer</option>
|
||||
<option value="23">Necromancer</option>
|
||||
<option value="24">Pyromancer</option>
|
||||
<option value="25">Cultist</option>
|
||||
<option value="26">Starcaller</option>
|
||||
<option value="27">Tinker</option>
|
||||
<option value="28">Venomancer</option>
|
||||
<option value="29">Reaper</option>
|
||||
<option value="30">Sun Cleric</option>
|
||||
<option value="31">Runemaster</option>
|
||||
<option value="32">Primalist</option>
|
||||
</>
|
||||
)}
|
||||
{selectedRealm === "wildcard" && (
|
||||
<option value="10">Hero (Freepick)</option>
|
||||
)}
|
||||
{selectedRealm === "reborn" && (
|
||||
<>
|
||||
<option value="1">Warrior</option>
|
||||
<option value="2">Paladin</option>
|
||||
<option value="3">Hunter</option>
|
||||
<option value="4">Rogue</option>
|
||||
<option value="5">Priest</option>
|
||||
<option value="6">Death Knight</option>
|
||||
<option value="7">Shaman</option>
|
||||
<option value="8">Mage</option>
|
||||
<option value="9">Warlock</option>
|
||||
<option value="11">Druid</option>
|
||||
</>
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Role Filter */}
|
||||
<div>
|
||||
<label className="text-xs text-muted">Combat Role</label>
|
||||
<select
|
||||
value={selectedRole}
|
||||
onChange={(e) => setSelectedRole(e.target.value)}
|
||||
className="mt-1.5 w-full rounded-md border border-line bg-bg px-3 py-1.5 text-sm outline-none focus:border-gold"
|
||||
>
|
||||
<option value="all">All Roles</option>
|
||||
<option value="tank">Tank</option>
|
||||
<option value="healer">Healer</option>
|
||||
<option value="melee">Melee DPS</option>
|
||||
<option value="ranged">Ranged Physical DPS</option>
|
||||
<option value="caster">Caster DPS</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Archetype Filter */}
|
||||
<div>
|
||||
<label className="text-xs text-muted">Archetype / Build</label>
|
||||
<select
|
||||
value={selectedArchetype}
|
||||
onChange={(e) => setSelectedArchetype(e.target.value)}
|
||||
className="mt-1.5 w-full rounded-md border border-line bg-bg px-3 py-1.5 text-sm outline-none focus:border-gold"
|
||||
>
|
||||
<option value="all">Auto / Integral Archetype</option>
|
||||
{selectedRealm === "wildcard" && (
|
||||
<>
|
||||
{wildcardArchetypes.map((b) => (
|
||||
<option key={b.id} value={b.id}>
|
||||
{b.name} ({formatRole(b.roles)}) [{formatStat(b.primary_stat)}]
|
||||
</option>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
{selectedRealm === "reborn" && (
|
||||
<>
|
||||
<option value="spiritguard">Spirit Guard Shaman (Tank)</option>
|
||||
<option value="darkapoth">Dark Apotheosis Warlock (Tank)</option>
|
||||
<option value="guardianbear">Guardian Bear Druid (Tank)</option>
|
||||
<option value="protpal">Protection Paladin (Tank)</option>
|
||||
<option value="protwar">Protection Warrior (Tank)</option>
|
||||
<option value="holypriest">Holy Priest (Healer)</option>
|
||||
<option value="restodruid">Restoration Druid / Shaman</option>
|
||||
</>
|
||||
)}
|
||||
{selectedRealm === "coa" && (
|
||||
<option value="class_spec">Class Mastery Specialization</option>
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Deployment Actions */}
|
||||
<div className="flex flex-wrap items-center gap-3 pt-2">
|
||||
<Button
|
||||
variant="primary"
|
||||
disabled={busy || !valid || job !== null || !isRealmOperational}
|
||||
onClick={() => void handleSpawn()}
|
||||
>
|
||||
{busy && <Loader2 className="h-4 w-4 animate-spin mr-2" />}
|
||||
{spawnMode === "fleet"
|
||||
? `Spawn Level ${targetLevel} Fleet`
|
||||
: `Deploy ${valid ? count : ""} Bots`}
|
||||
</Button>
|
||||
|
||||
{running && pop && pop.bots_total > pop.bots_online && (
|
||||
<Button
|
||||
variant="secondary"
|
||||
disabled={busy || job !== null || !isRealmOperational}
|
||||
onClick={() => void handleLoginAll()}
|
||||
title="Bring all created bots online"
|
||||
>
|
||||
<Power className="h-4 w-4 mr-1.5 text-ok" />
|
||||
Bring All Online ({pop.bots_total - pop.bots_online} idle)
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{!running && (
|
||||
<span className="text-xs text-muted">
|
||||
Server stopped: bots will be created directly in DB or queued for startup.
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Progress Bar during active spawn */}
|
||||
{job && (
|
||||
<div className="rounded-lg border border-line bg-bg/40 p-4 space-y-2">
|
||||
<div className="flex justify-between text-sm">
|
||||
<span className="font-medium">
|
||||
Creating bots: {done} / {job.target}
|
||||
</span>
|
||||
<span className="text-gold font-bold">
|
||||
{Math.round((done / job.target) * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-2 overflow-hidden rounded-full bg-white/10">
|
||||
<div
|
||||
className="h-full rounded-full bg-gold transition-[width] duration-300"
|
||||
style={{ width: `${(done / job.target) * 100}%` }}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex justify-between items-center pt-1">
|
||||
<span className="text-xs text-muted">
|
||||
Paced creation prevents server stalls and guarantees full talent/gear setup.
|
||||
</span>
|
||||
<Button size="sm" variant="ghost" disabled={busy} onClick={() => void stopCreating()}>
|
||||
Cancel Queue
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{note && !job && (
|
||||
<p className="text-sm text-ok flex items-center gap-1.5">
|
||||
<CheckCircle2 className="h-4 w-4 shrink-0" />
|
||||
{note}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Online Fleet Management (Despawn, Purge) */}
|
||||
{running && pop && pop.bots_total > 0 && isViewingActiveRealm && (
|
||||
<div className="border-t border-line pt-5 space-y-3">
|
||||
<h3 className="font-semibold text-sm tracking-wide uppercase text-muted">
|
||||
Online Fleet Management
|
||||
</h3>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3 text-sm">
|
||||
<label htmlFor="despawn-n" className="text-muted text-xs">
|
||||
Despawn Batch:
|
||||
</label>
|
||||
<input
|
||||
id="despawn-n"
|
||||
value={despawnN}
|
||||
onChange={(e) => setDespawnN(e.target.value)}
|
||||
inputMode="numeric"
|
||||
aria-invalid={!dnValid}
|
||||
className="w-20 rounded-md border border-line bg-bg px-3 py-1.5 text-right outline-none focus:border-gold"
|
||||
className="w-20 rounded-md border border-line bg-bg px-2.5 py-1 text-right text-sm outline-none focus:border-gold"
|
||||
/>
|
||||
<Button size="sm" variant="secondary" disabled={busy || !dnValid} onClick={() => void despawnSome()}>
|
||||
{t("comp.despawnSome", { n: dnValid ? dn : "…" })}
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
disabled={busy || !dnValid}
|
||||
onClick={() => void despawnSome()}
|
||||
>
|
||||
Despawn {dnValid ? dn : "…"} Bots
|
||||
</Button>
|
||||
</div>
|
||||
<p className="mt-1 text-xs text-muted">{t("comp.despawnHint")}</p>
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
|
||||
<Button size="sm" variant="secondary" disabled={busy} onClick={takeOffline}>
|
||||
{t("comp.offline")}
|
||||
Take All Offline
|
||||
</Button>
|
||||
<Button size="sm" variant="ghost" className="text-bad hover:text-bad" disabled={busy} onClick={deleteAll}>
|
||||
{t("comp.delete")}
|
||||
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="text-bad hover:text-bad ml-auto"
|
||||
disabled={busy}
|
||||
onClick={deleteAll}
|
||||
>
|
||||
Purge Entire Fleet ({pop.bots_total})
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="mt-5 border-t border-line pt-4">
|
||||
<h3 className="text-sm font-semibold">{t("comp.startTitle")}</h3>
|
||||
<label className="mt-2 flex cursor-pointer items-center gap-2 text-sm">
|
||||
<input type="checkbox" checked={autoOn} onChange={(e) => setAutoOn(e.target.checked)} />
|
||||
{t("comp.startAuto")}
|
||||
</label>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-2 text-sm">
|
||||
<label htmlFor="start-max" className="text-muted">{t("comp.startCount")}</label>
|
||||
<input
|
||||
id="start-max"
|
||||
value={autoMax}
|
||||
onChange={(e) => setAutoMax(e.target.value)}
|
||||
inputMode="numeric"
|
||||
disabled={!autoOn}
|
||||
aria-invalid={!maxValid}
|
||||
className="w-24 rounded-md border border-line bg-bg px-3 py-1.5 text-right outline-none focus:border-gold disabled:opacity-40"
|
||||
/>
|
||||
<Button size="sm" variant="secondary" disabled={startBusy || (autoOn && !maxValid)} onClick={() => void saveStart()}>
|
||||
{t("comp.startSave")}
|
||||
</Button>
|
||||
{/* Startup Auto-Login Configuration */}
|
||||
<div className="border-t border-line pt-5 space-y-3">
|
||||
<h3 className="font-semibold text-sm tracking-wide uppercase text-muted">
|
||||
Persistent Startup Fleet
|
||||
</h3>
|
||||
<p className="text-xs text-muted">
|
||||
Configure how many bots automatically log into the world whenever the server launches.
|
||||
</p>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-4 text-sm">
|
||||
<label className="flex cursor-pointer items-center gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={autoOn}
|
||||
onChange={(e) => setAutoOn(e.target.checked)}
|
||||
className="rounded border-line text-gold focus:ring-gold"
|
||||
/>
|
||||
<span>Enable Auto-Login on Server Startup</span>
|
||||
</label>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<label htmlFor="start-max" className="text-xs text-muted">
|
||||
Startup Limit:
|
||||
</label>
|
||||
<input
|
||||
id="start-max"
|
||||
value={autoMax}
|
||||
onChange={(e) => setAutoMax(e.target.value)}
|
||||
inputMode="numeric"
|
||||
disabled={!autoOn}
|
||||
aria-invalid={!maxValid}
|
||||
className="w-24 rounded-md border border-line bg-bg px-2.5 py-1 text-right text-sm outline-none focus:border-gold disabled:opacity-40"
|
||||
/>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
disabled={startBusy || (autoOn && !maxValid)}
|
||||
onClick={() => void saveStart()}
|
||||
>
|
||||
Save Setting
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{autoOn && !maxValid && autoMax !== "" && <p className="mt-1 text-xs text-warn">{t("comp.startInvalid")}</p>}
|
||||
<p className="mt-1 text-xs text-muted">{t("comp.startHint")}</p>
|
||||
{startNote && <p className="mt-2 text-sm text-ok" role="status">{startNote}</p>}
|
||||
{startNote && <p className="text-xs text-ok">{startNote}</p>}
|
||||
</div>
|
||||
{error && <p className="mt-3 text-sm text-bad" role="alert">{error.human.code === "unknown" ? error.technical : human(error.human).message}</p>}
|
||||
|
||||
{error && (
|
||||
<div className="rounded-md border border-bad/40 bg-bad/10 p-3 text-sm text-bad flex items-center gap-2">
|
||||
<AlertCircle className="h-4 w-4 shrink-0" />
|
||||
<span>{error.human.code === "unknown" ? error.technical : human(error.human).message}</span>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user