]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts
Fetch things in bulk for the homepage
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-playlist / video-playlist-miniature.component.ts
CommitLineData
37a44fc9
C
1import { LinkType } from 'src/types/link.type'
2import { Component, Input, OnInit } from '@angular/core'
67ed6552 3import { VideoPlaylist } from './video-playlist.model'
830b4faf
C
4
5@Component({
6 selector: 'my-video-playlist-miniature',
7 styleUrls: [ './video-playlist-miniature.component.scss' ],
8 templateUrl: './video-playlist-miniature.component.html'
9})
37a44fc9 10export class VideoPlaylistMiniatureComponent implements OnInit {
830b4faf 11 @Input() playlist: VideoPlaylist
37a44fc9 12
f0a39880 13 @Input() toManage = false
37a44fc9 14
bce47964
C
15 @Input() displayChannel = false
16 @Input() displayDescription = false
17 @Input() displayPrivacy = false
0f7407d9 18 @Input() displayAsRow = false
f0a39880 19
37a44fc9
C
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) {
d4a8e7a6 42 this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist)
37a44fc9
C
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 } ]
f0a39880 55
37a44fc9 56 return
f0a39880 57 }
830b4faf 58}