From 57fef1c9587fafbb1afd7db6a204c4a722ff90c8 Mon Sep 17 00:00:00 2001 From: Kevan Ahlquist Date: Wed, 12 Nov 2014 12:31:02 -0600 Subject: [PATCH] Move startContainer to its own submodule. --- app/app.js | 2 +- .../startContainerController.js | 47 +++++++++++++++++++ .../startContainer}/startcontainer.html | 0 app/controllers.js | 46 ------------------ index.html | 1 + 5 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 app/components/startContainer/startContainerController.js rename {partials => app/components/startContainer}/startcontainer.html (100%) diff --git a/app/app.js b/app/app.js index 11773f159..89d45788a 100644 --- a/app/app.js +++ b/app/app.js @@ -1,6 +1,6 @@ 'use strict'; -angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers', 'images', 'image']) +angular.module('dockerui', ['ngRoute', 'dockerui.services', 'dockerui.filters', 'masthead', 'footer', 'dashboard', 'container', 'containers', 'images', 'image', 'startContainer']) .config(['$routeProvider', function ($routeProvider) { $routeProvider.when('/', {templateUrl: 'app/components/dashboard/dashboard.html', controller: 'DashboardController'}); $routeProvider.when('/containers/', {templateUrl: 'app/components/containers/containers.html', controller: 'ContainersController'}); diff --git a/app/components/startContainer/startContainerController.js b/app/components/startContainer/startContainerController.js new file mode 100644 index 000000000..ad4015242 --- /dev/null +++ b/app/components/startContainer/startContainerController.js @@ -0,0 +1,47 @@ +angular.module('startContainer', []) +.controller('StartContainerController', ['$scope', '$routeParams', '$location', 'Container', 'Messages', +function($scope, $routeParams, $location, Container, Messages) { + $scope.template = 'app/components/startContainer/startcontainer.html'; + $scope.config = { + name: '', + memory: 0, + memorySwap: 0, + cpuShares: 1024, + env: '', + commands: '', + volumesFrom: '' + }; + $scope.commandPlaceholder = '["/bin/echo", "Hello world"]'; + + $scope.create = function() { + var cmds = null; + if ($scope.config.commands !== '') { + cmds = angular.fromJson($scope.config.commands); + } + var id = $routeParams.id; + var ctor = Container; + var loc = $location; + var s = $scope; + + Container.create({ + Image: id, + name: $scope.config.name, + Memory: $scope.config.memory, + MemorySwap: $scope.config.memorySwap, + CpuShares: $scope.config.cpuShares, + Cmd: cmds, + VolumesFrom: $scope.config.volumesFrom + }, function(d) { + if (d.Id) { + ctor.start({id: d.Id}, function(cd) { + $('#create-modal').modal('hide'); + loc.path('/containers/' + d.Id + '/'); + }, function(e) { + failedRequestHandler(e, Messages); + }); + } + }, function(e) { + failedRequestHandler(e, Messages); + }); + }; +}]); diff --git a/partials/startcontainer.html b/app/components/startContainer/startcontainer.html similarity index 100% rename from partials/startcontainer.html rename to app/components/startContainer/startcontainer.html diff --git a/app/controllers.js b/app/controllers.js index ea3bf23a8..4bfcb466b 100644 --- a/app/controllers.js +++ b/app/controllers.js @@ -67,52 +67,6 @@ function SettingsController($scope, System, Docker, Settings, Messages) { System.get({}, function(d) { $scope.info = d; }); } -function StartContainerController($scope, $routeParams, $location, Container, Messages) { - $scope.template = 'partials/startcontainer.html'; - $scope.config = { - name: '', - memory: 0, - memorySwap: 0, - cpuShares: 1024, - env: '', - commands: '', - volumesFrom: '' - }; - $scope.commandPlaceholder = '["/bin/echo", "Hello world"]'; - - $scope.create = function() { - var cmds = null; - if ($scope.config.commands !== '') { - cmds = angular.fromJson($scope.config.commands); - } - var id = $routeParams.id; - var ctor = Container; - var loc = $location; - var s = $scope; - - Container.create({ - Image: id, - name: $scope.config.name, - Memory: $scope.config.memory, - MemorySwap: $scope.config.memorySwap, - CpuShares: $scope.config.cpuShares, - Cmd: cmds, - VolumesFrom: $scope.config.volumesFrom - }, function(d) { - if (d.Id) { - ctor.start({id: d.Id}, function(cd) { - $('#create-modal').modal('hide'); - loc.path('/containers/' + d.Id + '/'); - }, function(e) { - failedRequestHandler(e, Messages); - }); - } - }, function(e) { - failedRequestHandler(e, Messages); - }); - }; -} - function BuilderController($scope, Dockerfile, Messages) { $scope.template = 'partials/builder.html'; } diff --git a/index.html b/index.html index d80be8b81..adac9bfbf 100644 --- a/index.html +++ b/index.html @@ -42,6 +42,7 @@ +