From 6adbd88b22804d113ceb57b6b71d44b8e1b80cd2 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Sun, 22 Mar 2026 03:16:24 -0400 Subject: [PATCH] Add remote reboot functionality to SettingsPanel --- web/client/src/components/SettingsPanel.jsx | 68 +++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/web/client/src/components/SettingsPanel.jsx b/web/client/src/components/SettingsPanel.jsx index abf780f..59dc4f7 100644 --- a/web/client/src/components/SettingsPanel.jsx +++ b/web/client/src/components/SettingsPanel.jsx @@ -2,14 +2,25 @@ import React, { useState, useCallback } from 'react'; import { useInventoryStore } from '../store/inventoryStore'; import './SettingsPanel.css'; +const REBOOT_TARGETS = [ + { value: 'all', label: 'All Devices', icon: '🔄', desc: 'Reboot everything (manager + clients + turtles + bridge)' }, + { value: 'client', label: 'Clients', icon: '💻', desc: 'Reboot all inventory client displays' }, + { value: 'turtle', label: 'Crafting Turtles', icon: '🐢', desc: 'Reboot all crafting turtles' }, + { value: 'bridge', label: 'Web Bridge', icon: '🌉', desc: 'Reboot the HTTP/WS bridge computer' }, + { value: 'manager', label: 'Manager', icon: '📦', desc: 'Reboot the inventory manager (will disconnect briefly)' }, +]; + function SettingsPanel({ isOpen, onClose }) { const droppers = useInventoryStore((state) => state.inventory.droppers) || []; const dropperNicknames = useInventoryStore((state) => state.dropperNicknames) || {}; const setDropperNickname = useInventoryStore((state) => state.setDropperNickname); + const rebootComputers = useInventoryStore((state) => state.rebootComputers); const [editingDropper, setEditingDropper] = useState(null); const [editValue, setEditValue] = useState(''); const [saving, setSaving] = useState(false); + const [rebootConfirm, setRebootConfirm] = useState(null); + const [rebootStatus, setRebootStatus] = useState(null); const startEditing = useCallback((dropperName) => { setEditingDropper(dropperName); @@ -39,6 +50,18 @@ function SettingsPanel({ isOpen, onClose }) { } }, [saveNickname]); + const handleReboot = useCallback(async (target) => { + setRebootConfirm(null); + setRebootStatus(`Sending reboot to ${target}...`); + const result = await rebootComputers(target); + if (result?.success) { + setRebootStatus(`✅ Reboot sent to: ${target}`); + } else { + setRebootStatus(`❌ Failed: ${result?.error || 'Unknown error'}`); + } + setTimeout(() => setRebootStatus(null), 4000); + }, [rebootComputers]); + if (!isOpen) return null; return ( @@ -136,6 +159,51 @@ function SettingsPanel({ isOpen, onClose }) { )} + +
+

🔄 Remote Reboot

+

+ Reboot CC:Tweaked computers remotely. They will auto-update from git and restart. +

+ + {rebootStatus && ( +
{rebootStatus}
+ )} + +
+ {REBOOT_TARGETS.map((t) => ( +
+
+ {t.icon} {t.label} + {t.desc} +
+ {rebootConfirm === t.value ? ( +
+ + +
+ ) : ( + + )} +
+ ))} +
+