X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-watch%2Fmodal%2Fvideo-share.component.ts;h=c6205e355ca53076f14e7eb454a3af96901b8ad5;hb=28f3d1b36a70426795240c9370e47b6c4ba847f8;hp=678cccfb5dfcc0557909850b04a60be677070a6e;hpb=4635f59d7c3fea4b97029f10886c62fdf38b2084;p=github%2FChocobozzz%2FPeerTube.git 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 678cccfb5..c6205e355 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 @@ -import { Component, Input, ViewChild } from '@angular/core' - -import { NotificationsService } from 'angular2-notifications' - -import { ModalDirective } from 'ngx-bootstrap/modal' +import { Component, ElementRef, Input, ViewChild } from '@angular/core' +import { Notifier } from '@app/core' import { VideoDetails } from '../../../shared/video/video-details.model' +import { buildVideoEmbed, buildVideoLink } from '../../../../assets/player/utils' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { durationToString } from '@app/shared/misc/utils' @Component({ selector: 'my-video-share', @@ -11,31 +12,36 @@ import { VideoDetails } from '../../../shared/video/video-details.model' styleUrls: [ './video-share.component.scss' ] }) export class VideoShareComponent { + @ViewChild('modal') modal: ElementRef + @Input() video: VideoDetails = null - @ViewChild('modal') modal: ModalDirective + startAtCheckbox = false + currentVideoTimestampString: string - constructor (private notificationsService: NotificationsService) { - // empty - } + private currentVideoTimestamp: number - show () { - this.modal.show() - } + constructor ( + private modalService: NgbModal, + private notifier: Notifier, + private i18n: I18n + ) { } + + show (currentVideoTimestamp?: number) { + this.currentVideoTimestamp = Math.floor(currentVideoTimestamp) + this.currentVideoTimestampString = durationToString(this.currentVideoTimestamp) - hide () { - this.modal.hide() + this.modalService.open(this.modal) } getVideoIframeCode () { - return '' + const embedUrl = buildVideoLink(this.getVideoTimestampIfEnabled(), this.video.embedUrl) + + return buildVideoEmbed(embedUrl) } getVideoUrl () { - return window.location.href + return buildVideoLink(this.getVideoTimestampIfEnabled()) } notSecure () { @@ -43,6 +49,16 @@ export class VideoShareComponent { } activateCopiedMessage () { - this.notificationsService.success('Success', 'Copied') + this.notifier.success(this.i18n('Copied')) + } + + getStartCheckboxLabel () { + return this.i18n('Start at {{timestamp}}', { timestamp: this.currentVideoTimestampString }) + } + + private getVideoTimestampIfEnabled () { + if (this.startAtCheckbox === true) return this.currentVideoTimestamp + + return undefined } }