This commit is contained in:
Fine 2024-11-27 10:12:21 +08:00
parent 283d922ab6
commit 68bd4c7c60
3 changed files with 6 additions and 16 deletions

View File

@ -25,13 +25,12 @@ import type {
import { store } from "@/store";
import graphql from "@/graphql";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
import type { AxiosResponse } from "axios";
import type { Instance } from "@/types/selector";
interface AsyncProfilingState {
taskList: Array<Recordable<AsyncProfilingTask>>;
labels: Option[];
asyncProfilingTips: string;
selectedTask: Recordable<AsyncProfilingTask>;
taskProgress: Recordable<AsyncProfilerTaskProgress>;
instances: Instance[];
@ -42,8 +41,6 @@ export const asyncProfilingStore = defineStore({
id: "asyncProfiling",
state: (): AsyncProfilingState => ({
taskList: [],
labels: [{ value: "", label: "" }],
asyncProfilingTips: "",
selectedTask: {},
taskProgress: {},
instances: [],
@ -53,15 +50,11 @@ export const asyncProfilingStore = defineStore({
setSelectedTask(task: Recordable<AsyncProfilingTask>) {
this.selectedTask = task || {};
},
async getTaskList(params: { serviceId: string; startTime: number; endTime: number }) {
if (!params.serviceId) {
return new Promise((resolve) => resolve({}));
}
async getTaskList(params?: { startTime: number; endTime: number }) {
const selectorStore = useSelectorStore();
const res: AxiosResponse = await graphql
.query("getAsyncTaskList")
.params({ request: { ...params, limit: 10000 } });
this.asyncProfilingTips = "";
.params({ request: { ...params, limit: 10000, serviceId: selectorStore.currentService.id } });
if (res.data.errors) {
return res.data;
}

View File

@ -77,12 +77,10 @@ limitations under the License. -->
}
async function createTask() {
emits("close");
const params = {
serviceId: selectorStore.currentService.id,
serviceInstanceIds: serviceInstanceIds.value,
duration: Number(duration.value),
createTime: new Date().getTime(),
events: asyncEvents.value,
execArgs: execArgs.value,
};
@ -96,6 +94,7 @@ limitations under the License. -->
ElMessage.error(tip);
return;
}
emits("close");
ElMessage.success("Task created successfully");
}
</script>

View File

@ -153,9 +153,7 @@ limitations under the License. -->
});
async function fetchTasks() {
const res = await asyncProfilingStore.getTaskList({
serviceId: selectorStore.currentService.id,
});
const res = await asyncProfilingStore.getTaskList();
if (res.errors) {
ElMessage.error(res.errors);
}