mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(containers) - clean non-persistent volumes when removing a container (#824)
This commit is contained in:
parent
5a07638f4d
commit
3d8eec2557
5 changed files with 103 additions and 40 deletions
|
@ -119,22 +119,26 @@ function ($scope, $state, $stateParams, $filter, Container, ContainerCommit, Ima
|
|||
};
|
||||
|
||||
$scope.confirmRemove = function () {
|
||||
var title = 'You are about to remove a container.';
|
||||
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();
|
||||
title = 'You are about to remove a running container.';
|
||||
}
|
||||
ModalService.confirmContainerDeletion(
|
||||
title,
|
||||
function (result) {
|
||||
if(!result) { return; }
|
||||
var cleanAssociatedVolumes = false;
|
||||
if (result[0]) {
|
||||
cleanAssociatedVolumes = true;
|
||||
}
|
||||
$scope.remove(cleanAssociatedVolumes);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
$scope.remove = function() {
|
||||
$scope.remove = function(cleanAssociatedVolumes) {
|
||||
$('#loadingViewSpinner').show();
|
||||
Container.remove({id: $stateParams.id, force: true}, function (d) {
|
||||
Container.remove({id: $stateParams.id, v: (cleanAssociatedVolumes) ? 1 : 0, force: true}, function (d) {
|
||||
if (d.message) {
|
||||
$('#loadingViewSpinner').hide();
|
||||
Notifications.error("Failure", d, "Unable to remove container");
|
||||
|
|
|
@ -17,6 +17,8 @@ angular.module('containers', [])
|
|||
Pagination.setPaginationCount('containers', $scope.state.pagination_count);
|
||||
};
|
||||
|
||||
$scope.cleanAssociatedVolumes = false;
|
||||
|
||||
function removeContainerResourceControl(container) {
|
||||
volumeResourceControlQueries = [];
|
||||
angular.forEach(container.Mounts, function (volume) {
|
||||
|
@ -128,7 +130,7 @@ angular.module('containers', [])
|
|||
});
|
||||
}
|
||||
else if (action === Container.remove) {
|
||||
action({id: c.Id, force: true}, function (d) {
|
||||
action({id: c.Id, v: ($scope.cleanAssociatedVolumes) ? 1 : 0, force: true}, function (d) {
|
||||
if (d.message) {
|
||||
Notifications.error("Error", d, "Unable to remove container");
|
||||
}
|
||||
|
@ -239,17 +241,21 @@ angular.module('containers', [])
|
|||
return;
|
||||
}
|
||||
});
|
||||
var title = 'You are about to remove one or more container.';
|
||||
if (isOneContainerRunning) {
|
||||
ModalService.confirmDeletion(
|
||||
'You are about to remove one or more running containers.',
|
||||
function (confirmed) {
|
||||
if(!confirmed) { return; }
|
||||
$scope.removeAction();
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$scope.removeAction();
|
||||
title = 'You are about to remove one or more running containers.';
|
||||
}
|
||||
ModalService.confirmContainerDeletion(
|
||||
title,
|
||||
function (result) {
|
||||
if(!result) { return; }
|
||||
$scope.cleanAssociatedVolumes = false;
|
||||
if (result[0]) {
|
||||
$scope.cleanAssociatedVolumes = true;
|
||||
}
|
||||
$scope.removeAction();
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
function retrieveSwarmHostsInfo(data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue