]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-custom-markup / peertube-custom-tags / video-miniature-markup.component.ts
CommitLineData
8b61dcaf 1import { finalize } from 'rxjs/operators'
0ca454e3 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
8b61dcaf 3import { AuthService, Notifier } from '@app/core'
9df52d66
C
4import { FindInBulkService } from '@app/shared/shared-search'
5import { Video } from '../../shared-main'
8ee25e17 6import { MiniatureDisplayOptions } from '../../shared-video-miniature'
0ca454e3 7import { CustomMarkupComponent } from './shared'
2539932e
C
8
9/*
10 * Markup component that creates a video miniature only
11*/
12
13@Component({
14 selector: 'my-video-miniature-markup',
15 templateUrl: 'video-miniature-markup.component.html',
16 styleUrls: [ 'video-miniature-markup.component.scss' ]
17})
0ca454e3 18export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
2539932e 19 @Input() uuid: string
9105634f 20 @Input() onlyDisplayTitle: boolean
e9609325 21 @Input() video: Video
2539932e 22
0ca454e3
C
23 @Output() loaded = new EventEmitter<boolean>()
24
2539932e
C
25 displayOptions: MiniatureDisplayOptions = {
26 date: true,
27 views: true,
28 by: true,
29 avatar: false,
30 privacyLabel: false,
31 privacyText: false,
32 state: false,
33 blacklistInfo: false
34 }
35
36 constructor (
37 private auth: AuthService,
3da38d6e 38 private findInBulk: FindInBulkService,
8b61dcaf 39 private notifier: Notifier
2539932e
C
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
e9609325
C
53 if (this.video) return
54
3da38d6e 55 this.findInBulk.getVideo(this.uuid)
8b61dcaf 56 .pipe(finalize(() => this.loaded.emit(true)))
1378c0d3
C
57 .subscribe({
58 next: video => this.video = video,
0ca454e3 59
1378c0d3
C
60 error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
61 })
2539932e
C
62 }
63}