]>
Commit | Line | Data |
---|---|---|
37a44fc9 C |
1 | import { LinkType } from 'src/types/link.type' |
2 | import { Component, Input, OnInit } from '@angular/core' | |
67ed6552 | 3 | import { VideoPlaylist } from './video-playlist.model' |
9f3bf143 | 4 | import { MarkdownService } from '@app/core' |
830b4faf C |
5 | |
6 | @Component({ | |
7 | selector: 'my-video-playlist-miniature', | |
8 | styleUrls: [ './video-playlist-miniature.component.scss' ], | |
9 | templateUrl: './video-playlist-miniature.component.html' | |
10 | }) | |
37a44fc9 | 11 | export class VideoPlaylistMiniatureComponent implements OnInit { |
830b4faf | 12 | @Input() playlist: VideoPlaylist |
37a44fc9 | 13 | |
f0a39880 | 14 | @Input() toManage = false |
37a44fc9 | 15 | |
bce47964 C |
16 | @Input() displayChannel = false |
17 | @Input() displayDescription = false | |
18 | @Input() displayPrivacy = false | |
0f7407d9 | 19 | @Input() displayAsRow = false |
f0a39880 | 20 | |
37a44fc9 C |
21 | @Input() linkType: LinkType = 'internal' |
22 | ||
23 | routerLink: any | |
24 | playlistHref: string | |
25 | playlistTarget: string | |
9f3bf143 | 26 | playlistDescription: string |
37a44fc9 | 27 | |
9f3bf143 P |
28 | constructor ( |
29 | private markdownService: MarkdownService | |
30 | ) {} | |
31 | ||
32 | async ngOnInit () { | |
37a44fc9 | 33 | this.buildPlaylistUrl() |
9f3bf143 P |
34 | if (this.displayDescription) { |
35 | this.playlistDescription = await this.markdownService.textMarkdownToHTML(this.playlist.description) | |
36 | } | |
37a44fc9 C |
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) { | |
d4a8e7a6 | 51 | this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist) |
37a44fc9 C |
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 } ] | |
f0a39880 | 64 | |
37a44fc9 | 65 | return |
f0a39880 | 66 | } |
830b4faf | 67 | } |