feat(ui): subscribe workflow runs status

This commit is contained in:
Fu Diwei
2025-02-08 23:03:31 +08:00
parent 0bc40fd676
commit a74ec95a6a
4 changed files with 43 additions and 11 deletions

View File

@@ -50,13 +50,9 @@ export const remove = async (record: MaybeModelRecordWithId<WorkflowModel>) => {
};
export const subscribe = async (id: string, cb: (e: RecordSubscription<WorkflowModel>) => void) => {
const pb = getPocketBase();
return pb.collection("workflow").subscribe(id, cb);
return getPocketBase().collection(COLLECTION_NAME).subscribe(id, cb);
};
export const unsubscribe = async (id: string) => {
const pb = getPocketBase();
return pb.collection("workflow").unsubscribe(id);
return getPocketBase().collection(COLLECTION_NAME).unsubscribe(id);
};

View File

@@ -1,4 +1,6 @@
import { type WorkflowRunModel } from "@/domain/workflowRun";
import { type RecordSubscription } from "pocketbase";
import { type WorkflowRunModel } from "@/domain/workflowRun";
import { getPocketBase } from "./_pocketbase";
@@ -35,3 +37,11 @@ export const list = async (request: ListWorkflowRunsRequest) => {
export const remove = async (record: MaybeModelRecordWithId<WorkflowRunModel>) => {
return await getPocketBase().collection(COLLECTION_NAME).delete(record.id);
};
export const subscribe = async (id: string, cb: (e: RecordSubscription<WorkflowRunModel>) => void) => {
return getPocketBase().collection(COLLECTION_NAME).subscribe(id, cb);
};
export const unsubscribe = async (id: string) => {
return getPocketBase().collection(COLLECTION_NAME).unsubscribe(id);
};