From 726c4478f56ebb9bab840d5c2e966834ea2ab224 Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Thu, 25 Jul 2024 16:17:10 -0500 Subject: [PATCH] Sankey is clickable to navigate to the circuit on the top/worst N charts. --- .../js_build/src/all_tree_sankey.js | 3 ++- .../js_build/src/graphs/top_n_sankey.js | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/rust/lqosd/src/node_manager/js_build/src/all_tree_sankey.js b/src/rust/lqosd/src/node_manager/js_build/src/all_tree_sankey.js index 4f597328..46ed2881 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/all_tree_sankey.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/all_tree_sankey.js @@ -32,7 +32,8 @@ class AllTreeSankey extends DashboardGraph { this.option && this.chart.setOption(this.option); this.chart.hideLoading(); this.chart.on('click', (params) => { - //console.log(params.name); + console.log(params.name); + console.log(this.nodeMap); let name = params.name; // If it contains a >, it's a link if (name.indexOf(" > ") === -1) { diff --git a/src/rust/lqosd/src/node_manager/js_build/src/graphs/top_n_sankey.js b/src/rust/lqosd/src/node_manager/js_build/src/graphs/top_n_sankey.js index 35ebe1d3..fddcbbe4 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/graphs/top_n_sankey.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/graphs/top_n_sankey.js @@ -4,6 +4,7 @@ import {lerpColor, lerpGreenToRedViaOrange, scaleNumber} from "../helpers/scalin export class TopNSankey extends DashboardGraph { constructor(id) { super(id); + this.nodeMap = {}; this.option = { series: [ { @@ -22,6 +23,23 @@ export class TopNSankey extends DashboardGraph { this.option.series[0].links = links; this.chart.hideLoading(); this.chart.setOption(this.option); + + this.chart.on('click', (params) => { + let name = params.name; + // Trim to before " (" + name = name.substring(0, name.indexOf(" (")); + if (name.indexOf(" > ") === -1) { + if (this.nodeMap[name] !== undefined) { + window.location.href = "/circuit.html?id=" + encodeURI(this.nodeMap[name]); + } + } else { + let actualName = params.data.target; + actualName = actualName.substring(0, actualName.indexOf(" (")); + if (this.nodeMap[actualName] !== undefined) { + window.location.href = "/circuit.html?id=" + encodeURI(this.nodeMap[actualName]); + } + } + }); } processMessage(msg) { @@ -33,7 +51,10 @@ export class TopNSankey extends DashboardGraph { label: "Root", }); + this.nodeMap = {}; msg.data.forEach((r) => { + this.nodeMap[r.ip_address] = r.circuit_id; + let label = { fontSize: 9, color: "#999"