Răsfoiți Sursa

HUE-7 [importer] Tweak the UX and add flags to enable the new version

Romain Rigaux 8 ani în urmă
părinte
comite
ef8812c

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -1167,6 +1167,9 @@
   # Flag to turn on the morphline based Solr indexer.
   ## enable_new_indexer=false
 
+  # Flag to turn on the new metadata importer.
+  ## enable_new_importer=false
+
 
 ###########################################################################
 # Settings to configure Job Designer

+ 3 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1171,6 +1171,9 @@
   # Flag to turn on the morphline based Solr indexer.
   ## enable_new_indexer=false
 
+  # Flag to turn on the new metadata importer.
+  ## enable_new_importer=false
+
 
 ###########################################################################
 # Settings to configure Job Designer

+ 8 - 2
desktop/core/src/desktop/templates/assist.mako

@@ -15,12 +15,15 @@
 ## limitations under the License.
 
 <%!
+from django.utils.translation import ugettext as _
+
 from desktop import conf
 from desktop.conf import USE_NEW_SIDE_PANELS
 from desktop.lib.i18n import smart_unicode
 from desktop.views import _ko
-from django.utils.translation import ugettext as _
+
 from metadata.conf import has_navigator
+from metastore.conf import ENABLE_NEW_CREATE_TABLE
 from notebook.conf import ENABLE_QUERY_BUILDER
 %>
 
@@ -1073,7 +1076,10 @@ from notebook.conf import ENABLE_QUERY_BUILDER
       </ul>
       <!-- /ko -->
       <a class="inactive-action" href="javascript:void(0)" data-bind="click: toggleSearch, css: { 'blue' : isSearchVisible }"><i class="pointer fa fa-filter" title="${_('Filter')}"></i></a>
-      ## <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='file', target_type='table') }' + 'default' }"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
+      % if ENABLE_NEW_CREATE_TABLE.get():
+        <a class="inactive-action" href="javascript:void(0)" data-bind="attr: { 'href': '${ url('indexer:importer_prefill', source_type='all', target_type='table') }' + 'default' }"><i class="pointer fa fa-plus" title="${_('Create table')}"></i></a>
+        ## For DB --> '${ url('indexer:importer_prefill', source_type='manual', target_type='database') }'
+      % endif
       <!-- ko if: sourceType === 'impala' -->
       <a class="inactive-action" href="javascript:void(0)" data-bind="templatePopover : { contentTemplate: 'ask-for-invalidate-content', titleTemplate: 'ask-for-invalidate-title', trigger: 'click', minWidth: '320px' }"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }" title="${_('Manually refresh the table list')}"></i></a>
       <!-- /ko -->

+ 7 - 1
desktop/libs/indexer/src/indexer/conf.py

@@ -59,10 +59,16 @@ def zkensemble():
     LOG.exception('failed to get solr url')
 
 
+ENABLE_NEW_IMPORTER = Config(
+  key="enable_new_importer",
+  help=_t("Flag to turn on the new metadata importer."),
+  type=bool,
+  default=False
+)
 
 ENABLE_NEW_INDEXER = Config(
   key="enable_new_indexer",
-  help=_t("Flag to turn on the morphline based Solr indexer."),
+  help=_t("Flag to turn on the new Solr indexer."),
   type=bool,
   default=False
 )

+ 15 - 9
desktop/libs/indexer/src/indexer/file_format.py

@@ -20,22 +20,28 @@ import logging
 
 from django.utils.translation import ugettext as _
 
+from indexer.argument import CheckboxArgument, TextDelimiterArgument
+from indexer.conf import ENABLE_NEW_INDEXER
 from indexer.fields import Field, guess_field_type_from_samples
-from indexer.argument import TextArgument, CheckboxArgument, TextDelimiterArgument
 from indexer.operations import get_operator
 
+
 LOG = logging.getLogger(__name__)
 
 
 def get_format_types():
-  return [
-    CSVFormat,
-    HueLogFormat,
-    ApacheCombinedFormat,
-    RubyLogFormat,
-    SyslogFormat,
-    ParquetFormat
-  ]
+  formats = [CSVFormat]
+
+  if ENABLE_NEW_INDEXER.get():
+    formats.extend([
+      HueLogFormat,
+      ApacheCombinedFormat,
+      RubyLogFormat,
+      SyslogFormat,
+      ParquetFormat
+    ])
+
+  return formats
 
 def get_file_indexable_format_types():
   return [format_ for format_ in get_format_types() if format_.is_file_indexable]

+ 31 - 12
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -15,10 +15,12 @@
 ## limitations under the License.
 
 <%!
-  from desktop import conf
-  from desktop.views import commonheader, commonfooter, commonshare, commonimportexport
   from django.utils.translation import ugettext as _
-  from desktop.views import _ko
+
+  from desktop import conf
+  from desktop.views import commonheader, commonfooter, commonshare, commonimportexport, _ko
+
+  from indexer.conf import ENABLE_NEW_INDEXER
 %>
 
 <%namespace name="actionbar" file="actionbar.mako" />
@@ -278,7 +280,14 @@ ${ assist.assistPanel() }
             <span class="fa fa-check"></span>
             <!-- /ko -->
           </div>
