Sfoglia il codice sorgente

HUE-8316 [importer] Base for SQL editor option to fields in the importer

Johan Ahlen 7 anni fa
parent
commit
5fd6d56a8f

File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue-embedded.css


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue.css


File diff suppressed because it is too large
+ 0 - 0
desktop/core/src/desktop/static/desktop/css/hue3-extra.css


+ 4 - 0
desktop/core/src/desktop/static/desktop/less/components/hue-simple-ace.less

@@ -71,4 +71,8 @@
   border: 1px solid @cui-gray-300;
   border-radius: 4px;
   width: 100%;
+
+  .ace_emptyMessage {
+    margin-left:3px;
+  }
 }

+ 3 - 8
desktop/core/src/desktop/templates/ko_components/ko_simple_ace_editor.mako

@@ -812,12 +812,7 @@ from desktop.views import _ko
                 return sourceType;
               },
               database: function () {
-                if (params.autocomplete.support.collection.name()) {
-                  var path = params.autocomplete.support.collection.name().split('.');
-                  return path.length > 1 ? path[0] : 'default';
-                } else {
-                  return 'default';
-                }
+                return params.database && params.database() ? params.database() : 'default';
               },
               positionStatement: function () {
                 return {
@@ -825,8 +820,8 @@ from desktop.views import _ko
                 }
               }
             },
-            fixedPrefix: sourceType !== 'solr' ? function() { return 'SELECT * FROM ' + params.autocomplete.support.collection.name() + ' WHERE '; } : undefined,
-            fixedPostfix: sourceType !== 'solr' ? function() { return ' GROUP BY 1;' } : undefined, // By adding group by it will limit it to the filter suggestions
+            fixedPrefix: params.fixedPrefix,
+            fixedPostfix: params.fixedPostfix,
             support: params.autocomplete.support
           };
 

+ 6 - 0
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -103,6 +103,9 @@ from dashboard.conf import USE_GRIDSTER, USE_NEW_ADD_METHOD, HAS_REPORT_ENABLED,
               placeHolder: $root.collection.engine() === 'solr' ? '${ _ko('Example: field:value, or press CTRL + space') }' : '${ _ko('Example: col = value, or press CTRL + space') }',
               autocomplete: { type: $root.collection.engine() + 'Query', support: { collection: $root.collection } },
               mode: $root.collection.engine(),
+              fixedPrefix: $root.collection.engine() !== 'solr' ? function() { return 'SELECT * FROM ' +  $root.collection.name() + ' WHERE '; } : undefined,
+              fixedPostfix: $root.collection.engine() !== 'solr' ? function() { return ' GROUP BY 1;' } : undefined,
+              database: function () { return $root.collection.name().split('.')[0] },
               singleLine: true }
             }"></div>
 ##             <input data-bind="clearable: q, valueUpdate:'afterkeydown', typeahead: { target: q, nonBindableSource: queryTypeahead, multipleValues: true, multipleValuesSeparator: ':', extraKeywords: 'AND OR TO', completeSolrRanges: true }, css: {'input-small': $root.query.qs().length > 1, 'flat-left': $index() === 0, 'input-xlarge': $root.collection.supportAnalytics()}" maxlength="4096" type="text" class="search-query">
@@ -2136,6 +2139,9 @@ ${ dashboard.layout_skeleton(suffix='search') }
         placeHolder: $root.collection.engine() === 'solr' ? '${ _ko('Example: field:value, or press CTRL + space') }' : '${ _ko('Example: col = value, or press CTRL + space') }',
         autocomplete: { type: $root.collection.engine() + 'Query', support: { collection: $root.collection } },
         mode: $root.collection.engine(),
+        fixedPrefix: $root.collection.engine() !== 'solr' ? function() { return 'SELECT * FROM ' +  $root.collection.name() + ' WHERE '; } : undefined,
+        fixedPostfix: $root.collection.engine() !== 'solr' ? function() { return ' GROUP BY 1;' } : undefined,
+        database: function () { return $root.collection.name().split('.')[0] },
         singleLine: true }
       }"></div>
     </span>

