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;
},
async getLinkClientMetrics(linkClientMetrics: string[]) {
if (!linkClientMetrics.length) {
this.setLinkClientMetrics({});
return;
}
const idsC = this.calls
.filter((i: Call) => i.detectPoints.includes("CLIENT"))
.map((b: Call) => b.id);
@ -414,6 +418,10 @@ export const topologyStore = defineStore({
}
},
async getLinkServerMetrics(linkServerMetrics: string[]) {
if (!linkServerMetrics.length) {
this.setLinkServerMetrics({});
return;
}
const idsS = this.calls
.filter((i: Call) => i.detectPoints.includes("SERVER"))
.map((b: Call) => b.id);
@ -425,6 +433,10 @@ export const topologyStore = defineStore({
}
},
async queryNodeMetrics(nodeMetrics: string[]) {
if (!nodeMetrics.length) {
this.setNodeMetricValue({});
return;
}
const ids = this.nodes.map((d: Node) => d.id);
const param = await useQueryTopologyMetrics(nodeMetrics, ids);
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 prop="name" label="Name">
<template #default="scope">
<span @click="handleView(scope.row)">{{ scope.row.name }}</span>
<span class="cp" @click="handleView(scope.row)">{{
scope.row.name
}}</span>
</template>
</el-table-column>
<el-table-column prop="layer" label="Layer" width="200" />

View File

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

View File

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