diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:10:17 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 67ed6552b831df66713bac9e672738796128d33f (patch) | |
tree | 59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/shared/video-ownership | |
parent | 0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff) | |
download | PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip |
Reorganize client shared modules
Diffstat (limited to 'client/src/app/shared/video-ownership')
-rw-r--r-- | client/src/app/shared/video-ownership/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/video-ownership/video-ownership.service.ts | 67 |
2 files changed, 0 insertions, 68 deletions
diff --git a/client/src/app/shared/video-ownership/index.ts b/client/src/app/shared/video-ownership/index.ts deleted file mode 100644 index fe8902ee2..000000000 --- a/client/src/app/shared/video-ownership/index.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export * from './video-ownership.service' | ||
diff --git a/client/src/app/shared/video-ownership/video-ownership.service.ts b/client/src/app/shared/video-ownership/video-ownership.service.ts deleted file mode 100644 index b95d5b792..000000000 --- a/client/src/app/shared/video-ownership/video-ownership.service.ts +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
2 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { environment } from '../../../environments/environment' | ||
5 | import { RestExtractor, RestService } from '../rest' | ||
6 | import { VideoChangeOwnershipCreate } from '../../../../../shared/models/videos' | ||
7 | import { Observable } from 'rxjs/index' | ||
8 | import { SortMeta } from 'primeng/api' | ||
9 | import { ResultList, VideoChangeOwnership } from '../../../../../shared' | ||
10 | import { RestPagination } from '@app/shared/rest' | ||
11 | import { VideoChangeOwnershipAccept } from '../../../../../shared/models/videos/video-change-ownership-accept.model' | ||
12 | |||
13 | @Injectable() | ||
14 | export class VideoOwnershipService { | ||
15 | private static BASE_VIDEO_CHANGE_OWNERSHIP_URL = environment.apiUrl + '/api/v1/videos/' | ||
16 | |||
17 | constructor ( | ||
18 | private authHttp: HttpClient, | ||
19 | private restService: RestService, | ||
20 | private restExtractor: RestExtractor | ||
21 | ) { | ||
22 | } | ||
23 | |||
24 | changeOwnership (id: number, username: string) { | ||
25 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + id + '/give-ownership' | ||
26 | const body: VideoChangeOwnershipCreate = { | ||
27 | username | ||
28 | } | ||
29 | |||
30 | return this.authHttp.post(url, body) | ||
31 | .pipe( | ||
32 | map(this.restExtractor.extractDataBool), | ||
33 | catchError(res => this.restExtractor.handleError(res)) | ||
34 | ) | ||
35 | } | ||
36 | |||
37 | getOwnershipChanges (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoChangeOwnership>> { | ||
38 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership' | ||
39 | |||
40 | let params = new HttpParams() | ||
41 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
42 | |||
43 | return this.authHttp.get<ResultList<VideoChangeOwnership>>(url, { params }) | ||
44 | .pipe( | ||
45 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
46 | catchError(res => this.restExtractor.handleError(res)) | ||
47 | ) | ||
48 | } | ||
49 | |||
50 | acceptOwnership (id: number, input: VideoChangeOwnershipAccept) { | ||
51 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id + '/accept' | ||
52 | return this.authHttp.post(url, input) | ||
53 | .pipe( | ||
54 | map(this.restExtractor.extractDataBool), | ||
55 | catchError(this.restExtractor.handleError) | ||
56 | ) | ||
57 | } | ||
58 | |||
59 | refuseOwnership (id: number) { | ||
60 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id + '/refuse' | ||
61 | return this.authHttp.post(url, {}) | ||
62 | .pipe( | ||
63 | map(this.restExtractor.extractDataBool), | ||
64 | catchError(this.restExtractor.handleError) | ||
65 | ) | ||
66 | } | ||
67 | } | ||