]>
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 | |
2539932e C |
23 | |
24 | videos: Video[] | |
25 | ||
26 | displayOptions: MiniatureDisplayOptions = { | |
9105634f | 27 | date: false, |
2539932e C |
28 | views: true, |
29 | by: true, | |
30 | avatar: false, | |
31 | privacyLabel: false, | |
32 | privacyText: false, | |
33 | state: false, | |
34 | blacklistInfo: false | |
35 | } | |
36 | ||
37 | constructor ( | |
38 | private auth: AuthService, | |
39 | private videoService: VideoService | |
40 | ) { } | |
41 | ||
42 | getUser () { | |
43 | return this.auth.getUser() | |
44 | } | |
45 | ||
46 | ngOnInit () { | |
9105634f C |
47 | if (this.onlyDisplayTitle) { |
48 | for (const key of Object.keys(this.displayOptions)) { | |
49 | this.displayOptions[key] = false | |
50 | } | |
51 | } | |
52 | ||
2539932e C |
53 | const options = { |
54 | videoPagination: { | |
55 | currentPage: 1, | |
56 | itemsPerPage: this.count | |
57 | }, | |
58 | categoryOneOf: this.categoryOneOf, | |
59 | languageOneOf: this.languageOneOf, | |
9105634f | 60 | filter: this.filter, |
2539932e C |
61 | sort: this.sort as VideoSortField |
62 | } | |
63 | ||
64 | this.videoService.getVideos(options) | |
65 | .subscribe(({ data }) => this.videos = data) | |
66 | } | |
67 | } |