server reboot too

This commit is contained in:
legop3
2026-02-18 15:13:38 -05:00
parent 40e21d4ac5
commit 7e772ab607
6 changed files with 98 additions and 11 deletions
+34 -2
View File
@@ -10,11 +10,21 @@ const MODES = [
];
export default function AdminPanel() {
const { session, lockRover, setMode, requestControl, setCommunityGoal, setAdminReason, rebootRover, adminLogs } =
useSession();
const {
session,
lockRover,
setMode,
requestControl,
setCommunityGoal,
setAdminReason,
rebootRover,
rebootServer,
adminLogs,
} = useSession();
const roster = useMemo(() => session?.roster ?? [], [session?.roster]);
const [lockStates, setLockStates] = useState({});
const [rebootStates, setRebootStates] = useState({});
const [serverRebooting, setServerRebooting] = useState(false);
const health = session?.health || null;
const currentGoal = session?.communityGoal?.text || '';
const goalUpdatedAt = session?.communityGoal?.updatedAt || null;
@@ -70,6 +80,18 @@ export default function AdminPanel() {
}
};
const handleServerReboot = async () => {
const ok = window.confirm('Reboot the server host now? This will disconnect all users.');
if (!ok) return;
setServerRebooting(true);
try {
await rebootServer();
} catch (err) {
alert(err.message);
setServerRebooting(false);
}
};
const handleGoalSave = async () => {
try {
await setCommunityGoal(goalDraft);
@@ -132,6 +154,16 @@ export default function AdminPanel() {
))}
</select>
</div>
<div className="flex gap-0.5 text-xs">
<button
type="button"
onClick={handleServerReboot}
disabled={serverRebooting}
className="button-danger disabled:cursor-not-allowed disabled:opacity-60"
>
{serverRebooting ? 'Server rebooting...' : 'Reboot Server'}
</button>
</div>
<div className="space-y-0.5">
<div className="flex items-center justify-between text-xs text-slate-400">
<span>Community goal</span>