1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-02 12:25:22 +02:00

feat(containers) - Add the ability to force remove a container with confirmation (#814)

This commit is contained in:
Thomas Krzero 2017-04-25 10:20:57 +02:00 committed by Anthony Lapenna
parent 2761959f93
commit ac872b577a
10 changed files with 48 additions and 13 deletions

View file

@ -31,7 +31,7 @@
<button type="button" class="btn btn-primary btn-responsive" ng-click="restartAction()" ng-disabled="!state.selectedItemCount"><i class="fa fa-refresh space-right" aria-hidden="true"></i>Restart</button>
<button type="button" class="btn btn-primary btn-responsive" ng-click="pauseAction()" ng-disabled="!state.selectedItemCount"><i class="fa fa-pause space-right" aria-hidden="true"></i>Pause</button>
<button type="button" class="btn btn-primary btn-responsive" ng-click="unpauseAction()" ng-disabled="!state.selectedItemCount"><i class="fa fa-play space-right" aria-hidden="true"></i>Resume</button>
<button type="button" class="btn btn-danger btn-responsive" ng-click="removeAction()" ng-disabled="!state.selectedItemCount"><i class="fa fa-trash space-right" aria-hidden="true"></i>Remove</button>
<button type="button" class="btn btn-danger btn-responsive" ng-click="confirmRemoveAction()" ng-disabled="!state.selectedItemCount"><i class="fa fa-trash space-right" aria-hidden="true"></i>Remove</button>
</div>
<a class="btn btn-primary" type="button" ui-sref="actions.create.container"><i class="fa fa-plus space-right" aria-hidden="true"></i>Add container</a>
</div>

View file

@ -128,7 +128,7 @@ angular.module('containers', [])
});
}
else if (action === Container.remove) {
action({id: c.Id}, function (d) {
action({id: c.Id, force: true}, function (d) {
if (d.message) {
Notifications.error("Error", d, "Unable to remove container");
}
@ -231,6 +231,27 @@ angular.module('containers', [])
batch($scope.containers, Container.remove, "Removed");
};
$scope.confirmRemoveAction = function () {
var isOneContainerRunning = false;
angular.forEach($scope.containers, function (c) {
if (c.Checked && c.State === 'running') {
isOneContainerRunning = true;
return;
}
});
if (isOneContainerRunning) {
ModalService.confirmDeletion(
'You are about to remove one or more running containers.',
function (confirmed) {
if(!confirmed) { return; }
$scope.removeAction();
}
);
} else {
$scope.removeAction();
}
};
function retrieveSwarmHostsInfo(data) {
var swarm_hosts = {};
var systemStatus = data.SystemStatus;