aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts')
-rw-r--r--client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts63
1 files changed, 63 insertions, 0 deletions
diff --git a/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
new file mode 100644
index 000000000..3ff45d9b7
--- /dev/null
+++ b/client/src/app/shared/shared-thumbnail/video-thumbnail.component.ts
@@ -0,0 +1,63 @@
1import { Component, EventEmitter, Input, Output } from '@angular/core'
2import { ScreenService } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { Video } from '../shared-main'
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
14 @Input() routerLink: any[]
15 @Input() queryParams: { [ p: string ]: any }
16
17 @Input() displayWatchLaterPlaylist: boolean
18 @Input() inWatchLaterPlaylist: boolean
19
20 @Output() watchLaterClick = new EventEmitter<boolean>()
21
22 addToWatchLaterText: string
23 addedToWatchLaterText: string
24
25 constructor (
26 private screenService: ScreenService,
27 private i18n: I18n
28 ) {
29 this.addToWatchLaterText = this.i18n('Add to watch later')
30 this.addedToWatchLaterText = this.i18n('Remove from watch later')
31 }
32
33 getImageUrl () {
34 if (!this.video) return ''
35
36 if (this.screenService.isInMobileView()) {
37 return this.video.previewUrl
38 }
39
40 return this.video.thumbnailUrl
41 }
42
43 getProgressPercent () {
44 if (!this.video.userHistory) return 0
45
46 const currentTime = this.video.userHistory.currentTime
47
48 return (currentTime / this.video.duration) * 100
49 }
50
51 getVideoRouterLink () {
52 if (this.routerLink) return this.routerLink
53
54 return [ '/videos/watch', this.video.uuid ]
55 }
56
57 onWatchLaterClick (event: Event) {
58 this.watchLaterClick.emit(this.inWatchLaterPlaylist)
59
60 event.stopPropagation()
61 return false
62 }
63}