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