feat: add new ws realtime event

This commit is contained in:
BennyKok
2023-12-11 10:49:37 +08:00
parent ed853fc5f1
commit f9ed8145d2
11 changed files with 272 additions and 108 deletions
+8 -9
View File
@@ -12,6 +12,7 @@ import {
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { createRun } from "@/server/createRun";
import type { getMachines } from "@/server/curdMachine";
import { Play } from "lucide-react";
import { parseAsInteger, useQueryState } from "next-usequerystate";
@@ -101,17 +102,15 @@ export function RunWorkflowButton({
className="gap-2"
disabled={isLoading}
onClick={async () => {
const workflow_version_id = workflow?.versions.find(
(x) => x.version === version
)?.id;
if (!workflow_version_id) return;
setIsLoading(true);
try {
await fetch(`/api/create-run`, {
method: "POST",
body: JSON.stringify({
workflow_version_id: workflow?.versions.find(
(x) => x.version === version
)?.id,
machine_id: machine,
}),
});
const origin = window.location.origin;
await createRun(origin, workflow_version_id, machine);
setIsLoading(false);
} catch (error) {
setIsLoading(false);