Added pagination directives

I'm injecting a global pagesize parameter for the UI to use across
all services that adhere to the storyboard contract. Then, I set
that as a default parameter within our API signature. This is
essentially a shim to ensure that for now, all of our content shows
up when we ask for it. More sophisticated paging will be required
eventually.

Also, removed unused header directives, and corrected the count
in the projects and stories list page.

Depends on https://review.openstack.org/#/c/83568

Change-Id: I4cb08e93ac57d089e6201236c3f640f0b2f9a31f
This commit is contained in:
Michael Krotscheck 2014-03-27 13:17:46 -07:00
parent f0232defc3
commit aab6e7d2d2
5 changed files with 30 additions and 32 deletions

View File

@ -27,8 +27,6 @@ angular.module('sb.projects').controller('ProjectListController',
function resetScope() {
$scope.projectCount = 0;
$scope.projectOffset = 0;
$scope.projectLimit = 10;
$scope.projects = [];
$scope.error = {};
}
@ -50,16 +48,9 @@ angular.module('sb.projects').controller('ProjectListController',
{ /*q: $scope.searchQuery || ''*/},
function (result, headers) {
// Extract metadata from returned headers.
var projectCount = headers('X-List-Total') || result.length;
var projectOffset = headers('X-List-Offset') || 0;
var projectLimit = headers('X-List-Limit') || result.length;
// Successful search results, apply the results to the
// scope and unset our progress flag.
$scope.projectCount = projectCount;
$scope.projectOffset = projectOffset;
$scope.projectLimit = projectLimit;
$scope.projectCount = headers('X-Total') || result.length;
$scope.projects = result;
$scope.isSearching = false;
},

View File

@ -36,8 +36,6 @@ angular.module('sb.projects').controller('ProjectStoryListController',
// Variables and methods available to the template...
function resetScope() {
$scope.storyCount = 0;
$scope.storyOffset = 0;
$scope.storyLimit = 10;
$scope.stories = [];
$scope.error = {};
}
@ -58,16 +56,9 @@ angular.module('sb.projects').controller('ProjectStoryListController',
{project_id: id},
function (result, headers) {
// Extract metadata from returned headers.
var storyCount = headers('X-List-Total') || result.length;
var storyOffset = headers('X-List-Offset') || 0;
var storyLimit = headers('X-List-Limit') || result.length;
// Successful search results, apply the results to the
// scope and unset our progress flag.
$scope.storyCount = storyCount;
$scope.storyOffset = storyOffset;
$scope.storyLimit = storyLimit;
$scope.storyCount = headers('X-Total') || result.length;
$scope.stories = result;
$scope.isSearching = false;
},

View File

@ -0,0 +1,22 @@
/*
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
/**
* Our globally configured page size.
*/
angular.module('sb.services').constant('pageSize', 500);

View File

@ -21,7 +21,7 @@
* @author Michael Krotscheck
*/
angular.module('sb.services')
.factory('storyboardApiSignature', function () {
.factory('storyboardApiSignature', function (pageSize) {
'use strict';
return {
@ -41,7 +41,10 @@ angular.module('sb.services')
'query': {
method: 'GET',
isArray: true,
responseType: 'json'
responseType: 'json',
params: {
limit: pageSize
}
}
};
}

View File

@ -29,8 +29,6 @@ angular.module('sb.story').controller('StoryListController',
// Variables and methods available to the template...
function resetScope() {
$scope.storyCount = 0;
$scope.storyOffset = 0;
$scope.storyLimit = 10;
$scope.stories = [];
$scope.error = {};
}
@ -52,16 +50,9 @@ angular.module('sb.story').controller('StoryListController',
{},
function (result, headers) {
// Extract metadata from returned headers.
var storyCount = headers('X-List-Total') || result.length;
var storyOffset = headers('X-List-Offset') || 0;
var storyLimit = headers('X-List-Limit') || result.length;
// Successful search results, apply the results to the
// scope and unset our progress flag.
$scope.storyCount = storyCount;
$scope.storyOffset = storyOffset;
$scope.storyLimit = storyLimit;
$scope.storyCount = headers('X-Total') || result.length;
$scope.stories = result;
$scope.isSearching = false;
},