feat(services): add a confirmation modal before deleting one or multiple services (#742)

pull/747/head
Anthony Lapenna 8 years ago committed by GitHub
parent f9c1941384
commit a48503d821

@ -1,6 +1,6 @@
angular.module('service', [])
.controller('ServiceController', ['$scope', '$stateParams', '$state', '$location', '$anchorScroll', 'Service', 'ServiceHelper', 'Task', 'Node', 'Messages', 'Pagination',
function ($scope, $stateParams, $state, $location, $anchorScroll, Service, ServiceHelper, Task, Node, Messages, Pagination) {
.controller('ServiceController', ['$scope', '$stateParams', '$state', '$location', '$anchorScroll', 'Service', 'ServiceHelper', 'Task', 'Node', 'Messages', 'Pagination', 'ModalService',
function ($scope, $stateParams, $state, $location, $anchorScroll, Service, ServiceHelper, Task, Node, Messages, Pagination, ModalService) {
$scope.state = {};
$scope.state.pagination_count = Pagination.getPaginationCount('service_tasks');
@ -213,8 +213,17 @@ function ($scope, $stateParams, $state, $location, $anchorScroll, Service, Servi
});
};
$scope.removeService = function() {
ModalService.confirmDeletion(
'Do you want to delete this service? All the containers associated to this service will be removed too.',
function onConfirm(confirmed) {
if(!confirmed) { return; }
removeService();
}
);
};
$scope.removeService = function removeService() {
function removeService() {
$('#loadingViewSpinner').show();
Service.remove({id: $stateParams.id}, function (d) {
if (d.message) {
@ -229,7 +238,7 @@ function ($scope, $stateParams, $state, $location, $anchorScroll, Service, Servi
$('#loadingViewSpinner').hide();
Messages.error("Failure", e, "Unable to remove service");
});
};
}
function translateServiceArrays(service) {
service.ServiceSecrets = service.Secrets;

@ -69,6 +69,16 @@ function ($q, $scope, $stateParams, $state, Service, ServiceHelper, Messages, Pa
};
$scope.removeAction = function() {
ModalService.confirmDeletion(
'Do you want to delete the selected service(s)? All the containers associated to the selected service(s) will be removed too.',
function onConfirm(confirmed) {
if(!confirmed) { return; }
removeServices();
}
);
};
function removeServices() {
$('#loadServicesSpinner').show();
var counter = 0;
var complete = function () {
@ -108,7 +118,11 @@ function ($q, $scope, $stateParams, $state, Service, ServiceHelper, Messages, Pa
});
}
});
};
}
// $scope.removeAction = function () {
//
// };
function mapUsersToServices(users) {
angular.forEach($scope.services, function (service) {

Loading…
Cancel
Save