]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
Only display homepage when components are loaded
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-custom-markup / peertube-custom-tags / video-miniature-markup.component.ts
1 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
2 import { AuthService } from '@app/core'
3 import { Video, VideoService } from '../../shared-main'
4 import { MiniatureDisplayOptions } from '../../shared-video-miniature'
5 import { CustomMarkupComponent } from './shared'
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 })
16 export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
17 @Input() uuid: string
18 @Input() onlyDisplayTitle: boolean
19
20 @Output() loaded = new EventEmitter<boolean>()
21
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 () {
45 if (this.onlyDisplayTitle) {
46 for (const key of Object.keys(this.displayOptions)) {
47 this.displayOptions[key] = false
48 }
49 }
50
51 this.videoService.getVideo({ videoId: this.uuid })
52 .subscribe({
53 next: video => this.video = video,
54
55 complete: () => this.loaded.emit(true)
56 })
57 }
58 }