clan-app: Fix machine update cancel task

This commit is contained in:
Qubasa
2025-05-13 14:05:56 +02:00
parent a12ba8e56f
commit daffc95c96
3 changed files with 32 additions and 74 deletions

View File

@@ -37,38 +37,31 @@ export const MachineListItem = (props: MachineListItemProps) => {
const active_clan = activeURI();
if (!active_clan) {
toast.error("No active clan selected");
console.error("No active clan selected");
return;
}
if (!info?.deploy?.targetHost) {
toast.error(
console.error(
"Machine does not have a target host. Specify where the machine should be deployed.",
);
return;
}
setInstalling(true);
await toast.promise(
callApi("install_machine", {
opts: {
machine: {
name: name,
flake: {
identifier: active_clan,
},
override_target_host: info?.deploy.targetHost,
await callApi("install_machine", {
opts: {
machine: {
name: name,
flake: {
identifier: active_clan,
},
no_reboot: true,
debug: true,
nix_options: [],
password: null,
override_target_host: info?.deploy.targetHost,
},
}),
{
loading: "Installing...",
success: "Installed",
error: "Failed to install",
no_reboot: true,
debug: true,
nix_options: [],
password: null,
},
);
});
setInstalling(false);
};
@@ -79,34 +72,26 @@ export const MachineListItem = (props: MachineListItemProps) => {
const active_clan = activeURI();
if (!active_clan) {
toast.error("No active clan selected");
console.error("No active clan selected");
return;
}
if (!info?.deploy.targetHost) {
toast.error(
console.error(
"Machine does not have a target host. Specify where the machine should be deployed.",
);
return;
}
setUpdating(true);
await toast.promise(
callApi("update_machines", {
base_path: active_clan,
machines: [
{
name: name,
deploy: {
targetHost: info?.deploy.targetHost,
},
},
],
}),
{
loading: "Updating...",
success: "Updated",
error: "Failed to update",
await callApi("deploy_machine", {
machine: {
name: name,
flake: {
identifier: active_clan,
},
override_target_host: info?.deploy.targetHost,
},
);
});
setUpdating(false);
};
return (

View File

@@ -457,16 +457,14 @@ const MachineForm = (props: MachineDetailsProps) => {
const target = targetHost();
setIsUpdating(true);
const r = await callApi("update_machines", {
base_path: curr_uri,
machines: [
{
name: machine,
deploy: {
targetHost: target,
},
const r = await callApi("deploy_machine", {
machine: {
name: machine,
flake: {
identifier: curr_uri,
},
],
override_target_host: target,
},
});
};