diff options
author | Green-Star <Green-Star@users.noreply.github.com> | 2017-09-22 09:13:43 +0200 |
---|---|---|
committer | Bigard Florian <florian.bigard@gmail.com> | 2017-09-22 09:13:43 +0200 |
commit | 792dbaf07f83fbe3f1d209cd9edf190442c7d2f3 (patch) | |
tree | f7edf9caf17baaaf95c219c3ac73d598e3fd3df8 /client/src/app/+admin/blacklist/shared | |
parent | c9d6d155c397d0da0cb2d50064264fc1716f0501 (diff) | |
download | PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.tar.gz PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.tar.zst PeerTube-792dbaf07f83fbe3f1d209cd9edf190442c7d2f3.zip |
Handle blacklist (#84)
* Client: Add list blacklist feature
* Server: Add list blacklist feature
* Client: Add videoId column
* Server: Add some video infos in the REST api
* Client: Add video information in the blacklist list
* Fix sortable columns :)
* Client: Add removeFromBlacklist feature
* Server: Add removeFromBlacklist feature
* Move to TypeScript
* Move to TypeScript and Promises
* Server: Fix blacklist list sort
* Server: Fetch videos informations
* Use common shared interface for client and server
* Add check-params remove blacklisted video tests
* Add check-params list blacklisted videos tests
* Add list blacklist tests
* Add remove from blacklist tests
* Add video blacklist management tests
* Fix rebase onto develop issues
* Server: Add sort on blacklist id column
* Server: Add blacklists library
* Add blacklist id sort test
* Add check-params tests for blacklist list pagination, count and sort
* Fix coding style
* Increase Remote API tests timeout
* Increase Request scheduler API tests timeout
* Fix typo
* Increase video transcoding API tests timeout
* Move tests to Typescript
* Use lodash orderBy method
* Fix typos
* Client: Remove optional tests in blacklist model attributes
* Move blacklist routes from 'blacklists' to 'blacklist'
* CLient: Remove blacklist-list.component.scss
* Rename 'blacklists' files to 'blacklist'
* Use only BlacklistedVideo interface
* Server: Use getFormattedObjects method in listBlacklist method
* Client: Use new coding style
* Server: Use new sort validator methods
* Server: Use new checkParams methods
* Client: Fix sortable columns
Diffstat (limited to 'client/src/app/+admin/blacklist/shared')
-rw-r--r-- | client/src/app/+admin/blacklist/shared/blacklist.service.ts | 44 | ||||
-rw-r--r-- | client/src/app/+admin/blacklist/shared/index.ts | 1 |
2 files changed, 45 insertions, 0 deletions
diff --git a/client/src/app/+admin/blacklist/shared/blacklist.service.ts b/client/src/app/+admin/blacklist/shared/blacklist.service.ts new file mode 100644 index 000000000..1b090c9c5 --- /dev/null +++ b/client/src/app/+admin/blacklist/shared/blacklist.service.ts | |||
@@ -0,0 +1,44 @@ | |||
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/components/common/sortmeta' | ||
8 | |||
9 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | ||
10 | import { Utils } from '../../../shared' | ||
11 | import { BlacklistedVideo, ResultList } from '../../../../../../shared' | ||
12 | |||
13 | @Injectable() | ||
14 | export class BlacklistService { | ||
15 | private static BASE_BLACKLISTS_URL = '/api/v1/blacklist/' | ||
16 | |||
17 | constructor ( | ||
18 | private authHttp: HttpClient, | ||
19 | private restService: RestService, | ||
20 | private restExtractor: RestExtractor | ||
21 | ) {} | ||
22 | |||
23 | getBlacklist (pagination: RestPagination, sort: SortMeta): Observable<ResultList<BlacklistedVideo>> { | ||
24 | let params = new HttpParams() | ||
25 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
26 | |||
27 | return this.authHttp.get<ResultList<BlacklistedVideo>>(BlacklistService.BASE_BLACKLISTS_URL, { params }) | ||
28 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | ||
29 | .map(res => this.restExtractor.applyToResultListData(res, this.formatBlacklistedVideo.bind(this))) | ||
30 | .catch(res => this.restExtractor.handleError(res)) | ||
31 | } | ||
32 | |||
33 | removeVideoFromBlacklist (entry: BlacklistedVideo) { | ||
34 | return this.authHttp.delete(BlacklistService.BASE_BLACKLISTS_URL + entry.id) | ||
35 | .map(this.restExtractor.extractDataBool) | ||
36 | .catch(res => this.restExtractor.handleError(res)) | ||
37 | } | ||
38 | |||
39 | private formatBlacklistedVideo (blacklistedVideo: BlacklistedVideo) { | ||
40 | return Object.assign(blacklistedVideo, { | ||
41 | createdAt: Utils.dateToHuman(blacklistedVideo.createdAt) | ||
42 | }) | ||
43 | } | ||
44 | } | ||
diff --git a/client/src/app/+admin/blacklist/shared/index.ts b/client/src/app/+admin/blacklist/shared/index.ts new file mode 100644 index 000000000..ad22e2d51 --- /dev/null +++ b/client/src/app/+admin/blacklist/shared/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './blacklist.service' | |||