From 9854f8a6abd09ef50ad02269e9af004d41a6ad4b Mon Sep 17 00:00:00 2001 From: Kia Lam Date: Wed, 9 Feb 2022 09:19:25 -0800 Subject: [PATCH] Use alpha decay percentage instead of absolute value for loading screen. --- awx/ui/src/screens/TopologyView/MeshGraph.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/awx/ui/src/screens/TopologyView/MeshGraph.js b/awx/ui/src/screens/TopologyView/MeshGraph.js index 546b3b44bc..a30d5785d2 100644 --- a/awx/ui/src/screens/TopologyView/MeshGraph.js +++ b/awx/ui/src/screens/TopologyView/MeshGraph.js @@ -226,9 +226,7 @@ function MeshGraph({ showLegend, zoom }) { .attr('y2', (d) => d.target.y); node.attr('transform', (d) => `translate(${d.x},${d.y})`); - if (simulation.alpha() < simulation.alphaMin()) { - d3.select('.simulation-loader').style('visibility', 'hidden'); - } + calculateAlphaDecay(simulation.alpha(), simulation.alphaMin(), 35); } svg.call(zoom); @@ -310,9 +308,17 @@ function MeshGraph({ showLegend, zoom }) { setIsNodeSelected(true); setSelectedNode(n); } + + function calculateAlphaDecay(a, aMin, x) { + const decayPercentage = Math.min((aMin / a) * 100); + if (decayPercentage >= x) { + d3.select('.simulation-loader').style('visibility', 'hidden'); + } + } }; async function redirectToDetailsPage() { + // TODO: redirect to top-level instances details page const { id: nodeId } = selectedNode; const { data: { results },