aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/modal/video-share.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-27 15:59:00 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 16:04:06 +0200
commit11b8762f9c815930982599f4ff90c0db60eaf0ca (patch)
treebfca3003c619559284e00fe804d080e66c3ede12 /client/src/app/videos/+video-watch/modal/video-share.component.ts
parentc9d5c64f98c1f1fe7950de60c58edeaf3ace070d (diff)
downloadPeerTube-11b8762f9c815930982599f4ff90c0db60eaf0ca.tar.gz
PeerTube-11b8762f9c815930982599f4ff90c0db60eaf0ca.tar.zst
PeerTube-11b8762f9c815930982599f4ff90c0db60eaf0ca.zip
Add start at checkbox in share modal
Diffstat (limited to 'client/src/app/videos/+video-watch/modal/video-share.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/modal/video-share.component.ts31
1 files changed, 26 insertions, 5 deletions
diff --git a/client/src/app/videos/+video-watch/modal/video-share.component.ts b/client/src/app/videos/+video-watch/modal/video-share.component.ts
index 14f557f9a..71d6f5633 100644
--- a/client/src/app/videos/+video-watch/modal/video-share.component.ts
+++ b/client/src/app/videos/+video-watch/modal/video-share.component.ts
@@ -1,9 +1,10 @@
1import { Component, ElementRef, Input, ViewChild } from '@angular/core' 1import { Component, ElementRef, Input, ViewChild } from '@angular/core'
2import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
3import { VideoDetails } from '../../../shared/video/video-details.model' 3import { VideoDetails } from '../../../shared/video/video-details.model'
4import { buildVideoEmbed } from '../../../../assets/player/utils' 4import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils'
5import { I18n } from '@ngx-translate/i18n-polyfill' 5import { I18n } from '@ngx-translate/i18n-polyfill'
6import { NgbModal } from '@ng-bootstrap/ng-bootstrap' 6import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
7import { durationToString } from '@app/shared/misc/utils'
7 8
8@Component({ 9@Component({
9 selector: 'my-video-share', 10 selector: 'my-video-share',
@@ -11,9 +12,14 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
11 styleUrls: [ './video-share.component.scss' ] 12 styleUrls: [ './video-share.component.scss' ]
12}) 13})
13export class VideoShareComponent { 14export class VideoShareComponent {
15 @ViewChild('modal') modal: ElementRef
16
14 @Input() video: VideoDetails = null 17 @Input() video: VideoDetails = null
15 18
16 @ViewChild('modal') modal: ElementRef 19 startAtCheckbox = false
20 currentVideoTimestampString: string
21
22 private currentVideoTimestamp: number
17 23
18 constructor ( 24 constructor (
19 private modalService: NgbModal, 25 private modalService: NgbModal,
@@ -23,16 +29,21 @@ export class VideoShareComponent {
23 // empty 29 // empty
24 } 30 }
25 31
26 show () { 32 show (currentVideoTimestamp?: number) {
33 this.currentVideoTimestamp = Math.floor(currentVideoTimestamp)
34 this.currentVideoTimestampString = durationToString(this.currentVideoTimestamp)
35
27 this.modalService.open(this.modal) 36 this.modalService.open(this.modal)
28 } 37 }
29 38
30 getVideoIframeCode () { 39 getVideoIframeCode () {
31 return buildVideoEmbed(this.video.embedUrl) 40 const embedUrl = buildVideoLink(this.getVideoTimestampIfEnabled(), this.video.embedUrl)
41
42 return buildVideoEmbed(embedUrl)
32 } 43 }
33 44
34 getVideoUrl () { 45 getVideoUrl () {
35 return window.location.href 46 return buildVideoLink(this.getVideoTimestampIfEnabled())
36 } 47 }
37 48
38 notSecure () { 49 notSecure () {
@@ -42,4 +53,14 @@ export class VideoShareComponent {
42 activateCopiedMessage () { 53 activateCopiedMessage () {
43 this.notificationsService.success(this.i18n('Success'), this.i18n('Copied')) 54 this.notificationsService.success(this.i18n('Success'), this.i18n('Copied'))
44 } 55 }
56
57 getStartCheckboxLabel () {
58 return this.i18n('Start at {{timestamp}}', { timestamp: this.currentVideoTimestampString })
59 }
60
61 private getVideoTimestampIfEnabled () {
62 if (this.startAtCheckbox === true) return this.currentVideoTimestamp
63
64 return undefined
65 }
45} 66}