Browse Source

HUE-8393 [report] Enable query chooser for the document widget

Enrico Berti 7 years ago
parent
commit
8b8c6bd88d

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -6936,7 +6936,7 @@
       }
       }
       var type = 'query-hive';
       var type = 'query-hive';
       if (options.type) {
       if (options.type) {
-        var tempType = options.type();
+        var tempType = ko.unwrap(options.type);
         if (tempType === 'function') {
         if (tempType === 'function') {
           tempType = tempType();
           tempType = tempType();
         }
         }

+ 1 - 0
desktop/core/src/desktop/templates/hue.mako

@@ -526,6 +526,7 @@ ${ commonshare() | n,unicode }
 <script src="${ static('desktop/ext/js/dropzone.min.js') }"></script>
 <script src="${ static('desktop/ext/js/dropzone.min.js') }"></script>
 
 
 <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
+<script src="${ static('desktop/js/autocomplete/sqlStatementsParser.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/globalSearchParser.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/globalSearchParser.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/solrQueryParser.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/solrQueryParser.js') }"></script>

File diff suppressed because it is too large
+ 0 - 0
desktop/libs/dashboard/src/dashboard/static/dashboard/css/search.css


+ 36 - 7
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -855,6 +855,35 @@ var Collection = function (vm, collection) {
       });
       });
     }
     }
 
 
+    facet.properties.parsedStatements = ko.observableArray([]);
+    facet.properties.selectedStatement = ko.observable();
+    facet.properties.selectedStatement.subscribe(function(val){
+      if (val) {
+        facet.properties.statement(val);
+        vm.search();
+      }
+    });
+
+    if (facet.properties.uuid) {
+      facet.properties.uuid.subscribe(function(val){
+        $.get('/desktop/api2/doc/', {
+          uuid: val,
+          data: true,
+          dependencies: true
+        }, function (data) {
+          if (data && data.data && data.data.snippets.length > 0) {
+            var snippet = data.data.snippets[0];
+            facet.properties.parsedStatements(sqlStatementsParser.parse(snippet.statement));
+            facet.template.chartSettings.chartType(snippet.chartType);
+            facet.template.chartSettings.chartX(snippet.chartX);
+            facet.template.chartSettings.chartYSingle(snippet.chartYSingle);
+            facet.template.chartSettings.chartYMulti(snippet.chartYMulti);
+            facet.properties.selectedStatement(facet.properties.parsedStatements()[0].statement);
+          }
+        });
+      });
+    }
+
     // For Solr 5+  only
     // For Solr 5+  only
     if (typeof facet.template != 'undefined') {
     if (typeof facet.template != 'undefined') {
       facet.template.filteredAttributeFields = ko.computed(function () { // Dup of template.filteredAttributeFields
       facet.template.filteredAttributeFields = ko.computed(function () { // Dup of template.filteredAttributeFields
@@ -929,13 +958,13 @@ var Collection = function (vm, collection) {
       });
       });
 
 
       /*facet.template.chartSettings.chartType.subscribe(function (newValue) {
       /*facet.template.chartSettings.chartType.subscribe(function (newValue) {
-        facet.widgetType(
-          newValue == ko.HUE_CHARTS.TYPES.PIECHART ? 'pie2-widget' :
-            (newValue == ko.HUE_CHARTS.TYPES.TIMELINECHART ? 'timeline-widget' :
-              (newValue == ko.HUE_CHARTS.TYPES.GRADIENTMAP ? 'gradient-map-widget' :
-                (newValue == ko.HUE_CHARTS.TYPES.COUNTER ? 'hit-widget' :
-                  (newValue == ko.HUE_CHARTS.TYPES.TEXTSELECT ? 'text-facet-widget' : 'bucket-widget'))))
-        );
+      if (facet.widgetType() === 'document-widget') {
+        var _fields = [];
+        $.each(facet.fields(), function (index, field) {
+          _fields.push(field.name());
+        });
+        facet.template.fieldsSelected(_fields);
+      }
       });*/
       });*/
 
 
       // TODO Reload QueryResult
       // TODO Reload QueryResult

+ 7 - 0
desktop/libs/dashboard/src/dashboard/static/dashboard/less/search.less

@@ -848,6 +848,13 @@
     max-height: 37px;
     max-height: 37px;
   }
   }
 
 
+  .query-chooser {
+    float: right;
+    .selectize-control {
+      min-width: 300px;
+    }
+  }
+
   @media screen and (max-width: 1000px) {
   @media screen and (max-width: 1000px) {
     .card-widget, .card-column {
     .card-widget, .card-column {
       float: left !important;
       float: left !important;

+ 14 - 2
desktop/libs/dashboard/src/dashboard/templates/common_search.mako

@@ -1803,14 +1803,26 @@ ${ dashboard.layout_skeleton(suffix='search') }
   ##  <i class="fa fa-spinner fa-spin"></i>
   ##  <i class="fa fa-spinner fa-spin"></i>
   ##</div>
   ##</div>
 
 
+
   <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
   <!-- ko if: $root.getFacetFromQuery(id()).has_data() -->
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
   <div class="row-fluid" data-bind="with: $root.getFacetFromQuery(id())">
 
 
     <!-- ko with: $root.collection.getFacetById($parent.id()) -->
     <!-- ko with: $root.collection.getFacetById($parent.id()) -->
     <div>
     <div>
+      <!-- ko if: properties.parsedStatements && properties.parsedStatements().length > 1 -->
+      <div class="selectize-wrapper query-chooser">
+        <select placeholder="${ _('Available statements') }" data-bind="selectize: properties.parsedStatements, optionsText: 'statement', optionsValue: 'statement', value: properties.selectedStatement"></select>
+      </div>
+      <!-- /ko -->
+      <div class="selectize-wrapper query-chooser">
+        <select placeholder="${ _('Search your queries...') }" data-bind="documentChooser: { value: properties.uuid, type: 'impala' }"></select>
+      </div>
+      <div class="clearfix"></div>
+    </div>
+    <div>
 
 
-      <input type="text" class="input-medium" data-bind="value: properties.engine"/>
-      <textarea data-bind="value: properties.statement"></textarea>
+##       <input type="text" class="input-medium" data-bind="value: properties.engine"/>
+##       <textarea data-bind="value: properties.statement"></textarea>
 
 
       ## Get sub widget by ID
       ## Get sub widget by ID
       ## <div data-bind="template: { name: function() { return widgetType(); }}" class="widget-main-section"></div>
       ## <div data-bind="template: { name: function() { return widgetType(); }}" class="widget-main-section"></div>

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