mirror of https://github.com/portainer/portainer
pull/526/head
parent
7d78871eee
commit
579241db92
|
@ -114,6 +114,12 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP
|
||||||
});
|
});
|
||||||
$scope.networkLegend = $sce.trustAsHtml(networkChart.generateLegend());
|
$scope.networkLegend = $sce.trustAsHtml(networkChart.generateLegend());
|
||||||
|
|
||||||
|
function setUpdateStatsTimeout() {
|
||||||
|
if(!destroyed) {
|
||||||
|
timeout = $timeout(updateStats, 5000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateStats() {
|
function updateStats() {
|
||||||
Container.stats({id: $stateParams.id}, function (d) {
|
Container.stats({id: $stateParams.id}, function (d) {
|
||||||
var arr = Object.keys(d).map(function (key) {
|
var arr = Object.keys(d).map(function (key) {
|
||||||
|
@ -129,15 +135,17 @@ function (Settings, $scope, Messages, $timeout, Container, ContainerTop, $stateP
|
||||||
updateCpuChart(d);
|
updateCpuChart(d);
|
||||||
updateMemoryChart(d);
|
updateMemoryChart(d);
|
||||||
updateNetworkChart(d);
|
updateNetworkChart(d);
|
||||||
timeout = $timeout(updateStats, 5000);
|
setUpdateStatsTimeout();
|
||||||
}, function () {
|
}, function () {
|
||||||
Messages.error('Unable to retrieve stats', {}, 'Is this container running?');
|
Messages.error('Unable to retrieve stats', {}, 'Is this container running?');
|
||||||
timeout = $timeout(updateStats, 5000);
|
setUpdateStatsTimeout();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var destroyed = false;
|
||||||
var timeout;
|
var timeout;
|
||||||
$scope.$on('$destroy', function () {
|
$scope.$on('$destroy', function () {
|
||||||
|
destroyed = true;
|
||||||
$timeout.cancel(timeout);
|
$timeout.cancel(timeout);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue