feat(ui): display an error message when trying to remove a running container (#28)

pull/30/head
Anthony Lapenna 2016-06-29 22:11:22 +12:00 committed by GitHub
parent 965a099495
commit 87e835e873
1 changed files with 18 additions and 7 deletions

View File

@ -1,6 +1,6 @@
angular.module('containers', []) angular.module('containers', [])
.controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'ViewSpinner', 'Config', .controller('ContainersController', ['$scope', 'Container', 'Settings', 'Messages', 'ViewSpinner', 'Config', 'errorMsgFilter',
function ($scope, Container, Settings, Messages, ViewSpinner, Config) { function ($scope, Container, Settings, Messages, ViewSpinner, Config, errorMsgFilter) {
$scope.state = {}; $scope.state = {};
$scope.state.displayAll = Settings.displayAll; $scope.state.displayAll = Settings.displayAll;
@ -40,13 +40,12 @@ function ($scope, Container, Settings, Messages, ViewSpinner, Config) {
}; };
angular.forEach(items, function (c) { angular.forEach(items, function (c) {
if (c.Checked) { if (c.Checked) {
counter = counter + 1;
if (action === Container.start) { if (action === Container.start) {
Container.get({id: c.Id}, function (d) { Container.get({id: c.Id}, function (d) {
c = d; c = d;
counter = counter + 1;
action({id: c.Id, HostConfig: c.HostConfig || {}}, function (d) { action({id: c.Id, HostConfig: c.HostConfig || {}}, function (d) {
Messages.send("Container " + msg, c.Id); Messages.send("Container " + msg, c.Id);
var index = $scope.containers.indexOf(c);
complete(); complete();
}, function (e) { }, function (e) {
Messages.error("Failure", e.data); Messages.error("Failure", e.data);
@ -62,11 +61,24 @@ function ($scope, Container, Settings, Messages, ViewSpinner, Config) {
complete(); complete();
}); });
} }
else if (action === Container.remove) {
action({id: c.Id}, function (d) {
var error = errorMsgFilter(d);
if (error) {
Messages.send("Error", "Unable to remove running container");
}
else {
Messages.send("Container " + msg, c.Id);
}
complete();
}, function (e) {
Messages.error("Failure", e.data);
complete();
});
}
else { else {
counter = counter + 1;
action({id: c.Id}, function (d) { action({id: c.Id}, function (d) {
Messages.send("Container " + msg, c.Id); Messages.send("Container " + msg, c.Id);
var index = $scope.containers.indexOf(c);
complete(); complete();
}, function (e) { }, function (e) {
Messages.error("Failure", e.data); Messages.error("Failure", e.data);
@ -74,7 +86,6 @@ function ($scope, Container, Settings, Messages, ViewSpinner, Config) {
}); });
} }
} }
}); });
if (counter === 0) { if (counter === 0) {