+ 35 - 2
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -852,8 +852,30 @@ ${ assist.assistPanel() }
 
         <!-- ko if: ['table', 'index', 'hbase'].indexOf(outputFormat()) != -1 -->
           <div class="card step">
-            <h4 class="show-edit-on-hover">${_('Fields')} <!-- ko if: $root.createWizard.isGuessingFieldTypes --><i class="fa fa-spinner fa-spin"></i><!-- /ko --> <a class="inactive-action pointer" data-bind="visible: columns().length > 0" href="#fieldsBulkEditor" data-toggle="modal"><i class="fa fa-edit"></i></a></h4>
+            <h4>
+              <!-- ko if: useFieldEditor -->
+              <a class="inactive-action" href="javascript:void(0);" data-bind="toggle: useFieldEditor">${_('Fields')} /</a> ${_('Editor')}
+              <!-- /ko -->
+              <!-- ko ifnot: useFieldEditor -->
+              ${_('Fields')} <!-- ko if: $root.createWizard.isGuessingFieldTypes --><i class="fa fa-spinner fa-spin"></i><!-- /ko --> <a class="inactive-action pointer" data-bind="visible: columns().length > 0" href="#fieldsBulkEditor" data-toggle="modal"><i class="fa fa-edit"></i></a> <!-- ko if: fieldEditorEnabled --><a class="inactive-action" href="javascript:void(0);" data-bind="toggle: useFieldEditor">/ ${_('Editor')}</a><!-- /ko -->
+              <!-- /ko -->
+            </h4>
             <div class="card-body no-margin-top columns-form">
+              <!-- ko if: useFieldEditor -->
+              <div data-bind="component: { name: 'hue-simple-ace-editor-multi', params: {
+                  value: fieldEditorValue,
+                  placeHolder: '${ _ko('Example: SELECT a, b FROM c') }',
+                  autocomplete: { type: 'hiveQuery' },
+                  lines: 5,
+                  aceOptions: {
+                    minLines: 10,
+                    maxLines: 25
+                  },
+                  database: fieldEditorDatabase,
+                  mode: 'hive'
+                }}"></div>
+              <!-- /ko -->
+              <!-- ko ifnot: useFieldEditor -->
               <!-- ko if: $root.createWizard.source.inputFormat() === 'manual' -->
                 <form class="form-inline inline-table" data-bind="foreach: columns">
                   <!-- ko if: $parent.outputFormat() == 'table' -->
@@ -889,6 +911,7 @@ ${ assist.assistPanel() }
 
               <div class="clearfix"></div>
               <!-- /ko -->
+              <!-- /ko -->
             </div>
           </div>
         <!-- /ko -->
@@ -1941,7 +1964,7 @@ ${ assist.assistPanel() }
       self.KUDU_DEFAULT_PARTITION_COLUMN = {columns: [], range_partitions: [self.KUDU_DEFAULT_RANGE_PARTITION_COLUMN], name: 'HASH', int_val: 16};
 
       self.tableFormats = ko.pureComputed(function() {
-        if (wizard.source.inputFormat() == 'kafka') {
+        if (wizard.source.inputFormat() === 'kafka') {
           return [{'value': 'kudu', 'name': 'Kudu'}];
         } else {
           return [
@@ -1962,6 +1985,16 @@ ${ assist.assistPanel() }
       self.primaryKeys = ko.observableArray();
       self.primaryKeyObjects = ko.observableArray();
 
+      self.useFieldEditor = ko.observable(false);
+      // TODO: Figure out the database to use for field editor autocomplete
+      self.fieldEditorDatabase = ko.observable('default');
+      // TODO: Do something with the editor value
+      self.fieldEditorValue = ko.observable();
+      self.fieldEditorEnabled = ko.pureComputed(function () {
+        // TODO: Decide when the editor should be enabled
+        return false; // Disabled for now
+      });
+
       self.importData = ko.observable(true);
       self.useDefaultLocation = ko.observable(true);
       self.nonDefaultLocation = ko.observable('');

Some files were not shown because too many files changed in this diff