From 56b5eff9523299de230702d177264ed1a07abc03 Mon Sep 17 00:00:00 2001 From: PipoCanaja <38363551+PipoCanaja@users.noreply.github.com> Date: Thu, 11 Jul 2024 17:02:11 +0200 Subject: [PATCH] Maps - Keep edge black when link is 0 bps (#16192) * Black when link is 0bps * style --- app/Http/Controllers/Maps/CustomMapDataController.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Maps/CustomMapDataController.php b/app/Http/Controllers/Maps/CustomMapDataController.php index 697281db0d..8c3bfd85ca 100644 --- a/app/Http/Controllers/Maps/CustomMapDataController.php +++ b/app/Http/Controllers/Maps/CustomMapDataController.php @@ -114,8 +114,8 @@ class CustomMapDataController extends Controller $edges[$edgeid]['port_topct'] = -1.0; $edges[$edgeid]['port_frompct'] = -1.0; } else { - $edges[$edgeid]['port_topct'] = round($rateto / $speedto * 100.0, 2); - $edges[$edgeid]['port_frompct'] = round($ratefrom / $speedfrom * 100.0, 2); + $edges[$edgeid]['port_topct'] = $rateto / $speedto * 100.0; + $edges[$edgeid]['port_frompct'] = $ratefrom / $speedfrom * 100.0; } if ($edge->port->ifOperStatus != 'up') { // If the port is not online, show the same as speed unknown @@ -125,6 +125,8 @@ class CustomMapDataController extends Controller $edges[$edgeid]['colour_to'] = $this->speedColour($edges[$edgeid]['port_topct']); $edges[$edgeid]['colour_from'] = $this->speedColour($edges[$edgeid]['port_frompct']); } + $edges[$edgeid]['port_topct'] = round($edges[$edgeid]['port_topct'], 2); + $edges[$edgeid]['port_frompct'] = round($edges[$edgeid]['port_frompct'], 2); $edges[$edgeid]['port_tobps'] = $this->rateString($rateto); $edges[$edgeid]['port_frombps'] = $this->rateString($ratefrom); $edges[$edgeid]['width_to'] = $this->speedWidth($speedto); @@ -305,8 +307,8 @@ class CustomMapDataController extends Controller { // For the maths below, the 5.1 is worked out as 255 / 50 // (255 being the max colour value and 50 is the max of the $pct calculation) - if ($pct < 0) { - // Black if we can't determine the percentage (link down or speed 0) + if ($pct <= 0) { + // Black if we can't determine the percentage (link down or speed 0), or link speed strictly 0 return '#000000'; } elseif ($pct < 50) { // 100% green and slowly increase the red until we get to yellow