feat: add rebuild machine option
This commit is contained in:
parent
2ff19f53d0
commit
b8e478c8ee
@ -32,6 +32,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
addCustomMachine,
|
addCustomMachine,
|
||||||
addMachine,
|
addMachine,
|
||||||
|
buildMachine,
|
||||||
deleteMachine,
|
deleteMachine,
|
||||||
disableMachine,
|
disableMachine,
|
||||||
enableMachine,
|
enableMachine,
|
||||||
@ -202,14 +203,28 @@ export const columns: ColumnDef<Machine>[] = [
|
|||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
)}
|
)}
|
||||||
{machine.type === "comfy-deploy-serverless" && (
|
{machine.type === "comfy-deploy-serverless" && (
|
||||||
<DropdownMenuItem asChild>
|
<>
|
||||||
<a
|
<DropdownMenuItem asChild>
|
||||||
target="_blank"
|
<a
|
||||||
href={machine.endpoint.replace("comfyui-api", "comfyui-app")}
|
target="_blank"
|
||||||
|
href={machine.endpoint.replace(
|
||||||
|
"comfyui-api",
|
||||||
|
"comfyui-app"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
Open ComfyUI
|
||||||
|
</a>
|
||||||
|
</DropdownMenuItem>
|
||||||
|
<DropdownMenuItem
|
||||||
|
onClick={() => {
|
||||||
|
buildMachine({
|
||||||
|
id: machine.id,
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Open ComfyUI
|
Rebuild
|
||||||
</a>
|
</DropdownMenuItem>
|
||||||
</DropdownMenuItem>
|
</>
|
||||||
)}
|
)}
|
||||||
<DropdownMenuItem onClick={() => setOpen(true)}>
|
<DropdownMenuItem onClick={() => setOpen(true)}>
|
||||||
Edit
|
Edit
|
||||||
|
@ -113,7 +113,7 @@ export const updateCustomMachine = withServerPromise(
|
|||||||
.where(eq(machinesTable.id, id));
|
.where(eq(machinesTable.id, id));
|
||||||
|
|
||||||
// Perform custom build if there are changes
|
// Perform custom build if there are changes
|
||||||
await buildMachine(data, currentMachine);
|
await _buildMachine(data, currentMachine);
|
||||||
redirect(`/machines/${id}`);
|
redirect(`/machines/${id}`);
|
||||||
} else {
|
} else {
|
||||||
revalidatePath("/machines");
|
revalidatePath("/machines");
|
||||||
@ -123,6 +123,32 @@ export const updateCustomMachine = withServerPromise(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const buildMachine = withServerPromise(
|
||||||
|
async ({ id }: { id: string }) => {
|
||||||
|
const { userId } = auth();
|
||||||
|
if (!userId) return { error: "No user id" };
|
||||||
|
|
||||||
|
const currentMachine = await db.query.machinesTable.findFirst({
|
||||||
|
where: eq(machinesTable.id, id),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!currentMachine) return { error: "Machine not found" };
|
||||||
|
|
||||||
|
const datas = await db
|
||||||
|
.update(machinesTable)
|
||||||
|
.set({
|
||||||
|
status: "building",
|
||||||
|
endpoint: "not-ready",
|
||||||
|
})
|
||||||
|
.where(eq(machinesTable.id, id))
|
||||||
|
.returning();
|
||||||
|
|
||||||
|
// Perform custom build if there are changes
|
||||||
|
await _buildMachine(datas[0], currentMachine);
|
||||||
|
redirect(`/machines/${id}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export const addCustomMachine = withServerPromise(
|
export const addCustomMachine = withServerPromise(
|
||||||
async (data: z.infer<typeof addCustomMachineSchema>) => {
|
async (data: z.infer<typeof addCustomMachineSchema>) => {
|
||||||
const { userId, orgId } = auth();
|
const { userId, orgId } = auth();
|
||||||
@ -143,14 +169,14 @@ export const addCustomMachine = withServerPromise(
|
|||||||
|
|
||||||
const b = a[0];
|
const b = a[0];
|
||||||
|
|
||||||
await buildMachine(data, b);
|
await _buildMachine(data, b);
|
||||||
redirect(`/machines/${b.id}`);
|
redirect(`/machines/${b.id}`);
|
||||||
// revalidatePath("/machines");
|
// revalidatePath("/machines");
|
||||||
return { message: "Machine Building" };
|
return { message: "Machine Building" };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
async function buildMachine(
|
async function _buildMachine(
|
||||||
data: z.infer<typeof addCustomMachineSchema>,
|
data: z.infer<typeof addCustomMachineSchema>,
|
||||||
b: MachineType
|
b: MachineType
|
||||||
) {
|
) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user