From 44f6e32953fce49364e52cb61cdf6ed3b17bd045 Mon Sep 17 00:00:00 2001 From: Fine Date: Wed, 7 Jun 2023 15:45:41 +0800 Subject: [PATCH] feat: update --- src/hooks/useExpressionsProcessor.ts | 14 ++++++++++---- src/hooks/useListConfig.ts | 2 +- .../configuration/widget/metric/Index.vue | 9 +++++---- src/views/dashboard/graphs/EndpointList.vue | 9 ++++++--- src/views/dashboard/graphs/InstanceList.vue | 7 +++++-- src/views/dashboard/graphs/ServiceList.vue | 7 +++++-- .../dashboard/graphs/components/ColumnGraph.vue | 11 ++++++----- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/hooks/useExpressionsProcessor.ts b/src/hooks/useExpressionsProcessor.ts index c57234f7..693c5a99 100644 --- a/src/hooks/useExpressionsProcessor.ts +++ b/src/hooks/useExpressionsProcessor.ts @@ -214,6 +214,7 @@ export async function useExpressionsQueryPodsMetrics( return {}; } const names: string[] = []; + const subNames: string[] = []; const metricConfigArr: MetricConfigOpt[] = []; const metricTypesArr: string[] = []; const data = pods.map((d: any, idx: number) => { @@ -256,16 +257,21 @@ export async function useExpressionsQueryPodsMetrics( return d; } const name = config.expressions[index] || ""; + const subName = config.subExpressions[index] || ""; if (!d[name]) { d[name] = {}; } d[name]["avg"] = [results[0].values[0].value]; if (subResults[0]) { - d[name]["values"] = subResults[0].values.map((d: { value: number }) => d.value); + if (!d[subName]) { + d[subName] = {}; + } + d[subName]["values"] = subResults[0].values.map((d: { value: number }) => d.value); } const j = names.find((d: string) => d === name); if (!j) { names.push(name); + subNames.push(subName); metricConfigArr.push(c); metricTypesArr.push(config.typesOfMQE[index]); } @@ -274,7 +280,7 @@ export async function useExpressionsQueryPodsMetrics( return d; }); - return { data, names, metricConfigArr, metricTypesArr }; + return { data, names, subNames, metricConfigArr, metricTypesArr }; } const dashboardStore = useDashboardStore(); const params = await expressionsGraphqlPods(); @@ -284,7 +290,7 @@ export async function useExpressionsQueryPodsMetrics( ElMessage.error(json.errors); return {}; } - const { data, names, metricTypesArr, metricConfigArr } = expressionsPodsSource(json); + const expressionParams = expressionsPodsSource(json); - return { data, names, metricTypesArr, metricConfigArr }; + return expressionParams; } diff --git a/src/hooks/useListConfig.ts b/src/hooks/useListConfig.ts index 004cd594..d0705b5d 100644 --- a/src/hooks/useListConfig.ts +++ b/src/hooks/useListConfig.ts @@ -17,7 +17,7 @@ import { MetricQueryTypes, Calculations } from "./data"; import { MetricModes } from "@/views/dashboard/data"; -export function useListConfig(config: Indexable, index: string) { +export function useListConfig(config: Indexable, index: number) { if (config.metricModes === MetricModes.Expression) { return { isLinear: false, diff --git a/src/views/dashboard/configuration/widget/metric/Index.vue b/src/views/dashboard/configuration/widget/metric/Index.vue index c54cdfda..44a07d8f 100644 --- a/src/views/dashboard/configuration/widget/metric/Index.vue +++ b/src/views/dashboard/configuration/widget/metric/Index.vue @@ -490,13 +490,14 @@ limitations under the License. --> const metricConfig = config[index] ? config.splice(index, 1) : config; let p = {}; if (isExpression.value) { - p = { typesOfMQE: states.metricTypes, expressions: states.metrics }; if (states.isList) { - states.subMetrics = [""]; - states.subMetricTypes = [""]; - states.subTips = [""]; + states.subMetrics.splice(index, 1); + states.subMetricTypes.splice(index, 1); + states.subTips.splice(index, 1); p = { ...p, + typesOfMQE: states.metricTypes, + expressions: states.metrics, subTypesOfMQE: states.subMetricTypes, subExpressions: states.subMetrics, }; diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue index 6781886a..c3653dec 100644 --- a/src/views/dashboard/graphs/EndpointList.vue +++ b/src/views/dashboard/graphs/EndpointList.vue @@ -36,9 +36,9 @@ limitations under the License. --> ([]); + const colSubMetrics = ref([]); const metricConfig = ref(props.config.metricConfig || []); const metricTypes = ref(props.config.metricTypes || []); const metricMode = ref(props.config.metricMode); @@ -180,11 +181,13 @@ limitations under the License. --> colMetrics.value = params.names; metricTypes.value = params.metricTypesArr; metricConfig.value = params.metricConfigArr; + colSubMetrics.value = params.colSubMetrics; return; } endpoints.value = currentPods; colMetrics.value = []; + colSubMetrics.value = []; metricTypes.value = []; metricConfig.value = []; } @@ -230,9 +233,9 @@ limitations under the License. --> ); diff --git a/src/views/dashboard/graphs/InstanceList.vue b/src/views/dashboard/graphs/InstanceList.vue index 5b754ac1..f3b32dca 100644 --- a/src/views/dashboard/graphs/InstanceList.vue +++ b/src/views/dashboard/graphs/InstanceList.vue @@ -35,9 +35,9 @@ limitations under the License. --> ([]); + const colSubMetrics = ref([]); const metricConfig = ref(props.config.metricConfig || []); const metricTypes = ref(props.config.metricTypes || []); const pods = ref([]); // all instances @@ -213,12 +214,14 @@ limitations under the License. --> ); instances.value = params.data; colMetrics.value = params.names; + colSubMetrics.value = params.colSubMetrics; metricTypes.value = params.metricTypesArr; metricConfig.value = params.metricConfigArr; return; } instances.value = currentInstances; + colSubMetrics.value = []; colMetrics.value = []; metricTypes.value = []; metricConfig.value = []; @@ -281,7 +284,7 @@ limitations under the License. --> ); diff --git a/src/views/dashboard/graphs/components/ColumnGraph.vue b/src/views/dashboard/graphs/components/ColumnGraph.vue index 43299417..d3b8fe76 100644 --- a/src/views/dashboard/graphs/components/ColumnGraph.vue +++ b/src/views/dashboard/graphs/components/ColumnGraph.vue @@ -48,7 +48,8 @@ limitations under the License. -->