1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 22:39:41 +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

@ -1,6 +1,6 @@
angular.module('container', [])
.controller('ContainerController', ['$scope', '$state','$stateParams', '$filter', 'Container', 'ContainerCommit', 'ImageHelper', 'Network', 'Notifications', 'Pagination',
function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, ImageHelper, Network, Notifications, Pagination) {
.controller('ContainerController', ['$scope', '$state','$stateParams', '$filter', 'Container', 'ContainerCommit', 'ImageHelper', 'Network', 'Notifications', 'Pagination', 'ModalService',
function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, ImageHelper, Network, Notifications, Pagination, ModalService) {
$scope.activityTime = 0;
$scope.portBindings = [];
$scope.config = {
@ -116,9 +116,23 @@ function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, Ima
});
};
$scope.remove = function () {
$scope.confirmRemove = function () {
if ($scope.container.State.Running) {
ModalService.confirmDeletion(
'You are about to remove a running container.',
function (confirmed) {
if(!confirmed) { return; }
$scope.remove();
}
);
} else {
$scope.remove();
}
};
$scope.remove = function() {
$('#loadingViewSpinner').show();
Container.remove({id: $stateParams.id}, function (d) {
Container.remove({id: $stateParams.id, force: true}, function (d) {
if (d.message) {
$('#loadingViewSpinner').hide();
Notifications.error("Failure", d, "Unable to remove container");