]>
Commit | Line | Data |
---|---|---|
1 | import { LinkType } from 'src/types/link.type' | |
2 | import { Component, Input, OnInit } from '@angular/core' | |
3 | import { VideoPlaylist } from './video-playlist.model' | |
4 | import { MarkdownService } from '@app/core' | |
5 | ||
6 | @Component({ | |
7 | selector: 'my-video-playlist-miniature', | |
8 | styleUrls: [ './video-playlist-miniature.component.scss' ], | |
9 | templateUrl: './video-playlist-miniature.component.html' | |
10 | }) | |
11 | export class VideoPlaylistMiniatureComponent implements OnInit { | |
12 | @Input() playlist: VideoPlaylist | |
13 | ||
14 | @Input() toManage = false | |
15 | ||
16 | @Input() displayChannel = false | |
17 | @Input() displayDescription = false | |
18 | @Input() displayPrivacy = false | |
19 | @Input() displayAsRow = false | |
20 | ||
21 | @Input() linkType: LinkType = 'internal' | |
22 | ||
23 | routerLink: any | |
24 | playlistHref: string | |
25 | playlistTarget: string | |
26 | playlistDescription: string | |
27 | ||
28 | constructor ( | |
29 | private markdownService: MarkdownService | |
30 | ) {} | |
31 | ||
32 | async ngOnInit () { | |
33 | this.buildPlaylistUrl() | |
34 | if (this.displayDescription) { | |
35 | this.playlistDescription = await this.markdownService.textMarkdownToHTML(this.playlist.description) | |
36 | } | |
37 | } | |
38 | ||
39 | buildPlaylistUrl () { | |
40 | if (this.toManage) { | |
41 | this.routerLink = [ '/my-library/video-playlists', this.playlist.uuid ] | |
42 | return | |
43 | } | |
44 | ||
45 | if (this.playlist.videosLength === 0) { | |
46 | this.routerLink = null | |
47 | return | |
48 | } | |
49 | ||
50 | if (this.linkType === 'internal' || !this.playlist.url) { | |
51 | this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist) | |
52 | return | |
53 | } | |
54 | ||
55 | if (this.linkType === 'external') { | |
56 | this.routerLink = null | |
57 | this.playlistHref = this.playlist.url | |
58 | this.playlistTarget = '_blank' | |
59 | return | |
60 | } | |
61 | ||
62 | // Lazy load | |
63 | this.routerLink = [ '/search/lazy-load-playlist', { url: this.playlist.url } ] | |
64 | ||
65 | return | |
66 | } | |
67 | } |