aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-11-02 14:14:26 +0100
committerChocobozzz <me@florianbigard.com>2021-11-02 14:14:26 +0100
commit05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc (patch)
tree7607cfb6856c279b50f38e92d9060ee687719409 /client/src/app/shared/shared-main/video
parent047f9585dd91d7765d78522edebfb64107450512 (diff)
downloadPeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.tar.gz
PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.tar.zst
PeerTube-05ac4ac7ed5107ac8ef1d0d1f9fd5009bf29bedc.zip
Move admin stuff in +admin
Diffstat (limited to 'client/src/app/shared/shared-main/video')
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts103
1 files changed, 12 insertions, 91 deletions
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 b7c563dca..6edcc3fe0 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -3,9 +3,8 @@ import { from, Observable } from 'rxjs'
3import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators' 3import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
4import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' 4import { 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, RestService, ServerService, UserService } from '@app/core'
7import { objectToFormData } from '@app/helpers' 7import { objectToFormData } from '@app/helpers'
8import { AdvancedInputFilter } from '@app/shared/shared-forms'
9import { 8import {
10 BooleanBothQuery, 9 BooleanBothQuery,
11 FeedFormat, 10 FeedFormat,
@@ -204,27 +203,6 @@ export class VideoService {
204 ) 203 )
205 } 204 }
206 205
207 getAdminVideos (
208 options: CommonVideoParams & { pagination: RestPagination, search?: string }
209 ): Observable<ResultList<Video>> {
210 const { pagination, search } = options
211
212 let params = new HttpParams()
213 params = this.buildCommonVideosParams({ params, ...options })
214
215 params = params.set('start', pagination.start.toString())
216 .set('count', pagination.count.toString())
217
218 params = this.buildAdminParamsFromSearch(search, params)
219
220 return this.authHttp
221 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
222 .pipe(
223 switchMap(res => this.extractVideos(res)),
224 catchError(err => this.restExtractor.handleError(err))
225 )
226 }
227
228 getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> { 206 getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> {
229 let params = new HttpParams() 207 let params = new HttpParams()
230 params = this.buildCommonVideosParams({ params, ...parameters }) 208 params = this.buildCommonVideosParams({ params, ...parameters })
@@ -405,21 +383,7 @@ export class VideoService {
405 : 'both' 383 : 'both'
406 } 384 }
407 385
408 private setVideoRate (id: number, rateType: UserVideoRateType) { 386 buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) {
409 const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
410 const body: UserVideoRateUpdate = {
411 rating: rateType
412 }
413
414 return this.authHttp
415 .put(url, body)
416 .pipe(
417 map(this.restExtractor.extractDataBool),
418 catchError(err => this.restExtractor.handleError(err))
419 )
420 }
421
422 private buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) {
423 const { 387 const {
424 params, 388 params,
425 videoPagination, 389 videoPagination,
@@ -453,60 +417,17 @@ export class VideoService {
453 return newParams 417 return newParams
454 } 418 }
455 419
456 buildAdminInputFilter (): AdvancedInputFilter[] { 420 private setVideoRate (id: number, rateType: UserVideoRateType) {
457 return [ 421 const url = `${VideoService.BASE_VIDEO_URL}/${id}/rate`
458 { 422 const body: UserVideoRateUpdate = {
459 title: $localize`Videos scope`, 423 rating: rateType
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
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
493 const filters = this.restService.parseQueryStringFilter(search, {
494 isLocal: {
495 prefix: 'isLocal:',
496 isBoolean: true
497 },
498 excludeMuted: {
499 prefix: 'excludeMuted',
500 handler: () => true
501 }
502 })
503
504 if (filters.excludeMuted) {
505 include &= ~VideoInclude.BLOCKED_OWNER
506
507 filters.excludeMuted = undefined
508 } 424 }
509 425
510 return this.restService.addObjectParams(params, { ...filters, include }) 426 return this.authHttp
427 .put(url, body)
428 .pipe(
429 map(this.restExtractor.extractDataBool),
430 catchError(err => this.restExtractor.handleError(err))
431 )
511 } 432 }
512} 433}