mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-18 01:42:20 +00:00
apiUrlService inside services
This commit is contained in:
parent
8f468c27ff
commit
e180f73a0e
4 changed files with 19 additions and 28 deletions
|
|
@ -29,9 +29,7 @@ factory('Facebook',
|
|||
email: response.email
|
||||
}
|
||||
|
||||
var API_URL = ApiUrlService.getApiUrl();
|
||||
|
||||
$http.post(API_URL + '/api/v2/user/auth/facebook', data).success(function(data, status, headers, config) {
|
||||
$http.post(ApiUrlService.get() + '/api/v2/user/auth/facebook', data).success(function(data, status, headers, config) {
|
||||
User.authenticate(data.id, data.token, function(err) {
|
||||
if (!err) {
|
||||
alert(window.env.t('loginSuccess'));
|
||||
|
|
|
|||
|
|
@ -7,16 +7,14 @@
|
|||
angular.module('challengeServices', ['ngResource']).
|
||||
factory('Challenges', ['ApiUrlService', '$resource', 'User', '$q', 'Members',
|
||||
function(ApiUrlService, $resource, User, $q, Members) {
|
||||
var API_URL = ApiUrlService.getApiUrl();
|
||||
|
||||
var Challenge = $resource(API_URL + '/api/v2/challenges/:cid',
|
||||
var Challenge = $resource(ApiUrlService.get() + '/api/v2/challenges/:cid',
|
||||
{cid:'@_id'},
|
||||
{
|
||||
//'query': {method: "GET", isArray:false}
|
||||
join: {method: "POST", url: API_URL + '/api/v2/challenges/:cid/join'},
|
||||
leave: {method: "POST", url: API_URL + '/api/v2/challenges/:cid/leave'},
|
||||
close: {method: "POST", params: {uid:''}, url: API_URL + '/api/v2/challenges/:cid/close'},
|
||||
getMember: {method: "GET", url: API_URL + '/api/v2/challenges/:cid/member/:uid'}
|
||||
join: {method: "POST", url: ApiUrlService.get() + '/api/v2/challenges/:cid/join'},
|
||||
leave: {method: "POST", url: ApiUrlService.get() + '/api/v2/challenges/:cid/leave'},
|
||||
close: {method: "POST", params: {uid:''}, url: ApiUrlService.get() + '/api/v2/challenges/:cid/close'},
|
||||
getMember: {method: "GET", url: ApiUrlService.get() + '/api/v2/challenges/:cid/member/:uid'}
|
||||
});
|
||||
|
||||
//var challenges = [];
|
||||
|
|
|
|||
|
|
@ -7,22 +7,20 @@
|
|||
angular.module('groupServices', ['ngResource']).
|
||||
factory('Groups', ['ApiUrlService', '$resource', '$q', '$http', 'User',
|
||||
function(ApiUrlService, $resource, $q, $http, User) {
|
||||
var API_URL = ApiUrlService.getApiUrl();
|
||||
|
||||
var Group = $resource(API_URL + '/api/v2/groups/:gid',
|
||||
var Group = $resource(ApiUrlService.get() + '/api/v2/groups/:gid',
|
||||
{gid:'@_id', messageId: '@_messageId'},
|
||||
{
|
||||
//query: {method: "GET", isArray:false},
|
||||
postChat: {method: "POST", url: API_URL + '/api/v2/groups/:gid/chat'},
|
||||
deleteChatMessage: {method: "DELETE", url: API_URL + '/api/v2/groups/:gid/chat/:messageId'},
|
||||
join: {method: "POST", url: API_URL + '/api/v2/groups/:gid/join'},
|
||||
leave: {method: "POST", url: API_URL + '/api/v2/groups/:gid/leave'},
|
||||
invite: {method: "POST", url: API_URL + '/api/v2/groups/:gid/invite'},
|
||||
removeMember: {method: "POST", url: API_URL + '/api/v2/groups/:gid/removeMember'},
|
||||
questAccept: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questAccept'},
|
||||
questReject: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questReject'},
|
||||
questCancel: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questCancel'},
|
||||
questAbort: {method: "POST", url: API_URL + '/api/v2/groups/:gid/questAbort'}
|
||||
postChat: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/chat'},
|
||||
deleteChatMessage: {method: "DELETE", url: ApiUrlService.get() + '/api/v2/groups/:gid/chat/:messageId'},
|
||||
join: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/join'},
|
||||
leave: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/leave'},
|
||||
invite: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/invite'},
|
||||
removeMember: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/removeMember'},
|
||||
questAccept: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/questAccept'},
|
||||
questReject: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/questReject'},
|
||||
questCancel: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/questCancel'},
|
||||
questAbort: {method: "POST", url: ApiUrlService.get() + '/api/v2/groups/:gid/questAbort'}
|
||||
});
|
||||
|
||||
// Defer loading everything until they're requested
|
||||
|
|
@ -49,7 +47,7 @@ angular.module('groupServices', ['ngResource']).
|
|||
|
||||
// On enter, set chat message to "seen"
|
||||
seenMessage: function(gid){
|
||||
$http.post('/api/v2/groups/'+gid+'/chat/seen');
|
||||
$http.post(ApiUrlService.get() + '/api/v2/groups/'+gid+'/chat/seen');
|
||||
if (User.user.newMessages) delete User.user.newMessages[gid];
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,8 @@
|
|||
angular.module('memberServices', ['ngResource', 'sharedServices']).
|
||||
factory('Members', ['$rootScope', 'Shared', 'ApiUrlService', '$resource',
|
||||
function($rootScope, Shared, ApiUrlService, $resource) {
|
||||
|
||||
var API_URL = ApiUrlService.getApiUrl();
|
||||
|
||||
var members = {};
|
||||
var Member = $resource(API_URL + '/api/v2/members/:uid', {uid:'@_id'});
|
||||
var Member = $resource(ApiUrlService.get() + '/api/v2/members/:uid', {uid:'@_id'});
|
||||
var memberServices = {
|
||||
|
||||
Member: Member,
|
||||
|
|
|
|||
Loading…
Reference in a new issue