]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
Filter videos by live in custom markup
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-custom-markup / peertube-custom-tags / video-miniature-markup.component.ts
1 import { finalize } from 'rxjs/operators'
2 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3 import { AuthService, Notifier } from '@app/core'
4 import { Video, VideoService } from '../../shared-main'
5 import { MiniatureDisplayOptions } from '../../shared-video-miniature'
6 import { CustomMarkupComponent } from './shared'
7 import { FindInBulkService } from '@app/shared/shared-search'
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 })
18 export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
19 @Input() uuid: string
20 @Input() onlyDisplayTitle: boolean
21
22 @Output() loaded = new EventEmitter<boolean>()
23
24 video: Video
25
26 displayOptions: MiniatureDisplayOptions = {
27 date: true,
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 findInBulk: FindInBulkService,
40 private notifier: Notifier
41 ) { }
42
43 getUser () {
44 return this.auth.getUser()
45 }
46
47 ngOnInit () {
48 if (this.onlyDisplayTitle) {
49 for (const key of Object.keys(this.displayOptions)) {
50 this.displayOptions[key] = false
51 }
52 }
53
54 this.findInBulk.getVideo(this.uuid)
55 .pipe(finalize(() => this.loaded.emit(true)))
56 .subscribe(
57 video => this.video = video,
58
59 err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
60 )
61 }
62 }