From 7d78871eeec90e367f3e486edbd1b68898e1a313 Mon Sep 17 00:00:00 2001 From: lpfeup Date: Sat, 21 Jan 2017 05:01:32 +0000 Subject: [PATCH] #446 fix(container-stats): fix issue in stats view with empty network data (#502) --- app/components/stats/statsController.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/components/stats/statsController.js b/app/components/stats/statsController.js index 88e6e1f34..eed96ef18 100644 --- a/app/components/stats/statsController.js +++ b/app/components/stats/statsController.js @@ -162,16 +162,18 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP $scope.networkName = Object.keys(data.networks)[0]; data.network = data.networks[$scope.networkName]; } - var rxBytes = 0, txBytes = 0; - if (lastRxBytes !== 0 || lastTxBytes !== 0) { - // These will be zero on first call, ignore to prevent large graph spike - rxBytes = data.network.rx_bytes - lastRxBytes; - txBytes = data.network.tx_bytes - lastTxBytes; + 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 + rxBytes = data.network.rx_bytes - lastRxBytes; + txBytes = data.network.tx_bytes - lastTxBytes; + } + lastRxBytes = data.network.rx_bytes; + lastTxBytes = data.network.tx_bytes; + networkChart.addData([rxBytes, txBytes], new Date(data.read).toLocaleTimeString()); + networkChart.removeData(); } - lastRxBytes = data.network.rx_bytes; - lastTxBytes = data.network.tx_bytes; - networkChart.addData([rxBytes, txBytes], new Date(data.read).toLocaleTimeString()); - networkChart.removeData(); } function calculateCPUPercent(stats) {