mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-31 10:32:11 +08:00
107 lines
3.6 KiB
TypeScript
107 lines
3.6 KiB
TypeScript
import { defineStore } from "pinia";
|
|
import { ref } from "vue";
|
|
|
|
import { GalaxyApi } from "@/api";
|
|
import type {
|
|
InvocationJobsSummary,
|
|
InvocationStep,
|
|
WorkflowInvocation,
|
|
WorkflowInvocationRequest,
|
|
} from "@/api/invocations";
|
|
import { type FetchParams, useKeyedCache } from "@/composables/keyedCache";
|
|
import type { GraphStep } from "@/composables/useInvocationGraph";
|
|
import { rethrowSimple } from "@/utils/simple-error";
|
|
|
|
type GraphSteps = { [index: string]: GraphStep };
|
|
|
|
export const useInvocationStore = defineStore("invocationStore", () => {
|
|
const graphStepsByStoreId = ref<{ [index: string]: GraphSteps }>({});
|
|
|
|
async function fetchInvocationDetails(params: FetchParams): Promise<WorkflowInvocation> {
|
|
const { data, error } = await GalaxyApi().GET("/api/invocations/{invocation_id}", {
|
|
params: { path: { invocation_id: params.id } },
|
|
});
|
|
if (error) {
|
|
rethrowSimple(error);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
async function fetchInvocationJobsSummary(params: FetchParams): Promise<InvocationJobsSummary> {
|
|
const { data, error } = await GalaxyApi().GET("/api/invocations/{invocation_id}/jobs_summary", {
|
|
params: { path: { invocation_id: params.id } },
|
|
});
|
|
if (error) {
|
|
rethrowSimple(error);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
async function fetchInvocationStep(params: FetchParams): Promise<InvocationStep> {
|
|
const { data, error } = await GalaxyApi().GET("/api/invocations/steps/{step_id}", {
|
|
params: { path: { step_id: params.id } },
|
|
});
|
|
if (error) {
|
|
rethrowSimple(error);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
async function fetchInvocationRequest(params: FetchParams): Promise<WorkflowInvocationRequest> {
|
|
const { data, error } = await GalaxyApi().GET("/api/invocations/{invocation_id}/request", {
|
|
params: {
|
|
path: {
|
|
invocation_id: params.id,
|
|
},
|
|
},
|
|
});
|
|
if (error) {
|
|
rethrowSimple(error);
|
|
}
|
|
return data;
|
|
}
|
|
|
|
async function cancelWorkflowScheduling(invocationId: string) {
|
|
const { data, error } = await GalaxyApi().DELETE("/api/invocations/{invocation_id}", {
|
|
params: {
|
|
path: { invocation_id: invocationId },
|
|
},
|
|
});
|
|
if (error) {
|
|
rethrowSimple(error);
|
|
}
|
|
storedInvocations.value[invocationId] = data;
|
|
return data;
|
|
}
|
|
|
|
const {
|
|
fetchItemById: fetchInvocationById,
|
|
getItemById: getInvocationById,
|
|
getItemLoadError: getInvocationLoadError,
|
|
isLoadingItem: isLoadingInvocation,
|
|
storedItems: storedInvocations,
|
|
} = useKeyedCache<WorkflowInvocation>(fetchInvocationDetails);
|
|
|
|
const { getItemById: getInvocationJobsSummaryById, fetchItemById: fetchInvocationJobsSummaryForId } =
|
|
useKeyedCache<InvocationJobsSummary>(fetchInvocationJobsSummary);
|
|
|
|
const { getItemById: getInvocationStepById, fetchItemById: fetchInvocationStepById } =
|
|
useKeyedCache<InvocationStep>(fetchInvocationStep);
|
|
|
|
const { getItemById: getInvocationRequestById } = useKeyedCache<WorkflowInvocationRequest>(fetchInvocationRequest);
|
|
|
|
return {
|
|
cancelWorkflowScheduling,
|
|
fetchInvocationById,
|
|
fetchInvocationJobsSummaryForId,
|
|
fetchInvocationStepById,
|
|
getInvocationById,
|
|
getInvocationJobsSummaryById,
|
|
getInvocationLoadError,
|
|
getInvocationStepById,
|
|
getInvocationRequestById,
|
|
graphStepsByStoreId,
|
|
isLoadingInvocation,
|
|
};
|
|
});
|