diff --git a/app/components/containers/containersController.js b/app/components/containers/containersController.js index 66e236cb3..773d753d2 100644 --- a/app/components/containers/containersController.js +++ b/app/components/containers/containersController.js @@ -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; diff --git a/app/components/templates/templatesController.js b/app/components/templates/templatesController.js index 98b235d84..0bebf9754 100644 --- a/app/components/templates/templatesController.js +++ b/app/components/templates/templatesController.js @@ -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); });