diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-09-14 11:57:49 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-09-14 11:57:49 +0200 |
commit | d592e0a9b2931c7c9cbedb27fb8efc9aaacad9bb (patch) | |
tree | 549b14b842de296efed846a11b3681efe08cfa9e /client/src/app/+admin/friends/shared/friend.service.ts | |
parent | 91f6f169b1110eeae6ebf5c387f4204b0d07703c (diff) | |
download | PeerTube-d592e0a9b2931c7c9cbedb27fb8efc9aaacad9bb.tar.gz PeerTube-d592e0a9b2931c7c9cbedb27fb8efc9aaacad9bb.tar.zst PeerTube-d592e0a9b2931c7c9cbedb27fb8efc9aaacad9bb.zip |
Move to HttpClient and PrimeNG data table
Diffstat (limited to 'client/src/app/+admin/friends/shared/friend.service.ts')
-rw-r--r-- | client/src/app/+admin/friends/shared/friend.service.ts | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/client/src/app/+admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts index 9b3ff04b1..45607e28d 100644 --- a/client/src/app/+admin/friends/shared/friend.service.ts +++ b/client/src/app/+admin/friends/shared/friend.service.ts | |||
@@ -1,24 +1,24 @@ | |||
1 | import { Injectable } from '@angular/core' | 1 | import { Injectable } from '@angular/core' |
2 | import { Observable } from 'rxjs/Observable' | 2 | import { HttpClient } from '@angular/common/http' |
3 | import 'rxjs/add/operator/catch' | 3 | import 'rxjs/add/operator/catch' |
4 | import 'rxjs/add/operator/map' | 4 | import 'rxjs/add/operator/map' |
5 | 5 | ||
6 | import { ServerDataSource } from 'ng2-smart-table' | 6 | import { RestExtractor, } from '../../../shared' |
7 | 7 | import { Pod, ResultList } from '../../../../../../shared' | |
8 | import { AuthHttp, RestExtractor, RestDataSource, ResultList } from '../../../shared' | ||
9 | import { Pod } from '../../../../../../shared' | ||
10 | 8 | ||
11 | @Injectable() | 9 | @Injectable() |
12 | export class FriendService { | 10 | export class FriendService { |
13 | private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/' | 11 | private static BASE_FRIEND_URL = API_URL + '/api/v1/pods/' |
14 | 12 | ||
15 | constructor ( | 13 | constructor ( |
16 | private authHttp: AuthHttp, | 14 | private authHttp: HttpClient, |
17 | private restExtractor: RestExtractor | 15 | private restExtractor: RestExtractor |
18 | ) {} | 16 | ) {} |
19 | 17 | ||
20 | getDataSource () { | 18 | getFriends () { |
21 | return new RestDataSource(this.authHttp, FriendService.BASE_FRIEND_URL) | 19 | return this.authHttp.get<ResultList<Pod>>(FriendService.BASE_FRIEND_URL) |
20 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | ||
21 | .catch(res => this.restExtractor.handleError(res)) | ||
22 | } | 22 | } |
23 | 23 | ||
24 | makeFriends (notEmptyHosts: String[]) { | 24 | makeFriends (notEmptyHosts: String[]) { |
@@ -28,18 +28,18 @@ export class FriendService { | |||
28 | 28 | ||
29 | return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'make-friends', body) | 29 | return this.authHttp.post(FriendService.BASE_FRIEND_URL + 'make-friends', body) |
30 | .map(this.restExtractor.extractDataBool) | 30 | .map(this.restExtractor.extractDataBool) |
31 | .catch((res) => this.restExtractor.handleError(res)) | 31 | .catch(res => this.restExtractor.handleError(res)) |
32 | } | 32 | } |
33 | 33 | ||
34 | quitFriends () { | 34 | quitFriends () { |
35 | return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quit-friends') | 35 | return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quit-friends') |
36 | .map(res => res.status) | 36 | .map(this.restExtractor.extractDataBool) |
37 | .catch((res) => this.restExtractor.handleError(res)) | 37 | .catch(res => this.restExtractor.handleError(res)) |
38 | } | 38 | } |
39 | 39 | ||
40 | removeFriend (friend: Pod) { | 40 | removeFriend (friend: Pod) { |
41 | return this.authHttp.delete(FriendService.BASE_FRIEND_URL + friend.id) | 41 | return this.authHttp.delete(FriendService.BASE_FRIEND_URL + friend.id) |
42 | .map(this.restExtractor.extractDataBool) | 42 | .map(this.restExtractor.extractDataBool) |
43 | .catch((res) => this.restExtractor.handleError(res)) | 43 | .catch(res => this.restExtractor.handleError(res)) |
44 | } | 44 | } |
45 | } | 45 | } |