]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/videos/+video-watch/modal/video-share.component.ts
Add to playlist dropdown
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / modal / video-share.component.ts
CommitLineData
63347a0f 1import { Component, ElementRef, Input, ViewChild } from '@angular/core'
f8b2c1b4 2import { Notifier } from '@app/core'
4635f59d 3import { VideoDetails } from '../../../shared/video/video-details.model'
11b8762f 4import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils'
b1d40cff 5import { I18n } from '@ngx-translate/i18n-polyfill'
63347a0f 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
11b8762f 7import { durationToString } from '@app/shared/misc/utils'
cf02fbfb
C
8
9@Component({
10 selector: 'my-video-share',
c7e1e432
JL
11 templateUrl: './video-share.component.html',
12 styleUrls: [ './video-share.component.scss' ]
cf02fbfb
C
13})
14export class VideoShareComponent {
11b8762f
C
15 @ViewChild('modal') modal: ElementRef
16
404b54e1 17 @Input() video: VideoDetails = null
cf02fbfb 18
f0a39880 19 currentVideoTimestamp: number
11b8762f 20 startAtCheckbox = false
cf02fbfb 21
b1d40cff 22 constructor (
63347a0f 23 private modalService: NgbModal,
f8b2c1b4 24 private notifier: Notifier,
b1d40cff 25 private i18n: I18n
23db998f 26 ) { }
cf02fbfb 27
11b8762f 28 show (currentVideoTimestamp?: number) {
f0a39880 29 this.currentVideoTimestamp = currentVideoTimestamp ? Math.floor(currentVideoTimestamp) : 0
11b8762f 30
63347a0f 31 this.modalService.open(this.modal)
cf02fbfb
C
32 }
33
df98563e 34 getVideoIframeCode () {
11b8762f
C
35 const embedUrl = buildVideoLink(this.getVideoTimestampIfEnabled(), this.video.embedUrl)
36
37 return buildVideoEmbed(embedUrl)
cf02fbfb
C
38 }
39
df98563e 40 getVideoUrl () {
11b8762f 41 return buildVideoLink(this.getVideoTimestampIfEnabled())
cf02fbfb 42 }
2c8d4697 43
df98563e
C
44 notSecure () {
45 return window.location.protocol === 'http:'
2c8d4697 46 }
c7e1e432
JL
47
48 activateCopiedMessage () {
f8b2c1b4 49 this.notifier.success(this.i18n('Copied'))
c7e1e432 50 }
11b8762f 51
11b8762f
C
52 private getVideoTimestampIfEnabled () {
53 if (this.startAtCheckbox === true) return this.currentVideoTimestamp
54
55 return undefined
56 }
cf02fbfb 57}