diff --git a/ui/src/main.tsx b/ui/src/main.tsx index e3badd1..02eec9d 100644 --- a/ui/src/main.tsx +++ b/ui/src/main.tsx @@ -42,6 +42,7 @@ import SettingsHardwareRoute from "./routes/devices.$id.settings.hardware"; import SettingsVideoRoute from "./routes/devices.$id.settings.video"; import SettingsAppearanceRoute from "./routes/devices.$id.settings.appearance"; import * as SettingsGeneralIndexRoute from "./routes/devices.$id.settings.general._index"; +import SettingsGeneralRebootRoute from "./routes/devices.$id.settings.general.reboot"; import SettingsGeneralUpdateRoute from "./routes/devices.$id.settings.general.update"; import SettingsNetworkRoute from "./routes/devices.$id.settings.network"; import SecurityAccessLocalAuthRoute from "./routes/devices.$id.settings.access.local-auth"; @@ -140,6 +141,10 @@ if (isOnDevice) { index: true, element: , }, + { + path: "reboot", + element: , + }, { path: "update", element: , diff --git a/ui/src/routes/devices.$id.settings.general._index.tsx b/ui/src/routes/devices.$id.settings.general._index.tsx index 6d1d0ce..ecefdfa 100644 --- a/ui/src/routes/devices.$id.settings.general._index.tsx +++ b/ui/src/routes/devices.$id.settings.general._index.tsx @@ -92,6 +92,21 @@ export default function SettingsGeneralRoute() { /> + +
+ +
+
+
diff --git a/ui/src/routes/devices.$id.settings.general.reboot.tsx b/ui/src/routes/devices.$id.settings.general.reboot.tsx new file mode 100644 index 0000000..c6889f6 --- /dev/null +++ b/ui/src/routes/devices.$id.settings.general.reboot.tsx @@ -0,0 +1,66 @@ +import { useNavigate } from "react-router-dom"; +import { useCallback } from "react"; + +import { useJsonRpc } from "@/hooks/useJsonRpc"; +import { Button } from "@components/Button"; + +export default function SettingsGeneralRebootRoute() { + const navigate = useNavigate(); + const [send] = useJsonRpc(); + + const onConfirmUpdate = useCallback(() => { + // This is where we send the RPC to the golang binary + send("reboot", {force: true}); + }, [send]); + + { + /* TODO: Migrate to using URLs instead of the global state. To simplify the refactoring, we'll keep the global state for now. */ + } + return navigate("..")} onConfirmUpdate={onConfirmUpdate} />; +} + +export function Dialog({ + onClose, + onConfirmUpdate, +}: { + onClose: () => void; + onConfirmUpdate: () => void; +}) { + + return ( +
+
+ +
+
+ ); +} + +function ConfirmationBox({ + onYes, + onNo, +}: { + onYes: () => void; + onNo: () => void; +}) { + return ( +
+
+

+ Reboot JetKVM +

+

+ Do you want to proceed with rebooting the system? +

+ +
+
+
+
+ ); +}