diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-06-02 20:50:42 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-06-10 21:12:05 +0200 |
commit | 5baee5fca418487e72ddcd6419d31bca8659b668 (patch) | |
tree | 6604cc16d42152f4929d888565d2d435e2480d47 /client/src/app/shared/video-block | |
parent | d840487fed32b4604b02030c0d7464afa925904f (diff) | |
download | PeerTube-5baee5fca418487e72ddcd6419d31bca8659b668.tar.gz PeerTube-5baee5fca418487e72ddcd6419d31bca8659b668.tar.zst PeerTube-5baee5fca418487e72ddcd6419d31bca8659b668.zip |
rename blacklist to block/blocklist, merge block and auto-block views
- also replace whitelist with allowlist
- add advanced filters for video-block-list view
- move icons in video-block-list and video-abuse-list to left side
for visibility
- add robot icon to depict automated nature of a block in
video-block-list
resolves #2790
Diffstat (limited to 'client/src/app/shared/video-block')
-rw-r--r-- | client/src/app/shared/video-block/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/video-block/video-block.service.ts | 77 |
2 files changed, 78 insertions, 0 deletions
diff --git a/client/src/app/shared/video-block/index.ts b/client/src/app/shared/video-block/index.ts new file mode 100644 index 000000000..a99551a38 --- /dev/null +++ b/client/src/app/shared/video-block/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './video-block.service' | |||
diff --git a/client/src/app/shared/video-block/video-block.service.ts b/client/src/app/shared/video-block/video-block.service.ts new file mode 100644 index 000000000..67ca1d85b --- /dev/null +++ b/client/src/app/shared/video-block/video-block.service.ts | |||
@@ -0,0 +1,77 @@ | |||
1 | import { catchError, map, concatMap, toArray } from 'rxjs/operators' | ||
2 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { SortMeta } from 'primeng/api' | ||
5 | import { from as observableFrom, Observable } from 'rxjs' | ||
6 | import { VideoBlocklist, VideoBlockType, ResultList } from '../../../../../shared' | ||
7 | import { environment } from '../../../environments/environment' | ||
8 | import { RestExtractor, RestPagination, RestService } from '../rest' | ||
9 | |||
10 | @Injectable() | ||
11 | export class VideoBlockService { | ||
12 | private static BASE_VIDEOS_URL = environment.apiUrl + '/api/v1/videos/' | ||
13 | |||
14 | constructor ( | ||
15 | private authHttp: HttpClient, | ||
16 | private restService: RestService, | ||
17 | private restExtractor: RestExtractor | ||
18 | ) {} | ||
19 | |||
20 | listBlocks (options: { | ||
21 | pagination: RestPagination | ||
22 | sort: SortMeta | ||
23 | search?: string | ||
24 | type?: VideoBlockType | ||
25 | }): Observable<ResultList<VideoBlocklist>> { | ||
26 | const { pagination, sort, search, type } = options | ||
27 | |||
28 | let params = new HttpParams() | ||
29 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
30 | |||
31 | if (search) { | ||
32 | const filters = this.restService.parseQueryStringFilter(search, { | ||
33 | type: { | ||
34 | prefix: 'type:', | ||
35 | handler: v => { | ||
36 | if (v === 'manual') return VideoBlockType.MANUAL | ||
37 | if (v === 'auto') return VideoBlockType.AUTO_BEFORE_PUBLISHED | ||
38 | |||
39 | return undefined | ||
40 | } | ||
41 | } | ||
42 | }) | ||
43 | |||
44 | params = this.restService.addObjectParams(params, filters) | ||
45 | } | ||
46 | |||
47 | return this.authHttp.get<ResultList<VideoBlocklist>>(VideoBlockService.BASE_VIDEOS_URL + 'blacklist', { params }) | ||
48 | .pipe( | ||
49 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
50 | catchError(res => this.restExtractor.handleError(res)) | ||
51 | ) | ||
52 | } | ||
53 | |||
54 | unblockVideo (videoIdArgs: number | number[]) { | ||
55 | const videoIds = Array.isArray(videoIdArgs) ? videoIdArgs : [ videoIdArgs ] | ||
56 | |||
57 | return observableFrom(videoIds) | ||
58 | .pipe( | ||
59 | concatMap(id => this.authHttp.delete(VideoBlockService.BASE_VIDEOS_URL + id + '/blacklist')), | ||
60 | toArray(), | ||
61 | catchError(err => this.restExtractor.handleError(err)) | ||
62 | ) | ||
63 | } | ||
64 | |||
65 | blockVideo (videoId: number, reason: string, unfederate: boolean) { | ||
66 | const body = { | ||
67 | unfederate, | ||
68 | reason | ||
69 | } | ||
70 | |||
71 | return this.authHttp.post(VideoBlockService.BASE_VIDEOS_URL + videoId + '/blacklist', body) | ||
72 | .pipe( | ||
73 | map(this.restExtractor.extractDataBool), | ||
74 | catchError(res => this.restExtractor.handleError(res)) | ||
75 | ) | ||
76 | } | ||
77 | } | ||