1 import { Component, Input, OnInit } from '@angular/core'
2 import { AuthService } from '@app/core'
3 import { VideoFilter, VideoSortField } from '@shared/models'
4 import { Video, VideoService } from '../../shared-main'
5 import { MiniatureDisplayOptions } from '../../shared-video-miniature'
8 * Markup component list videos depending on criterias
12 selector: 'my-videos-list-markup',
13 templateUrl: 'videos-list-markup.component.html',
14 styleUrls: [ 'videos-list-markup.component.scss' ]
16 export class VideosListMarkupComponent implements OnInit {
18 @Input() categoryOneOf: number[]
19 @Input() languageOneOf: string[]
20 @Input() count: number
21 @Input() onlyDisplayTitle: boolean
22 @Input() filter: VideoFilter
23 @Input() maxRows: number
27 displayOptions: MiniatureDisplayOptions = {
39 private auth: AuthService,
40 private videoService: VideoService
44 return this.auth.getUser()
48 if (this.maxRows <= 0) return {}
51 'grid-template-rows': `repeat(${this.maxRows}, 1fr)`,
52 'grid-auto-rows': '0', // Set height to 0 for autogenerated grid rows
53 'overflow-y': 'hidden' // Hide grid items that overflow
58 if (this.onlyDisplayTitle) {
59 for (const key of Object.keys(this.displayOptions)) {
60 this.displayOptions[key] = false
67 itemsPerPage: this.count
69 categoryOneOf: this.categoryOneOf,
70 languageOneOf: this.languageOneOf,
72 sort: this.sort as VideoSortField
75 this.videoService.getVideos(options)
76 .subscribe(({ data }) => this.videos = data)