Copy to clipboard (#142)
authorJulien Lemaire <sticmac@outlook.fr>
Mon, 11 Dec 2017 16:59:39 +0000 (11:59 -0500)
committerChocobozzz <me@florianbigard.com>
Mon, 11 Dec 2017 16:59:39 +0000 (17:59 +0100)
* Copy buttons on share view

Ugly but working buttons to copy video url and video iframe code.

Add ngx-clipboard dependency to allow easy copy to clipboard directive.

* Designed copy buttons

Using some css (scss) rules to make buttons look better.

* First version on copy feedback

Little success alert message on copy.

Fix lint errors

Move dependencies to dev dependencies

* Update button design

* Use of notifications service

Provides feedback of copy action to the user through the
angular2-notifications module.

client/package.json
client/src/app/app.component.scss
client/src/app/videos/+video-watch/video-share.component.html
client/src/app/videos/+video-watch/video-share.component.scss [new file with mode: 0644]
client/src/app/videos/+video-watch/video-share.component.ts
client/src/app/videos/+video-watch/video-watch.module.ts
client/yarn.lock

index 45f555f2968e95e9792cef85b49bbf3604f2c34f..7441d15ec8c92b99bb12904c58c96da3be39f9a1 100644 (file)
@@ -71,6 +71,7 @@
     "ngc-webpack": "3.2.2",
     "ngx-bootstrap": "2.0.0-beta.9",
     "ngx-chips": "1.5.3",
+    "ngx-clipboard": "^9.0.0",
     "ngx-infinite-scroll": "^0.7.0",
     "ngx-pipes": "^2.0.5",
     "node-sass": "^4.1.1",
index 008c6d1f072a1057be934449d63b246df2933c0d..c0ec2025d17ee0b0201be5dce82422023b70843d 100644 (file)
@@ -86,3 +86,8 @@ footer {
   margin-top: $footer-margin;
   height: $footer-height;
 }
+
+simple-notifications {
+  position: relative;
+  z-index: 1500;
+}
index 36ec38d8869015d862b16de9e7e754e725cf35de..52ee36a2ea880a9cf9524163c8a21d3d56196d66 100644 (file)
       <div class="modal-body">
         <div class="form-group">
           <label>URL</label>
-          <input #urlInput (click)="urlInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="getVideoUrl()" />
+          <div class="input-group">
+            <input #urlInput (click)="urlInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="getVideoUrl()" />
+            <div class="input-group-btn" placement="bottom right">
+              <button [ngxClipboard]="urlInput" (click)="activateCopiedMessage()" type="button" class="btn btn-default btn-search">
+                <span class="glyphicon glyphicon-copy"></span>
+              </button>
+            </div>
+          </div>
         </div>
 
         <div class="form-group">
           <label>Embed</label>
-          <input #shareInput (click)="shareInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="getVideoIframeCode()" />
+          <div class="input-group">
+            <input #shareInput (click)="shareInput.select()" type="text" class="form-control input-sm readonly" readonly [value]="getVideoIframeCode()" />
+            <div class="input-group-btn" placement="bottom right">
+              <button [ngxClipboard]="shareInput" (click)="activateCopiedMessage()" type="button" class="btn btn-default btn-search">
+                <span class="glyphicon glyphicon-copy"></span>
+              </button>
+            </div>
+          </div>
         </div>
 
         <div *ngIf="notSecure()" class="alert alert-warning">
diff --git a/client/src/app/videos/+video-watch/video-share.component.scss b/client/src/app/videos/+video-watch/video-share.component.scss
new file mode 100644 (file)
index 0000000..5196317
--- /dev/null
@@ -0,0 +1,3 @@
+.btn-search {
+  padding: 4.1px 12px;
+}
index 4df9adf29dea3faa364ad0e7d94fd41e52dc2c26..0664c28be553767e39df752cfb8caef2729878d2 100644 (file)
@@ -1,17 +1,21 @@
 import { Component, Input, ViewChild } from '@angular/core'
+
+import { NotificationsService } from 'angular2-notifications'
+
 import { ModalDirective } from 'ngx-bootstrap/modal'
 import { VideoDetails } from '../../shared/video/video-details.model'
 
 @Component({
   selector: 'my-video-share',
-  templateUrl: './video-share.component.html'
+  templateUrl: './video-share.component.html',
+  styleUrls: [ './video-share.component.scss' ]
 })
 export class VideoShareComponent {
   @Input() video: VideoDetails = null
 
   @ViewChild('modal') modal: ModalDirective
 
-  constructor () {
+  constructor (private notificationsService: NotificationsService) {
     // empty
   }
 
@@ -37,4 +41,8 @@ export class VideoShareComponent {
   notSecure () {
     return window.location.protocol === 'http:'
   }
+
+  activateCopiedMessage () {
+    this.notificationsService.success('Success', 'Copied')
+  }
 }
index 0b1dd5c15ebf47b542f5dbe3c886911f9d10608c..18319de1a7e241678e641f41cb29a1bb5a7cc365 100644 (file)
@@ -3,6 +3,7 @@ import { NgModule } from '@angular/core'
 import { VideoWatchRoutingModule } from './video-watch-routing.module'
 import { MarkdownService } from '../shared'
 import { SharedModule } from '../../shared'
+import { ClipboardModule } from 'ngx-clipboard'
 
 import { VideoWatchComponent } from './video-watch.component'
 import { VideoReportComponent } from './video-report.component'
@@ -12,7 +13,8 @@ import { VideoDownloadComponent } from './video-download.component'
 @NgModule({
   imports: [
     VideoWatchRoutingModule,
-    SharedModule
+    SharedModule,
+    ClipboardModule
   ],
 
   declarations: [
index bd6870061a3c285d7f69f0486a169daa51e0ad9d..9cead52e4744da3ed27bacb63ac68c2ac09df38f 100644 (file)
@@ -4714,6 +4714,16 @@ ngx-chips@1.5.3:
   dependencies:
     ng2-material-dropdown "0.7.10"
 
+ngx-clipboard@^9.0.0:
+  version "9.0.0"
+  resolved "https://registry.yarnpkg.com/ngx-clipboard/-/ngx-clipboard-9.0.0.tgz#a56e4a3d0488a491898ee5209980b81ddad8b659"
+  dependencies:
+    ngx-window-token "0.0.4"
+
+ngx-window-token@0.0.4:
+  version "0.0.4"
+  resolved "https://registry.yarnpkg.com/ngx-window-token/-/ngx-window-token-0.0.4.tgz#47e7aaa465411c4ab5f7ba17601bc593c956c736"
+
 ngx-infinite-scroll@^0.7.0:
   version "0.7.0"
   resolved "https://registry.yarnpkg.com/ngx-infinite-scroll/-/ngx-infinite-scroll-0.7.0.tgz#a390c61c6a05ac14485e1c5bc8b4e6f6bd62fd6a"