diff --git a/awx/ui/static/js/controllers/Credentials.js b/awx/ui/static/js/controllers/Credentials.js index e9e8213236..e26e70c5e0 100644 --- a/awx/ui/static/js/controllers/Credentials.js +++ b/awx/ui/static/js/controllers/Credentials.js @@ -33,6 +33,10 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res scope.removePostRefresh(); } scope.removePostRefresh = scope.$on('PostRefresh', function() { + // Cleanup after a delete + Wait('stop'); + $('#prompt-modal').off(); + list.fields.kind.searchOptions = scope.credential_kind_options; // Translate the kind value @@ -88,20 +92,18 @@ function CredentialsList ($scope, $rootScope, $location, $log, $routeParams, Res scope.deleteCredential = function(id, name) { var action = function() { - Wait('start'); + $('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); }); + $('#prompt-modal').modal('hide'); var url = defaultUrl + id + '/'; Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - Wait('stop'); - $('#prompt-modal').modal('hide'); scope.search(list.iterator); }) .error( function(data, status, headers, config) { Wait('stop'); - $('#prompt-modal').modal('hide'); ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); + { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); }); }; diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index a2457ae4ec..f042f15d8f 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -67,6 +67,10 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res scope.removePostRefresh(); } scope.removePostRefresh = scope.$on('PostRefresh', function() { + //If we got here by deleting an inventory, stop the spinner and cleanup events + Wait('stop'); + $('#prompt-modal').off(); + for (var i=0; i < scope.inventories.length; i++) { // Set values for Failed Hosts column @@ -152,15 +156,15 @@ function InventoriesList ($scope, $rootScope, $location, $log, $routeParams, Res scope.deleteInventory = function(id, name) { var action = function() { - Wait('start'); var url = defaultUrl + id + '/'; + $('#prompt-modal').on('hidden.bs.modal', function() { + Wait('start'); + }); $('#prompt-modal').modal('hide'); - Wait('start'); Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - scope.search(list.iterator); - Wait('stop'); + scope.search(list.iterator); }) .error( function(data, status, headers, config) { Wait('stop'); diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index 36967f3b4a..b9f64cd4bc 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -25,6 +25,15 @@ function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Re var scope = view.inject(list, { mode: mode }); $rootScope.flashMessage = null; + if (scope.removePostRefresh) { + scope.removePostRefresh(); + } + scope.removePostRefresh = scope.$on('PostRefresh', function() { + // Cleanup after a delete + Wait('stop'); + $('#prompt-modal').off(); + }); + SearchInit({ scope: scope, set: 'job_templates', list: list, url: defaultUrl }); PaginateInit({ scope: scope, list: list, url: defaultUrl }); @@ -51,20 +60,18 @@ function JobTemplatesList ($scope, $rootScope, $location, $log, $routeParams, Re scope.deleteJobTemplate = function(id, name) { var action = function() { - Wait('start'); + $('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); }); + $('#prompt-modal').modal('hide'); var url = defaultUrl + id + '/'; Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - Wait('stop'); - $('#prompt-modal').modal('hide'); scope.search(list.iterator); }) .error( function(data, status, headers, config) { Wait('stop'); - $('#prompt-modal').modal('hide'); ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); + { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); }); }; diff --git a/awx/ui/static/js/controllers/Organizations.js b/awx/ui/static/js/controllers/Organizations.js index f9df59c865..67dd5f908d 100644 --- a/awx/ui/static/js/controllers/Organizations.js +++ b/awx/ui/static/js/controllers/Organizations.js @@ -31,6 +31,15 @@ function OrganizationsList ($routeParams, $scope, $rootScope, $location, $log, R var url = GetBasePath('projects') + $routeParams.project_id + '/organizations/'; SelectionInit({ scope: scope, list: list, url: url, returnToCaller: 1 }); + if (scope.removePostRefresh) { + scope.removePostRefresh(); + } + scope.removePostRefresh = scope.$on('PostRefresh', function() { + // Cleanup after a delete + Wait('stop'); + $('#prompt-modal').off(); + }); + // Initialize search and paginate pieces and load data SearchInit({ scope: scope, set: list.name, list: list, url: defaultUrl }); PaginateInit({ scope: scope, list: list, url: defaultUrl }); @@ -49,18 +58,16 @@ function OrganizationsList ($routeParams, $scope, $rootScope, $location, $log, R scope.deleteOrganization = function(id, name) { var action = function() { - Wait('start'); + $('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); }); + $('#prompt-modal').modal('hide'); var url = defaultUrl + id + '/'; Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - Wait('stop'); - $('#prompt-modal').modal('hide'); scope.search(list.iterator); }) .error( function(data, status, headers, config) { Wait('stop'); - $('#prompt-modal').modal('hide'); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); }); diff --git a/awx/ui/static/js/controllers/Permissions.js b/awx/ui/static/js/controllers/Permissions.js index 78f3453e72..2e4ed0e3b1 100644 --- a/awx/ui/static/js/controllers/Permissions.js +++ b/awx/ui/static/js/controllers/Permissions.js @@ -16,6 +16,15 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res scope.selected = []; CheckAccess({ scope: scope }); + + if (scope.removePostRefresh) { + scope.removePostRefresh(); + } + scope.removePostRefresh = scope.$on('PostRefresh', function() { + // Cleanup after a delete + Wait('stop'); + $('#prompt-modal').off(); + }); SearchInit({ scope: scope, set: 'permissions', list: list, url: defaultUrl }); PaginateInit({ scope: scope, list: list, url: defaultUrl }); @@ -35,18 +44,16 @@ function PermissionsList ($scope, $rootScope, $location, $log, $routeParams, Res scope.deletePermission = function(id, name) { var action = function() { - Wait('start'); + $('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); }); + $('#prompt-modal').modal('hide'); var url = GetBasePath('base') + 'permissions/' + id + '/'; Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - Wait('stop'); - $('#prompt-modal').modal('hide'); scope.search(list.iterator); }) .error( function(data, status, headers, config) { Wait('stop'); - $('#prompt-modal').modal('hide'); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); }); diff --git a/awx/ui/static/js/controllers/Projects.js b/awx/ui/static/js/controllers/Projects.js index db71fa08e5..763d058832 100644 --- a/awx/ui/static/js/controllers/Projects.js +++ b/awx/ui/static/js/controllers/Projects.js @@ -36,6 +36,10 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, scope.removePostRefresh(); } scope.removePostRefresh = scope.$on('PostRefresh', function() { + // Cleanup after a delete + Wait('stop'); + $('#prompt-modal').off(); + if (scope.projects) { for (var i=0; i < scope.projects.length; i++) { if (scope.projects[i].status == 'ok') { @@ -114,20 +118,18 @@ function ProjectsList ($scope, $rootScope, $location, $log, $routeParams, Rest, scope.deleteProject = function(id, name) { var action = function() { - Wait('start'); + $('#prompt-modal').on('hiden.bs.modal', function(){ Wait('start'); }); + $('#prompt-modal').modal('hide'); var url = defaultUrl + id + '/'; Rest.setUrl(url); Rest.destroy() .success( function(data, status, headers, config) { - Wait('stop'); - $('#prompt-modal').modal('hide'); scope.search(list.iterator); }) .error( function(data, status, headers, config) { Wait('stop'); - $('#prompt-modal').modal('hide'); ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); + { hdr: 'Error!', msg: 'Call to ' + url + ' failed. DELETE returned status: ' + status }); }); }; diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index cd5534abd3..81d03788ac 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -1076,7 +1076,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' var inventory_id = params.inventory_id; var obj = scope['selectedNode']; var parent = obj.parent().parent(); - //var parent = (obj.parent().last().prop('tagName') == 'LI') ? obj.parent().last() : obj.parent().parent().last(); var url; if (parent.attr('data-group-id')) { @@ -1086,8 +1085,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' url = GetBasePath('inventory') + inventory_id + '/groups/'; } var action_to_take = function() { + $('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); }); $('#prompt-modal').modal('hide'); - Wait('start'); Rest.setUrl(url); Rest.post({ id: group_id, disassociate: 1 }) .success( function(data, status, headers, config) { @@ -1101,7 +1100,7 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' id: parent.attr('id'), moveable: true }); - Wait('stop'); + $('#prompt-modal').off(); }) .error( function(data, status, headers, config) { Wait('stop'); @@ -1143,13 +1142,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' 'You must first edit the group, provide Source settings, and then run an update.', 'alert-info'); } else { - if ($rootScope.removeShowStatus) { - $rootScope.removeShowStatus(); - } - $rootScope.removeShowStatus = $rootScope.$on('showStatus', function(e, results) { - - }); - // Retrieve detail record and prepopulate the form Rest.setUrl(last_update); Rest.get() diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index b1d3dec0ff..086d15a211 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -435,8 +435,8 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H .factory('HostsDelete', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'Prompt', 'ProcessErrors', 'GetBasePath', - 'HostsReload', - function($rootScope, $location, $log, $routeParams, Rest, Alert, Prompt, ProcessErrors, GetBasePath, HostsReload) { + 'HostsReload', 'Wait', + function($rootScope, $location, $log, $routeParams, Rest, Alert, Prompt, ProcessErrors, GetBasePath, HostsReload, Wait) { return function(params) { // Remove the selected host from the current group by disassociating @@ -454,18 +454,20 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H scope.removeHostsReload(); } scope.removeHostsReload = scope.$on('hostsReload', function() { + params.action = function() { $('#prompt-modal').off(); Wait('stop'); } HostsReload(params); }); var action_to_take = function() { + $('#prompt-modal').on('hidden.bs.modal', function(){ Wait('start'); }) + $('#prompt-modal').modal('hide'); Rest.setUrl(url); Rest.post({ id: host_id, disassociate: 1 }) - .success( function(data, status, headers, config) { - $('#prompt-modal').modal('hide'); + .success( function(data, status, headers, config) { scope.$emit('hostsReload'); }) .error( function(data, status, headers, config) { - $('#prompt-modal').modal('hide'); + Wait('stop'); scope.$emit('hostsReload'); ProcessErrors(scope, data, status, null, { hdr: 'Error!', msg: 'Attempt to delete ' + host_name + ' failed. POST returned status: ' + status });