v3: correctly use v3 routes in client

This commit is contained in:
Matteo Pagliazzi
2016-05-19 22:59:17 +02:00
parent 5ba33bc5a1
commit bf776e38c7
2 changed files with 17 additions and 11 deletions

View File

@@ -2,10 +2,12 @@
habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource',
function($scope, $rootScope, User, Notification, ApiUrl, $resource) {
var Hero = $resource(ApiUrl.get() + '/api/v2/hall/heroes/:uid', {uid:'@_id'});
var Hero = $resource(ApiUrl.get() + '/api/v3/hall/heroes/:uid', {uid:'@_id'});
$scope.hero = undefined;
$scope.loadHero = function(uuid){
$scope.hero = Hero.get({uid:uuid});
Hero.query({uid:uuid}, function (heroData) {
$scope.hero = heroData.data;
});
}
$scope.saveHero = function(hero) {
$scope.hero.contributor.admin = ($scope.hero.contributor.level > 7) ? true : false;
@@ -13,10 +15,14 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica
Notification.text("User updated");
$scope.hero = undefined;
$scope._heroID = undefined;
$scope.heroes = Hero.query();
Hero.query({}, function (heroesData) {
$scope.heroes = heroesData.data;
});
})
}
$scope.heroes = Hero.query();
Hero.query({}, function (heroesData) {
$scope.heroes = heroesData.data;
});
$scope.populateContributorInput = function(id) {
$scope._heroID = id;
@@ -27,14 +33,14 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource',
function($scope, $rootScope, User, Notification, ApiUrl, $resource) {
var Patron = $resource(ApiUrl.get() + '/api/v2/hall/patrons/:uid', {uid:'@_id'});
var Patron = $resource(ApiUrl.get() + '/api/v3/hall/patrons/:uid', {uid:'@_id'});
var page = 0;
$scope.patrons = [];
$scope.loadMore = function(){
Patron.query({page: page++}, function(patrons){
$scope.patrons = $scope.patrons.concat(patrons);
Patron.query({page: page++}, function(patronsData){
$scope.patrons = $scope.patrons.concat(patronsData.data);
})
}
$scope.loadMore();