- Install:
+
+
+
+ Install:{" "}
+
+
{props.name}
-
-
- Install the system for the first time. This will erase the disk and
- bootstrap a new device.
-
+
+
+ {/* Stepper container */}
+
+ {/* A Step with a circle a number inside. Label is below */}
+
+ {([idx, label]) => (
+
+
+ = step()}
+ fallback={}
+ >
+ {idx}
+
+
+
+ {label}
+
+
+ )}
+
+
-
-
Hardware detection
-
-
-
}
+
+
+
+ handleNext()}
+ footer={}
+ />
+
+
+
+
+ Single Disk
+
+
- Run hardware Report
-
-
-
-
Disk schema
-
-
- }
+ Change schema
+
+
+
+
+
+
+
+
+
+
- Select disk Schema
-
-
-
-
-
-
{(field, fieldProps) => "disk"}
-
-
info
-
-
Summary:
-
- Install to {props.targetHost} using{" "}
- {props.sshKey?.name || "default ssh key"} for
- authentication.
-
- This may take ~15 minutes depending on the initial closure and the
- environmental setup.
-
-
-
- }
+ Hardware Report
+
+
+ Target}
+ field={
+
+ 192.157.124.81
+
+ }
+ >
+
+
+
+
- Install
-
- }
- >
- }
- >
- Install
-
-
-
-
-
- >
+ Disk Configuration
+
+
+ Disk Layout}
+ field={
+
+ Single Disk
+
+ }
+ >
+
+ Main Disk}
+ field={
+
+ Samsung evo 850 efkjhasd
+
+ }
+ >
+
+
+
+
+ Setup your device.
+
+
+ This will erase the disk and bootstrap fresh.
+
+
+ }
+ />
+
+ }>Install
+
+
+
+
);
};
@@ -235,6 +403,8 @@ const MachineForm = (props: MachineDetailsProps) => {
const machineName = () =>
getValue(formStore, "machine.name") || props.initialData.machine.name;
+ const [installModalOpen, setInstallModalOpen] = createSignal(false);
+
const handleSubmit = async (values: MachineFormInterface) => {
console.log("submitting", values);
@@ -309,7 +479,7 @@ const MachineForm = (props: MachineDetailsProps) => {
General
-
-
+ setInstallModalOpen(false)}
+ class="min-w-[600px]"
+ >
+
+
Update the system if changes should be synced after the installation
diff --git a/pkgs/webview-ui/app/src/routes/machines/install/hardware-step.tsx b/pkgs/webview-ui/app/src/routes/machines/install/hardware-step.tsx
new file mode 100644
index 000000000..8ce0ab499
--- /dev/null
+++ b/pkgs/webview-ui/app/src/routes/machines/install/hardware-step.tsx
@@ -0,0 +1,179 @@
+import { callApi } from "@/src/api";
+import { activeURI } from "@/src/App";
+import { Button } from "@/src/components/button";
+import Icon from "@/src/components/icon";
+import { InputError, InputLabel } from "@/src/components/inputBase";
+import { FieldLayout } from "@/src/Form/fields/layout";
+import {
+ createForm,
+ SubmitHandler,
+ FieldValues,
+ validate,
+ required,
+ getValue,
+ submit,
+ setValue,
+} from "@modular-forms/solid";
+import { createEffect, createSignal, JSX, Match, Switch } from "solid-js";
+import toast from "solid-toast";
+import { Group } from "../details";
+import { TextInput } from "@/src/Form/fields";
+import { createQuery } from "@tanstack/solid-query";
+
+interface Hardware extends FieldValues {
+ report: boolean;
+ target: string;
+}
+
+export interface StepProps {
+ machine_id: string;
+ dir: string;
+ handleNext: () => void;
+ footer: JSX.Element;
+ initial?: Partial;
+}
+export const HWStep = (props: StepProps) => {
+ const [formStore, { Form, Field }] = createForm({
+ initialValues: props.initial || {},
+ });
+
+ const handleSubmit: SubmitHandler = async (values, event) => {
+ console.log("Submit Hardware", { values });
+ const valid = await validate(formStore);
+ console.log("Valid", valid);
+ if (!valid) return;
+ props.handleNext();
+ };
+
+ const [isGenerating, setIsGenerating] = createSignal(false);
+
+ const hwReportQuery = createQuery(() => ({
+ queryKey: [props.dir, props.machine_id, "hw_report"],
+ queryFn: async () => {
+ const result = await callApi("show_machine_hardware_config", {
+ clan_dir: props.dir,
+ machine_name: props.machine_id,
+ });
+ if (result.status === "error") throw new Error("Failed to fetch data");
+ return result.data;
+ },
+ }));
+ // Workaround to set the form state
+ createEffect(() => {
+ const report = hwReportQuery.data;
+ if (report === "nixos-facter" || report === "nixos-generate-config") {
+ setValue(formStore, "report", true);
+ }
+ });
+
+ const generateReport = async (e: Event) => {
+ const curr_uri = activeURI();
+ if (!curr_uri) return;
+
+ const loading_toast = toast.loading("Generating hardware report...");
+
+ await validate(formStore, "target");
+ const target = getValue(formStore, "target");
+
+ if (!target) {
+ toast.error("Target ip must be provided");
+ return;
+ }
+ setIsGenerating(true);
+ const r = await callApi("generate_machine_hardware_info", {
+ opts: {
+ flake: { loc: curr_uri },
+ machine: props.machine_id,
+ target_host: target,
+ backend: "nixos-facter",
+ },
+ });
+ setIsGenerating(false);
+ toast.dismiss(loading_toast);
+ // TODO: refresh the machine details
+
+ if (r.status === "error") {
+ toast.error(`Failed to generate report. ${r.errors[0].message}`);
+ }
+ if (r.status === "success") {
+ toast.success("Report generated successfully");
+ }
+ hwReportQuery.refetch();
+ submit(formStore);
+ };
+
+ return (
+
+ );
+};