From 8479ca14b7e94d0ef27da923fab56984e8aad6ec Mon Sep 17 00:00:00 2001 From: Fine Date: Thu, 8 Jun 2023 16:51:15 +0800 Subject: [PATCH] feat: remove typesOfMQE --- src/hooks/useExpressionsProcessor.ts | 12 +++++------- src/views/dashboard/graphs/EndpointList.vue | 5 ++--- src/views/dashboard/graphs/InstanceList.vue | 5 ++--- src/views/dashboard/graphs/ServiceList.vue | 5 ++--- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/hooks/useExpressionsProcessor.ts b/src/hooks/useExpressionsProcessor.ts index 448549d0..1adea5d1 100644 --- a/src/hooks/useExpressionsProcessor.ts +++ b/src/hooks/useExpressionsProcessor.ts @@ -159,7 +159,6 @@ export async function useExpressionsQueryPodsMetrics( pods: Array<(Instance | Endpoint | Service) & Indexable>, config: { expressions: string[]; - typesOfMQE: string[]; subExpressions: string[]; metricConfig: MetricConfigOpt[]; }, @@ -168,16 +167,13 @@ export async function useExpressionsQueryPodsMetrics( function expressionsGraphqlPods() { const metrics: string[] = []; const subMetrics: string[] = []; - const metricTypes: string[] = []; config.expressions = config.expressions || []; config.subExpressions = config.subExpressions || []; - config.typesOfMQE = config.typesOfMQE || []; for (let i = 0; i < config.expressions.length; i++) { if (config.expressions[i]) { metrics.push(config.expressions[i]); subMetrics.push(config.subExpressions[i]); - metricTypes.push(config.typesOfMQE[i]); } } if (!metrics.length) { @@ -236,7 +232,9 @@ export async function useExpressionsQueryPodsMetrics( const c: MetricConfigOpt = (config.metricConfig && config.metricConfig[index]) || {}; const k = "expression" + idx + index; const sub = "subexpression" + idx + index; - const results = (resp.data[k] && resp.data[k].results) || []; + const obj = resp.data[k] || {}; + const results = obj.results || []; + const typesOfMQE = obj.type || ""; const subResults = (resp.data[sub] && resp.data[sub].results) || []; if (results.length > 1) { @@ -263,7 +261,7 @@ export async function useExpressionsQueryPodsMetrics( if (!j) { names.push(name); metricConfigArr.push({ ...c, index: i }); - metricTypesArr.push(config.typesOfMQE[index]); + metricTypesArr.push(typesOfMQE); } } } else { @@ -287,7 +285,7 @@ export async function useExpressionsQueryPodsMetrics( names.push(name); subNames.push(subName); metricConfigArr.push(c); - metricTypesArr.push(config.typesOfMQE[index]); + metricTypesArr.push(typesOfMQE); } } } diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue index c3653dec..e0de2209 100644 --- a/src/views/dashboard/graphs/EndpointList.vue +++ b/src/views/dashboard/graphs/EndpointList.vue @@ -168,13 +168,12 @@ limitations under the License. --> } async function queryEndpointExpressions(currentPods: Endpoint[]) { const expressions = props.config.expressions || []; - const typesOfMQE = props.config.typesOfMQE || []; const subExpressions = props.config.subExpressions || []; - if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) { + if (expressions.length && expressions[0]) { const params = await useExpressionsQueryPodsMetrics( currentPods, - { ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions }, + { metricConfig: metricConfig.value || [], expressions, subExpressions }, EntityType[2].value, ); endpoints.value = params.data; diff --git a/src/views/dashboard/graphs/InstanceList.vue b/src/views/dashboard/graphs/InstanceList.vue index f3b32dca..608756d4 100644 --- a/src/views/dashboard/graphs/InstanceList.vue +++ b/src/views/dashboard/graphs/InstanceList.vue @@ -203,13 +203,12 @@ limitations under the License. --> async function queryInstanceExpressions(currentInstances: Instance[]) { const expressions = props.config.expressions || []; - const typesOfMQE = props.config.typesOfMQE || []; const subExpressions = props.config.subExpressions || []; - if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) { + if (expressions.length && expressions[0]) { const params = await useExpressionsQueryPodsMetrics( currentInstances, - { ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions }, + { metricConfig: metricConfig.value || [], expressions, subExpressions }, EntityType[3].value, ); instances.value = params.data; diff --git a/src/views/dashboard/graphs/ServiceList.vue b/src/views/dashboard/graphs/ServiceList.vue index 83e27c70..945d0e8e 100644 --- a/src/views/dashboard/graphs/ServiceList.vue +++ b/src/views/dashboard/graphs/ServiceList.vue @@ -251,13 +251,12 @@ limitations under the License. --> } async function queryServiceExpressions(currentServices: Service[]) { const expressions = props.config.expressions || []; - const typesOfMQE = props.config.typesOfMQE || []; const subExpressions = props.config.subExpressions || []; - if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) { + if (expressions.length && expressions[0]) { const params = await useExpressionsQueryPodsMetrics( currentServices, - { ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions }, + { metricConfig: metricConfig.value || [], expressions, subExpressions }, EntityType[0].value, ); services.value = params.data;