You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by fe...@apache.org on 2019/01/19 08:02:08 UTC

[zeppelin] branch master updated: [ZEPPELIN-3575] Add 'Copy Column Name' to table visualisation-table (#3254)

This is an automated email from the ASF dual-hosted git repository.

felixcheung pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zeppelin.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b4920c  [ZEPPELIN-3575] Add 'Copy Column Name' to table visualisation-table  (#3254)
2b4920c is described below

commit 2b4920c97484abd942acdd18dce3097eace7fc64
Author: Egor Klimov <kl...@yandex.ru>
AuthorDate: Sat Jan 19 11:02:02 2019 +0300

    [ZEPPELIN-3575] Add 'Copy Column Name' to table visualisation-table  (#3254)
    
    ### What is this PR for?
    Add button to drop-down list in visualization table to copy column name.
    I know that column name could be obtained in a different way, for example, by auto-complete.
    Nevertheless I think this feature is comfortable.
    
    ### What type of PR is it?
    Feature
    
    ### What is the Jira issue?
    [ZEPPELIN-3575](https://issues.apache.org/jira/browse/ZEPPELIN-3575)
    
    ### How should this be tested?
    * Manually
    
    ### Screenshots (if appropriate)
    ![zp-20](https://user-images.githubusercontent.com/6136993/48303733-168ebc00-e51f-11e8-8317-008d59a6b55e.gif)
    
    ### Questions:
    * Does the licenses files need update? No
    * Is there breaking changes for older versions? No
    * Does this needs documentation? No
    
    * ZEPPELIN-3575 - Add 'Copy Column Name' button in visualization table
    
    * Move option
---
 .../app/visualization/builtins/visualization-table.js | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/zeppelin-web/src/app/visualization/builtins/visualization-table.js b/zeppelin-web/src/app/visualization/builtins/visualization-table.js
index 179fd9a..4227258 100644
--- a/zeppelin-web/src/app/visualization/builtins/visualization-table.js
+++ b/zeppelin-web/src/app/visualization/builtins/visualization-table.js
@@ -230,6 +230,15 @@ export default class TableVisualization extends Visualization {
     gridOptions.columnDefs.map((colDef) => {
       colDef.menuItems = [
         {
+          title: 'Copy Column Name',
+          action: function() {
+            self.copyStringToClipboard(this.context.col.displayName);
+          },
+          active: function() {
+            return false;
+          },
+        },
+        {
           title: 'Type: String',
           action: function() {
             self.updateColDefType(this.context.col.colDef, TableColumnType.STRING);
@@ -515,4 +524,14 @@ export default class TableVisualization extends Visualization {
       },
     };
   }
+
+  copyStringToClipboard(copyString) {
+    const strToClipboard = document.createElement('textarea');
+    strToClipboard.value = copyString;
+    document.body.appendChild(strToClipboard);
+    strToClipboard.select();
+    document.execCommand('copy');
+    document.body.removeChild(strToClipboard);
+    return;
+  }
 }