feat: add node status

This commit is contained in:
Fine 2023-03-17 11:52:46 +08:00
parent 0dd95021f3
commit 367f95332e

View File

@ -29,15 +29,7 @@ limitations under the License. -->
@click="handleNodeClick($event, n)" @click="handleNodeClick($event, n)"
class="topo-node" class="topo-node"
> >
<circle <circle class="node" r="18" stroke-width="6" :stroke="getNodeStatus(n)" fill="none" :cx="n.x" :cy="n.y" />
class="node"
r="18"
stroke-width="6"
:stroke="n.isReal ? '#72c59f' : '#ed374d'"
fill="none"
:cx="n.x"
:cy="n.y"
/>
<image <image
width="18" width="18"
height="18" height="18"
@ -215,11 +207,6 @@ limitations under the License. -->
return; return;
} }
} }
function svgEvent() {
topologyStore.setNode(null);
topologyStore.setLink(null);
dashboardStore.selectWidget(props.config);
}
function draw() { function draw() {
const levels = []; const levels = [];
const nodes = topologyStore.nodes.sort((a: any, b: any) => b.service_cpm - a.service_cpm); const nodes = topologyStore.nodes.sort((a: any, b: any) => b.service_cpm - a.service_cpm);
@ -265,6 +252,24 @@ limitations under the License. -->
} }
} }
} }
function getNodeStatus(d: any) {
const legend = settings.value.legend;
if (!legend) {
return "#72c59f";
}
if (!legend.length) {
return "#72c59f";
}
let c = true;
for (const l of legend) {
if (l.condition === "<") {
c = c && d[l.name] < Number(l.value);
} else {
c = c && d[l.name] > Number(l.value);
}
}
return c && d.isReal ? "#f18586" : "#72c59f";
}
function showNodeTip(event: MouseEvent, data: Node) { function showNodeTip(event: MouseEvent, data: Node) {
const nodeMetrics: string[] = settings.value.nodeMetrics || []; const nodeMetrics: string[] = settings.value.nodeMetrics || [];
const nodeMetricConfig = settings.value.nodeMetricConfig || []; const nodeMetricConfig = settings.value.nodeMetricConfig || [];
@ -474,6 +479,11 @@ limitations under the License. -->
} }
} }
} }
function svgEvent() {
topologyStore.setNode(null);
topologyStore.setLink(null);
dashboardStore.selectWidget(props.config);
}
async function freshNodes() { async function freshNodes() {
if (!svg.value) { if (!svg.value) {
return; return;