diff --git a/src/store/modules/topology.ts b/src/store/modules/topology.ts index 58dd7ef6..2c425c93 100644 --- a/src/store/modules/topology.ts +++ b/src/store/modules/topology.ts @@ -544,11 +544,13 @@ export const topologyStore = defineStore({ this.setLinkClientMetrics(res.data.data); return res.data; }, - async getHierarchyServiceTopology(params: { serviceId: string; layer: string }) { - if (!(params.serviceId && params.layer)) { + async getHierarchyServiceTopology() { + if (!(this.node.id && this.node.layer)) { return new Promise((resolve) => resolve({})); } - const res: AxiosResponse = await graphql.query("getHierarchyServiceTopology").params(params); + const res: AxiosResponse = await graphql + .query("getHierarchyServiceTopology") + .params({ serviceId: this.node.id, layer: this.node.layer }); if (res.data.errors) { return res.data; } diff --git a/src/views/dashboard/related/topology/components/HierarchyMap.vue b/src/views/dashboard/related/topology/components/HierarchyMap.vue index dc3177ae..6cf086ad 100644 --- a/src/views/dashboard/related/topology/components/HierarchyMap.vue +++ b/src/views/dashboard/related/topology/components/HierarchyMap.vue @@ -120,7 +120,6 @@ limitations under the License. --> const graph = ref>(null); const settings = ref(props.config); const graphConfig = computed(() => props.config.graph || {}); - const depth = ref(graphConfig.value.depth || 2); const topologyLayout = ref({}); const popover = ref>(null); const graphWidth = ref(100); @@ -154,7 +153,7 @@ limitations under the License. --> } async function freshNodes() { topologyStore.setHierarchyServiceNode(null); - const resp = await getTopology(); + const resp = await topologyStore.getHierarchyServiceTopology(); loading.value = false; if (resp && resp.errors) { @@ -164,7 +163,6 @@ limitations under the License. --> } async function update() { - window.addEventListener("resize", resize); await initLegendMetrics(); draw(); popover.value = d3.select("#popover"); @@ -287,9 +285,10 @@ limitations under the License. --> event.stopPropagation(); hideTip(); topologyStore.setHierarchyServiceNode(d); - // handleGoDashboard(d.name); + handleGoDashboard(); } - function handleGoDashboard(name: string) { + function handleGoDashboard() { + const name = ""; // todo const path = `/dashboard/${dashboardStore.layerId}/${EntityType[0].value}/${topologyStore.node.id}/${name}`; const routeUrl = router.resolve({ path }); @@ -297,28 +296,11 @@ limitations under the License. --> dashboardStore.setEntity(origin); } - async function getTopology() { - const ids = selectorStore.services.map((d: Service) => d.id); - const serviceIds = dashboardStore.entity === EntityType[0].value ? [selectorStore.currentService.id] : ids; - const resp = await topologyStore.getDepthServiceTopology(serviceIds, Number(depth.value)); - return resp; - } - function resize() { - const dom = document.querySelector(".hierarchy-related")?.getBoundingClientRect() || { - height: 40, - width: 0, - }; - height.value = dom.height - 80; - width.value = dom.width; - } function svgEvent() { topologyStore.setHierarchyServiceNode(null); dashboardStore.selectWidget(props.config); } - onBeforeUnmount(() => { - window.removeEventListener("resize", resize); - }); watch( () => appStore.durationTime, () => {