Maps - Keep edge black when link is 0 bps (#16192)

* Black when link is 0bps

* style
This commit is contained in:
PipoCanaja
2024-07-11 17:02:11 +02:00
committed by GitHub
parent d1fd57a64a
commit 56b5eff952

View File

@@ -114,8 +114,8 @@ class CustomMapDataController extends Controller
$edges[$edgeid]['port_topct'] = -1.0; $edges[$edgeid]['port_topct'] = -1.0;
$edges[$edgeid]['port_frompct'] = -1.0; $edges[$edgeid]['port_frompct'] = -1.0;
} else { } else {
$edges[$edgeid]['port_topct'] = round($rateto / $speedto * 100.0, 2); $edges[$edgeid]['port_topct'] = $rateto / $speedto * 100.0;
$edges[$edgeid]['port_frompct'] = round($ratefrom / $speedfrom * 100.0, 2); $edges[$edgeid]['port_frompct'] = $ratefrom / $speedfrom * 100.0;
} }
if ($edge->port->ifOperStatus != 'up') { if ($edge->port->ifOperStatus != 'up') {
// If the port is not online, show the same as speed unknown // 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_to'] = $this->speedColour($edges[$edgeid]['port_topct']);
$edges[$edgeid]['colour_from'] = $this->speedColour($edges[$edgeid]['port_frompct']); $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_tobps'] = $this->rateString($rateto);
$edges[$edgeid]['port_frombps'] = $this->rateString($ratefrom); $edges[$edgeid]['port_frombps'] = $this->rateString($ratefrom);
$edges[$edgeid]['width_to'] = $this->speedWidth($speedto); $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 // 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) // (255 being the max colour value and 50 is the max of the $pct calculation)
if ($pct < 0) { if ($pct <= 0) {
// Black if we can't determine the percentage (link down or speed 0) // Black if we can't determine the percentage (link down or speed 0), or link speed strictly 0
return '#000000'; return '#000000';
} elseif ($pct < 50) { } elseif ($pct < 50) {
// 100% green and slowly increase the red until we get to yellow // 100% green and slowly increase the red until we get to yellow