clan-app: Fix UI errors

This commit is contained in:
Qubasa
2025-06-17 12:13:20 +02:00
parent b66f4c889d
commit 8941b75d48
3 changed files with 158 additions and 7 deletions

View File

@@ -47,6 +47,27 @@ export const MachineListItem = (props: MachineListItemProps) => {
); );
return; return;
} }
const target_host = await callApi("get_host", {
field: "targetHost",
flake: { identifier: active_clan },
name: name,
}).promise;
if (target_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (target_host.data === null) {
console.error("No target host found for the machine");
return;
}
if (!target_host.data!.data) {
console.error("No target host found for the machine");
return;
}
setInstalling(true); setInstalling(true);
await callApi("install_machine", { await callApi("install_machine", {
opts: { opts: {
@@ -55,15 +76,14 @@ export const MachineListItem = (props: MachineListItemProps) => {
flake: { flake: {
identifier: active_clan, identifier: active_clan,
}, },
override_target_host: info?.deploy.targetHost,
}, },
no_reboot: true, no_reboot: true,
debug: true, debug: true,
nix_options: [], nix_options: [],
password: null, password: null,
}, },
}).promise; target_host: target_host.data!.data,
setInstalling(false); }).promise.finally(() => setInstalling(false));
}; };
const handleUpdate = async () => { const handleUpdate = async () => {
@@ -83,14 +103,53 @@ export const MachineListItem = (props: MachineListItemProps) => {
return; return;
} }
setUpdating(true); setUpdating(true);
const target_host = await callApi("get_host", {
field: "targetHost",
flake: { identifier: active_clan },
name: name,
}).promise;
if (target_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (target_host.data === null) {
console.error("No target host found for the machine");
return;
}
if (!target_host.data!.data) {
console.error("No target host found for the machine");
return;
}
const build_host = await callApi("get_host", {
field: "buildHost",
flake: { identifier: active_clan },
name: name,
}).promise;
if (build_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (build_host.data === null) {
console.error("No target host found for the machine");
return;
}
await callApi("deploy_machine", { await callApi("deploy_machine", {
machine: { machine: {
name: name, name: name,
flake: { flake: {
identifier: active_clan, identifier: active_clan,
}, },
override_target_host: info?.deploy.targetHost,
}, },
target_host: target_host.data!.data,
build_host: build_host.data?.data || null,
}).promise; }).promise;
setUpdating(false); setUpdating(false);

View File

@@ -135,6 +135,27 @@ const InstallMachine = (props: InstallMachineProps) => {
setProgressText("Installing machine ... (2/5)"); setProgressText("Installing machine ... (2/5)");
const target_host = await callApi("get_host", {
field: "targetHost",
flake: { identifier: curr_uri },
name: props.name,
}).promise;
if (target_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (target_host.data === null) {
console.error("No target host found for the machine");
return;
}
if (!target_host.data!.data) {
console.error("No target host found for the machine");
return;
}
const installPromise = callApi("install_machine", { const installPromise = callApi("install_machine", {
opts: { opts: {
machine: { machine: {
@@ -142,11 +163,11 @@ const InstallMachine = (props: InstallMachineProps) => {
flake: { flake: {
identifier: curr_uri, identifier: curr_uri,
}, },
override_target_host: target,
private_key: values.sshKey?.name, private_key: values.sshKey?.name,
}, },
password: "", password: "",
}, },
target_host: target_host.data!.data,
}); });
// Next step // Next step
@@ -480,6 +501,49 @@ const MachineForm = (props: MachineDetailsProps) => {
const target = targetHost(); const target = targetHost();
const active_clan = activeClanURI();
if (!active_clan) {
console.error("No active clan selected");
return;
}
const target_host = await callApi("get_host", {
field: "targetHost",
flake: { identifier: active_clan },
name: machine,
}).promise;
if (target_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (target_host.data === null) {
console.error("No target host found for the machine");
return;
}
if (!target_host.data!.data) {
console.error("No target host found for the machine");
return;
}
const build_host = await callApi("get_host", {
field: "buildHost",
flake: { identifier: active_clan },
name: machine,
}).promise;
if (build_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (build_host.data === null) {
console.error("No target host found for the machine");
return;
}
setIsUpdating(true); setIsUpdating(true);
const r = await callApi("deploy_machine", { const r = await callApi("deploy_machine", {
machine: { machine: {
@@ -487,8 +551,9 @@ const MachineForm = (props: MachineDetailsProps) => {
flake: { flake: {
identifier: curr_uri, identifier: curr_uri,
}, },
override_target_host: target,
}, },
target_host: target_host.data!.data,
build_host: build_host.data!.data,
}).promise; }).promise;
}; };

View File

@@ -90,11 +90,37 @@ export const HWStep = (props: StepProps<HardwareValues>) => {
return; return;
} }
const active_clan = activeClanURI();
if (!active_clan) {
console.error("No active clan selected");
return;
}
const target_host = await callApi("get_host", {
field: "targetHost",
flake: { identifier: active_clan },
name: props.machine_id,
}).promise;
if (target_host.status == "error") {
console.error("No target host found for the machine");
return;
}
if (target_host.data === null) {
console.error("No target host found for the machine");
return;
}
if (!target_host.data!.data) {
console.error("No target host found for the machine");
return;
}
const r = await callApi("generate_machine_hardware_info", { const r = await callApi("generate_machine_hardware_info", {
opts: { opts: {
machine: { machine: {
name: props.machine_id, name: props.machine_id,
override_target_host: target,
private_key: sshFile?.name, private_key: sshFile?.name,
flake: { flake: {
identifier: curr_uri, identifier: curr_uri,
@@ -102,6 +128,7 @@ export const HWStep = (props: StepProps<HardwareValues>) => {
}, },
backend: "nixos-facter", backend: "nixos-facter",
}, },
target_host: target_host.data!.data,
}); });
// TODO: refresh the machine details // TODO: refresh the machine details