From bfc94df0bf33e520287e61b740c9c0af0481b8f3 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Thu, 7 Jan 2016 19:39:45 +0545 Subject: Shaper use full bandwidth units of measure In 2.2.* the shaper bandwidth type dropdowns show "Bit/s", "Kbit/s"... but in 2.3-BETA they are just showing "b", "Kb"... That is fixed in the various array() definitions here. I also added GetBwscaleText() function that will return the full text "Bit/s" etc associated with the current bandwidth type. Then call that in a couple of places that were displaying just the "raw" bandwidthtype on the screen. e.g. firewall_shaper_queues.php was displaying just "Kb" etc and now it will display "Kbit/s". That "issue" was in 2.2.* also - so that is an "enhancement". --- src/etc/inc/shaper.inc | 82 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 19 deletions(-) diff --git a/src/etc/inc/shaper.inc b/src/etc/inc/shaper.inc index 25afd86..3d48490 100644 --- a/src/etc/inc/shaper.inc +++ b/src/etc/inc/shaper.inc @@ -292,7 +292,7 @@ class altq_root_queue { var $interface; var $tbrconfig ; var $bandwidth; - var $bandwidthtype; /* b, Kb, Mb */ + var $bandwidthtype; /* b, Kb, Mb, Gb, % */ var $scheduler; var $qlimit; var $queues = array(); @@ -383,6 +383,28 @@ class altq_root_queue { $this->qlimit = $limit; } + function GetBwscaleText() { + switch ($this->bandwidthtype) { + case "b": + $bwscaletext = "Bit/s"; + break; + case "Kb": + $bwscaletext = "Kbit/s"; + break; + case "Mb": + $bwscaletext = "Mbit/s"; + break; + case "Gb": + $bwscaletext = "Gbit/s"; + break; + default: + /* For others that do not need translating like % */ + $bwscaletext = $this->bandwidthtype; + break; + } + return $bwscaletext; + } + function validate_input($data, &$input_errors) { $reqdfields[] = "bandwidth"; @@ -719,7 +741,7 @@ class altq_root_queue { $form .= 'Bandwidth'; $form .= ' '; $form .= '
'; - $form .= $this->GetBandwidth() . ' ' . $this->GetBwscale(); + $form .= $this->GetBandwidth() . ' ' . $this->GetBwscaleText(); $form .= '
'; $form .= '
'; @@ -792,10 +814,10 @@ class altq_root_queue { 'bandwidthtype', null, $this->GetBwscale(), - array('Kb' => 'Kb', - 'Mb' => 'Mb', - 'Gb' => 'Gb', - 'b' => 'b', + array('Kb' => 'Kbit/s', + 'Mb' => 'Mbit/s', + 'Gb' => 'Gbit/s', + 'b' => 'Bit/s', '%' => '%') )); @@ -1022,6 +1044,28 @@ class priq_queue { $this->qack = $ack; } + function GetBwscaleText() { + switch ($this->qbandwidthtype) { + case "b": + $bwscaletext = "Bit/s"; + break; + case "Kb": + $bwscaletext = "Kbit/s"; + break; + case "Mb": + $bwscaletext = "Mbit/s"; + break; + case "Gb": + $bwscaletext = "Gbit/s"; + break; + default: + /* For others that do not need translating like % */ + $bwscaletext = $this->qbandwidthtype; + break; + } + return $bwscaletext; + } + function build_javascript() { $javascript = "