|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
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 = {};
|
|
|
|
|
|
|
|
|
@ -17,15 +18,16 @@ angular.module('dashboard', [])
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function fetchDashboardData() {
|
|
|
|
|
Container.query({all: 1}, function (d) {
|
|
|
|
|
var running = 0;
|
|
|
|
|
var ghost = 0;
|
|
|
|
|
var stopped = 0;
|
|
|
|
|
|
|
|
|
|
// TODO: centralize that
|
|
|
|
|
var containers = d.filter(function (container) {
|
|
|
|
|
return container.Image !== 'swarm';
|
|
|
|
|
});
|
|
|
|
|
var containers = d;
|
|
|
|
|
if (hiddenLabels) {
|
|
|
|
|
containers = hideContainers(d);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < containers.length; i++) {
|
|
|
|
|
var item = containers[i];
|
|
|
|
@ -43,4 +45,25 @@ angular.module('dashboard', [])
|
|
|
|
|
|
|
|
|
|
buildCharts(containers);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hideContainers = function (containers) {
|
|
|
|
|
return containers.filter(function (container) {
|
|
|
|
|
var filterContainer = false;
|
|
|
|
|
hiddenLabels.forEach(function(label, index) {
|
|
|
|
|
if (_.has(container.Labels, label.name) &&
|
|
|
|
|
container.Labels[label.name] === label.value) {
|
|
|
|
|
filterContainer = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (!filterContainer) {
|
|
|
|
|
return container;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Config.$promise.then(function (c) {
|
|
|
|
|
hiddenLabels = c.hiddenLabels;
|
|
|
|
|
fetchDashboardData();
|
|
|
|
|
});
|
|
|
|
|
}]);
|
|
|
|
|