Skip to content

Commit

Permalink
Corrected bugs introduced in 1.14.0 that caused issues with people ru…
Browse files Browse the repository at this point in the history
…nning the non lighttpd mode and getting inaccurate speed readings in the download and upload rate.
  • Loading branch information
vortex-5 committed Dec 20, 2019
1 parent 600eca5 commit ba7d3f0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
18 changes: 9 additions & 9 deletions bwmon/www/bwmon.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,27 +141,27 @@
<div class="left">
<div class="controls">
<div class="btn-group">
<label class="btn btn-default btn-responsive" ng-model="displayDensity" btn-radio="'Normal'">Normal</label>
<label class="btn btn-default btn-responsive" ng-model="displayDensity" btn-radio="'Compact'">Compact</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayDensity" btn-radio="'Normal'">Normal</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayDensity" btn-radio="'Compact'">Compact</label>
</div>
</div>
<div class="controls">
<div class="btn-group" tooltip="Shortcut double click on the device field in the table above to cycle through." tooltip-placement="right">
<label class="btn btn-default btn-responsive" ng-model="displayNameType" btn-radio="'NAME'">Name</label>
<label class="btn btn-default btn-responsive" ng-model="displayNameType" btn-radio="'IP'">IP</label>
<label class="btn btn-default btn-responsive" ng-model="displayNameType" btn-radio="'MAC'">MAC</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayNameType" btn-radio="'NAME'">Name</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayNameType" btn-radio="'IP'">IP</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayNameType" btn-radio="'MAC'">MAC</label>
</div>
</div>
<div class="controls">
<div class="btn-group">
<label class="btn btn-default btn-responsive" ng-model="displayRate" btn-radio="'Kbps'">Kbps</label>
<label class="btn btn-default btn-responsive" ng-model="displayRate" btn-radio="'KB/s'">KB/s</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayRate" btn-radio="'Kbps'">Kbps</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayRate" btn-radio="'KB/s'">KB/s</label>
</div>
</div>
<div class="controls">
<div class="btn-group">
<label class="btn btn-default btn-responsive" checked ng-model="displayStyleSheet" btn-radio="'bwmondark'">Dark</label>
<label class="btn btn-default btn-responsive" ng-model="displayStyleSheet" btn-radio="'bwmon'">Light</label>
<label class="btn btn-default btn-responsive" checked ng-model="$parent.displayStyleSheet" btn-radio="'bwmondark'">Dark</label>
<label class="btn btn-default btn-responsive" ng-model="$parent.displayStyleSheet" btn-radio="'bwmon'">Light</label>
</div>
</div>
<div class="controls">
Expand Down
38 changes: 20 additions & 18 deletions bwmon/www/bwmon.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,31 +563,31 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location',
return $scope.round(B) + ' B';
};

$scope.getRate = function(Bps10) {
if (isNaN(Bps10) || Bps10 < 0)
$scope.getRate = function(KBps10) {
if (isNaN(KBps10) || KBps10 < 0)
return '--';

if ($scope.displayRate === 'Kbps') {
let bps = Bps10 * $scope.CONVERSION_FACTOR;
let kbps = KBps10 * $scope.CONVERSION_FACTOR;

if (bps / Math.pow(1000,2) > 1)
return $scope.round(bps/Math.pow(1000,2)) + ' Gbps';
if (kbps / Math.pow(1000,2) > 1)
return $scope.round(kbps/Math.pow(1000,2)) + ' Gbps';

if (bps / 1000 > 1)
return $scope.round(bps/1000) + ' Mbps';
if (kbps / 1000 > 1)
return $scope.round(kbps/1000) + ' Mbps';

return $scope.round(bps) + ' Kbps';
return $scope.round(kbps) + ' Kbps';
}
else {
let Bps = Bps10;
let KBps = KBps10;

if (Bps / Math.pow(1000, 2) > 1)
return $scope.round(Bps/Math.pow(1000, 2)) + ' GB/s';
if (KBps / Math.pow(1000, 2) > 1)
return $scope.round(KBps/Math.pow(1000, 2)) + ' GB/s';

if (Bps / 1000 > 1)
return $scope.round(Bps/1000) + ' MB/s';
if (KBps / 1000 > 1)
return $scope.round(KBps/1000) + ' MB/s';

return $scope.round(Bps) + ' KB/s';
return $scope.round(KBps) + ' KB/s';
}
};

Expand Down Expand Up @@ -616,10 +616,11 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location',
let ip = $scope.macToIpMapping[device.mac];
if (!ip)
return 0;
return $scope.downRateAverage[ip];
return $scope.downRateAverage[ip]; // Average rates are already per second.
}
else {
return (device.postDown - device.preDown) / $scope.SERVICE_INTERVAL;
// postDown and preDown are in bytes we need KB
return ((device.postDown / 1000) - (device.preDown / 1000)) / $scope.SCRIPT_INTERVAL; // A rate is per second pre and post are per interval.
}
};

Expand All @@ -631,10 +632,11 @@ bwmon.controller('MainController', ['$scope', '$interval', '$http', '$location',
let ip = $scope.macToIpMapping[device.mac];
if (!ip)
return 0;
return $scope.upRateAverage[ip];
return $scope.upRateAverage[ip]; // Average rates are already per second.
}
else {
return (device.postUp - device.preUp) / $scope.SERVICE_INTERVAL;
// postUp and preUp are in bytes we need KB
return ((device.postUp / 1000) - (device.preUp / 1000)) / $scope.SCRIPT_INTERVAL; // A rate is per second pre and post are per interval.
}
};

Expand Down

0 comments on commit ba7d3f0

Please sign in to comment.