diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-02 17:48:50 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-06 11:19:16 +0200 |
commit | ed31c059851a30bd5ba9999f8ecb3822d576b9f4 (patch) | |
tree | 7923ef7891ae9fd26965c3004bd75e736f0fedd0 /client/src/app/shared | |
parent | 299474e8279675adb6c5ce140e7e39c6f3439453 (diff) | |
download | PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.tar.gz PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.tar.zst PeerTube-ed31c059851a30bd5ba9999f8ecb3822d576b9f4.zip |
Add ability to list video imports
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/video-import/video-import.service.ts | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/client/src/app/shared/video-import/video-import.service.ts b/client/src/app/shared/video-import/video-import.service.ts index b4709866a..59b58ab38 100644 --- a/client/src/app/shared/video-import/video-import.service.ts +++ b/client/src/app/shared/video-import/video-import.service.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { catchError } from 'rxjs/operators' | 1 | import { catchError, map, switchMap } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { Observable } from 'rxjs' | 4 | import { Observable } from 'rxjs' |
5 | import { VideoImport } from '../../../../../shared' | 5 | import { VideoImport } from '../../../../../shared' |
@@ -8,6 +8,12 @@ import { RestExtractor, RestService } from '../rest' | |||
8 | import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model' | 8 | import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model' |
9 | import { objectToFormData } from '@app/shared/misc/utils' | 9 | import { objectToFormData } from '@app/shared/misc/utils' |
10 | import { VideoUpdate } from '../../../../../shared/models/videos' | 10 | import { VideoUpdate } from '../../../../../shared/models/videos' |
11 | import { ResultList } from '../../../../../shared/models/result-list.model' | ||
12 | import { UserService } from '@app/shared/users/user.service' | ||
13 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
14 | import { RestPagination } from '@app/shared/rest' | ||
15 | import { ServerService } from '@app/core' | ||
16 | import { peertubeTranslate } from '@app/shared/i18n/i18n-utils' | ||
11 | 17 | ||
12 | @Injectable() | 18 | @Injectable() |
13 | export class VideoImportService { | 19 | export class VideoImportService { |
@@ -16,7 +22,8 @@ export class VideoImportService { | |||
16 | constructor ( | 22 | constructor ( |
17 | private authHttp: HttpClient, | 23 | private authHttp: HttpClient, |
18 | private restService: RestService, | 24 | private restService: RestService, |
19 | private restExtractor: RestExtractor | 25 | private restExtractor: RestExtractor, |
26 | private serverService: ServerService | ||
20 | ) {} | 27 | ) {} |
21 | 28 | ||
22 | importVideo (targetUrl: string, video: VideoUpdate): Observable<VideoImport> { | 29 | importVideo (targetUrl: string, video: VideoUpdate): Observable<VideoImport> { |
@@ -53,4 +60,29 @@ export class VideoImportService { | |||
53 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 60 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
54 | } | 61 | } |
55 | 62 | ||
63 | getMyVideoImports (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoImport>> { | ||
64 | let params = new HttpParams() | ||
65 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
66 | |||
67 | return this.authHttp | ||
68 | .get<ResultList<VideoImport>>(UserService.BASE_USERS_URL + '/me/videos/imports', { params }) | ||
69 | .pipe( | ||
70 | switchMap(res => this.extractVideoImports(res)), | ||
71 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
72 | catchError(err => this.restExtractor.handleError(err)) | ||
73 | ) | ||
74 | } | ||
75 | |||
76 | private extractVideoImports (result: ResultList<VideoImport>): Observable<ResultList<VideoImport>> { | ||
77 | return this.serverService.localeObservable | ||
78 | .pipe( | ||
79 | map(translations => { | ||
80 | result.data.forEach(d => | ||
81 | d.state.label = peertubeTranslate(d.state.label, translations) | ||
82 | ) | ||
83 | |||
84 | return result | ||
85 | }) | ||
86 | ) | ||
87 | } | ||
56 | } | 88 | } |