aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-02 17:48:50 +0200
committerChocobozzz <me@florianbigard.com>2018-08-06 11:19:16 +0200
commited31c059851a30bd5ba9999f8ecb3822d576b9f4 (patch)
tree7923ef7891ae9fd26965c3004bd75e736f0fedd0 /client/src/app/shared
parent299474e8279675adb6c5ce140e7e39c6f3439453 (diff)
downloadPeerTube-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.ts38
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 @@
1import { catchError } from 'rxjs/operators' 1import { catchError, map, switchMap } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { Observable } from 'rxjs' 4import { Observable } from 'rxjs'
5import { VideoImport } from '../../../../../shared' 5import { VideoImport } from '../../../../../shared'
@@ -8,6 +8,12 @@ import { RestExtractor, RestService } from '../rest'
8import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model' 8import { VideoImportCreate } from '../../../../../shared/models/videos/video-import-create.model'
9import { objectToFormData } from '@app/shared/misc/utils' 9import { objectToFormData } from '@app/shared/misc/utils'
10import { VideoUpdate } from '../../../../../shared/models/videos' 10import { VideoUpdate } from '../../../../../shared/models/videos'
11import { ResultList } from '../../../../../shared/models/result-list.model'
12import { UserService } from '@app/shared/users/user.service'
13import { SortMeta } from 'primeng/components/common/sortmeta'
14import { RestPagination } from '@app/shared/rest'
15import { ServerService } from '@app/core'
16import { peertubeTranslate } from '@app/shared/i18n/i18n-utils'
11 17
12@Injectable() 18@Injectable()
13export class VideoImportService { 19export 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}