From a1d9d4d4b4726d9c5ea3a3d1fafdb25960aaf3ae Mon Sep 17 00:00:00 2001 From: Fine Date: Fri, 12 Jan 2024 20:27:07 +0800 Subject: [PATCH] feat: add topology --- src/store/modules/topology.ts | 8 ++++++-- src/views/dashboard/panel/Tool.vue | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/store/modules/topology.ts b/src/store/modules/topology.ts index a4390aa3..b14e09fd 100644 --- a/src/store/modules/topology.ts +++ b/src/store/modules/topology.ts @@ -600,12 +600,16 @@ export const topologyStore = defineStore({ return res.data; }, async getHierarchyServiceTopology() { - if (!(this.node.id && this.node.layer)) { + const dashboardStore = useDashboardStore(); + const { currentService } = useSelectorStore(); + const id = this.node ? this.node.id : (currentService || {}).id; + const layer = this.node ? this.node.layer : dashboardStore.layerId; + if (!(id && layer)) { return new Promise((resolve) => resolve({})); } const res: AxiosResponse = await graphql .query("getHierarchyServiceTopology") - .params({ serviceId: this.node.id, layer: this.node.layer }); + .params({ serviceId: id, layer: layer }); if (res.data.errors) { return res.data; } diff --git a/src/views/dashboard/panel/Tool.vue b/src/views/dashboard/panel/Tool.vue index 45a6139a..16dab18d 100644 --- a/src/views/dashboard/panel/Tool.vue +++ b/src/views/dashboard/panel/Tool.vue @@ -26,6 +26,9 @@ limitations under the License. --> @change="changeService" class="selectors" /> + + +
@@ -135,7 +138,8 @@ limitations under the License. -->
@@ -159,13 +163,16 @@ limitations under the License. --> WidgetType, } from "@/views/dashboard/data"; import { useSelectorStore } from "@/store/modules/selectors"; + import { useTopologyStore } from "@/store/modules/topology"; import { ElMessage } from "element-plus"; import type { Option } from "@/types/app"; import InstanceMap from "@/views/dashboard/related/topology/pod/InstanceMap.vue"; + import HierarchyMap from "@/views/dashboard/related/topology/service/HierarchyMap.vue"; const { t } = useI18n(); const dashboardStore = useDashboardStore(); const selectorStore = useSelectorStore(); + const topologyStore = useTopologyStore(); const appStore = useAppStoreWithOut(); const params = useRoute().params; const toolIcons = ref<{ name: string; content: string; id: WidgetType }[]>(AllTools); @@ -651,6 +658,10 @@ limitations under the License. --> }; fetchPods(EntityType[6].value, selectorStore.currentDestService.id, false, param); } + function viewTopology() { + showHierarchy.value = true; + topologyStore.setNode(null); + } watch( () => dashboardStore.entity, (newVal, oldVal) => { @@ -730,7 +741,7 @@ limitations under the License. --> } .hierarchy-related { - height: 400px; + height: 600px; width: 600px; overflow: auto; }