diff --git a/app/components/containers/containers.html b/app/components/containers/containers.html index 9d5a86722..5d37ef4a8 100644 --- a/app/components/containers/containers.html +++ b/app/components/containers/containers.html @@ -25,12 +25,12 @@
- - + + - - + +
Add container diff --git a/app/components/containers/containersController.js b/app/components/containers/containersController.js index da858ade5..1dd1a22be 100644 --- a/app/components/containers/containersController.js +++ b/app/components/containers/containersController.js @@ -41,6 +41,7 @@ angular.module('containers', []) } return model; }); + updateSelectionFlags(); $('#loadContainersSpinner').hide(); }, function (e) { $('#loadContainersSpinner').hide(); @@ -117,17 +118,15 @@ angular.module('containers', []) angular.forEach($scope.state.filteredContainers, function (container) { if (container.Checked !== allSelected) { container.Checked = allSelected; - $scope.selectItem(container); + toggleItemSelection(container); } }); + updateSelectionFlags(); }; $scope.selectItem = function (item) { - if (item.Checked) { - $scope.state.selectedItemCount++; - } else { - $scope.state.selectedItemCount--; - } + toggleItemSelection(item); + updateSelectionFlags(); }; $scope.toggleGetAll = function () { @@ -186,6 +185,33 @@ angular.module('containers', []) } ); }; + + function toggleItemSelection(item) { + if (item.Checked) { + $scope.state.selectedItemCount++; + } else { + $scope.state.selectedItemCount--; + } + } + + function updateSelectionFlags() { + $scope.state.noStoppedItemsSelected = true; + $scope.state.noRunningItemsSelected = true; + $scope.state.noPausedItemsSelected = true; + $scope.containers.forEach(function(container) { + if(!container.Checked) { + return; + } + + if(container.Status === 'paused') { + $scope.state.noPausedItemsSelected = false; + } else if(container.Status === 'stopped') { + $scope.state.noStoppedItemsSelected = false; + } else if(container.Status === 'running') { + $scope.state.noRunningItemsSelected = false; + } + } ); + } function retrieveSwarmHostsInfo(data) { var swarm_hosts = {};