fix(templates): hide hidden containers in templates (#165)

pull/172/head
Anthony Lapenna 8 years ago committed by GitHub
parent 3c75c5fe25
commit e81bfb6f37

@ -142,6 +142,7 @@ function ($scope, Container, Info, Settings, Messages, Config, errorMsgFilter) {
batch($scope.containers, Container.remove, "Removed");
};
// TODO: centralize (already exist in TemplatesController)
var hideContainers = function (containers) {
return containers.filter(function (container) {
var filterContainer = false;

@ -159,8 +159,25 @@ function initTemplates() {
});
}
// TODO: centralize (already exist in containersController)
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) {
$scope.swarm = c.swarm;
hiddenLabels = c.hiddenLabels;
Network.query({}, function (d) {
var networks = d;
if ($scope.swarm) {
@ -181,7 +198,11 @@ Config.$promise.then(function (c) {
Messages.error("Unable to retrieve available networks", e.data);
});
Container.query({all: 0}, function (d) {
$scope.runningContainers = d;
var containers = d;
if (hiddenLabels) {
containers = hideContainers(d);
}
$scope.runningContainers = containers;
}, function (e) {
Messages.error("Unable to retrieve running containers", e.data);
});

Loading…
Cancel
Save