]>
Commit | Line | Data |
---|---|---|
0ca454e3 | 1 | import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' |
2539932e | 2 | import { AuthService } from '@app/core' |
8ee25e17 C |
3 | import { Video, VideoService } from '../../shared-main' |
4 | import { MiniatureDisplayOptions } from '../../shared-video-miniature' | |
0ca454e3 | 5 | import { CustomMarkupComponent } from './shared' |
2539932e C |
6 | |
7 | /* | |
8 | * Markup component that creates a video miniature only | |
9 | */ | |
10 | ||
11 | @Component({ | |
12 | selector: 'my-video-miniature-markup', | |
13 | templateUrl: 'video-miniature-markup.component.html', | |
14 | styleUrls: [ 'video-miniature-markup.component.scss' ] | |
15 | }) | |
0ca454e3 | 16 | export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit { |
2539932e | 17 | @Input() uuid: string |
9105634f | 18 | @Input() onlyDisplayTitle: boolean |
2539932e | 19 | |
0ca454e3 C |
20 | @Output() loaded = new EventEmitter<boolean>() |
21 | ||
2539932e C |
22 | video: Video |
23 | ||
24 | displayOptions: MiniatureDisplayOptions = { | |
25 | date: true, | |
26 | views: true, | |
27 | by: true, | |
28 | avatar: false, | |
29 | privacyLabel: false, | |
30 | privacyText: false, | |
31 | state: false, | |
32 | blacklistInfo: false | |
33 | } | |
34 | ||
35 | constructor ( | |
36 | private auth: AuthService, | |
37 | private videoService: VideoService | |
38 | ) { } | |
39 | ||
40 | getUser () { | |
41 | return this.auth.getUser() | |
42 | } | |
43 | ||
44 | ngOnInit () { | |
9105634f C |
45 | if (this.onlyDisplayTitle) { |
46 | for (const key of Object.keys(this.displayOptions)) { | |
47 | this.displayOptions[key] = false | |
48 | } | |
49 | } | |
50 | ||
2539932e | 51 | this.videoService.getVideo({ videoId: this.uuid }) |
0ca454e3 C |
52 | .subscribe({ |
53 | next: video => this.video = video, | |
54 | ||
55 | complete: () => this.loaded.emit(true) | |
56 | }) | |
2539932e C |
57 | } |
58 | } |