diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-15 10:10:41 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 51548b31815c6f96f314ae96588a9adca150519d (patch) | |
tree | b3298447b7ac128823016fdec92d083e07d9432e /client/src/app/+admin/follows/shared/follow.service.ts | |
parent | 350e31d6b64e4973dfa5e9f7b46841cb09aeb1ad (diff) | |
download | PeerTube-51548b31815c6f96f314ae96588a9adca150519d.tar.gz PeerTube-51548b31815c6f96f314ae96588a9adca150519d.tar.zst PeerTube-51548b31815c6f96f314ae96588a9adca150519d.zip |
Add follow tabs
Following
Follow
Followers
Diffstat (limited to 'client/src/app/+admin/follows/shared/follow.service.ts')
-rw-r--r-- | client/src/app/+admin/follows/shared/follow.service.ts | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/client/src/app/+admin/follows/shared/follow.service.ts b/client/src/app/+admin/follows/shared/follow.service.ts new file mode 100644 index 000000000..622c33cea --- /dev/null +++ b/client/src/app/+admin/follows/shared/follow.service.ts | |||
@@ -0,0 +1,49 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
3 | import { Observable } from 'rxjs/Observable' | ||
4 | import 'rxjs/add/operator/catch' | ||
5 | import 'rxjs/add/operator/map' | ||
6 | |||
7 | import { SortMeta } from 'primeng/primeng' | ||
8 | |||
9 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | ||
10 | import { Pod, ResultList } from '../../../../../../shared' | ||
11 | |||
12 | @Injectable() | ||
13 | export class FollowService { | ||
14 | private static BASE_APPLICATION_URL = API_URL + '/api/v1/application' | ||
15 | |||
16 | constructor ( | ||
17 | private authHttp: HttpClient, | ||
18 | private restService: RestService, | ||
19 | private restExtractor: RestExtractor | ||
20 | ) {} | ||
21 | |||
22 | getFollowing (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> { | ||
23 | let params = new HttpParams() | ||
24 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
25 | |||
26 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/following', { params }) | ||
27 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | ||
28 | .catch(res => this.restExtractor.handleError(res)) | ||
29 | } | ||
30 | |||
31 | getFollowers (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Pod>> { | ||
32 | let params = new HttpParams() | ||
33 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
34 | |||
35 | return this.authHttp.get<ResultList<Account>>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) | ||
36 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | ||
37 | .catch(res => this.restExtractor.handleError(res)) | ||
38 | } | ||
39 | |||
40 | follow (notEmptyHosts: String[]) { | ||
41 | const body = { | ||
42 | hosts: notEmptyHosts | ||
43 | } | ||
44 | |||
45 | return this.authHttp.post(FollowService.BASE_APPLICATION_URL + '/follow', body) | ||
46 | .map(this.restExtractor.extractDataBool) | ||
47 | .catch(res => this.restExtractor.handleError(res)) | ||
48 | } | ||
49 | } | ||