]>
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 | ||
5 | @Component({ | |
6 | selector: 'my-video-playlist-miniature', | |
7 | styleUrls: [ './video-playlist-miniature.component.scss' ], | |
8 | templateUrl: './video-playlist-miniature.component.html' | |
9 | }) | |
10 | export class VideoPlaylistMiniatureComponent implements OnInit { | |
11 | @Input() playlist: VideoPlaylist | |
12 | ||
13 | @Input() toManage = false | |
14 | ||
15 | @Input() displayChannel = false | |
16 | @Input() displayDescription = false | |
17 | @Input() displayPrivacy = false | |
18 | @Input() displayAsRow = false | |
19 | ||
20 | @Input() linkType: LinkType = 'internal' | |
21 | ||
22 | routerLink: any | |
23 | playlistHref: string | |
24 | playlistTarget: string | |
25 | ||
26 | ngOnInit () { | |
27 | this.buildPlaylistUrl() | |
28 | } | |
29 | ||
30 | buildPlaylistUrl () { | |
31 | if (this.toManage) { | |
32 | this.routerLink = [ '/my-library/video-playlists', this.playlist.uuid ] | |
33 | return | |
34 | } | |
35 | ||
36 | if (this.playlist.videosLength === 0) { | |
37 | this.routerLink = null | |
38 | return | |
39 | } | |
40 | ||
41 | if (this.linkType === 'internal' || !this.playlist.url) { | |
42 | this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist) | |
43 | return | |
44 | } | |
45 | ||
46 | if (this.linkType === 'external') { | |
47 | this.routerLink = null | |
48 | this.playlistHref = this.playlist.url | |
49 | this.playlistTarget = '_blank' | |
50 | return | |
51 | } | |
52 | ||
53 | // Lazy load | |
54 | this.routerLink = [ '/search/lazy-load-playlist', { url: this.playlist.url } ] | |
55 | ||
56 | return | |
57 | } | |
58 | } |