1 import { finalize } from 'rxjs/operators'
2 import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3 import { AuthService, Notifier } from '@app/core'
4 import { FindInBulkService } from '@app/shared/shared-search'
5 import { Video } from '../../shared-main'
6 import { MiniatureDisplayOptions } from '../../shared-video-miniature'
7 import { CustomMarkupComponent } from './shared'
10 * Markup component that creates a video miniature only
14 selector: 'my-video-miniature-markup',
15 templateUrl: 'video-miniature-markup.component.html',
16 styleUrls: [ 'video-miniature-markup.component.scss' ],
17 changeDetection: ChangeDetectionStrategy.OnPush
19 export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
21 @Input() onlyDisplayTitle: boolean
24 @Output() loaded = new EventEmitter<boolean>()
26 displayOptions: MiniatureDisplayOptions = {
38 private auth: AuthService,
39 private findInBulk: FindInBulkService,
40 private notifier: Notifier
44 return this.auth.getUser()
48 if (this.onlyDisplayTitle) {
49 for (const key of Object.keys(this.displayOptions)) {
50 this.displayOptions[key] = false
54 if (this.video) return
56 this.findInBulk.getVideo(this.uuid)
57 .pipe(finalize(() => this.loaded.emit(true)))
59 next: video => this.video = video,
61 error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)