diff --git a/js/controllers.js b/js/controllers.js index 7943a97ea..af8817d50 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -68,8 +68,7 @@ function ContainerController($scope, $routeParams, $location, Container) { $scope.start = function(){ Container.start({id: $routeParams.id}, function(d) { - console.log(d); - setSuccessfulResponse($scope, 'Container started.', '#response'); + console.log(d); setSuccessfulResponse($scope, 'Container started.', '#response'); }, function(e) { console.log(e); setFailedResponse($scope, e.data, '#response'); @@ -137,14 +136,31 @@ function ContainerController($scope, $routeParams, $location, Container) { function ContainersController($scope, Container, Settings, ViewSpinner) { $scope.displayAll = Settings.displayAll; $scope.predicate = '-Created'; + $scope.toggle = false; var update = function(data) { ViewSpinner.spin(); Container.query(data, function(d) { - $scope.containers = d; + $scope.containers = d.map(function(item) { return new ContainerViewModel(item); }); ViewSpinner.stop(); }); }; + + var batch = function(items, action) { + angular.forEach(items, function(c) { + if (c.Checked) { + action({id: c.Id}, function(d) { + console.log(d); + }); + } + }); + }; + + $scope.toggleSelectAll = function() { + angular.forEach($scope.containers, function(i) { + i.Checked = $scope.toggle; + }); + }; $scope.toggleGetAll = function() { Settings.displayAll = $scope.displayAll; @@ -157,6 +173,22 @@ function ContainersController($scope, Container, Settings, ViewSpinner) { u(data); }; + $scope.startAction = function() { + batch($scope.containers, Container.start); + }; + + $scope.stopAction = function() { + batch($scope.containers, Container.stop); + }; + + $scope.killAction = function() { + batch($scope.containers, Container.kill); + }; + + $scope.removeAction = function() { + batch($scope.containers, Container.remove); + }; + update({all: $scope.displayAll ? 1 : 0}); } diff --git a/js/viewmodel.js b/js/viewmodel.js index 11560ab2d..20763a255 100644 --- a/js/viewmodel.js +++ b/js/viewmodel.js @@ -6,3 +6,13 @@ function ImageViewModel(data) { this.Created = data.Created; this.Checked = false; } + +function ContainerViewModel(data) { + this.Id = data.Id; + this.Image = data.Image; + this.Command = data.Command; + this.Created = data.Created; + this.SizeRw = data.SizeRw; + this.Status = data.Status; + this.Checked = false; +} diff --git a/partials/containers.html b/partials/containers.html index 3af32b232..77f42be62 100644 --- a/partials/containers.html +++ b/partials/containers.html @@ -1,12 +1,27 @@
Action | Id | Image | Command | @@ -17,6 +32,7 @@
---|---|---|---|
{{ container.Id|truncate:10}} | {{ container.Image }} | {{ container.Command|truncate:40 }} |