diff --git a/src/components/Graph.vue b/src/components/Graph.vue index dd4fd445..619d71f0 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -41,8 +41,11 @@ onMounted(() => { watch( () => props.option, - (opt) => { - setOptions(opt); + (newVal, oldVal) => { + if (JSON.stringify(newVal) === JSON.stringify(oldVal)) { + return; + } + setOptions(newVal); } ); diff --git a/src/hooks/useProcessor.ts b/src/hooks/useProcessor.ts index 8dad9179..888694f0 100644 --- a/src/hooks/useProcessor.ts +++ b/src/hooks/useProcessor.ts @@ -79,10 +79,10 @@ export function useQueryProcessor(config: any) { ? undefined : selectorStore.currentService.normal, serviceInstanceName: dashboardStore.entity.includes("ServiceInstance") - ? selectorStore.currentPod.value + ? selectorStore.currentPod && selectorStore.currentPod.value : undefined, endpointName: dashboardStore.entity.includes("Endpoint") - ? selectorStore.currentPod.value + ? selectorStore.currentPod && selectorStore.currentPod.value : undefined, destNormal: isRelation ? selectorStore.currentDestService.normal @@ -92,11 +92,13 @@ export function useQueryProcessor(config: any) { : undefined, destServiceInstanceName: dashboardStore.entity === "ServiceInstanceRelation" - ? selectorStore.currentDestPod.value + ? selectorStore.currentDestPod && + selectorStore.currentDestPod.value : undefined, destEndpointName: dashboardStore.entity === "EndpointRelation" - ? selectorStore.currentDestPod.value + ? selectorStore.currentDestPod && + selectorStore.currentDestPod.value : undefined, }, }; diff --git a/src/store/modules/selectors.ts b/src/store/modules/selectors.ts index fe8aa820..1f3cc5b3 100644 --- a/src/store/modules/selectors.ts +++ b/src/store/modules/selectors.ts @@ -48,6 +48,7 @@ export const selectorStore = defineStore({ this.currentService = service; }, setCurrentPod(pod: Nullable) { + console.log(pod); this.currentPod = pod; }, async fetchLayers(): Promise { diff --git a/src/views/dashboard/configuration/MetricOptions.vue b/src/views/dashboard/configuration/MetricOptions.vue index 15ce0d57..09677570 100644 --- a/src/views/dashboard/configuration/MetricOptions.vue +++ b/src/views/dashboard/configuration/MetricOptions.vue @@ -93,6 +93,7 @@ import { EntityType, ChartTypes, PodsChartTypes, + TableEntity, } from "../data"; import { ElMessage } from "element-plus"; import Icon from "@/components/Icon.vue"; @@ -127,7 +128,11 @@ states.visTypes = setVisTypes(); setMetricType(); async function setMetricType(catalog?: string) { - catalog = catalog || dashboardStore.entity; + if (states.isTable) { + catalog = catalog || TableEntity[graph.type]; + } else { + catalog = catalog || dashboardStore.entity; + } const json = await dashboardStore.fetchMetricList(); if (json.errors) { ElMessage.error(json.errors); diff --git a/src/views/dashboard/controls/Widget.vue b/src/views/dashboard/controls/Widget.vue index 9599e42b..2393da29 100644 --- a/src/views/dashboard/controls/Widget.vue +++ b/src/views/dashboard/controls/Widget.vue @@ -62,7 +62,6 @@ limitations under the License. --> diff --git a/src/views/dashboard/graphs/InstanceList.vue b/src/views/dashboard/graphs/InstanceList.vue index 68b478b4..aadcb2b0 100644 --- a/src/views/dashboard/graphs/InstanceList.vue +++ b/src/views/dashboard/graphs/InstanceList.vue @@ -50,13 +50,13 @@ limitations under the License. -->
@@ -128,6 +128,8 @@ async function queryInstance() { return; } searchInstances.value = selectorStore.pods; + instances.value = searchInstances.value.splice(0, pageSize); + queryInstanceMetrics(instances.value); } async function queryInstanceMetrics(currentInstances: Instance[]) { @@ -168,10 +170,7 @@ function searchList() { watch( () => [props.config.metricTypes, props.config.metrics], () => { - if (dashboardStore.selectedGrid.i === props.config.i) { - const currentInstances = searchInstances.value.splice(0, pageSize); - queryInstanceMetrics(currentInstances); - } + queryInstanceMetrics(instances.value); } ); diff --git a/src/views/dashboard/graphs/ServiceList.vue b/src/views/dashboard/graphs/ServiceList.vue index 22bdce5e..b5f1430d 100644 --- a/src/views/dashboard/graphs/ServiceList.vue +++ b/src/views/dashboard/graphs/ServiceList.vue @@ -43,7 +43,7 @@ limitations under the License. --> @@ -88,7 +88,13 @@ const props = defineProps({ type: Object, }, config: { - type: Object as PropType, + type: Object as PropType< + ServiceListConfig & { + i: string; + metrics: string[]; + metricTypes: string[]; + } + >, default: () => ({ dashboardName: "", fontSize: 12 }), }, intervalTime: { type: Array as PropType, default: () => [] }, @@ -114,7 +120,7 @@ async function queryServices() { services.value = selectorStore.services.splice(0, pageSize); } async function queryServiceMetrics(currentServices: Service[]) { - const { metrics } = dashboardStore.selectedGrid; + const { metrics } = props.config; if (metrics.length && metrics[0]) { const params = await useQueryPodsMetrics( @@ -147,14 +153,9 @@ function searchList() { services.value = searchServices.value.splice(0, pageSize); } watch( - () => [ - dashboardStore.selectedGrid.metricTypes, - dashboardStore.selectedGrid.metrics, - ], + () => [props.config.metricTypes, props.config.metrics], () => { - if (dashboardStore.selectedGrid.i === props.config.i) { - queryServiceMetrics(services.value); - } + queryServiceMetrics(services.value); } );