add missing pagination folder

This commit is contained in:
John Mitchell 2016-01-12 11:54:26 -05:00
parent c6f9dc90fb
commit 6a8955b817
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,11 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
import pagination from './pagination.service';
export default
angular.module('pagination', [])
.factory('pagination', pagination);

View File

@ -0,0 +1,26 @@
/*************************************************
* Copyright (c) 2015 Ansible, Inc.
*
* All Rights Reserved
*************************************************/
export default ['$q', '$http', function($q, $http) {
return {
getInitialPageForList: function(id, url, pageSize) {
// get the name of the object
return $http.get(url + "?id=" + id)
.then(function (data) {
var name = data.data.results[0].name;
// get how many results are less than or equal to
// the name
return $http.get(url + "?name__lte=" + name)
.then(function (data) {
// divide by the page size to get what
// page the data should be on
var count = data.data.count;
return Math.ceil(count/pageSize);
});
});
}
};
}];