From db2c980cbe395b18ac40595bb494acdbe0d8a169 Mon Sep 17 00:00:00 2001 From: Herbert Wolverson Date: Thu, 18 Jul 2024 12:20:03 -0500 Subject: [PATCH] Improved ns scale RTT display. --- .../js_build/src/dashlets/endpoints_by_country.js | 6 +++--- .../js_build/src/dashlets/top10flows_bytes.js | 6 +++--- .../js_build/src/dashlets/top10flows_rate.js | 6 +++--- .../src/node_manager/js_build/src/helpers/scaling.js | 9 +++++++++ 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/rust/lqosd/src/node_manager/js_build/src/dashlets/endpoints_by_country.js b/src/rust/lqosd/src/node_manager/js_build/src/dashlets/endpoints_by_country.js index 34257d95..4c444040 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/dashlets/endpoints_by_country.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/dashlets/endpoints_by_country.js @@ -1,6 +1,6 @@ import {BaseDashlet} from "./base_dashlet"; import {clearDashDiv, theading} from "../helpers/builders"; -import {scaleNumber, scaleNanos} from "../helpers/scaling"; +import {scaleNumber, scaleNanos, lerpGreenToRedViaOrange, rttNanosAsSpan} from "../helpers/scaling"; export class Top10EndpointsByCountry extends BaseDashlet { constructor(slot) { @@ -68,11 +68,11 @@ export class Top10EndpointsByCountry extends BaseDashlet { row.appendChild(dlu); let rttd = document.createElement("td"); - rttd.innerText = scaleNanos(r[2][0]); + rttd.innerHTML = rttNanosAsSpan(r[2][0]); row.appendChild(rttd); let rttu = document.createElement("td"); - rttu.innerText = scaleNanos(r[2][1]); + rttu.innerHTML = rttNanosAsSpan(r[2][1]); row.appendChild(rttu); t.appendChild(row); diff --git a/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_bytes.js b/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_bytes.js index 971f05be..ddac2579 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_bytes.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_bytes.js @@ -1,6 +1,6 @@ import {BaseDashlet} from "./base_dashlet"; import {clearDashDiv, theading} from "../helpers/builders"; -import {scaleNumber, scaleNanos, formatRetransmit} from "../helpers/scaling"; +import {scaleNumber, formatRetransmit, rttNanosAsSpan} from "../helpers/scaling"; import {RttCache} from "../helpers/rtt_cache"; export class Top10FlowsBytes extends BaseDashlet { @@ -98,11 +98,11 @@ export class Top10FlowsBytes extends BaseDashlet { } let rttD = document.createElement("td"); - rttD.innerText = scaleNanos(rtt.down, 0); + rttD.innerHTML = rttNanosAsSpan(rtt.down); row.appendChild(rttD); let rttU = document.createElement("td"); - rttU.innerText = scaleNanos(rtt.up, 0); + rttU.innerHTML = rttNanosAsSpan(rtt.up); row.appendChild(rttU); let tcp1 = document.createElement("td"); diff --git a/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_rate.js b/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_rate.js index ae6849f6..1b514c08 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_rate.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/dashlets/top10flows_rate.js @@ -1,6 +1,6 @@ import {BaseDashlet} from "./base_dashlet"; import {clearDashDiv, theading} from "../helpers/builders"; -import {scaleNumber, scaleNanos, formatRetransmit} from "../helpers/scaling"; +import {scaleNumber, formatRetransmit, rttNanosAsSpan} from "../helpers/scaling"; import {RttCache} from "../helpers/rtt_cache"; export class Top10FlowsRate extends BaseDashlet { @@ -98,11 +98,11 @@ export class Top10FlowsRate extends BaseDashlet { } let rttD = document.createElement("td"); - rttD.innerText = scaleNanos(rtt.down, 0); + rttD.innerHTML = rttNanosAsSpan(rtt.down); row.appendChild(rttD); let rttU = document.createElement("td"); - rttU.innerText = scaleNanos(rtt.up, 0); + rttU.innerHTML = rttNanosAsSpan(rtt.up); row.appendChild(rttU); let tcp1 = document.createElement("td"); diff --git a/src/rust/lqosd/src/node_manager/js_build/src/helpers/scaling.js b/src/rust/lqosd/src/node_manager/js_build/src/helpers/scaling.js index 3f9a6f94..5d802f05 100644 --- a/src/rust/lqosd/src/node_manager/js_build/src/helpers/scaling.js +++ b/src/rust/lqosd/src/node_manager/js_build/src/helpers/scaling.js @@ -133,4 +133,13 @@ export function lerpColor(color1, color2, weight) { export function formatPercent(percent, digits=0) { let color = lerpGreenToRedViaOrange(100-Math.min(100,percent), 100); return "" + percent.toFixed(digits) + "%"; +} + +export function rttNanosAsSpan(rttNanos, precision=0) { + let rttInMs = Math.min(200, rttNanos / 1000000); + let color = lerpGreenToRedViaOrange(200 - rttInMs, 200); + let html = ""; + html += scaleNanos(rttNanos, precision); + html += ""; + return html; } \ No newline at end of file