#446 fix(container-stats): fix issue in stats view with empty network data (#502)

pull/526/head
lpfeup 2017-01-21 05:01:32 +00:00 committed by Anthony Lapenna
parent 3a6e9d2fbe
commit 7d78871eee
1 changed files with 11 additions and 9 deletions

View File

@ -162,6 +162,7 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP
$scope.networkName = Object.keys(data.networks)[0];
data.network = data.networks[$scope.networkName];
}
if(data.network) {
var rxBytes = 0, txBytes = 0;
if (lastRxBytes !== 0 || lastTxBytes !== 0) {
// These will be zero on first call, ignore to prevent large graph spike
@ -173,6 +174,7 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP
networkChart.addData([rxBytes, txBytes], new Date(data.read).toLocaleTimeString());
networkChart.removeData();
}
}
function calculateCPUPercent(stats) {
// Same algorithm the official client uses: https://github.com/docker/docker/blob/master/api/client/stats.go#L195-L208