X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fvideo%2Fvideo-thumbnail.component.ts;h=111b4c8bbe57e3fde7f028bda6867a971e5f6322;hb=45c6bcf312d2e9578501eaaf7511183bc570fe91;hp=e543e9903bbf1855bc7e5d820b07f1f699634c30;hpb=202f6b6c9dcc9b0aec4b0c1b15e455c22a7952a7;p=oweals%2Fpeertube.git diff --git a/client/src/app/shared/video/video-thumbnail.component.ts b/client/src/app/shared/video/video-thumbnail.component.ts index e543e9903..111b4c8bb 100644 --- a/client/src/app/shared/video/video-thumbnail.component.ts +++ b/client/src/app/shared/video/video-thumbnail.component.ts @@ -1,5 +1,7 @@ -import { Component, Input } from '@angular/core' +import { Component, EventEmitter, Input, Output } from '@angular/core' import { Video } from './video.model' +import { ScreenService } from '@app/shared/misc/screen.service' +import { I18n } from '@ngx-translate/i18n-polyfill' @Component({ selector: 'my-video-thumbnail', @@ -9,4 +11,53 @@ import { Video } from './video.model' export class VideoThumbnailComponent { @Input() video: Video @Input() nsfw = false + @Input() routerLink: any[] + @Input() queryParams: { [ p: string ]: any } + + @Input() displayWatchLaterPlaylist: boolean + @Input() inWatchLaterPlaylist: boolean + + @Output() watchLaterClick = new EventEmitter() + + addToWatchLaterText: string + addedToWatchLaterText: string + + constructor ( + private screenService: ScreenService, + private i18n: I18n + ) { + this.addToWatchLaterText = this.i18n('Add to watch later') + this.addedToWatchLaterText = this.i18n('Remove from watch later') + } + + getImageUrl () { + if (!this.video) return '' + + if (this.screenService.isInMobileView()) { + return this.video.previewUrl + } + + return this.video.thumbnailUrl + } + + getProgressPercent () { + if (!this.video.userHistory) return 0 + + const currentTime = this.video.userHistory.currentTime + + return (currentTime / this.video.duration) * 100 + } + + getVideoRouterLink () { + if (this.routerLink) return this.routerLink + + return [ '/videos/watch', this.video.uuid ] + } + + onWatchLaterClick (event: Event) { + this.watchLaterClick.emit(this.inWatchLaterPlaylist) + + event.stopPropagation() + return false + } }