aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-main/video
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-main/video')
-rw-r--r--client/src/app/shared/shared-main/video/embed.component.html3
-rw-r--r--client/src/app/shared/shared-main/video/embed.component.scss10
-rw-r--r--client/src/app/shared/shared-main/video/embed.component.ts35
-rw-r--r--client/src/app/shared/shared-main/video/index.ts1
-rw-r--r--client/src/app/shared/shared-main/video/video.service.ts85
5 files changed, 120 insertions, 14 deletions
diff --git a/client/src/app/shared/shared-main/video/embed.component.html b/client/src/app/shared/shared-main/video/embed.component.html
new file mode 100644
index 000000000..3b088d058
--- /dev/null
+++ b/client/src/app/shared/shared-main/video/embed.component.html
@@ -0,0 +1,3 @@
1<div class="screenratio">
2 <div [innerHTML]="embedHTML"></div>
3</div>
diff --git a/client/src/app/shared/shared-main/video/embed.component.scss b/client/src/app/shared/shared-main/video/embed.component.scss
new file mode 100644
index 000000000..420ba6f23
--- /dev/null
+++ b/client/src/app/shared/shared-main/video/embed.component.scss
@@ -0,0 +1,10 @@
1@use '_mixins' as *;
2@use '_variables' as *;
3
4.screenratio {
5 @include block-ratio($selector: 'div, ::ng-deep iframe') {
6 width: 100% !important;
7 height: 100% !important;
8 left: 0;
9 };
10}
diff --git a/client/src/app/shared/shared-main/video/embed.component.ts b/client/src/app/shared/shared-main/video/embed.component.ts
new file mode 100644
index 000000000..4732efa44
--- /dev/null
+++ b/client/src/app/shared/shared-main/video/embed.component.ts
@@ -0,0 +1,35 @@
1import { buildVideoOrPlaylistEmbed } from 'src/assets/player/utils'
2import { environment } from 'src/environments/environment'
3import { Component, Input, OnInit } from '@angular/core'
4import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
5import { buildVideoEmbedLink, decorateVideoLink } from '@shared/core-utils'
6import { Video } from '@shared/models'
7
8@Component({
9 selector: 'my-embed',
10 styleUrls: [ './embed.component.scss' ],
11 templateUrl: './embed.component.html'
12})
13export class EmbedComponent implements OnInit {
14 @Input() video: Pick<Video, 'name' | 'uuid'>
15
16 embedHTML: SafeHtml
17
18 constructor (private sanitizer: DomSanitizer) {
19
20 }
21
22 ngOnInit () {
23 const html = buildVideoOrPlaylistEmbed(
24 decorateVideoLink({
25 url: buildVideoEmbedLink(this.video, environment.originServerUrl),
26
27 title: false,
28 warningTitle: false
29 }),
30 this.video.name
31 )
32
33 this.embedHTML = this.sanitizer.bypassSecurityTrustHtml(html)
34 }
35}
diff --git a/client/src/app/shared/shared-main/video/index.ts b/client/src/app/shared/shared-main/video/index.ts
index 3053df4ef..e72c0c3d6 100644
--- a/client/src/app/shared/shared-main/video/index.ts
+++ b/client/src/app/shared/shared-main/video/index.ts
@@ -1,3 +1,4 @@
1export * from './embed.component'
1export * from './redundancy.service' 2export * from './redundancy.service'
2export * from './video-details.model' 3export * from './video-details.model'
3export * from './video-edit.model' 4export * from './video-edit.model'
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 7935569e7..9e3aa1e6a 100644
--- a/client/src/app/shared/shared-main/video/video.service.ts
+++ b/client/src/app/shared/shared-main/video/video.service.ts
@@ -1,8 +1,9 @@
1import { Observable } from 'rxjs' 1import { SortMeta } from 'primeng/api'
2import { catchError, map, switchMap } from 'rxjs/operators' 2import { from, Observable } from 'rxjs'
3import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'
3import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http' 4import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'
4import { Injectable } from '@angular/core' 5import { Injectable } from '@angular/core'
5import { ComponentPaginationLight, RestExtractor, RestService, ServerService, UserService } from '@app/core' 6import { ComponentPaginationLight, RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'
6import { objectToFormData } from '@app/helpers' 7import { objectToFormData } from '@app/helpers'
7import { 8import {
8 BooleanBothQuery, 9 BooleanBothQuery,
@@ -31,8 +32,8 @@ import { VideoEdit } from './video-edit.model'
31import { Video } from './video.model' 32import { Video } from './video.model'
32 33
33export type CommonVideoParams = { 34export type CommonVideoParams = {
34 videoPagination: ComponentPaginationLight 35 videoPagination?: ComponentPaginationLight
35 sort: VideoSortField 36 sort: VideoSortField | SortMeta
36 filter?: VideoFilter 37 filter?: VideoFilter
37 categoryOneOf?: number[] 38 categoryOneOf?: number[]
38 languageOneOf?: string[] 39 languageOneOf?: string[]
@@ -200,6 +201,31 @@ export class VideoService {
200 ) 201 )
201 } 202 }
202 203
204 getAdminVideos (
205 parameters: Omit<CommonVideoParams, 'filter'> & { pagination: RestPagination, search?: string }
206 ): Observable<ResultList<Video>> {
207 const { pagination, search } = parameters
208
209 let params = new HttpParams()
210 params = this.buildCommonVideosParams({ params, ...parameters })
211
212 params = params.set('start', pagination.start.toString())
213 .set('count', pagination.count.toString())
214
215 if (search) {
216 params = this.buildAdminParamsFromSearch(search, params)
217 }
218
219 if (!params.has('filter')) params = params.set('filter', 'all')
220
221 return this.authHttp
222 .get<ResultList<Video>>(VideoService.BASE_VIDEO_URL, { params })
223 .pipe(
224 switchMap(res => this.extractVideos(res)),
225 catchError(err => this.restExtractor.handleError(err))
226 )
227 }
228
203 getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> { 229 getVideos (parameters: CommonVideoParams): Observable<ResultList<Video>> {
204 let params = new HttpParams() 230 let params = new HttpParams()
205 params = this.buildCommonVideosParams({ params, ...parameters }) 231 params = this.buildCommonVideosParams({ params, ...parameters })
@@ -284,13 +310,15 @@ export class VideoService {
284 ) 310 )
285 } 311 }
286 312
287 removeVideo (id: number) { 313 removeVideo (idArg: number | number[]) {
288 return this.authHttp 314 const ids = Array.isArray(idArg) ? idArg : [ idArg ]
289 .delete(VideoService.BASE_VIDEO_URL + id) 315
290 .pipe( 316 return from(ids)
291 map(this.restExtractor.extractDataBool), 317 .pipe(
292 catchError(err => this.restExtractor.handleError(err)) 318 concatMap(id => this.authHttp.delete(VideoService.BASE_VIDEO_URL + id)),
293 ) 319 toArray(),
320 catchError(err => this.restExtractor.handleError(err))
321 )
294 } 322 }
295 323
296 loadCompleteDescription (descriptionPath: string) { 324 loadCompleteDescription (descriptionPath: string) {
@@ -393,9 +421,23 @@ export class VideoService {
393 } 421 }
394 422
395 private buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) { 423 private buildCommonVideosParams (options: CommonVideoParams & { params: HttpParams }) {
396 const { params, videoPagination, sort, filter, categoryOneOf, languageOneOf, skipCount, nsfwPolicy, isLive, nsfw } = options 424 const {
425 params,
426 videoPagination,
427 sort,
428 filter,
429 categoryOneOf,
430 languageOneOf,
431 skipCount,
432 nsfwPolicy,
433 isLive,
434 nsfw
435 } = options
436
437 const pagination = videoPagination
438 ? this.restService.componentToRestPagination(videoPagination)
439 : undefined
397 440
398 const pagination = this.restService.componentToRestPagination(videoPagination)
399 let newParams = this.restService.addRestGetParams(params, pagination, sort) 441 let newParams = this.restService.addRestGetParams(params, pagination, sort)
400 442
401 if (filter) newParams = newParams.set('filter', filter) 443 if (filter) newParams = newParams.set('filter', filter)
@@ -409,4 +451,19 @@ export class VideoService {
409 451
410 return newParams 452 return newParams
411 } 453 }
454
455 private buildAdminParamsFromSearch (search: string, params: HttpParams) {
456 const filters = this.restService.parseQueryStringFilter(search, {
457 filter: {
458 prefix: 'local:',
459 handler: v => {
460 if (v === 'true') return 'all-local'
461
462 return 'all'
463 }
464 }
465 })
466
467 return this.restService.addObjectParams(params, filters)
468 }
412} 469}