Bläddra i källkod

HUE-7177 [assist] Right click "Open in Importer"

Enrico Berti 8 år sedan
förälder
incheckning
2f65ea4b5c

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/assist/assistHdfsEntry.js

@@ -250,5 +250,9 @@ var AssistHdfsEntry = (function () {
     });
   };
 
+  AssistHdfsEntry.prototype.openInImporter = function () {
+    huePubSub.publish('open.in.importer', this.definition.path);
+  };
+
   return AssistHdfsEntry;
 })();

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/assist/assistS3Entry.js

@@ -246,5 +246,9 @@ var AssistS3Entry = (function () {
     });
   };
 
+  AssistS3Entry.prototype.openInImporter = function () {
+    huePubSub.publish('open.in.importer', this.definition.path);
+  };
+
   return AssistS3Entry;
 })();

+ 3 - 0
desktop/core/src/desktop/templates/assist.mako

@@ -168,6 +168,9 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, get_ord
 
   <script type="text/html" id="hdfs-context-items">
     <li><a href="javascript:void(0);" data-bind="hueLink: definition.url"><i class="fa fa-fw" data-bind="css: {'fa-folder-open-o': definition.type === 'dir', 'fa-file-text-o': definition.type === 'file'}"></i> ${ _('Open in File Browser') }</a></li>
+    <!-- ko if: IS_HUE_4 -->
+    <li><a href="javascript:void(0);" data-bind="click: openInImporter"><!-- ko template: { name: 'app-icon-template', data: { icon: 'importer' } } --><!-- /ko --> ${ _('Open in Importer') }</a></li>
+    <!-- /ko -->
     <!-- ko if: $currentApp() === 'editor' -->
     <li><a href="javascript:void(0);" data-bind="click: dblClick"><i class="fa fa-fw fa-paste"></i> ${ _('Insert at cursor') }</a></li>
     <!-- /ko -->

+ 10 - 4
desktop/core/src/desktop/templates/hue.mako

@@ -891,12 +891,16 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           $('.dz-drag-hover').removeClass('dz-drag-hover');
         };
 
+        var openImporter = function (path) {
+          self.loadApp('importer');
+          self.getActiveAppViewModel(function (vm) {
+            vm.createWizard.source.path(path);
+          });
+        };
+
         self.dropzoneComplete = function (path) {
           if (path.toLowerCase().endsWith('.csv')){
-            self.loadApp('importer');
-            self.getActiveAppViewModel(function (vm) {
-              vm.createWizard.source.path(path);
-            });
+            openImporter(path);
           }
           else {
             huePubSub.publish('open.link', '/filebrowser/view=' + path);
@@ -904,6 +908,8 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
           $('.dz-drag-hover').removeClass('dz-drag-hover');
         };
 
+        huePubSub.subscribe('open.in.importer', openImporter);
+
         // prepend /hue to all the link on this page
         $('a[href]').each(function () {
           var link = $(this).attr('href');