From 687ed7bac2cd6b3484e947a9c7a3552b16e39eb2 Mon Sep 17 00:00:00 2001 From: Kevan Ahlquist Date: Sun, 25 Jan 2015 19:18:46 -0600 Subject: [PATCH] Fixed Cmd parsing for strings, added error handling to start step. --- .../startContainer/startContainerController.js | 17 +++++++++++++---- .../startContainerController.spec.js | 8 ++++---- dist/dockerui.js | 17 +++++++++++++---- test/unit/karma.conf.js | 1 + 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/components/startContainer/startContainerController.js b/app/components/startContainer/startContainerController.js index ddd606aa3..c4da4e99b 100644 --- a/app/components/startContainer/startContainerController.js +++ b/app/components/startContainer/startContainerController.js @@ -54,6 +54,8 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt if (config.Cmd && config.Cmd[0] === "[") { config.Cmd = angular.fromJson(config.Cmd); + } else if (config.Cmd) { + config.Cmd = config.Cmd.split(' '); } config.Env = config.Env.map(function(envar) {return envar.name + '=' + envar.value;}); @@ -71,7 +73,6 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt var ExposedPorts = {}; var PortBindings = {}; - // TODO: consider using compatibility library config.HostConfig.PortBindings.forEach(function(portBinding) { var intPort = portBinding.intPort + "/tcp"; var binding = { @@ -86,7 +87,7 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt PortBindings[intPort] = [binding]; } } else { - // TODO: Send warning message? Internal port need to be specified. + Messages.send('Warning', 'Internal port must be specified for PortBindings'); } }); config.ExposedPorts = ExposedPorts; @@ -102,8 +103,16 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt Container.create(config, function(d) { if (d.Id) { ctor.start({id: d.Id}, function(cd) { - $('#create-modal').modal('hide'); - loc.path('/containers/' + d.Id + '/'); + if (cd.id) { + Messages.send('Container Started', d.Id); + $('#create-modal').modal('hide'); + loc.path('/containers/' + d.Id + '/'); + } else { + failedRequestHandler(cd, Messages); + ctor.remove({id: d.Id}, function() { + Messages.send('Container Removed', d.Id); + }); + } }, function(e) { failedRequestHandler(e, Messages); }); diff --git a/app/components/startContainer/startContainerController.spec.js b/app/components/startContainer/startContainerController.spec.js index 0ce1f15f2..8b51e029a 100644 --- a/app/components/startContainer/startContainerController.spec.js +++ b/app/components/startContainer/startContainerController.spec.js @@ -60,7 +60,7 @@ describe('startContainerController', function() { 'Warnings': null }); $httpBackend.expectPOST('dockerapi/containers/' + id + '/start?').respond({ - 'Id': id, + 'id': id, 'Warnings': null }); @@ -92,7 +92,7 @@ describe('startContainerController', function() { 'Warnings': null }); $httpBackend.expectPOST('dockerapi/containers/' + id + '/start?').respond({ - 'Id': id, + 'id': id, 'Warnings': null }); @@ -128,7 +128,7 @@ describe('startContainerController', function() { 'Warnings': null }); $httpBackend.expectPOST('dockerapi/containers/' + id + '/start?').respond({ - 'Id': id, + 'id': id, 'Warnings': null }); @@ -165,7 +165,7 @@ describe('startContainerController', function() { 'Warnings': null }); $httpBackend.expectPOST('dockerapi/containers/' + id + '/start?').respond({ - 'Id': id, + 'id': id, 'Warnings': null }); diff --git a/dist/dockerui.js b/dist/dockerui.js index 67b0d0359..847ebbf09 100644 --- a/dist/dockerui.js +++ b/dist/dockerui.js @@ -557,6 +557,8 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt if (config.Cmd && config.Cmd[0] === "[") { config.Cmd = angular.fromJson(config.Cmd); + } else if (config.Cmd) { + config.Cmd = config.Cmd.split(' '); } config.Env = config.Env.map(function(envar) {return envar.name + '=' + envar.value;}); @@ -574,7 +576,6 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt var ExposedPorts = {}; var PortBindings = {}; - // TODO: consider using compatibility library config.HostConfig.PortBindings.forEach(function(portBinding) { var intPort = portBinding.intPort + "/tcp"; var binding = { @@ -589,7 +590,7 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt PortBindings[intPort] = [binding]; } } else { - // TODO: Send warning message? Internal port need to be specified. + Messages.send('Warning', 'Internal port must be specified for PortBindings'); } }); config.ExposedPorts = ExposedPorts; @@ -605,8 +606,16 @@ function($scope, $routeParams, $location, Container, Messages, containernameFilt Container.create(config, function(d) { if (d.Id) { ctor.start({id: d.Id}, function(cd) { - $('#create-modal').modal('hide'); - loc.path('/containers/' + d.Id + '/'); + if (cd.id) { + Messages.send('Container Started', d.Id); + $('#create-modal').modal('hide'); + loc.path('/containers/' + d.Id + '/'); + } else { + failedRequestHandler(cd, Messages); + ctor.remove({id: d.Id}, function() { + Messages.send('Container Removed', d.Id); + }); + } }, function(e) { failedRequestHandler(e, Messages); }); diff --git a/test/unit/karma.conf.js b/test/unit/karma.conf.js index ab13ae32c..40cb82077 100644 --- a/test/unit/karma.conf.js +++ b/test/unit/karma.conf.js @@ -6,6 +6,7 @@ files = [ JASMINE, JASMINE_ADAPTER, 'assets/js/jquery-1.11.1.min.js', + 'assets/js/jquery.gritter.min.js', 'assets/js/bootstrap.min.js', 'assets/js/angularjs/1.2.6/angular.min.js', 'assets/js/angularjs/1.2.6/angular-route.min.js',