Client: add share button
authorChocobozzz <florian.bigard@gmail.com>
Tue, 8 Nov 2016 20:11:57 +0000 (21:11 +0100)
committerChocobozzz <florian.bigard@gmail.com>
Tue, 8 Nov 2016 20:11:57 +0000 (21:11 +0100)
client/src/app/videos/video-watch/video-watch.component.html
client/src/app/videos/video-watch/video-watch.component.scss
client/src/app/videos/video-watch/video-watch.component.ts

index 0bbb5d3e8531701944bca710118b39c1cf00fa9a..f3a41636747ec32f75d84b7f5990585ac10e5067 100644 (file)
     </div>
 
     <div id="video-actions" class="col-md-4 text-right">
+      <button id="share" class="btn btn-default" (click)="showShareModal()">
+        <span class="glyphicon glyphicon-share"></span> Share
+      </button>
+
       <button title="Get magnet URI" id="magnet-uri" class="btn btn-default" (click)="showMagnetUriModal()">
         <span class="glyphicon glyphicon-magnet"></span> Magnet
       </button>
@@ -72,9 +76,9 @@
   </div>
 </div>
 
-<div *ngIf="video !== null" bsModal #magnetUriModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="magnetUriModal" aria-hidden="true">
+<div *ngIf="video !== null" bsModal #magnetUriModal="bs-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="magnetUriModal" aria-hidden="true">
   <div class="modal-dialog">
-    <div class="modal-content">
+    <div class="modal-content modal-lg">
 
       <div class="modal-header">
         <button type="button" class="close" aria-label="Close" (click)="hideMagnetUriModal()">
     </div>
   </div>
 </div>
+
+<div *ngIf="video !== null" bsModal #shareModal="bs-modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="shareModal" aria-hidden="true">
+  <div class="modal-dialog modal-lg">
+    <div class="modal-content">
+
+      <div class="modal-header">
+        <button type="button" class="close" aria-label="Close" (click)="hideShareModal()">
+          <span aria-hidden="true">&times;</span>
+        </button>
+        <h4 class="modal-title">Share</h4>
+      </div>
+
+      <div class="modal-body">
+        <div class="form-group">
+          <label>URL</label>
+          <input #urlInput (click)="urlInput.select()" type="text" class="form-control input-sm" readonly [value]="getVideoUrl()" />
+        </div>
+
+        <div class="form-group">
+          <label>Embed</label>
+          <input #shareInput (click)="shareInput.select()" type="text" class="form-control input-sm" readonly [value]="getVideoIframeCode()" />
+        </div>
+      </div>
+    </div>
+  </div>
+</div>
index 9d335c3baf6d99abeecc113cb59fe8790cbd3bd0..fe23b849f49165089fbf2ad27dd6827270599202 100644 (file)
@@ -39,7 +39,7 @@
       top: 2px;
     }
 
-    #magnet-uri {
+    #magnet-uri, #share {
       font-weight: bold;
       opacity: 0.85;
     }
     }
   }
 }
+
+.modal-content {
+  input {
+    /* Force blank on readonly inputs */
+    background-color: #fff;
+  }
+}
index 6012daa5c833cc42bd438ff4f938022195cb49a6..0ae323c9fa3736b29f61883d01838bd0a28e646a 100644 (file)
@@ -18,6 +18,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   private static LOADTIME_TOO_LONG: number = 30000;
 
   @ViewChild('magnetUriModal') magnetUriModal: ModalDirective;
+  @ViewChild('shareModal') shareModal: ModalDirective;
 
   downloadSpeed: number;
   error: boolean = false;
@@ -74,8 +75,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
   }
 
   loadVideo() {
-    console.log('<iframe width="560" height="315" src="' + window.location.origin + '/videos/embed/' + this.video.id + '" frameborder="0" allowfullscreen></iframe>');
-
     // Reset the error
     this.error = false;
     // We are loading the video
@@ -116,6 +115,25 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     this.magnetUriModal.hide();
   }
 
+  showShareModal() {
+    this.shareModal.show();
+  }
+
+  hideShareModal() {
+    this.shareModal.hide();
+  }
+
+  getVideoIframeCode() {
+    return '<iframe width="560" height="315" ' +
+           'src="' + window.location.origin + '/videos/embed/' + this.video.id + '" ' +
+           'frameborder="0" allowfullscreen>' +
+           '</iframe>';
+  }
+
+  getVideoUrl() {
+    return window.location.href;
+  }
+
   private loadTooLong() {
     this.error = true;
     console.error('The video load seems to be abnormally long.');