hall: use infinite-scroll to load patrons, since there are so many

This commit is contained in:
Tyler Renelle 2014-01-05 19:51:33 -07:00
parent a5db8628e2
commit eb5a9150ab
7 changed files with 24 additions and 5 deletions

View file

@ -39,7 +39,8 @@
"sticky": "*",
"bootstrap-tour": "~0.8.0",
"angular-ui-utils": "~0.1.0",
"swagger-ui": "https://github.com/wordnik/swagger-ui.git#105c516f5f055b140e935e9cfe0c36f841921dff"
"swagger-ui": "https://github.com/wordnik/swagger-ui.git#105c516f5f055b140e935e9cfe0c36f841921dff",
"ngInfiniteScroll": "~1.0.0"
},
"resolutions": {
"jquery": "~2.0.3",

View file

@ -18,7 +18,7 @@ window.env.t = function(string){
window.habitrpg = angular.module('habitrpg',
['ngResource', 'ngSanitize', 'userServices', 'groupServices', 'memberServices', 'challengeServices',
'authServices', 'notificationServices', 'guideServices',
'ui.bootstrap', 'ui.keypress', 'ui.router', 'chieffancypants.loadingBar', 'At', 'pasvaz.bindonce'])
'ui.bootstrap', 'ui.keypress', 'ui.router', 'chieffancypants.loadingBar', 'At', 'pasvaz.bindonce', 'infinite-scroll'])
// @see https://github.com/angular-ui/ui-router/issues/110 and https://github.com/HabitRPG/habitrpg/issues/1705
// temporary hack until they have a better solution

View file

@ -21,5 +21,15 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'API_URL', '$resource',
function($scope, $rootScope, User, Notification, API_URL, $resource) {
var Patron = $resource(API_URL + '/api/v2/hall/patrons/:uid', {uid:'@_id'});
$scope.patrons = Patron.query();
var page = 0;
$scope.patrons = [];
$scope.loadMore = function(){
Patron.query({page: page++}, function(patrons){
$scope.patrons = $scope.patrons.concat(patrons);
})
}
$scope.loadMore();
}]);

View file

@ -18,6 +18,7 @@
"bower_components/angular-bindonce/bindonce.js",
"bower_components/js-emoji/emoji.js",
"bower_components/sticky/jquery.sticky.js",
"bower_components/ngInfiniteScroll/ng-infinite-scroll.js",
"bower_components/bootstrap/docs/assets/js/bootstrap.js",
"bower_components/angular-bootstrap/ui-bootstrap.js",

View file

@ -23,9 +23,13 @@ api.getHeroes = function(req,res,next) {
}
api.getPatrons = function(req,res,next){
var page = req.query.page || 0,
perPage = 50;
User.find({'backer.tier':{$ne:null}})
.select('contributor backer profile.name')
.sort('-backer.tier')
.skip(page*perPage)
.limit(perPage)
.exec(function(err, users){
if (err) return next(err);
res.json(users);

View file

@ -511,7 +511,10 @@ module.exports = (swagger, v2) ->
action: hall.updateHero
"/hall/patrons":
spec: {}
spec:
params: [
query 'page','Page number to fetch (this list is long)','string'
]
middleware:[auth.auth]
action: hall.getPatrons

View file

@ -82,7 +82,7 @@ script(type='text/ng-template', id='partials/options.social.hall.heroes.html')
markdown(ng-model='hero.contributor.contributions', target='_blank')
script(type='text/ng-template', id='partials/options.social.hall.patrons.html')
table.table.table-striped
table.table.table-striped(infinite-scroll="loadMore()",infinite-scroll-distance="3")
tr
thead
tr