]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-custom-markup/peertube-custom-tags/videos-list-markup.component.ts
Playlist miniature consistent font size
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-custom-markup / peertube-custom-tags / videos-list-markup.component.ts
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'
6
7 /*
8 * Markup component list videos depending on criterias
9 */
10
11 @Component({
12 selector: 'my-videos-list-markup',
13 templateUrl: 'videos-list-markup.component.html',
14 styleUrls: [ 'videos-list-markup.component.scss' ]
15 })
16 export class VideosListMarkupComponent implements OnInit {
17 @Input() sort: string
18 @Input() categoryOneOf: number[]
19 @Input() languageOneOf: string[]
20 @Input() count: number
21 @Input() onlyDisplayTitle: boolean
22 @Input() filter: VideoFilter
23 @Input() maxRows: number
24
25 videos: Video[]
26
27 displayOptions: MiniatureDisplayOptions = {
28 date: false,
29 views: true,
30 by: true,
31 avatar: false,
32 privacyLabel: false,
33 privacyText: false,
34 state: false,
35 blacklistInfo: false
36 }
37
38 constructor (
39 private auth: AuthService,
40 private videoService: VideoService
41 ) { }
42
43 getUser () {
44 return this.auth.getUser()
45 }
46
47 limitRowsStyle () {
48 if (this.maxRows <= 0) return {}
49
50 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
54 }
55 }
56
57 ngOnInit () {
58 if (this.onlyDisplayTitle) {
59 for (const key of Object.keys(this.displayOptions)) {
60 this.displayOptions[key] = false
61 }
62 }
63
64 const options = {
65 videoPagination: {
66 currentPage: 1,
67 itemsPerPage: this.count
68 },
69 categoryOneOf: this.categoryOneOf,
70 languageOneOf: this.languageOneOf,
71 filter: this.filter,
72 sort: this.sort as VideoSortField
73 }
74
75 this.videoService.getVideos(options)
76 .subscribe(({ data }) => this.videos = data)
77 }
78 }