This commit is contained in:
Qiuxia Fan 2022-03-22 11:57:42 +08:00
parent b48358e43d
commit 632e5089a7
4 changed files with 29 additions and 7 deletions

View File

@ -403,6 +403,10 @@ export const topologyStore = defineStore({
return res.data; return res.data;
}, },
async getLinkClientMetrics(linkClientMetrics: string[]) { async getLinkClientMetrics(linkClientMetrics: string[]) {
if (!linkClientMetrics.length) {
this.setLinkClientMetrics({});
return;
}
const idsC = this.calls const idsC = this.calls
.filter((i: Call) => i.detectPoints.includes("CLIENT")) .filter((i: Call) => i.detectPoints.includes("CLIENT"))
.map((b: Call) => b.id); .map((b: Call) => b.id);
@ -414,6 +418,10 @@ export const topologyStore = defineStore({
} }
}, },
async getLinkServerMetrics(linkServerMetrics: string[]) { async getLinkServerMetrics(linkServerMetrics: string[]) {
if (!linkServerMetrics.length) {
this.setLinkServerMetrics({});
return;
}
const idsS = this.calls const idsS = this.calls
.filter((i: Call) => i.detectPoints.includes("SERVER")) .filter((i: Call) => i.detectPoints.includes("SERVER"))
.map((b: Call) => b.id); .map((b: Call) => b.id);
@ -425,6 +433,10 @@ export const topologyStore = defineStore({
} }
}, },
async queryNodeMetrics(nodeMetrics: string[]) { async queryNodeMetrics(nodeMetrics: string[]) {
if (!nodeMetrics.length) {
this.setNodeMetricValue({});
return;
}
const ids = this.nodes.map((d: Node) => d.id); const ids = this.nodes.map((d: Node) => d.id);
const param = await useQueryTopologyMetrics(nodeMetrics, ids); const param = await useQueryTopologyMetrics(nodeMetrics, ids);
const res = await this.getNodeMetricValue(param); const res = await this.getNodeMetricValue(param);

View File

@ -46,7 +46,9 @@ limitations under the License. -->
<el-table-column type="selection" width="55" /> <el-table-column type="selection" width="55" />
<el-table-column prop="name" label="Name"> <el-table-column prop="name" label="Name">
<template #default="scope"> <template #default="scope">
<span @click="handleView(scope.row)">{{ scope.row.name }}</span> <span class="cp" @click="handleView(scope.row)">{{
scope.row.name
}}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="layer" label="Layer" width="200" /> <el-table-column prop="layer" label="Layer" width="200" />

View File

@ -132,9 +132,9 @@ onMounted(async () => {
if (resp && resp.errors) { if (resp && resp.errors) {
ElMessage.error(resp.errors); ElMessage.error(resp.errors);
} }
topologyStore.getLinkClientMetrics(settings.value.linkClientMetrics); topologyStore.getLinkClientMetrics(settings.value.linkClientMetrics || []);
topologyStore.getLinkServerMetrics(settings.value.linkServerMetrics); topologyStore.getLinkServerMetrics(settings.value.linkServerMetrics || []);
topologyStore.queryNodeMetrics(settings.value.nodeMetrics); topologyStore.queryNodeMetrics(settings.value.nodeMetrics || []);
const dom = document.querySelector(".topology")?.getBoundingClientRect() || { const dom = document.querySelector(".topology")?.getBoundingClientRect() || {
height: 40, height: 40,
width: 0, width: 0,
@ -243,6 +243,7 @@ function handleLinkClick(event: any, d: Call) {
if (!settings.value.linkDashboard) { if (!settings.value.linkDashboard) {
return; return;
} }
const origin = dashboardStore.entity;
const e = const e =
dashboardStore.entity === EntityType[1].value dashboardStore.entity === EntityType[1].value
? EntityType[0].value ? EntityType[0].value
@ -258,6 +259,7 @@ function handleLinkClick(event: any, d: Call) {
}/${p.name.split(" ").join("-")}`; }/${p.name.split(" ").join("-")}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
dashboardStore.setEntity(origin);
} }
function update() { function update() {
// node element // node element
@ -387,6 +389,7 @@ async function handleInspect() {
update(); update();
} }
function handleGoEndpoint(name: string) { function handleGoEndpoint(name: string) {
const origin = dashboardStore.entity;
const p = getDashboard({ const p = getDashboard({
name, name,
layer: dashboardStore.layerId, layer: dashboardStore.layerId,
@ -399,8 +402,10 @@ function handleGoEndpoint(name: string) {
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
dashboardStore.setEntity(origin);
} }
function handleGoInstance(name: string) { function handleGoInstance(name: string) {
const origin = dashboardStore.entity;
const p = getDashboard({ const p = getDashboard({
name, name,
layer: dashboardStore.layerId, layer: dashboardStore.layerId,
@ -413,8 +418,10 @@ function handleGoInstance(name: string) {
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
dashboardStore.setEntity(origin);
} }
function handleGoDashboard(name: string) { function handleGoDashboard(name: string) {
const origin = dashboardStore.entity;
const p = getDashboard({ const p = getDashboard({
name, name,
layer: dashboardStore.layerId, layer: dashboardStore.layerId,
@ -427,6 +434,7 @@ function handleGoDashboard(name: string) {
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
window.open(routeUrl.href, "_blank"); window.open(routeUrl.href, "_blank");
dashboardStore.setEntity(origin);
} }
function handleGoAlarm() { function handleGoAlarm() {
const path = `/alarm`; const path = `/alarm`;

View File

@ -135,9 +135,9 @@ async function loadTopology(id: string) {
}; };
height.value = dom.height - 70; height.value = dom.height - 70;
width.value = dom.width - 5; width.value = dom.width - 5;
topologyStore.getLinkClientMetrics(settings.value.linkClientMetrics); topologyStore.getLinkClientMetrics(settings.value.linkClientMetrics || []);
topologyStore.getLinkServerMetrics(settings.value.linkServerMetrics); topologyStore.getLinkServerMetrics(settings.value.linkServerMetrics || []);
topologyStore.queryNodeMetrics(settings.value.nodeMetrics); topologyStore.queryNodeMetrics(settings.value.nodeMetrics || []);
} }
function inspect() { function inspect() {