diff --git a/awx/ui/static/js/controllers/JobEvents.js b/awx/ui/static/js/controllers/JobEvents.js index e0fe76491d..5ba5498fd3 100644 --- a/awx/ui/static/js/controllers/JobEvents.js +++ b/awx/ui/static/js/controllers/JobEvents.js @@ -130,7 +130,9 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, }); SearchInit({ scope: scope, set: 'jobevents', list: list, url: defaultUrl }); - PaginateInit({ scope: scope, list: list, url: defaultUrl }); + + var page = ($routeParams.page) ? parseInt($routeParams.page) - 1 : null; + PaginateInit({ scope: scope, list: list, url: defaultUrl, page: page }); // Called from Inventories tab, host failed events link: if ($routeParams.host) { @@ -139,7 +141,7 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, scope[list.iterator + 'SearchFieldLabel'] = list.fields['host'].label; } - scope.search(list.iterator); + scope.search(list.iterator, $routeParams.page); scope.toggleChildren = function(id, children) { ToggleChildren({ @@ -153,7 +155,11 @@ function JobEventsList ($scope, $rootScope, $location, $log, $routeParams, Rest, LoadBreadCrumbs(); scope.viewJobEvent = function(id) { - $location.path('/jobs/' + $routeParams.id + '/job_events/' + id); + var url = '/jobs/' + $routeParams.id + '/job_events/' + id; + if (scope['jobeventPage']) { + url += '?&page=' + (scope['jobeventPage'] + 1); + } + $location.url(url); } scope.refresh = function() { @@ -260,7 +266,11 @@ function JobEventsEdit ($scope, $rootScope, $compile, $location, $log, $routePar }); scope.navigateBack = function() { - window.history.back(); + var url = '/jobs/' + $routeParams.job_id + '/job_events'; + if ($routeParams.page) { + url += '?page=' + $routeParams.page; + } + $location.url(url); } scope.rawView = function() { diff --git a/awx/ui/static/js/helpers/paginate.js b/awx/ui/static/js/helpers/paginate.js index b78f5f4baf..4f73081de9 100644 --- a/awx/ui/static/js/helpers/paginate.js +++ b/awx/ui/static/js/helpers/paginate.js @@ -25,8 +25,13 @@ angular.module('PaginateHelper', ['RefreshHelper', 'ngCookies']) var mode = (params.mode) ? params.mode : null; var cookieSize = $cookieStore.get(iterator + 'PageSize'); - scope[iterator + 'Page'] = 0; - + if (params.page) { + scope[iterator + 'Page'] = params.page; + } + else { + scope[iterator + 'Page'] = 0; + } + if (cookieSize && mode != 'lookup') { // use the size found in session cookie, when available scope[iterator + 'PageSize'] = cookieSize; diff --git a/awx/ui/static/js/helpers/search.js b/awx/ui/static/js/helpers/search.js index 09789e232b..a5560b6892 100644 --- a/awx/ui/static/js/helpers/search.js +++ b/awx/ui/static/js/helpers/search.js @@ -106,7 +106,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) scope.search(iterator); } - scope.search = function(iterator) { + scope.search = function(iterator, page) { + // Page is optional. Added to accomodate back function on Job Events detail. + scope[iterator + 'SearchSpin'] = true; scope[iterator + 'Loading'] = true; scope[iterator + 'SearchParms'] = ''; @@ -155,7 +157,7 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) else { scope[iterator + 'SearchParams'] = (sort_order) ? 'order_by=' + escape(sort_order) : ""; } - scope[iterator + 'Page'] = 0; + scope[iterator + 'Page'] = (page) ? parseInt(page) - 1 : 0; if (/\/$/.test(url)) { url += '?' + scope[iterator + 'SearchParams']; } @@ -164,6 +166,9 @@ angular.module('SearchHelper', ['RestServices', 'Utilities', 'RefreshHelper']) } url = url.replace(/\&\&/,'&'); url += (scope[iterator + 'PageSize']) ? '&page_size=' + scope[iterator + 'PageSize'] : ""; + if (page) { + url += '&page=' + page; + } Refresh({ scope: scope, set: set, iterator: iterator, url: url }); }