mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
v3: correctly use v3 routes in client
This commit is contained in:
@@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource',
|
habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource',
|
||||||
function($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.hero = undefined;
|
||||||
$scope.loadHero = function(uuid){
|
$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.saveHero = function(hero) {
|
||||||
$scope.hero.contributor.admin = ($scope.hero.contributor.level > 7) ? true : false;
|
$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");
|
Notification.text("User updated");
|
||||||
$scope.hero = undefined;
|
$scope.hero = undefined;
|
||||||
$scope._heroID = 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.populateContributorInput = function(id) {
|
||||||
$scope._heroID = id;
|
$scope._heroID = id;
|
||||||
@@ -27,14 +33,14 @@ habitrpg.controller("HallHeroesCtrl", ['$scope', '$rootScope', 'User', 'Notifica
|
|||||||
|
|
||||||
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource',
|
habitrpg.controller("HallPatronsCtrl", ['$scope', '$rootScope', 'User', 'Notification', 'ApiUrl', '$resource',
|
||||||
function($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;
|
var page = 0;
|
||||||
$scope.patrons = [];
|
$scope.patrons = [];
|
||||||
|
|
||||||
$scope.loadMore = function(){
|
$scope.loadMore = function(){
|
||||||
Patron.query({page: page++}, function(patrons){
|
Patron.query({page: page++}, function(patronsData){
|
||||||
$scope.patrons = $scope.patrons.concat(patrons);
|
$scope.patrons = $scope.patrons.concat(patronsData.data);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$scope.loadMore();
|
$scope.loadMore();
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ habitrpg.controller('SettingsCtrl',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.changeUser = function(attr, updates){
|
$scope.changeUser = function(attr, updates){
|
||||||
$http.post(ApiUrl.get() + '/api/v2/user/change-'+attr, updates)
|
$http.put(ApiUrl.get() + '/api/v3/user/auth/update-'+attr, updates)
|
||||||
.success(function(){
|
.success(function(){
|
||||||
alert(window.env.t(attr+'Success'));
|
alert(window.env.t(attr+'Success'));
|
||||||
_.each(updates, function(v,k){updates[k]=null;});
|
_.each(updates, function(v,k){updates[k]=null;});
|
||||||
@@ -181,7 +181,7 @@ habitrpg.controller('SettingsCtrl',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope['delete'] = function(){
|
$scope['delete'] = function(){
|
||||||
$http['delete'](ApiUrl.get() + '/api/v2/user')
|
$http['delete'](ApiUrl.get() + '/api/v3/user')
|
||||||
.success(function(res, code){
|
.success(function(res, code){
|
||||||
if (res.err) return alert(res.err);
|
if (res.err) return alert(res.err);
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
@@ -190,7 +190,7 @@ habitrpg.controller('SettingsCtrl',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.enterCoupon = function(code) {
|
$scope.enterCoupon = function(code) {
|
||||||
$http.post(ApiUrl.get() + '/api/v2/user/coupon/' + code).success(function(res,code){
|
$http.post(ApiUrl.get() + '/api/v3/coupons/enter/' + code).success(function(res,code){
|
||||||
if (code!==200) return;
|
if (code!==200) return;
|
||||||
User.sync();
|
User.sync();
|
||||||
Notification.text(env.t('promoCodeApplied'));
|
Notification.text(env.t('promoCodeApplied'));
|
||||||
@@ -259,7 +259,7 @@ habitrpg.controller('SettingsCtrl',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$scope.applyCoupon = function(coupon){
|
$scope.applyCoupon = function(coupon){
|
||||||
$http.get(ApiUrl.get() + '/api/v2/coupons/valid-discount/'+coupon)
|
$http.get(ApiUrl.get() + '/api/v3/coupons/validate/'+coupon)
|
||||||
.success(function(){
|
.success(function(){
|
||||||
Notification.text("Coupon applied!");
|
Notification.text("Coupon applied!");
|
||||||
var subs = Content.subscriptionBlocks;
|
var subs = Content.subscriptionBlocks;
|
||||||
|
|||||||
Reference in New Issue
Block a user