|
|
@ -1,5 +1,6 @@
|
|
|
|
angular.module('dashboard', [])
|
|
|
|
angular.module('dashboard', [])
|
|
|
|
.controller('DashboardController', ['$scope', 'Container', 'Image', 'Settings', 'LineChart', function ($scope, Container, Image, Settings, LineChart) {
|
|
|
|
.controller('DashboardController', ['$scope', 'Config', 'Container', 'Image', 'Settings', 'LineChart',
|
|
|
|
|
|
|
|
function ($scope, Config, Container, Image, Settings, LineChart) {
|
|
|
|
|
|
|
|
|
|
|
|
$scope.containerData = {};
|
|
|
|
$scope.containerData = {};
|
|
|
|
|
|
|
|
|
|
|
@ -17,30 +18,52 @@ angular.module('dashboard', [])
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Container.query({all: 1}, function (d) {
|
|
|
|
function fetchDashboardData() {
|
|
|
|
var running = 0;
|
|
|
|
Container.query({all: 1}, function (d) {
|
|
|
|
var ghost = 0;
|
|
|
|
var running = 0;
|
|
|
|
var stopped = 0;
|
|
|
|
var ghost = 0;
|
|
|
|
|
|
|
|
var stopped = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: centralize that
|
|
|
|
var containers = d;
|
|
|
|
var containers = d.filter(function (container) {
|
|
|
|
if (hiddenLabels) {
|
|
|
|
return container.Image !== 'swarm';
|
|
|
|
containers = hideContainers(d);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < containers.length; i++) {
|
|
|
|
|
|
|
|
var item = containers[i];
|
|
|
|
|
|
|
|
if (item.Status === "Ghost") {
|
|
|
|
|
|
|
|
ghost += 1;
|
|
|
|
|
|
|
|
} else if (item.Status.indexOf('Exit') !== -1) {
|
|
|
|
|
|
|
|
stopped += 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
running += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$scope.containerData.running = running;
|
|
|
|
|
|
|
|
$scope.containerData.stopped = stopped;
|
|
|
|
|
|
|
|
$scope.containerData.ghost = ghost;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildCharts(containers);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < containers.length; i++) {
|
|
|
|
var hideContainers = function (containers) {
|
|
|
|
var item = containers[i];
|
|
|
|
return containers.filter(function (container) {
|
|
|
|
if (item.Status === "Ghost") {
|
|
|
|
var filterContainer = false;
|
|
|
|
ghost += 1;
|
|
|
|
hiddenLabels.forEach(function(label, index) {
|
|
|
|
} else if (item.Status.indexOf('Exit') !== -1) {
|
|
|
|
if (_.has(container.Labels, label.name) &&
|
|
|
|
stopped += 1;
|
|
|
|
container.Labels[label.name] === label.value) {
|
|
|
|
} else {
|
|
|
|
filterContainer = true;
|
|
|
|
running += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!filterContainer) {
|
|
|
|
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$scope.containerData.running = running;
|
|
|
|
};
|
|
|
|
$scope.containerData.stopped = stopped;
|
|
|
|
|
|
|
|
$scope.containerData.ghost = ghost;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
buildCharts(containers);
|
|
|
|
Config.$promise.then(function (c) {
|
|
|
|
|
|
|
|
hiddenLabels = c.hiddenLabels;
|
|
|
|
|
|
|
|
fetchDashboardData();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}]);
|
|
|
|
}]);
|
|
|
|