From 880966f3ba20a2d2b016b447c48473056fb9f2fc Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Sun, 9 Jun 2013 17:16:37 -0900 Subject: [PATCH] Add ability to launch container from image --- js/controllers.js | 43 ++++++++++++++++++++++++++++++++++++ partials/image.html | 5 +++++ partials/startcontainer.html | 27 ++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 partials/startcontainer.html diff --git a/js/controllers.js b/js/controllers.js index bb34ff93f..362d097b0 100644 --- a/js/controllers.js +++ b/js/controllers.js @@ -269,3 +269,46 @@ function ImageController($scope, $routeParams, $location, Image) { $scope.getHistory(); } + +function StartContainerController($scope, $routeParams, $location, Container) { + $scope.template = 'partials/startcontainer.html'; + $scope.memory = 0; + $scope.memorySwap = 0; + $scope.env = ''; + $scope.dns = ''; + $scope.volumesFrom = ''; + $scope.commands = ''; + + $scope.launchContainer = function() { + var cmds = null; + if ($scope.commands !== '') { + cmds = $scope.commands.split('\n'); + } + var id = $routeParams.id; + var ctor = Container; + var loc = $location; + var s = $scope; + + Container.create({ + Image: id, + Memory: $scope.memory, + MemorySwap: $scope.memorySwap, + Cmd: cmds, + VolumesFrom: $scope.volumesFrom + }, function(d) { + console.log(d); + if (d.Id) { + ctor.start({id: d.Id}, function(cd) { + console.log(cd); + loc.path('/containers/' + d.Id + '/'); + }, function(e) { + console.log(e); + s.resonse = e.data; + }); + } + }, function(e) { + console.log(e); + $scope.response = e.data; + }); + }; +} diff --git a/partials/image.html b/partials/image.html index dc8cb8183..05f7b021a 100644 --- a/partials/image.html +++ b/partials/image.html @@ -76,6 +76,11 @@ + +
+ +
+
diff --git a/partials/startcontainer.html b/partials/startcontainer.html new file mode 100644 index 000000000..98a81f608 --- /dev/null +++ b/partials/startcontainer.html @@ -0,0 +1,27 @@ + +
+ {{ response }} +
+ + +
+
+ Start container from Image + + + + Place each command on a new line + + + + + + + + + + +
+ +
+