diff --git a/config/mac-studio-sandbox.json b/config/mac-studio-sandbox.json index 2c6f6328055dfcd772d866d91f8360ed92453ddc..5c369e99f3ceeed7cc38bac3cddcebe155dd0a8d 100644 --- a/config/mac-studio-sandbox.json +++ b/config/mac-studio-sandbox.json @@ -1,4 +1,5 @@ { "dataset": "globe/clover/mac-studio-sandbox", - "mountPoint": "/srv/mac-studio-vm/sandbox" + "mountPoint": "/srv/mac-studio-vm/sandbox", + "clientAddress": "10.0.0.222" } diff --git a/dashboard/src/apps.rs b/dashboard/src/apps.rs index a9d0fa10154a357f3abfb8b6f31e536262674f31..2ba9e755d8234f9dad4b0e833d763d159df6bd07 100644 --- a/dashboard/src/apps.rs +++ b/dashboard/src/apps.rs @@ -299,7 +299,7 @@ pub async fn route( } let allocated: f64 = array(&values[1]) .iter() - .filter(|vm| !["shutoff", "crashed"].contains(&string(&vm["state"]))) + .filter(|vm| vm["host"] == values[0]["name"] && !["shutoff", "crashed"].contains(&string(&vm["state"]))) .map(|vm| number(&vm["balloon"])) .sum(); values[0]["availableMemory"] = @@ -361,6 +361,9 @@ pub async fn route( ["vms", name, tail @ ..] => { vm_name(name)?; match tail { + ["clipboard"] if method == Method::POST => { + vm_call("clipboard", Some(json!({"name":name,"text":body["text"]}))).await?; + } ["access"] if method == Method::GET => { let mut response = Document::new(vm_call("access", Some(json!({"name":name}))).await?) @@ -410,7 +413,7 @@ pub async fn route( } [action] if method == Method::POST - && ["start", "shutdown", "reboot", "destroy", "resume"] + && ["start", "shutdown", "reboot", "destroy", "resume", "suspend"] .contains(action) => { vm_call("act", Some(json!({"name":name,"action":action}))).await?; diff --git a/dashboard/src/host.rs b/dashboard/src/host.rs index 614bba347bdba754ca7729abaa75488d6b41f95c..15b310924166ff3a833d46112e15b9994405f082 100644 --- a/dashboard/src/host.rs +++ b/dashboard/src/host.rs @@ -34,6 +34,8 @@ pub async fn open(request: Value) -> Result<(Value, tokio::net::UnixStream)> { Some("vm.create" | "vm.media" | "vm.preset") ) { 910 + } else if request["operation"] == "vm.act" { + 240 } else if request["operation"] == "copyparty.manage" { 310 } else { diff --git a/dashboard/web/api.contract.ts b/dashboard/web/api.contract.ts index 03aa202ec49da1cdc42c30649378f20c3f9ac16c..8b727100e352371b30ff33a2ff518e8b9eb007a2 100644 --- a/dashboard/web/api.contract.ts +++ b/dashboard/web/api.contract.ts @@ -320,6 +320,9 @@ export type Api = Hono<{}, { "/vms/:name/media": { $put: Endpoint; }; + "/vms/:name/clipboard": { + $post: Endpoint; + }; "/vms/:name/access": { $get: Endpoint<{ username: string; password: string; hostname: string } | null, { param: { name: string } }>; }; @@ -327,7 +330,7 @@ export type Api = Hono<{}, { $post: Endpoint; }; "/vms/:name/:action": { - $post: Endpoint; + $post: Endpoint; }; "/account": { $get: Endpoint; diff --git a/dashboard/web/components/VMConsole.tsx b/dashboard/web/components/VMConsole.tsx index 1263edcf49ce81a097475716d40eb62406248690..3079ba17f2736bf29b8adba802689595a648bb7a 100644 --- a/dashboard/web/components/VMConsole.tsx +++ b/dashboard/web/components/VMConsole.tsx @@ -9,6 +9,7 @@ import Check from "lucide-solid/icons/check"; import RemoteKeyboard from "@novnc/keyboard"; import { VM_SETUP, type Domain } from "../types/vms.ts"; import { StatusLabel } from "./Status.tsx"; +import { toast } from "./Toast.tsx"; type WindowSurface = { id: number; x: number; y: number; width: number; height: number; atlas_x: number; atlas_y: number; @@ -16,7 +17,7 @@ type WindowSurface = { }; type WindowFrame = { windows: WindowSurface[]; rtpTimestamp: number }; -export function VMConsole(props: { name: string; enabled: boolean; active: boolean; setup?: Domain["setup"]; toolbar: JSX.Element; content: (toolbar: HTMLDivElement) => JSX.Element }) { +export function VMConsole(props: { name: string; platform: Domain["platform"]; enabled: boolean; active: boolean; setup?: Domain["setup"]; unavailable?: string; clipboard?: (text: string) => Promise; toolbar: JSX.Element; content: (toolbar: HTMLDivElement) => JSX.Element }) { const enabled = createMemo(() => props.enabled); const preparing = () => !!props.setup && props.setup !== "ready"; let reconnectTimer: number | undefined; @@ -72,6 +73,7 @@ export function VMConsole(props: { name: string; enabled: boolean; active: boole const connected = () => state() === "Connected"; const [problem, setProblem] = createSignal(""); const [clipboard, setClipboard] = createSignal(""); + const [sendingClipboard, setSendingClipboard] = createSignal(false); const [showClipboard, setShowClipboard] = createSignal(false); const [windowsAvailable, setWindowsAvailable] = createSignal(false); const [separateWindows, setSeparateWindows] = createSignal(false); @@ -389,7 +391,7 @@ export function VMConsole(props: { name: string; enabled: boolean; active: boole {props.toolbar} - + @@ -404,7 +406,7 @@ export function VMConsole(props: { name: string; enabled: boolean; active: boole Ctrl+Alt+Esc releases keyboard - {preparing() ? "" : props.enabled ? state() : "Off"} + {preparing() ? "" : props.enabled ? state() : props.unavailable ? "Unavailable" : "Off"} @@ -418,9 +420,15 @@ export function VMConsole(props: { name: string; enabled: boolean; active: boole