X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-video-playlist%2Fvideo-playlist-miniature.component.ts;h=225c4eb644d2fcf7790314b86b7a5797cfa74e9f;hb=0e45e336f62a411b3c423be46d16252355c754d7;hp=6b0b1056f1211cfce30ed33c37d69c00f3fde48f;hpb=4024c44f9027a32809931de0692d40d001df721c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts index 6b0b1056f..225c4eb64 100644 --- a/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts +++ b/client/src/app/shared/shared-video-playlist/video-playlist-miniature.component.ts @@ -1,23 +1,67 @@ -import { Component, Input } from '@angular/core' +import { LinkType } from 'src/types/link.type' +import { Component, Input, OnInit } from '@angular/core' import { VideoPlaylist } from './video-playlist.model' +import { MarkdownService } from '@app/core' @Component({ selector: 'my-video-playlist-miniature', styleUrls: [ './video-playlist-miniature.component.scss' ], templateUrl: './video-playlist-miniature.component.html' }) -export class VideoPlaylistMiniatureComponent { +export class VideoPlaylistMiniatureComponent implements OnInit { @Input() playlist: VideoPlaylist + @Input() toManage = false + @Input() displayChannel = false @Input() displayDescription = false @Input() displayPrivacy = false @Input() displayAsRow = false - getPlaylistUrl () { - if (this.toManage) return [ '/my-library/video-playlists', this.playlist.uuid ] - if (this.playlist.videosLength === 0) return null + @Input() linkType: LinkType = 'internal' + + routerLink: any + playlistHref: string + playlistTarget: string + playlistDescription: string + + constructor ( + private markdownService: MarkdownService + ) {} + + async ngOnInit () { + this.buildPlaylistUrl() + if (this.displayDescription) { + this.playlistDescription = await this.markdownService.textMarkdownToHTML({ markdown: this.playlist.description }) + } + } + + buildPlaylistUrl () { + if (this.toManage) { + this.routerLink = [ '/my-library/video-playlists', this.playlist.uuid ] + return + } + + if (this.playlist.videosLength === 0) { + this.routerLink = null + return + } + + if (this.linkType === 'internal' || !this.playlist.url) { + this.routerLink = VideoPlaylist.buildWatchUrl(this.playlist) + return + } + + if (this.linkType === 'external') { + this.routerLink = null + this.playlistHref = this.playlist.url + this.playlistTarget = '_blank' + return + } + + // Lazy load + this.routerLink = [ '/search/lazy-load-playlist', { url: this.playlist.url } ] - return [ '/videos/watch/playlist', this.playlist.uuid ] + return } }