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

View File

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

View File

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