From 6a8955b8174abafcdb77ea720e7e861d3c9ace9b Mon Sep 17 00:00:00 2001 From: John Mitchell Date: Tue, 12 Jan 2016 11:54:26 -0500 Subject: [PATCH] add missing pagination folder --- awx/ui/client/src/shared/pagination/main.js | 11 ++++++++ .../shared/pagination/pagination.service.js | 26 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 awx/ui/client/src/shared/pagination/main.js create mode 100644 awx/ui/client/src/shared/pagination/pagination.service.js diff --git a/awx/ui/client/src/shared/pagination/main.js b/awx/ui/client/src/shared/pagination/main.js new file mode 100644 index 0000000000..088bb0e399 --- /dev/null +++ b/awx/ui/client/src/shared/pagination/main.js @@ -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); diff --git a/awx/ui/client/src/shared/pagination/pagination.service.js b/awx/ui/client/src/shared/pagination/pagination.service.js new file mode 100644 index 0000000000..f18d7890e9 --- /dev/null +++ b/awx/ui/client/src/shared/pagination/pagination.service.js @@ -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); + }); + }); + } + }; +}];