diff --git a/app/docker/views/volumes/edit/volumeController.js b/app/docker/views/volumes/edit/volumeController.js index 51e70fbf6..e3cb8ce84 100644 --- a/app/docker/views/volumes/edit/volumeController.js +++ b/app/docker/views/volumes/edit/volumeController.js @@ -51,14 +51,18 @@ angular.module('portainer.docker').controller('VolumeController', [ }; $scope.removeVolume = function removeVolume() { - VolumeService.remove($scope.volume) - .then(function success() { - Notifications.success('Volume successfully removed', $transition$.params().id); - $state.go('docker.volumes', {}); - }) - .catch(function error(err) { - Notifications.error('Failure', err, 'Unable to remove volume'); - }); + ModalService.confirmDeletion('Do you want to remove this volume?', (confirmed) => { + if (confirmed) { + VolumeService.remove($scope.volume) + .then(function success() { + Notifications.success('Volume successfully removed', $transition$.params().id); + $state.go('docker.volumes', {}); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to remove volume'); + }); + } + }); }; function getVolumeDataFromContainer(container, volumeId) { diff --git a/app/docker/views/volumes/volumesController.js b/app/docker/views/volumes/volumesController.js index bfd0a14b7..8496a9e22 100644 --- a/app/docker/views/volumes/volumesController.js +++ b/app/docker/views/volumes/volumesController.js @@ -9,26 +9,31 @@ angular.module('portainer.docker').controller('VolumesController', [ 'HttpRequestHelper', 'EndpointProvider', 'Authentication', - function ($q, $scope, $state, VolumeService, ServiceService, VolumeHelper, Notifications, HttpRequestHelper, EndpointProvider, Authentication) { + 'ModalService', + function ($q, $scope, $state, VolumeService, ServiceService, VolumeHelper, Notifications, HttpRequestHelper, EndpointProvider, Authentication, ModalService) { $scope.removeAction = function (selectedItems) { - var actionCount = selectedItems.length; - angular.forEach(selectedItems, function (volume) { - HttpRequestHelper.setPortainerAgentTargetHeader(volume.NodeName); - VolumeService.remove(volume) - .then(function success() { - Notifications.success('Volume successfully removed', volume.Id); - var index = $scope.volumes.indexOf(volume); - $scope.volumes.splice(index, 1); - }) - .catch(function error(err) { - Notifications.error('Failure', err, 'Unable to remove volume'); - }) - .finally(function final() { - --actionCount; - if (actionCount === 0) { - $state.reload(); - } + ModalService.confirmDeletion('Do you want to remove the selected volume(s)?', (confirmed) => { + if (confirmed) { + var actionCount = selectedItems.length; + angular.forEach(selectedItems, function (volume) { + HttpRequestHelper.setPortainerAgentTargetHeader(volume.NodeName); + VolumeService.remove(volume) + .then(function success() { + Notifications.success('Volume successfully removed', volume.Id); + var index = $scope.volumes.indexOf(volume); + $scope.volumes.splice(index, 1); + }) + .catch(function error(err) { + Notifications.error('Failure', err, 'Unable to remove volume'); + }) + .finally(function final() { + --actionCount; + if (actionCount === 0) { + $state.reload(); + } + }); }); + } }); };