feat: update layers for Hierarchy topology

This commit is contained in:
Fine 2024-01-30 15:45:17 +08:00
parent 341224a10c
commit 4da6b4ae3c
2 changed files with 27 additions and 2 deletions

View File

@ -599,7 +599,12 @@ export const topologyStore = defineStore({
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const { currentService } = useSelectorStore(); const { currentService } = useSelectorStore();
const id = this.node ? this.node.id : (currentService || {}).id; const id = this.node ? this.node.id : (currentService || {}).id;
const layer = this.node ? this.node.layer : dashboardStore.layerId; let layer = dashboardStore.layerId;
if (this.node) {
layer = this.node.layers.includes(dashboardStore.layerId)
? dashboardStore.layerId
: this.node.layers.filter((d: string) => d !== dashboardStore.layerId)[0];
}
if (!(id && layer)) { if (!(id && layer)) {
return new Promise((resolve) => resolve({})); return new Promise((resolve) => resolve({}));
} }

View File

@ -128,7 +128,13 @@ limitations under the License. -->
{{ item.title }} {{ item.title }}
</span> </span>
</div> </div>
<el-dialog v-model="hierarchyRelated" :destroy-on-close="true" @closed="hierarchyRelated = false" width="640px"> <el-dialog
v-model="hierarchyRelated"
:title="getHierarchyTitle()"
:destroy-on-close="true"
@closed="hierarchyRelated = false"
width="640px"
>
<div class="hierarchy-related"> <div class="hierarchy-related">
<hierarchy-map :config="config" /> <hierarchy-map :config="config" />
</div> </div>
@ -269,6 +275,20 @@ limitations under the License. -->
currentNode.value = null; currentNode.value = null;
} }
function getHierarchyTitle() {
if (!currentNode.value) {
return;
}
if (currentNode.value.layers.includes(dashboardStore.layerId)) {
return `${dashboardStore.layerId} --> ${currentNode.value.name}`;
}
const layer = currentNode.value.layers.filter((d: string) => d !== dashboardStore.layerId);
if (layer.length) {
return `${layer[0]} --> ${currentNode.value.name}`;
}
return "";
}
async function initLegendMetrics() { async function initLegendMetrics() {
if (!topologyStore.nodes.length) { if (!topologyStore.nodes.length) {
return; return;