mirror of https://github.com/portainer/portainer
fix(stats): fix a small issue within statsController
parent
52ab0bd50d
commit
38244312c5
|
@ -22,6 +22,8 @@ function (Pagination, $scope, Messages, $timeout, Container, ContainerTop, $stat
|
||||||
$scope.containerTop = data;
|
$scope.containerTop = data;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var destroyed = false;
|
||||||
|
var timeout;
|
||||||
$document.ready(function(){
|
$document.ready(function(){
|
||||||
var cpuLabels = [];
|
var cpuLabels = [];
|
||||||
var cpuData = [];
|
var cpuData = [];
|
||||||
|
@ -117,6 +119,7 @@ function (Pagination, $scope, Messages, $timeout, Container, ContainerTop, $stat
|
||||||
});
|
});
|
||||||
$scope.networkLegend = $sce.trustAsHtml(networkChart.generateLegend());
|
$scope.networkLegend = $sce.trustAsHtml(networkChart.generateLegend());
|
||||||
|
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -139,8 +142,7 @@ function (Pagination, $scope, Messages, $timeout, Container, ContainerTop, $stat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var destroyed = false;
|
|
||||||
var timeout;
|
|
||||||
$scope.$on('$destroy', function () {
|
$scope.$on('$destroy', function () {
|
||||||
destroyed = true;
|
destroyed = true;
|
||||||
$timeout.cancel(timeout);
|
$timeout.cancel(timeout);
|
||||||
|
@ -198,13 +200,13 @@ function (Pagination, $scope, Messages, $timeout, Container, ContainerTop, $stat
|
||||||
}
|
}
|
||||||
return cpuPercent;
|
return cpuPercent;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
function setUpdateStatsTimeout() {
|
function setUpdateStatsTimeout() {
|
||||||
if(!destroyed) {
|
if(!destroyed) {
|
||||||
timeout = $timeout(updateStats, 5000);
|
timeout = $timeout(updateStats, 5000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
Container.get({id: $stateParams.id}, function (d) {
|
Container.get({id: $stateParams.id}, function (d) {
|
||||||
$scope.container = d;
|
$scope.container = d;
|
||||||
|
|
Loading…
Reference in New Issue