From 5be106fc4f9aa0dc2103f35cc438dccb60b7031d Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Mon, 28 Nov 2022 22:49:23 +0800 Subject: [PATCH] fix: add `ProcessRelation` to entity types (#194) --- src/hooks/useMetricsProcessor.ts | 133 +++++++++--------- src/layout/components/SideBar.vue | 2 +- src/views/dashboard/data.ts | 1 + src/views/dashboard/graphs/TopList.vue | 6 +- .../network-profiling/components/NewTask.vue | 4 +- 5 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/hooks/useMetricsProcessor.ts b/src/hooks/useMetricsProcessor.ts index 979d9507..adefcd2b 100644 --- a/src/hooks/useMetricsProcessor.ts +++ b/src/hooks/useMetricsProcessor.ts @@ -73,79 +73,74 @@ export function useQueryProcessor(config: any) { topN: c.topN || 10, order: c.sortOrder || "DES", }; - } else if ([MetricQueryTypes.ReadRecords].includes(metricType)) { - variables.push(`$condition${index}: RecordCondition!`); - conditions[`condition${index}`] = { - name, - parentEntity: { - scope: config.catalog, - normal: selectorStore.currentService - ? selectorStore.currentService.normal - : true, - serviceName: ["All"].includes(dashboardStore.entity) - ? null - : selectorStore.currentService.value, - }, - topN: c.topN || 10, - order: c.sortOrder || "DES", - }; } else { - if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) { - const labels = (c.labelsIndex || "") - .split(",") - .map((item: string) => item.replace(/^\s*|\s*$/g, "")); - variables.push(`$labels${index}: [String!]!`); - conditions[`labels${index}`] = labels; - } - variables.push(`$condition${index}: MetricsCondition!`); - conditions[`condition${index}`] = { - name, - entity: { - scope: dashboardStore.entity, - serviceName: - dashboardStore.entity === "All" - ? undefined - : selectorStore.currentService.value, - normal: - dashboardStore.entity === "All" - ? undefined - : selectorStore.currentService.normal, - serviceInstanceName: [ - "ServiceInstance", - "ServiceInstanceRelation", - "ProcessRelation", - ].includes(dashboardStore.entity) - ? selectorStore.currentPod && selectorStore.currentPod.value - : undefined, - endpointName: dashboardStore.entity.includes("Endpoint") - ? selectorStore.currentPod && selectorStore.currentPod.value - : undefined, - processName: dashboardStore.entity.includes("Process") - ? selectorStore.currentProcess && selectorStore.currentProcess.value - : undefined, - destNormal: isRelation - ? selectorStore.currentDestService.normal - : undefined, - destServiceName: isRelation - ? selectorStore.currentDestService.value - : undefined, - destServiceInstanceName: [ - "ServiceInstanceRelation", - "ProcessRelation", - ].includes(dashboardStore.entity) + const entity = { + scope: config.catalog, + serviceName: + dashboardStore.entity === "All" + ? undefined + : selectorStore.currentService.value, + normal: + dashboardStore.entity === "All" + ? undefined + : selectorStore.currentService.normal, + serviceInstanceName: [ + "ServiceInstance", + "ServiceInstanceRelation", + "ProcessRelation", + ].includes(dashboardStore.entity) + ? selectorStore.currentPod && selectorStore.currentPod.value + : undefined, + endpointName: dashboardStore.entity.includes("Endpoint") + ? selectorStore.currentPod && selectorStore.currentPod.value + : undefined, + processName: dashboardStore.entity.includes("Process") + ? selectorStore.currentProcess && selectorStore.currentProcess.value + : undefined, + destNormal: isRelation + ? selectorStore.currentDestService.normal + : undefined, + destServiceName: isRelation + ? selectorStore.currentDestService.value + : undefined, + destServiceInstanceName: [ + "ServiceInstanceRelation", + "ProcessRelation", + ].includes(dashboardStore.entity) + ? selectorStore.currentDestPod && selectorStore.currentDestPod.value + : undefined, + destEndpointName: + dashboardStore.entity === "EndpointRelation" ? selectorStore.currentDestPod && selectorStore.currentDestPod.value : undefined, - destEndpointName: - dashboardStore.entity === "EndpointRelation" - ? selectorStore.currentDestPod && - selectorStore.currentDestPod.value - : undefined, - destProcessName: dashboardStore.entity.includes("ProcessRelation") - ? selectorStore.currentDestProcess && - selectorStore.currentDestProcess.value - : undefined, - }, + destProcessName: dashboardStore.entity.includes("ProcessRelation") + ? selectorStore.currentDestProcess && + selectorStore.currentDestProcess.value + : undefined, }; + if ([MetricQueryTypes.ReadRecords].includes(metricType)) { + variables.push(`$condition${index}: RecordCondition!`); + conditions[`condition${index}`] = { + name, + parentEntity: entity, + topN: c.topN || 10, + order: c.sortOrder || "DES", + }; + } else { + entity.scope = dashboardStore.entity; + if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) { + const labels = (c.labelsIndex || "") + .split(",") + .map((item: string) => item.replace(/^\s*|\s*$/g, "")); + variables.push(`$labels${index}: [String!]!`); + conditions[`labels${index}`] = labels; + } + variables.push(`$condition${index}: MetricsCondition!`); + conditions[`condition${index}`] = { + name, + entity, + }; + } } if (metricType === MetricQueryTypes.ReadLabeledMetricsValues) { return `${name}${index}: ${metricType}(condition: $condition${index}, labels: $labels${index}, duration: $duration)${RespFields[metricType]}`; diff --git a/src/layout/components/SideBar.vue b/src/layout/components/SideBar.vue index 403f56cb..8414697c 100644 --- a/src/layout/components/SideBar.vue +++ b/src/layout/components/SideBar.vue @@ -107,7 +107,7 @@ if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) { } else { appStore.setIsMobile(false); } -const isCollapse = ref(true); +const isCollapse = ref(false); const controlMenu = () => { isCollapse.value = !isCollapse.value; }; diff --git a/src/views/dashboard/data.ts b/src/views/dashboard/data.ts index ff3d28a6..b386e28a 100644 --- a/src/views/dashboard/data.ts +++ b/src/views/dashboard/data.ts @@ -145,6 +145,7 @@ export enum MetricCatalog { SERVICE_RELATION = "ServiceRelation", SERVICE_INSTANCE_RELATION = "ServiceInstanceRelation", ENDPOINT_RELATION = "EndpointRelation", + PROCESS_RELATION = "ProcessRelation", } export const EntityType = [ { value: "Service", label: "Service", key: 1 }, diff --git a/src/views/dashboard/graphs/TopList.vue b/src/views/dashboard/graphs/TopList.vue index 91aab28f..aac7fce9 100644 --- a/src/views/dashboard/graphs/TopList.vue +++ b/src/views/dashboard/graphs/TopList.vue @@ -43,7 +43,11 @@ limitations under the License. --> diff --git a/src/views/dashboard/related/network-profiling/components/NewTask.vue b/src/views/dashboard/related/network-profiling/components/NewTask.vue index 9bce52a7..44b2058c 100644 --- a/src/views/dashboard/related/network-profiling/components/NewTask.vue +++ b/src/views/dashboard/related/network-profiling/components/NewTask.vue @@ -69,8 +69,8 @@ const activeNames = ref([0]); const conditionsList = ref([ { uriRegex: "", - when4xx: InitTaskField.Whenxx[0].value, - when5xx: InitTaskField.Whenxx[1].value, + when4xx: InitTaskField.Whenxx[1].value, + when5xx: InitTaskField.Whenxx[0].value, minDuration: NaN, }, ]);