فهرست منبع

HUE-7137 [editor] Move copy to clipboard inside the download dropdown

Enrico Berti 8 سال پیش
والد
کامیت
961498862f

+ 33 - 0
desktop/core/src/desktop/templates/common_notebook_ko_components.mako

@@ -196,6 +196,11 @@ except ImportError, e:
           </a>
         </li>
         % endif
+        <li>
+          <a data-bind="css: clipboardClass" title="${ _('Copy the displayed results in your clipboard') }">
+            <i class="fa fa-fw fa-clipboard"></i> ${ _('Clipboard') }
+          </a>
+        </li>
         <li>
           <a class="download" href="javascript:void(0)" data-bind="click: function() { savePath(''); $('#saveResultsModal').modal('show'); }" title="${ _('Save the result in a file, a new table...') }">
             <i class="fa fa-fw fa-save"></i> ${ _('Save') }
@@ -341,6 +346,34 @@ except ImportError, e:
           return self.savePath() !== '' && (self.saveTarget() != 'hive-table' || /^([a-zA-Z0-9_]+\.)?[a-zA-Z0-9_]*$/.test(self.savePath()));
         });
 
+        self.clipboardClass = ko.pureComputed(function () {
+          return 'download pointer clipboard' + self.snippet.id().split('-')[0];
+        });
+
+        var clipboard = new Clipboard('.clipboard' + self.snippet.id().split('-')[0], {
+          text: function () {
+            if (self.snippet.result && self.snippet.result.data()) {
+              var data = self.snippet.result.data();
+              var result = '';
+              data.forEach(function (row) {
+                for (var i = 1; i < row.length; i++) { // skip the row number column
+                  result += hueUtils.html2text(row[i]) + '\t';
+                }
+                result += '\n';
+              });
+              return result;
+            }
+            else {
+              return CopyToClipboardGlobals.i18n.ERROR;
+            }
+          }
+        });
+
+        clipboard.on('success', function (e) {
+          $.jHueNotify.info(CopyToClipboardGlobals.i18n.SUCCESS)
+          e.clearSelection();
+        });
+
         self.trySaveResults = function () {
           if (self.isValidDestination()) {
             self.saveResults();

+ 0 - 28
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -456,34 +456,6 @@ var EditorViewModel = (function() {
       }
     };
 
-    self.clipboardClass = ko.pureComputed(function () {
-      return 'snippet-side-btn clipboard' + self.id().split('-')[0];
-    });
-
-    var clipboard = new Clipboard('.clipboard' + self.id().split('-')[0], {
-      text: function () {
-        if (self.result && self.result.data()) {
-          var data = self.result.data();
-          var result = '';
-          data.forEach(function (row) {
-            for (var i = 1; i < row.length; i++) { // skip the row number column
-              result += hueUtils.html2text(row[i]) + '\t';
-            }
-            result += '\n';
-          });
-          return result;
-        }
-        else {
-          return CopyToClipboardGlobals.i18n.ERROR;
-        }
-      }
-    });
-
-    clipboard.on('success', function (e) {
-      $.jHueNotify.info(CopyToClipboardGlobals.i18n.SUCCESS)
-      e.clearSelection();
-    });
-
     self.isSqlDialect.subscribe(updateDatabases);
     updateDatabases();
 

+ 1 - 7
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -680,7 +680,7 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
               (<span data-bind="text: result.rows().toLocaleString() + (type() == 'impala' && result.rows() == 1024 ? '+' : '')" title="${ _('Number of rows') }"></span>)
             <!-- /ko -->
             <!-- ko if: showGrid -->
-            <div class="inline-block inactive-action pointer" title="${_('Search the results')}" data-bind="click: function(data, e){ $(e.target).parents('.snippet').find('.resultTable').hueDataTable().fnShowSearch() }"><i class="snippet-icon fa fa-search"></i></div>
+            <div class="inline-block inactive-action pointer margin-left-10" title="${_('Search the results')}" data-bind="click: function(data, e){ $(e.target).parents('.snippet').find('.resultTable').hueDataTable().fnShowSearch() }"><i class="snippet-icon fa fa-search"></i></div>
             <!-- /ko -->
             <div class="inline-block inactive-action pointer" title="${_('Expand results')}" rel="tooltip" data-bind="css: { 'margin-left-10': !showGrid()}, visible: !$root.isFullscreenMode() && !$root.isPlayerMode(), click: function(){ $root.isPlayerMode(true); }"><i class="snippet-icon fa fa-expand"></i></div>
             <div class="inline-block inactive-action pointer" title="${_('Collapse results')}" rel="tooltip" data-bind="visible: !$root.isFullscreenMode() && $root.isPlayerMode(), click: function(){ $root.isPlayerMode(false); }"><i class="snippet-icon fa fa-compress"></i></div>
@@ -1771,12 +1771,6 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
       </a>
     </div>
 
-    <div>
-      <a data-bind="css: clipboardClass" title="${ _('Copy the displayed results in your clipboard') }">
-        <i class="fa fa-fw fa-clipboard"></i>
-      </a>
-    </div>
-
     <div data-bind="component: { name: 'downloadSnippetResults', params: { snippet: $data, notebook: $parent } }" style="display:inline-block;"></div>
   </div>
 </script>