]>
Commit | Line | Data |
---|---|---|
2539932e C |
1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { AuthService } from '@app/core' | |
9105634f | 3 | import { VideoFilter, VideoSortField } from '@shared/models' |
8ee25e17 C |
4 | import { Video, VideoService } from '../../shared-main' |
5 | import { MiniatureDisplayOptions } from '../../shared-video-miniature' | |
2539932e C |
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 { | |
9105634f | 17 | @Input() sort: string |
2539932e C |
18 | @Input() categoryOneOf: number[] |
19 | @Input() languageOneOf: string[] | |
9105634f C |
20 | @Input() count: number |
21 | @Input() onlyDisplayTitle: boolean | |
22 | @Input() filter: VideoFilter | |
5d6395af | 23 | @Input() maxRows: number |
2539932e C |
24 | |
25 | videos: Video[] | |
26 | ||
27 | displayOptions: MiniatureDisplayOptions = { | |
9105634f | 28 | date: false, |
2539932e C |
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 | ||
5d6395af C |
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 | ||
2539932e | 57 | ngOnInit () { |
9105634f C |
58 | if (this.onlyDisplayTitle) { |
59 | for (const key of Object.keys(this.displayOptions)) { | |
60 | this.displayOptions[key] = false | |
61 | } | |
62 | } | |
63 | ||
2539932e C |
64 | const options = { |
65 | videoPagination: { | |
66 | currentPage: 1, | |
67 | itemsPerPage: this.count | |
68 | }, | |
69 | categoryOneOf: this.categoryOneOf, | |
70 | languageOneOf: this.languageOneOf, | |
9105634f | 71 | filter: this.filter, |
2539932e C |
72 | sort: this.sort as VideoSortField |
73 | } | |
74 | ||
75 | this.videoService.getVideos(options) | |
76 | .subscribe(({ data }) => this.videos = data) | |
77 | } | |
78 | } |