diff --git a/pkgs/webview-ui/app/src/components/MachineListItem.tsx b/pkgs/webview-ui/app/src/components/MachineListItem.tsx index e5ba35e54..5eca6d334 100644 --- a/pkgs/webview-ui/app/src/components/MachineListItem.tsx +++ b/pkgs/webview-ui/app/src/components/MachineListItem.tsx @@ -1,7 +1,8 @@ -import { Accessor, createEffect, Show } from "solid-js"; -import { SuccessData } from "../api"; +import { Accessor, createSignal, Show } from "solid-js"; +import { callApi, SuccessData } from "../api"; import { Menu } from "./Menu"; -import { setRoute } from "../App"; +import { activeURI, setRoute } from "../App"; +import toast from "solid-toast"; type MachineDetails = SuccessData<"list_inventory_machines">["data"][string]; @@ -14,6 +15,8 @@ interface MachineListItemProps { export const MachineListItem = (props: MachineListItemProps) => { const { name, info, nixOnly } = props; + const [deploying, setDeploying] = createSignal(false); + return (
  • @@ -40,6 +43,16 @@ export const MachineListItem = (props: MachineListItemProps) => {
    {(d) => d()?.description}
    +
    + + {(d) => ( + <> + cast_connected + {d()?.deploy.targetHost} + + )} + +
    @@ -57,8 +70,55 @@ export const MachineListItem = (props: MachineListItemProps) => { Edit
  • -
  • - Deploy +
  • { + if (!info?.deploy.targetHost || deploying()) { + return; + } + + const active_clan = activeURI(); + if (!active_clan) { + toast.error("No active clan selected"); + return; + } + if (!info?.deploy.targetHost) { + toast.error( + "Machine does not have a target host. Specify where the machine should be deployed.", + ); + return; + } + setDeploying(true); + await toast.promise( + callApi("install_machine", { + opts: { + machine: name, + flake: { + loc: active_clan, + }, + no_reboot: true, + target_host: info?.deploy.targetHost, + debug: true, + nix_options: [], + }, + password: null, + }), + { + loading: "Deploying...", + success: "Deployed", + error: "Failed to deploy", + }, + ); + setDeploying(false); + }} + > + + + {(d) => `Deploy to ${d()}`} + +
  • diff --git a/pkgs/webview-ui/app/src/routes/flash/view.tsx b/pkgs/webview-ui/app/src/routes/flash/view.tsx index 7f94dd7df..d27847f19 100644 --- a/pkgs/webview-ui/app/src/routes/flash/view.tsx +++ b/pkgs/webview-ui/app/src/routes/flash/view.tsx @@ -308,10 +308,10 @@ export const Flash = () => { {/* WiFi Networks */}
    -

    WiFi Networks

    +

    WiFi Networks

    {(network, index) => ( -
    +
    { />