]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/modal/video-share.component.ts
Fix scrolling with hash in url
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / modal / video-share.component.ts
index f45afccfb9010b232387d04cd57350fb5f2531aa..3550556a0273ff483b2acf3dcea767004f091a47 100644 (file)
@@ -1,10 +1,9 @@
 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, NgbTabChangeEvent } from '@ng-bootstrap/ng-bootstrap'
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { VideoCaption } from '@shared/models'
+import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
 
 type Customizations = {
   startAtCheckbox: boolean
@@ -34,18 +33,16 @@ export class VideoShareComponent {
 
   @Input() video: VideoDetails = null
   @Input() videoCaptions: VideoCaption[] = []
+  @Input() playlist: VideoPlaylist = null
 
-  activeId: 'url' | 'qrcode' | 'embed'
+  activeId: 'url' | 'qrcode' | 'embed' = 'url'
   customizations: Customizations
   isAdvancedCustomizationCollapsed = true
+  includeVideoInPlaylist = false
 
   private currentVideoTimestamp: number
 
-  constructor (
-    private modalService: NgbModal,
-    private notifier: Notifier,
-    private i18n: I18n
-  ) { }
+  constructor (private modalService: NgbModal) { }
 
   show (currentVideoTimestamp?: number) {
     this.currentVideoTimestamp = currentVideoTimestamp
@@ -75,7 +72,7 @@ export class VideoShareComponent {
       controls: true
     }
 
-    this.modalService.open(this.modal)
+    this.modalService.open(this.modal, { centered: true })
   }
 
   getVideoIframeCode () {
@@ -86,27 +83,32 @@ export class VideoShareComponent {
   }
 
   getVideoUrl () {
-    const options = this.getOptions()
+    const baseUrl = window.location.origin + '/videos/watch/' + this.video.uuid
+    const options = this.getOptions(baseUrl)
 
     return buildVideoLink(options)
   }
 
-  notSecure () {
-    return window.location.protocol === 'http:'
-  }
+  getPlaylistUrl () {
+    const base = window.location.origin + '/videos/watch/playlist/' + this.playlist.uuid
+
+    if (!this.includeVideoInPlaylist) return base
 
-  activateCopiedMessage () {
-    this.notifier.success(this.i18n('Copied'))
+    return base + '?videoId=' + this.video.uuid
   }
 
-  onTabChange (event: NgbTabChangeEvent) {
-    this.activeId = event.nextId as any
+  notSecure () {
+    return window.location.protocol === 'http:'
   }
 
   isInEmbedTab () {
     return this.activeId === 'embed'
   }
 
+  hasPlaylist () {
+    return !!this.playlist
+  }
+
   private getOptions (baseUrl?: string) {
     return {
       baseUrl,