From 300fb677fac8fbe80cfbe387ffce62a8e3a22061 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Mon, 24 Nov 2014 13:29:30 -0500 Subject: [PATCH] Portal mode pagination fixed the pagination on the job templates portal widget. To fix this i had to include an '&' in the pagination url creation in paginationhelpers.js. not sure if this could have effect on anything else that uses pagination. --- awx/ui/static/js/controllers/Portal.js | 63 +++++++++++++------ awx/ui/static/js/helpers/PaginationHelpers.js | 2 +- awx/ui/static/js/widgets/PortalJobs.js | 10 +-- awx/ui/templates/ui/index.html | 2 +- 4 files changed, 53 insertions(+), 24 deletions(-) diff --git a/awx/ui/static/js/controllers/Portal.js b/awx/ui/static/js/controllers/Portal.js index 95bdc98b14..035c62fb97 100644 --- a/awx/ui/static/js/controllers/Portal.js +++ b/awx/ui/static/js/controllers/Portal.js @@ -35,6 +35,7 @@ function PortalController($scope, $compile, $routeParams, $rootScope, $location, list = PortalJobTemplateList, view= GenerateList, defaultUrl = GetBasePath('job_templates'), + max_rows, buttons = { refresh: { mode: 'all', @@ -79,6 +80,7 @@ function PortalController($scope, $compile, $routeParams, $rootScope, $location, searchSize: 'col-lg-6 col-md-6' }); + $scope.job_templatePageSize = $scope.getMaxRows(); SearchInit({ scope: $scope, @@ -89,16 +91,10 @@ function PortalController($scope, $compile, $routeParams, $rootScope, $location, PaginateInit({ scope: $scope, list: list, - url: defaultUrl + url: defaultUrl, + pageSize: $scope.job_templatePageSize }); - // Called from Inventories tab, host failed events link: - if ($routeParams.name) { - $scope[list.iterator + 'SearchField'] = 'name'; - $scope[list.iterator + 'SearchValue'] = $routeParams.name; - $scope[list.iterator + 'SearchFieldLabel'] = list.fields.name.label; - } - $scope.search(list.iterator); PortalJobsWidget({ @@ -126,22 +122,53 @@ function PortalController($scope, $compile, $routeParams, $rootScope, $location, jobs_scope.search('portal_job'); //processEvent(event); }); + $scope.getMaxRows = function(){ + var docw = $(window).width(), + box_height, available_height, search_row, page_row, height, header, row_height; + + available_height = Math.floor($(window).height() - $('#main-menu-container .navbar').outerHeight() - $('#refresh-row').outerHeight() - 35); + $('.portal-job-template-container').height(available_height); + $('.portal-container').height(available_height); + search_row = Math.max($('.search-row:eq(0)').outerHeight(), 50); + page_row = Math.max($('.page-row:eq(0)').outerHeight(), 33); + header = 0; //Math.max($('#completed_jobs_table thead').height(), 41); + height = Math.floor(available_height) - header - page_row - search_row ; + if (docw < 765 && docw >= 493) { + row_height = 27; + } + else if (docw < 493) { + row_height = 47; + } + else if (docw < 865) { + row_height = 87; + } + else if (docw < 925) { + row_height = 67; + } + else if (docw < 1415) { + row_height = 47; + } + else { + row_height = 35; + } + max_rows = Math.floor(height / row_height); + if (max_rows < 5){ + box_height = header+page_row + search_row + 40 + (5 * row_height); + if (docw < 1140) { + box_height += 40; + } + // $('.portal-job-template-container').height(box_height); + max_rows = 5; + } + return max_rows; + }; + $scope.submitJob = function (id) { PlaybookRun({ scope: $scope, id: id }); }; $scope.refresh = function () { $scope.$emit('LoadPortal'); - // Wait('start'); - // loadedCount = 0; - // Rest.setUrl(GetBasePath('dashboard')); - // Rest.get() - // .success(function (data) { - // $scope.$emit('dashboardReady', data); - // }) - // .error(function (data, status) { - // ProcessErrors($scope, data, status, null, { hdr: 'Error!', msg: 'Failed to get dashboard: ' + status }); - // }); }; $scope.refresh(); diff --git a/awx/ui/static/js/helpers/PaginationHelpers.js b/awx/ui/static/js/helpers/PaginationHelpers.js index f1d25531a2..87ac589aad 100644 --- a/awx/ui/static/js/helpers/PaginationHelpers.js +++ b/awx/ui/static/js/helpers/PaginationHelpers.js @@ -138,7 +138,7 @@ angular.module('PaginationHelpers', ['Utilities', 'RefreshHelper', 'RefreshRelat connect = (/\/$/.test(new_url)) ? '?' : '&'; new_url += connect + 'page=' + page; new_url += (scope[iterator + 'SearchParams']) ? '&' + scope[iterator + 'SearchParams'] + - '&page_size=' + scope[iterator + '_page_size'] : 'page_size=' + scope[iterator + 'PageSize']; + '&page_size=' + scope[iterator + '_page_size'] : '&page_size=' + scope[iterator + 'PageSize']; Wait('start'); Refresh({ scope: scope, set: set, iterator: iterator, url: new_url }); }; diff --git a/awx/ui/static/js/widgets/PortalJobs.js b/awx/ui/static/js/widgets/PortalJobs.js index 84d17a51d9..dddfde7a45 100644 --- a/awx/ui/static/js/widgets/PortalJobs.js +++ b/awx/ui/static/js/widgets/PortalJobs.js @@ -11,8 +11,8 @@ 'use strict'; angular.module('PortalJobsWidget', ['RestServices', 'Utilities']) -.factory('PortalJobsWidget', ['$rootScope', '$compile', 'LoadSchedulesScope', 'LoadJobsScope', 'PortalJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', - function ($rootScope, $compile, LoadSchedulesScope, LoadJobsScope, PortalJobsList, ScheduledJobsList, GetChoices, GetBasePath) { +.factory('PortalJobsWidget', ['$rootScope', '$compile', 'LoadSchedulesScope', 'LoadJobsScope', 'PortalJobsList', 'ScheduledJobsList', 'GetChoices', 'GetBasePath', 'PortalJobTemplateList', + function ($rootScope, $compile, LoadSchedulesScope, LoadJobsScope, PortalJobsList, ScheduledJobsList, GetChoices, GetBasePath, PortalJobTemplateList) { return function (params) { var scope = params.scope, target = params.target, @@ -70,6 +70,7 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities']) }); + $(window).resize(_.debounce(function() { resizePortalJobsWidget(); }, 500)); @@ -150,8 +151,9 @@ angular.module('PortalJobsWidget', ['RestServices', 'Utilities']) setPortalJobsHeight(); jobs_scope[PortalJobsList.iterator + '_page_size'] = max_rows; jobs_scope.changePageSize(PortalJobsList.name, PortalJobsList.iterator, false); - // scheduled_scope[ScheduledJobsList.iterator + '_page_size'] = max_rows; - // scheduled_scope.changePageSize(ScheduledJobsList.name, ScheduledJobsList.iterator, false); + scope[PortalJobTemplateList.iterator + '_page_size'] = max_rows; + scope[PortalJobTemplateList.iterator + 'PageSize'] = max_rows; + scope.changePageSize(PortalJobTemplateList.name, PortalJobTemplateList.iterator, false); } diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index b695b1dce3..1f8604ffdb 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -205,7 +205,7 @@ Monitor Tower Portal Mode View License - Exit Portal Mode + Exit Portal Logout