aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main')
-rw-r--r--client/src/app/shared/shared-main/video-caption/video-caption.service.ts6
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts79
2 files changed, 62 insertions, 23 deletions
diff --git a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
index 283c63f98..29d6d0f4c 100644
--- a/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
+++ b/client/src/app/shared/shared-main/video-caption/video-caption.service.ts
@@ -18,7 +18,7 @@ export class VideoCaptionService {
18 ) {} 18 ) {}
19 19
20 listCaptions (videoId: number | string): Observable<ResultList<VideoCaption>> { 20 listCaptions (videoId: number | string): Observable<ResultList<VideoCaption>> {
21 return this.authHttp.get<ResultList<VideoCaption>>(VideoService.BASE_VIDEO_URL + videoId + '/captions') 21 return this.authHttp.get<ResultList<VideoCaption>>(`${VideoService.BASE_VIDEO_URL}/${videoId}/captions`)
22 .pipe( 22 .pipe(
23 switchMap(captionsResult => { 23 switchMap(captionsResult => {
24 return this.serverService.getServerLocale() 24 return this.serverService.getServerLocale()
@@ -41,7 +41,7 @@ export class VideoCaptionService {
41 } 41 }
42 42
43 removeCaption (videoId: number | string, language: string) { 43 removeCaption (videoId: number | string, language: string) {
44 return this.authHttp.delete(VideoService.BASE_VIDEO_URL + videoId + '/captions/' + language) 44 return this.authHttp.delete(`${VideoService.BASE_VIDEO_URL}/${videoId}/captions/${language}`)
45 .pipe( 45 .pipe(
46 map(this.restExtractor.extractDataBool), 46 map(this.restExtractor.extractDataBool),
47 catchError(res => this.restExtractor.handleError(res)) 47 catchError(res => this.restExtractor.handleError(res))
@@ -52,7 +52,7 @@ export class VideoCaptionService {
52 const body = { captionfile } 52 const body = { captionfile }
53 const data = objectToFormData(body) 53 const data = objectToFormData(body)
54 54
55 return this.authHttp.put(VideoService.BASE_VIDEO_URL + videoId + '/captions/' + language, data) 55 return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${videoId}/captions/${language}`, data)
56 .pipe( 56 .pipe(
57 map(this.restExtractor.extractDataBool), 57 map(this.restExtractor.extractDataBool),
58 catchError(res => this.restExtractor.handleError(res)) 58 catchError(res => this.restExtractor.handleError(res))
diff --git a/client/src/app/shared/shared-main/video/video.service.ts b/client/src/app/shared/shared-main/video/video.service.ts
index 819847ac6..b7c563dca 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -5,6 +5,7 @@ import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
5import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
6import { ComponentPaginationLight, RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core' 6import { ComponentPaginationLight, RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'
7import { objectToFormData } from '@app/helpers' 7import { objectToFormData } from '@app/helpers'
8import { AdvancedInputFilter } from '@app/shared/shared-forms'
8import { 9import {
9 BooleanBothQuery, 10 BooleanBothQuery,
10 FeedFormat, 11 FeedFormat,
@@ -60,18 +61,18 @@ export class VideoService {
60 ) {} 61 ) {}
61 62
62 getVideoViewUrl (uuid: string) { 63 getVideoViewUrl (uuid: string) {
63 return VideoService.BASE_VIDEO_URL + '/' + uuid + '/views' 64 return `${VideoService.BASE_VIDEO_URL}/${uuid}/views`
64 } 65 }
65 66
66 getUserWatchingVideoUrl (uuid: string) { 67 getUserWatchingVideoUrl (uuid: string) {
67 return VideoService.BASE_VIDEO_URL + '/' + uuid + '/watching' 68 return `${VideoService.BASE_VIDEO_URL}/${uuid}/watching`
68 } 69 }
69 70
70 getVideo (options: { videoId: string }): Observable<VideoDetails> { 71 getVideo (options: { videoId: string }): Observable<VideoDetails> {
71 return this.serverService.getServerLocale() 72 return this.serverService.getServerLocale()
72 .pipe( 73 .pipe(
73 switchMap(translations => { 74 switchMap(translations => {
74 return this.authHttp.get<VideoDetailsServerModel>(VideoService.BASE_VIDEO_URL + '/' + options.videoId) 75 return this.authHttp.get<VideoDetailsServerModel>(`${VideoService.BASE_VIDEO_URL}/${options.videoId}`)
75 .pipe(map(videoHash => ({ videoHash, translations }))) 76 .pipe(map(videoHash => ({ videoHash, translations })))
76 }), 77 }),
77 map(({ videoHash, translations }) => new VideoDetails(videoHash, translations)), 78 map(({ videoHash, translations }) => new VideoDetails(videoHash, translations)),
@@ -111,7 +112,7 @@ export class VideoService {
111 112
112 const data = objectToFormData(body) 113 const data = objectToFormData(body)
113 114
114 return this.authHttp.put(VideoService.BASE_VIDEO_URL + '/' + video.id, data) 115 return this.authHttp.put(`${VideoService.BASE_VIDEO_URL}/${video.id}`, data)
115 .pipe( 116 .pipe(
116 map(this.restExtractor.extractDataBool), 117 map(this.restExtractor.extractDataBool),
117 catchError(err => this.restExtractor.handleError(err)) 118 catchError(err => this.restExtractor.handleError(err))
@@ -119,7 +120,7 @@ export class VideoService {
119 } 120 }
120 121
121 uploadVideo (video: FormData) { 122 uploadVideo (video: FormData) {
122 const req = new HttpRequest('POST', VideoService.BASE_VIDEO_URL + '/' + 'upload', video, { reportProgress: true }) 123 const req = new HttpRequest('POST', `${VideoService.BASE_VIDEO_URL}/upload`, video, { reportProgress: true })
123 124
124 return this.authHttp 125 return this.authHttp
125 .request<{ video: { id: number, uuid: string } }>(req) 126 .request<{ video: { id: number, uuid: string } }>(req)
@@ -204,25 +205,17 @@ export class VideoService {
204 } 205 }
205 206
206 getAdminVideos ( 207 getAdminVideos (
207 parameters: CommonVideoParams & { pagination: RestPagination, search?: string } 208 options: CommonVideoParams & { pagination: RestPagination, search?: string }
208 ): Observable<ResultList<Video>> { 209 ): Observable<ResultList<Video>> {
209 const { pagination, search } = parameters 210 const { pagination, search } = options
210
211 const include = VideoInclude.BLACKLISTED |
212 VideoInclude.BLOCKED_OWNER |
213 VideoInclude.HIDDEN_PRIVACY |
214 VideoInclude.NOT_PUBLISHED_STATE |
215 VideoInclude.FILES
216 211
217 let params = new HttpParams() 212 let params = new HttpParams()
218 params = this.buildCommonVideosParams({ params, include, ...parameters }) 213 params = this.buildCommonVideosParams({ params, ...options })
219 214
220 params = params.set('start', pagination.start.toString()) 215 params = params.set('start', pagination.start.toString())
221 .set('count', pagination.count.toString()) 216 .set('count', pagination.count.toString())
222 217
223 if (search) { 218 params = this.buildAdminParamsFromSearch(search, params)
224 params = this.buildAdminParamsFromSearch(search, params)
225 }
226 219
227 return this.authHttp 220 return this.authHttp
228 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params }) 221 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
@@ -321,7 +314,7 @@ export class VideoService {
321 314
322 return from(ids) 315 return from(ids)
323 .pipe( 316 .pipe(
324 concatMap(id => this.authHttp.delete(VideoService.BASE_VIDEO_URL + '/' + id)), 317 concatMap(id => this.authHttp.delete(`${VideoService.BASE_VIDEO_URL}/${id}`)),
325 toArray(), 318 toArray(),
326 catchError(err => this.restExtractor.handleError(err)) 319 catchError(err => this.restExtractor.handleError(err))
327 ) 320 )
@@ -413,7 +406,7 @@ export class VideoService {
413 } 406 }
414 407
415 private setVideoRate (id: number, rateType: UserVideoRateType) { 408 private setVideoRate (id: number, rateType: UserVideoRateType) {
416 const url = VideoService.BASE_VIDEO_URL + '/' + id + '/rate' 409 const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
417 const body: UserVideoRateUpdate = { 410 const body: UserVideoRateUpdate = {
418 rating: rateType 411 rating: rateType
419 } 412 }
@@ -460,14 +453,60 @@ export class VideoService {
460 return newParams 453 return newParams
461 } 454 }
462 455
456 buildAdminInputFilter (): AdvancedInputFilter[] {
457 return [
458 {
459 title: $localize`Videos scope`,
460 children: [
461 {
462 queryParams: { search: 'isLocal:false' },
463 label: $localize`Remote videos`
464 },
465 {
466 queryParams: { search: 'isLocal:true' },
467 label: $localize`Local videos`
468 }
469 ]
470 },
471
472 {
473 title: $localize`Include/Exclude`,
474 children: [
475 {
476 queryParams: { search: 'excludeMuted' },
477 label: $localize`Exclude muted accounts`
478 }
479 ]
480 }
481 ]
482 }
483
463 private buildAdminParamsFromSearch (search: string, params: HttpParams) { 484 private buildAdminParamsFromSearch (search: string, params: HttpParams) {
485 let include = VideoInclude.BLACKLISTED |
486 VideoInclude.BLOCKED_OWNER |
487 VideoInclude.HIDDEN_PRIVACY |
488 VideoInclude.NOT_PUBLISHED_STATE |
489 VideoInclude.FILES
490
491 if (!search) return this.restService.addObjectParams(params, { include })
492
464 const filters = this.restService.parseQueryStringFilter(search, { 493 const filters = this.restService.parseQueryStringFilter(search, {
465 isLocal: { 494 isLocal: {
466 prefix: 'isLocal:', 495 prefix: 'isLocal:',
467 isBoolean: true 496 isBoolean: true
497 },
498 excludeMuted: {
499 prefix: 'excludeMuted',
500 handler: () => true
468 } 501 }
469 }) 502 })
470 503
471 return this.restService.addObjectParams(params, filters) 504 if (filters.excludeMuted) {
505 include &= ~VideoInclude.BLOCKED_OWNER
506
507 filters.excludeMuted = undefined
508 }
509
510 return this.restService.addObjectParams(params, { ...filters, include })
472 } 511 }
473} 512}