diff --git a/awx/ui/client/src/controllers/Credentials.js b/awx/ui/client/src/controllers/Credentials.js index db1b3a3527..618879037a 100644 --- a/awx/ui/client/src/controllers/Credentials.js +++ b/awx/ui/client/src/controllers/Credentials.js @@ -103,6 +103,9 @@ export function CredentialsList($scope, $rootScope, $location, $log, Rest.destroy() .success(function () { $scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { ProcessErrors($scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/controllers/Projects.js b/awx/ui/client/src/controllers/Projects.js index 8a347e623c..6e5a4e68d1 100644 --- a/awx/ui/client/src/controllers/Projects.js +++ b/awx/ui/client/src/controllers/Projects.js @@ -247,6 +247,9 @@ export function ProjectsList ($scope, $rootScope, $location, $log, $stateParams, Rest.destroy() .success(function () { $scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { ProcessErrors($scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/controllers/Teams.js b/awx/ui/client/src/controllers/Teams.js index e2be443712..a430a7fb6a 100644 --- a/awx/ui/client/src/controllers/Teams.js +++ b/awx/ui/client/src/controllers/Teams.js @@ -98,6 +98,9 @@ export function TeamsList($scope, $rootScope, $location, $log, $stateParams, Wait('stop'); $('#prompt-modal').modal('hide'); $scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { Wait('stop'); diff --git a/awx/ui/client/src/controllers/Users.js b/awx/ui/client/src/controllers/Users.js index 1babee857a..0a03e8b02a 100644 --- a/awx/ui/client/src/controllers/Users.js +++ b/awx/ui/client/src/controllers/Users.js @@ -112,6 +112,9 @@ export function UsersList($scope, $rootScope, $location, $log, $stateParams, Rest.destroy() .success(function () { $scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { ProcessErrors($scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/helpers/Schedules.js b/awx/ui/client/src/helpers/Schedules.js index 2dcc6f93e4..bc4fd84aff 100644 --- a/awx/ui/client/src/helpers/Schedules.js +++ b/awx/ui/client/src/helpers/Schedules.js @@ -428,8 +428,8 @@ export default * }) * */ - .factory('DeleteSchedule', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Find', - function(GetBasePath, Rest, Wait, ProcessErrors, Prompt, Find) { + .factory('DeleteSchedule', ['GetBasePath','Rest', 'Wait', 'ProcessErrors', 'Prompt', 'Find', '$location', + function(GetBasePath, Rest, Wait, ProcessErrors, Prompt, Find, $location) { return function(params) { var scope = params.scope, @@ -455,6 +455,9 @@ export default .success(function () { $('#prompt-modal').modal('hide'); scope.$emit(callback, id); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $location.url($location.url().replace(/[/][0-9]+$/, "")); // go to list view + } }) .error(function (data, status) { try { diff --git a/awx/ui/client/src/inventories/list/inventory-list.controller.js b/awx/ui/client/src/inventories/list/inventory-list.controller.js index f38e99239f..54fc4fd3eb 100644 --- a/awx/ui/client/src/inventories/list/inventory-list.controller.js +++ b/awx/ui/client/src/inventories/list/inventory-list.controller.js @@ -323,6 +323,9 @@ function InventoriesList($scope, $rootScope, $location, $log, Rest.destroy() .success(function () { $scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { ProcessErrors( $scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/inventory-scripts/list/list.controller.js b/awx/ui/client/src/inventory-scripts/list/list.controller.js index 293bd7c4a4..c7a2b3e404 100644 --- a/awx/ui/client/src/inventory-scripts/list/list.controller.js +++ b/awx/ui/client/src/inventory-scripts/list/list.controller.js @@ -7,11 +7,11 @@ export default [ '$rootScope','Wait', 'generateList', 'inventoryScriptsListObject', 'GetBasePath' , 'SearchInit' , 'PaginateInit', - 'Rest' , 'ProcessErrors', 'Prompt', '$state', + 'Rest' , 'ProcessErrors', 'Prompt', '$state', '$location', function( $rootScope,Wait, GenerateList, inventoryScriptsListObject, GetBasePath, SearchInit, PaginateInit, - Rest, ProcessErrors, Prompt, $state + Rest, ProcessErrors, Prompt, $state, $location ) { var scope = $rootScope.$new(), defaultUrl = GetBasePath('inventory_scripts'), @@ -59,6 +59,9 @@ export default Rest.destroy() .success(function () { scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { ProcessErrors(scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/job-templates/list/job-templates-list.controller.js b/awx/ui/client/src/job-templates/list/job-templates-list.controller.js index fa3a422f80..3d1e144921 100644 --- a/awx/ui/client/src/job-templates/list/job-templates-list.controller.js +++ b/awx/ui/client/src/job-templates/list/job-templates-list.controller.js @@ -78,6 +78,9 @@ export default Rest.destroy() .success(function () { $scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data) { Wait('stop'); diff --git a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js index 5c64299c70..0167b32d3f 100644 --- a/awx/ui/client/src/notifications/notification-templates-list/list.controller.js +++ b/awx/ui/client/src/notifications/notification-templates-list/list.controller.js @@ -8,12 +8,12 @@ export default [ '$rootScope','Wait', 'generateList', 'NotificationTemplatesList', 'GetBasePath' , 'SearchInit' , 'PaginateInit', 'Rest' , 'ProcessErrors', 'Prompt', '$state', 'GetChoices', 'Empty', 'Find', - 'ngToast', '$compile', '$filter', + 'ngToast', '$compile', '$filter', '$location', function( $rootScope,Wait, GenerateList, NotificationTemplatesList, GetBasePath, SearchInit, PaginateInit, Rest, ProcessErrors, Prompt, $state, GetChoices, Empty, Find, ngToast, - $compile, $filter) { + $compile, $filter, $location) { var scope = $rootScope.$new(), defaultUrl = GetBasePath('notification_templates'), list = NotificationTemplatesList, @@ -183,6 +183,9 @@ export default Rest.destroy() .success(function () { scope.search(list.iterator); + if (new RegExp('/' + id + '$').test($location.$$url)) { + $state.go('^'); + } }) .error(function (data, status) { ProcessErrors(scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/shared/pagination/pagination.service.js b/awx/ui/client/src/shared/pagination/pagination.service.js index 36e87c0807..73249da8ad 100644 --- a/awx/ui/client/src/shared/pagination/pagination.service.js +++ b/awx/ui/client/src/shared/pagination/pagination.service.js @@ -12,11 +12,16 @@ export default ['$http', '$q', function($http, $q) { return $http.get(url + "?id=" + id) .then(function (data) { var queryValue, queryType; - if (data.data.results[0].type === "user") { - queryValue = data.data.results[0].username; - queryType = "username"; + if (data.data.results.length) { + if (data.data.results[0].type === "user") { + queryValue = data.data.results[0].username; + queryType = "username"; + } else { + queryValue = data.data.results[0].name; + queryType = "name"; + } } else { - queryValue = data.data.results[0].name; + queryValue = ""; queryType = "name"; } // get how many results are less than or equal to @@ -26,7 +31,7 @@ export default ['$http', '$q', function($http, $q) { // divide by the page size to get what // page the data should be on var count = data.data.count; - return Math.ceil(count/parseInt(pageSize)); + return Math.max(1, Math.ceil(count/parseInt(pageSize))); }); }); } else {