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