diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-08-12 18:22:58 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-08-12 18:22:58 +0200 |
commit | e2f555cab7563cd74fa790cea5fc65f2e31b0dc0 (patch) | |
tree | 73b68f28c3d8b4521612e5c6de120d2d2614dd70 /client/src/app/admin/friends/shared/friend.service.ts | |
parent | c323efb9cdc6a605242d112ac0c9db9f67eabaad (diff) | |
download | PeerTube-e2f555cab7563cd74fa790cea5fc65f2e31b0dc0.tar.gz PeerTube-e2f555cab7563cd74fa790cea5fc65f2e31b0dc0.tar.zst PeerTube-e2f555cab7563cd74fa790cea5fc65f2e31b0dc0.zip |
Client: add friends page
Diffstat (limited to 'client/src/app/admin/friends/shared/friend.service.ts')
-rw-r--r-- | client/src/app/admin/friends/shared/friend.service.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/admin/friends/shared/friend.service.ts new file mode 100644 index 000000000..da4d64611 --- /dev/null +++ b/client/src/app/admin/friends/shared/friend.service.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { Injectable } from '@angular/core'; | ||
2 | import { Response } from '@angular/http'; | ||
3 | import { Observable } from 'rxjs/Observable'; | ||
4 | |||
5 | import { Friend } from './friend.model'; | ||
6 | import { AuthHttp, AuthService } from '../../../shared'; | ||
7 | |||
8 | @Injectable() | ||
9 | export class FriendService { | ||
10 | private static BASE_FRIEND_URL: string = '/api/v1/pods/'; | ||
11 | |||
12 | constructor ( | ||
13 | private authHttp: AuthHttp, | ||
14 | private authService: AuthService | ||
15 | ) {} | ||
16 | |||
17 | getFriends(): Observable<Friend[]> { | ||
18 | return this.authHttp.get(FriendService.BASE_FRIEND_URL) | ||
19 | .map(res => <Friend[]>res.json()) | ||
20 | .catch(this.handleError); | ||
21 | } | ||
22 | |||
23 | makeFriends() { | ||
24 | return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'makefriends') | ||
25 | .map(res => res.status) | ||
26 | .catch(this.handleError); | ||
27 | } | ||
28 | |||
29 | quitFriends() { | ||
30 | return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends') | ||
31 | .map(res => res.status) | ||
32 | .catch(this.handleError); | ||
33 | } | ||
34 | |||
35 | private handleError (error: Response) { | ||
36 | console.error(error); | ||
37 | return Observable.throw(error.json().error || 'Server error'); | ||
38 | } | ||
39 | } | ||