aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/admin/friends
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/admin/friends')
-rw-r--r--client/src/app/admin/friends/shared/friend.service.ts22
1 files changed, 9 insertions, 13 deletions
diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/admin/friends/shared/friend.service.ts
index e4e680c29..75826fc17 100644
--- a/client/src/app/admin/friends/shared/friend.service.ts
+++ b/client/src/app/admin/friends/shared/friend.service.ts
@@ -1,9 +1,8 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Response } from '@angular/http';
3import { Observable } from 'rxjs/Observable'; 2import { Observable } from 'rxjs/Observable';
4 3
5import { Friend } from './friend.model'; 4import { Friend } from './friend.model';
6import { AuthHttp, AuthService } from '../../../shared'; 5import { AuthHttp, RestExtractor } from '../../../shared';
7 6
8@Injectable() 7@Injectable()
9export class FriendService { 8export class FriendService {
@@ -11,13 +10,15 @@ export class FriendService {
11 10
12 constructor ( 11 constructor (
13 private authHttp: AuthHttp, 12 private authHttp: AuthHttp,
14 private authService: AuthService 13 private restExtractor: RestExtractor
15 ) {} 14 ) {}
16 15
17 getFriends(): Observable<Friend[]> { 16 getFriends(): Observable<Friend[]> {
18 return this.authHttp.get(FriendService.BASE_FRIEND_URL) 17 return this.authHttp.get(FriendService.BASE_FRIEND_URL)
19 .map(res => <Friend[]>res.json()) 18 // Not implemented as a data list by the server yet
20 .catch(this.handleError); 19 // .map(this.restExtractor.extractDataList)
20 .map((res) => res.json())
21 .catch((res) => this.restExtractor.handleError(res));
21 } 22 }
22 23
23 makeFriends(notEmptyUrls) { 24 makeFriends(notEmptyUrls) {
@@ -26,18 +27,13 @@ export class FriendService {
26 }; 27 };
27 28
28 return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body) 29 return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'makefriends', body)
29 .map(res => res.status) 30 .map(this.restExtractor.extractDataBool)
30 .catch(this.handleError); 31 .catch((res) => this.restExtractor.handleError(res));
31 } 32 }
32 33
33 quitFriends() { 34 quitFriends() {
34 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends') 35 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
35 .map(res => res.status) 36 .map(res => res.status)
36 .catch(this.handleError); 37 .catch((res) => this.restExtractor.handleError(res));
37 }
38
39 private handleError (error: Response) {
40 console.error(error);
41 return Observable.throw(error.json().error || 'Server error');
42 } 38 }
43} 39}