From 29a282e0c904c3f4f9277f2fe52453750bbe594a Mon Sep 17 00:00:00 2001 From: Fine Date: Tue, 23 May 2023 17:43:25 +0800 Subject: [PATCH] feat: add selectors --- src/store/modules/continous-profiling.ts | 32 ++++++++ .../related/continuous-profiling/Content.vue | 3 +- .../components/GraphPanel.vue | 79 +++++++++++++++++++ .../components/Policy.vue | 8 +- 4 files changed, 117 insertions(+), 5 deletions(-) create mode 100644 src/views/dashboard/related/continuous-profiling/components/GraphPanel.vue diff --git a/src/store/modules/continous-profiling.ts b/src/store/modules/continous-profiling.ts index 2af4ee6b..3182fac4 100644 --- a/src/store/modules/continous-profiling.ts +++ b/src/store/modules/continous-profiling.ts @@ -15,8 +15,10 @@ * limitations under the License. */ import { defineStore } from "pinia"; +import { useAppStoreWithOut } from "@/store/modules/app"; import type { StrategyItem, CheckItems } from "@/types/continous-profiling"; import type { ProcessNode, EBPFTaskList } from "@/types/ebpf"; +import type { Instance, Process } from "@/types/selector"; import { store } from "@/store"; import graphql from "@/graphql"; import type { AxiosResponse } from "axios"; @@ -32,6 +34,8 @@ interface ContinousProfilingState { selectedContinousTask: Recordable; errorTip: string; errorReason: string; + processes: Process[]; + instances: Instance[]; nodes: ProcessNode[]; calls: Call[]; node: Nullable; @@ -52,6 +56,8 @@ export const continousProfilingStore = defineStore({ selectedContinousTask: {}, errorReason: "", errorTip: "", + processes: [], + instances: [], nodes: [], calls: [], node: null, @@ -192,6 +198,32 @@ export const continousProfilingStore = defineStore({ } return res.data; }, + async getServiceInstances(serviceId: string): Promise> { + if (!serviceId) { + return null; + } + const res: AxiosResponse = await graphql.query("queryInstances").params({ + serviceId, + duration: useAppStoreWithOut().durationTime, + }); + if (!res.data.errors) { + this.instances = res.data.data.pods || []; + } + return res.data; + }, + async getProcesses(instanceId: string): Promise> { + if (!instanceId) { + return null; + } + const res: AxiosResponse = await graphql.query("queryProcesses").params({ + instanceId, + duration: useAppStoreWithOut().durationTime, + }); + if (!res.data.errors) { + this.processes = res.data.data.processes || []; + } + return res.data; + }, async getProcessTopology(params: { duration: DurationTime; serviceInstanceId: string }) { this.loadNodes = true; const res: AxiosResponse = await graphql.query("getProcessTopology").params(params); diff --git a/src/views/dashboard/related/continuous-profiling/Content.vue b/src/views/dashboard/related/continuous-profiling/Content.vue index 35fc3e6d..a2f1dded 100644 --- a/src/views/dashboard/related/continuous-profiling/Content.vue +++ b/src/views/dashboard/related/continuous-profiling/Content.vue @@ -18,7 +18,7 @@ limitations under the License. --> -
graph
+ + diff --git a/src/views/dashboard/related/continuous-profiling/components/Policy.vue b/src/views/dashboard/related/continuous-profiling/components/Policy.vue index 50fdf462..a3948859 100644 --- a/src/views/dashboard/related/continuous-profiling/components/Policy.vue +++ b/src/views/dashboard/related/continuous-profiling/components/Policy.vue @@ -83,13 +83,13 @@ limitations under the License. --> const { t } = useI18n(); const states = reactive(props.data); - function changeType(opt: any[]) { - states.type = (opt.map((d) => d.value)[0] || {}).value; + function changeType(opt: { value: string }[]) { + states.type = opt[0].value; emits("edit", states, props.order); } - function changeMonitorType(opt: any[], index: number) { - states.checkItems[index].type = (opt.map((d) => d.value)[0] || {}).value; + function changeMonitorType(opt: { value: string }[], index: number) { + states.checkItems[index].type = opt[0].value; emits("edit", states, props.order); }