Fixed Cmd parsing for strings, added error handling to start step.

pull/2/head
Kevan Ahlquist 2015-01-25 19:18:46 -06:00
parent 314fc51f6d
commit 687ed7bac2
4 changed files with 31 additions and 12 deletions

View File

@ -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);
});

View File

@ -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
});

17
dist/dockerui.js vendored
View File

@ -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);
});

View File

@ -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',