diff --git a/src/hooks/useProcessor.ts b/src/hooks/useProcessor.ts index b50ffb46..a5573594 100644 --- a/src/hooks/useProcessor.ts +++ b/src/hooks/useProcessor.ts @@ -195,7 +195,8 @@ function aggregation(json: { export function useQueryPodsMetrics( pods: Array, - config: { metrics: string[]; metricTypes: string[] } + config: { metrics: string[]; metricTypes: string[] }, + scope: string ) { const appStore = useAppStoreWithOut(); const selectorStore = useSelectorStore(); @@ -207,9 +208,10 @@ export function useQueryPodsMetrics( const fragmentList = pods.map((d: Instance | Endpoint, index: number) => { const param = { - scope: "ServiceInstance", + scope, serviceName: currentService.label, - serviceInstanceName: d.label, + serviceInstanceName: scope === "ServiceInstance" ? d.label : undefined, + endpointName: scope === "Endpoint" ? d.label : undefined, normal: currentService.normal, }; const f = config.metrics.map((name: string, idx: number) => { diff --git a/src/views/dashboard/graphs/EndpointList.vue b/src/views/dashboard/graphs/EndpointList.vue index eff152f9..e9937d39 100644 --- a/src/views/dashboard/graphs/EndpointList.vue +++ b/src/views/dashboard/graphs/EndpointList.vue @@ -100,8 +100,8 @@ const selectorStore = useSelectorStore(); const dashboardStore = useDashboardStore(); const chartLoading = ref(false); const endpoints = ref([]); -const currentEndpoints = ref([]); -const pageSize = 7; +const searchEndpoints = ref([]); +const pageSize = 5; const searchText = ref(""); queryEndpoints(); @@ -115,16 +115,18 @@ async function queryEndpoints() { ElMessage.error(resp.errors); return; } + searchEndpoints.value = selectorStore.endpoints; endpoints.value = selectorStore.endpoints.splice(0, pageSize); - queryMetrics(endpoints.value); + queryEndpointMetrics(endpoints.value); } -async function queryMetrics(currentPods: Endpoint[]) { +async function queryEndpointMetrics(currentPods: Endpoint[]) { const { metrics } = dashboardStore.selectedGrid; if (metrics.length && metrics[0]) { const params = await useQueryPodsMetrics( currentPods, - dashboardStore.selectedGrid + dashboardStore.selectedGrid, + "Endpoint" ); const json = await dashboardStore.fetchMetricValue(params); @@ -142,13 +144,14 @@ async function queryMetrics(currentPods: Endpoint[]) { endpoints.value = currentPods; } function changePage(pageIndex: number) { - endpoints.value = selectorStore.endpoints.splice(pageIndex - 1, pageSize); + endpoints.value = searchEndpoints.value.splice(pageIndex - 1, pageSize); } function searchList() { - currentEndpoints.value = selectorStore.instances.filter( + const currentEndpoints = selectorStore.instances.filter( (d: { label: string }) => d.label.includes(searchText.value) ); - endpoints.value = currentEndpoints.value.splice(0, pageSize); + searchEndpoints.value = currentEndpoints; + endpoints.value = currentEndpoints.splice(0, pageSize); } watch( () => [ @@ -156,11 +159,14 @@ watch( dashboardStore.selectedGrid.metrics, ], () => { - const currentPods = currentEndpoints.value.splice(0, pageSize); - queryMetrics(currentPods); + queryEndpointMetrics(endpoints.value); } ); diff --git a/src/views/dashboard/graphs/InstanceList.vue b/src/views/dashboard/graphs/InstanceList.vue index b290f5c9..bc0e345d 100644 --- a/src/views/dashboard/graphs/InstanceList.vue +++ b/src/views/dashboard/graphs/InstanceList.vue @@ -115,16 +115,17 @@ async function queryInstance() { searchInstances.value = selectorStore.instances; const currentInstances = searchInstances.value.splice(0, pageSize); - queryMetrics(currentInstances); + queryInstanceMetrics(currentInstances); } -async function queryMetrics(currentInstances: Instance[]) { +async function queryInstanceMetrics(currentInstances: Instance[]) { const { metrics } = dashboardStore.selectedGrid; if (metrics.length && metrics[0]) { const params = await useQueryPodsMetrics( currentInstances, - dashboardStore.selectedGrid + dashboardStore.selectedGrid, + "ServiceInstance" ); const json = await dashboardStore.fetchMetricValue(params); @@ -158,8 +159,7 @@ watch( dashboardStore.selectedGrid.metrics, ], () => { - const currentInstances = searchInstances.value.splice(0, pageSize); - queryMetrics(currentInstances); + queryInstanceMetrics(instances.value); } ); diff --git a/src/views/dashboard/graphs/ServiceList.vue b/src/views/dashboard/graphs/ServiceList.vue index c4d71efc..0b6cb3de 100644 --- a/src/views/dashboard/graphs/ServiceList.vue +++ b/src/views/dashboard/graphs/ServiceList.vue @@ -75,10 +75,11 @@ defineProps({ type: Object as PropType, default: () => ({ dashboardName: "", fontSize: 12 }), }, + intervalTime: { type: Array as PropType, default: () => [] }, }); const selectorStore = useSelectorStore(); const chartLoading = ref(false); -const pageSize = 7; +const pageSize = 5; const services = ref<{ label: string; layer: string }[]>([]); const searchServices = ref<{ layer: string; label: string }[]>([]); const searchText = ref(""); @@ -105,4 +106,8 @@ function searchList() {