]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
Migrate to $localize
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-thumbnail / video-thumbnail.component.ts
CommitLineData
b7819090 1import { Component, EventEmitter, Input, Output } from '@angular/core'
67ed6552 2import { ScreenService } from '@app/core'
67ed6552 3import { Video } from '../shared-main'
202f6b6c
C
4
5@Component({
6 selector: 'my-video-thumbnail',
7 styleUrls: [ './video-thumbnail.component.scss' ],
8 templateUrl: './video-thumbnail.component.html'
9})
10export class VideoThumbnailComponent {
11 @Input() video: Video
12 @Input() nsfw = false
0bdad52f
C
13
14 @Input() videoRouterLink: any[]
be27ef3b 15 @Input() queryParams: { [ p: string ]: any }
0bdad52f
C
16 @Input() videoHref: string
17 @Input() videoTarget: string
3290f37c 18
b7819090
C
19 @Input() displayWatchLaterPlaylist: boolean
20 @Input() inWatchLaterPlaylist: boolean
29128b2f 21
b7819090
C
22 @Output() watchLaterClick = new EventEmitter<boolean>()
23
24 addToWatchLaterText: string
25 addedToWatchLaterText: string
29128b2f 26
66357162
C
27 constructor (private screenService: ScreenService) {
28 this.addToWatchLaterText = $localize`Add to watch later`
29 this.addedToWatchLaterText = $localize`Remove from watch later`
e2f01c47 30 }
bbe0f064 31
3290f37c
C
32 getImageUrl () {
33 if (!this.video) return ''
34
bbe0f064 35 if (this.screenService.isInMobileView()) {
3290f37c
C
36 return this.video.previewUrl
37 }
38
39 return this.video.thumbnailUrl
40 }
6e46de09
C
41
42 getProgressPercent () {
43 if (!this.video.userHistory) return 0
44
45 const currentTime = this.video.userHistory.currentTime
46
47 return (currentTime / this.video.duration) * 100
48 }
e2f01c47
C
49
50 getVideoRouterLink () {
0bdad52f 51 if (this.videoRouterLink) return this.videoRouterLink
e2f01c47
C
52
53 return [ '/videos/watch', this.video.uuid ]
54 }
29128b2f 55
b7819090
C
56 onWatchLaterClick (event: Event) {
57 this.watchLaterClick.emit(this.inWatchLaterPlaylist)
29128b2f 58
b7819090
C
59 event.stopPropagation()
60 return false
29128b2f 61 }
202f6b6c 62}