Browse Source

HUE-3228 [dashboard] Unify the hue.ini properties

Romain Rigaux 8 years ago
parent
commit
77cdef58ff

+ 13 - 2
desktop/conf.dist/hue.ini

@@ -787,8 +787,19 @@
 
 
 [dashboard]
 [dashboard]
 
 
-  # Use latest Solr 5+ functionalities like Analytics Facets and Nested Documents (warning: still in beta).
-  ## support_latest_solr=false
+  ## Activate the Dashboard link in the menu.
+  # is_enabled=false
+
+  [[engines]]
+
+    #  [[[solr]]]
+    ##  Requires Solr 6+
+    #  analytics=false
+    #  nesting=false
+
+    #  [[[sql]]]
+    #  analytics=true
+    #  nesting=false
 
 
 
 
 ###########################################################################
 ###########################################################################

+ 13 - 2
desktop/conf/pseudo-distributed.ini.tmpl

@@ -789,8 +789,19 @@
 
 
 [dashboard]
 [dashboard]
 
 
-  # Use latest Solr 5+ functionalities like Analytics Facets and Nested Documents (warning: still in beta).
-  ## support_latest_solr=false
+  ## Activate the Dashboard link in the menu.
+  # is_enabled=false
+
+  [[engines]]
+
+    #  [[[solr]]]
+    ##  Requires Solr 6+
+    #  analytics=false
+    #  nesting=false
+
+    #  [[[sql]]]
+    #  analytics=true
+    #  nesting=false
 
 
 
 
 ###########################################################################
 ###########################################################################

+ 4 - 11
desktop/libs/dashboard/src/dashboard/conf.py

@@ -31,17 +31,10 @@ IS_ENABLED = Config(
   type=coerce_bool
   type=coerce_bool
 )
 )
 
 
-# [[properties]]
-#  [[[solr]]]
-#  analytics=false
-#  nesting=false
-#  [[sql]]]
-#  analytics=true
-#  nesting=false
  
  
 def get_properties():
 def get_properties():
-  if PROPERTIES.get():
-    engines = PROPERTIES.get()
+  if ENGINES.get():
+    engines = ENGINES.get()
     return dict([
     return dict([
       (i, {
       (i, {
         'analytics': engines[i].ANALYTICS.get(),
         'analytics': engines[i].ANALYTICS.get(),
@@ -88,8 +81,8 @@ def get_engines(user):
 
 
 
 
 
 
-PROPERTIES = UnspecifiedConfigSection(
-  "properties",
+ENGINES = UnspecifiedConfigSection(
+  "engines",
   help="One entry for each type of snippet.",
   help="One entry for each type of snippet.",
   each=ConfigSection(
   each=ConfigSection(
     help=_t("Name of the interface to use as query engine for the dashboard, e.g. solr, sql."),
     help=_t("Name of the interface to use as query engine for the dashboard, e.g. solr, sql."),

+ 1 - 2
desktop/libs/dashboard/src/dashboard/models.py

@@ -29,8 +29,6 @@ from django.utils.translation import ugettext as _
 from desktop.lib.i18n import smart_unicode, smart_str
 from desktop.lib.i18n import smart_unicode, smart_str
 from desktop.models import get_data_link
 from desktop.models import get_data_link
 
 
-from libsolr.api import SolrApi
-
 from dashboard.dashboard_api import get_engine
 from dashboard.dashboard_api import get_engine
 
 
 
 
@@ -443,6 +441,7 @@ def augment_solr_response(response, collection, query):
             cols.append(f['field'])
             cols.append(f['field'])
             last_xx_col = last_x_col
             last_xx_col = last_x_col
             last_x_col = i + 2
             last_x_col = i + 2
+          from libsolr.api import SolrApi
           cols.append(SolrApi._get_aggregate_function(f))
           cols.append(SolrApi._get_aggregate_function(f))
         rows = []
         rows = []
 
 

+ 15 - 2
desktop/libs/dashboard/src/dashboard/static/dashboard/js/search.ko.js

@@ -462,10 +462,12 @@ var Collection = function (vm, collection) {
     type: self.engine(),
     type: self.engine(),
   }));
   }));
   self.supportAnalytics = ko.pureComputed(function() {
   self.supportAnalytics = ko.pureComputed(function() {
-    return self.engine()['analytics'];
+    var engine = vm.initial.getEngine(self.engine());
+    return engine && engine.analytics();
   });
   });
   self.supportNesting = ko.pureComputed(function() {
   self.supportNesting = ko.pureComputed(function() {
-    return self.engine()['nesting'];
+    var engine = vm.initial.getEngine(self.engine());
+    return engine && engine.nesting();
   });
   });
   self.nested = ko.mapping.fromJS(collection.nested);
   self.nested = ko.mapping.fromJS(collection.nested);
   self.nestedNames = ko.computed(function() {
   self.nestedNames = ko.computed(function() {
@@ -1437,6 +1439,17 @@ var NewTemplate = function (vm, initial) {
       self.inited(true);
       self.inited(true);
     });
     });
   };
   };
+
+  self.getEngine = function(type) {
+     var _engine = null;
+     $.each(self.engines(), function (index, engine) {
+      if (engine.type() == type) {
+        _engine = engine;
+        return false;
+      }
+    });
+    return _engine;
+  };
 };
 };