-          <div class="caption">${ _('Pick data from ') }<span data-bind="text: createWizard.source.inputFormat"></span></div>
+          <div class="caption">
+            <!-- ko if: createWizard.source.inputFormat() != 'manual' -->
+            ${ _('Pick data from ') }<span data-bind="text: createWizard.source.inputFormat"></span> <span data-bind="text: createWizard.source.path"></span>
+            <!-- /ko -->
+            <!-- ko if: createWizard.source.inputFormat() == 'manual' -->
+            ${ _('No source data') }
+          <!-- /ko -->
+          </div>
         </li>
 
         <li data-bind="css: { 'inactive': currentStep() == 1, 'active': currentStep() == 2, 'complete': currentStep() == 3 }, click: function() { currentStep(2) }">
@@ -304,7 +313,7 @@ ${ assist.assistPanel() }
       <h3 class="card-heading simple">${_('Source')}</h3>
       <div class="card-body">
         <div>
-          <div class="control-group" data-bind="visible: ! createWizard.prefill.target_type">
+          <div class="control-group" data-bind="visible: ! createWizard.prefill.target_type || createWizard.prefill.source_type() == 'all'">
             <label for="sourceType" class="control-label"><div>${ _('Type') }</div>
               <select id="sourceType" data-bind="selectize: createWizard.source.inputFormats, value: createWizard.source.inputFormat, optionsText: 'name', optionsValue: 'value'"></select>
             </label>
@@ -314,6 +323,11 @@ ${ assist.assistPanel() }
             <label for="path" class="control-label"><div>${ _('Path') }</div>
               <input type="text" class="form-control path input-xxlarge" data-bind="value: createWizard.source.path, filechooser: createWizard.source.path, filechooserOptions: { linkMarkup: true, skipInitialPathIfEmpty: true, openOnFocus: true }" placeholder="${ _('Click or drag & drop') }">
             </label>
+            <!-- ko if: createWizard.source.path().length > 0 -->
+              <a data-bind="attr: {href: '/filebrowser/view=' + createWizard.source.path() }" target="_blank" title="${ _('Open') }">
+                <i class="fa fa-external-link-square"></i>
+              </a>
+            <!-- /ko -->
           </div>
 
           <div class="control-group" data-bind="visible: createWizard.source.inputFormat() == 'table'">
@@ -339,7 +353,10 @@ ${ assist.assistPanel() }
       <!-- ko ifnot: createWizard.isGuessingFormat -->
       <h3 class="card-heading simple">${_('Format')}</h3>
       <div class="card-body">
-        <label data-bind="visible: ! createWizard.prefill.source_type"><div>${_('File Type')}</div> <select data-bind="selectize: $root.createWizard.fileTypes, value: $root.createWizard.fileTypeName, optionsText: 'description', optionsValue: 'name'"></select></label>
+        <label data-bind="visible: (! createWizard.prefill.source_type) && createWizard.source.inputFormat() != 'table'">
+          <div>${_('File Type')}</div>
+          <select data-bind="selectize: $root.createWizard.fileTypes, value: $root.createWizard.fileTypeName, optionsText: 'description', optionsValue: 'name'"></select>
+        </label>
         <span data-bind="with: createWizard.source.format, visible: createWizard.source.show">
           <!-- ko template: {name: 'format-settings'} --> <!-- /ko -->
         </span>
@@ -451,7 +468,7 @@ ${ assist.assistPanel() }
             </label>
 
             <label class="checkbox" data-bind="visible: $root.createWizard.source.inputFormat() == 'file'">
-              <input type="checkbox" data-bind="checked: hasHeader"> ${_('Use first row has header')}
+              <input type="checkbox" data-bind="checked: hasHeader"> ${_('Use first row as header')}
             </label>
 
             <label class="checkbox" data-bind="visible: tableFormat() == 'text'">
@@ -1004,11 +1021,13 @@ ${ assist.assistPanel() }
       });
       self.inputFormats = ko.observableArray([
           {'value': 'file', 'name': 'File'},
-          {'value': 'table', 'name': 'Table'},
-          {'value': 'text', 'name': 'Paste Text'},
-          {'value': 'query', 'name': 'SQL Query'},
-          {'value': 'dbms', 'name': 'DBMS'},
           {'value': 'manual', 'name': 'Manually'},
+          % if ENABLE_NEW_INDEXER.get():
+          {'value': 'query', 'name': 'SQL Query'},
+          {'value': 'table', 'name': 'Table'},
+          % endif
+          ##{'value': 'dbms', 'name': 'DBMS'},
+          ##{'value': 'text', 'name': 'Paste Text'},
       ]);
       if (wizard.prefill.source_type) {
         self.inputFormats([
@@ -1213,9 +1232,9 @@ ${ assist.assistPanel() }
           {'value': 'parquet', 'name': 'Parquet'},
           {'value': 'json', 'name': 'Json'},
           {'value': 'kudu', 'name': 'Kudu'},
-          {'value': 'orc', 'name': 'ORC'},
           {'value': 'avro', 'name': 'Avro'},
           {'value': 'rcfile', 'name': 'RCFile'},
+          {'value': 'orc', 'name': 'ORC'},
           {'value': 'sequencefile', 'name': 'SequenceFile'}
       ]);