Browse Source

HUE-8330 [importer] Use the compute and namespace for the importer autocomplete

Johan Ahlen 7 years ago
parent
commit
459ff1662f

+ 1 - 1
apps/metastore/src/metastore/templates/metastore.mako

@@ -117,7 +117,7 @@ ${ components.menubar(is_embeddable) }
     <!-- ko if: editingTable -->
     <!-- ko if: editingTable -->
       <!-- ko with: table -->
       <!-- ko with: table -->
       <li class="editable-breadcrumb-input">
       <li class="editable-breadcrumb-input">
-        <input type="text" data-bind="hivechooser: { data: catalogEntry.name, database: $parent.catalogEntry. name, skipColumns: true, searchEverywhere: true, onChange: function(val) { $parent.setTableByName(val); $parent.editingTable(false); }, apiHelperUser: '${ user }', apiHelperType: $root.source().type }" autocomplete="off" />
+        <input type="text" data-bind="hivechooser: { data: catalogEntry.name, database: $parent.catalogEntry.name, namespace: $parent.catalogEntry.namespace, compute: $parent.catalogEntry.compute, skipColumns: true, searchEverywhere: true, onChange: function(val) { $parent.setTableByName(val); $parent.editingTable(false); }, apiHelperUser: '${ user }', apiHelperType: $root.source().type }" autocomplete="off" />
       </li>
       </li>
       <!-- /ko -->
       <!-- /ko -->
     <!-- /ko -->
     <!-- /ko -->

+ 84 - 103
desktop/core/src/desktop/static/desktop/js/jquery.hiveautocomplete.js

@@ -25,12 +25,9 @@
       home: "/",
       home: "/",
       skipColumns: false,
       skipColumns: false,
       skipTables: false,
       skipTables: false,
-      onEnter: function () {
-      },
-      onBlur: function () {
-      },
-      onPathChange: function () {
-      },
+      onEnter: function () {},
+      onBlur: function () {},
+      onPathChange: function () {},
       pathChangeLevel: '',
       pathChangeLevel: '',
       smartTooltip: '',
       smartTooltip: '',
       smartTooltipThreshold: 10, // needs 10 up/down or click actions and no tab to activate the smart tooltip
       smartTooltipThreshold: 10, // needs 10 up/down or click actions and no tab to activate the smart tooltip
@@ -50,15 +47,26 @@
     self._defaults = defaults;
     self._defaults = defaults;
     self._name = pluginName;
     self._name = pluginName;
 
 
-    self.activeContextNamespaceDeferred = $.Deferred();
-    if (self.options.activeNamespace) {
-      self.activeContextNamespaceDeferred.resolve(self.options.activeNamespace);
+    self.namespaceDeferred = $.Deferred();
+    self.computeDeferred = $.Deferred();
+
+    if (self.options.namespace) {
+      self.namespaceDeferred.resolve(self.options.namespace);
     } else {
     } else {
-      ContextCatalog.getNamespaces({ sourceType: 'hive' }).done(function (context) {
-        // TODO: Namespace selection in caller
-        self.activeContextNamespaceDeferred.resolve(context.namespaces[0]);
+      ContextCatalog.getNamespaces({ sourceType: options.apiHelperType }).done(function (context) {
+        self.namespaceDeferred.resolve(context.namespaces[0]);
       })
       })
     }
     }
+    self.namespaceDeferred.done(function (namespace) {
+      if (!self.options.compute || !namespace.computes.some(function (compute) {
+        if (compute.id === self.options.compute.id) {
+          self.computeDeferred.resolve(compute);
+          return true;
+        }
+      })) {
+        self.computeDeferred.resolve(namespace.computes[0]);
+      }
+    });
 
 
     this.init();
     this.init();
   }
   }
@@ -68,7 +76,7 @@
     var $el = $(self.element);
     var $el = $(self.element);
 
 
     // creates autocomplete popover
     // creates autocomplete popover
-    if ($("#jHueGenericAutocomplete").length == 0) {
+    if ($("#jHueGenericAutocomplete").length === 0) {
       $("<div>").attr("id", "jHueGenericAutocomplete").addClass("jHueAutocomplete popover")
       $("<div>").attr("id", "jHueGenericAutocomplete").addClass("jHueAutocomplete popover")
         .attr("style", "position:absolute;display:none;max-width:1000px;z-index:33000")
         .attr("style", "position:absolute;display:none;max-width:1000px;z-index:33000")
         .html('<div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><ul class="unstyled"></ul></div></div>')
         .html('<div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><ul class="unstyled"></ul></div></div>')
@@ -87,8 +95,7 @@
         _oSel.moveStart('character', elemLength);
         _oSel.moveStart('character', elemLength);
         _oSel.moveEnd('character', 0);
         _oSel.moveEnd('character', 0);
         _oSel.select();
         _oSel.select();
-      }
-      else if (element.selectionStart || element.selectionStart == '0') {
+      } else if (element.selectionStart || element.selectionStart === '0') {
         element.selectionStart = elemLength;
         element.selectionStart = elemLength;
         element.selectionEnd = elemLength;
         element.selectionEnd = elemLength;
         element.focus();
         element.focus();
@@ -105,7 +112,7 @@
     });
     });
 
 
     $el.keydown(function (e) {
     $el.keydown(function (e) {
-      if (e.keyCode == 9) {
+      if (e.keyCode === 9) {
         e.preventDefault();
         e.preventDefault();
         showAutocomplete(function () {
         showAutocomplete(function () {
           var path = $el.val();
           var path = $el.val();
@@ -118,9 +125,9 @@
     });
     });
 
 
     function smartTooltipMaker() {
     function smartTooltipMaker() {
-      if (self.options.smartTooltip != "" && typeof $.totalStorage != "undefined" && $.totalStorage("jHueGenericAutocompleteTooltip") != -1) {
+      if (self.options.smartTooltip !== "" && typeof $.totalStorage !== "undefined" && $.totalStorage("jHueGenericAutocompleteTooltip") !== -1) {
         var cnt = 0;
         var cnt = 0;
-        if ($.totalStorage("jHueGenericAutocompleteTooltip") != null) {
+        if ($.totalStorage("jHueGenericAutocompleteTooltip")) {
           cnt = $.totalStorage("jHueGenericAutocompleteTooltip") + 1;
           cnt = $.totalStorage("jHueGenericAutocompleteTooltip") + 1;
         }
         }
         $.totalStorage("jHueGenericAutocompleteTooltip", cnt);
         $.totalStorage("jHueGenericAutocompleteTooltip", cnt);
@@ -147,7 +154,7 @@
     var _filterTimeout = -1;
     var _filterTimeout = -1;
     $el.keyup(function (e) {
     $el.keyup(function (e) {
       window.clearTimeout(_filterTimeout);
       window.clearTimeout(_filterTimeout);
-      if ($.inArray(e.keyCode, [17, 38, 40, 13, 32, 191]) == -1) {
+      if ($.inArray(e.keyCode, [17, 38, 40, 13, 32, 191]) === -1) {
         _hiveAutocompleteSelectedIndex = -1;
         _hiveAutocompleteSelectedIndex = -1;
         _filterTimeout = window.setTimeout(function () {
         _filterTimeout = window.setTimeout(function () {
           var path = $el.val();
           var path = $el.val();
@@ -156,15 +163,14 @@
           }
           }
           $("#jHueGenericAutocomplete").show();
           $("#jHueGenericAutocomplete").show();
           $("#jHueGenericAutocomplete ul li").show();
           $("#jHueGenericAutocomplete ul li").show();
-          if (path != "") {
+          if (path !== "") {
             $("#jHueGenericAutocomplete ul li").each(function () {
             $("#jHueGenericAutocomplete ul li").each(function () {
               if (self.options.searchEverywhere) {
               if (self.options.searchEverywhere) {
-                if ($(this).text().trim().toLowerCase().indexOf(path.toLowerCase()) == -1) {
+                if ($(this).text().trim().toLowerCase().indexOf(path.toLowerCase()) === -1) {
                   $(this).hide();
                   $(this).hide();
                 }
                 }
-              }
-              else {
-                if ($(this).text().trim().indexOf(path) != 0) {
+              } else {
+                if ($(this).text().trim().indexOf(path) !== 0) {
                   $(this).hide();
                   $(this).hide();
                 }
                 }
               }
               }
@@ -175,38 +181,35 @@
           }
           }
         }, 500);
         }, 500);
       }
       }
-      if (e.keyCode == 38) {
+      if (e.keyCode === 38) {
         if (_hiveAutocompleteSelectedIndex <= 0) {
         if (_hiveAutocompleteSelectedIndex <= 0) {
           _hiveAutocompleteSelectedIndex = $("#jHueGenericAutocomplete ul li:visible").length - 1;
           _hiveAutocompleteSelectedIndex = $("#jHueGenericAutocomplete ul li:visible").length - 1;
-        }
-        else {
+        } else {
           _hiveAutocompleteSelectedIndex--;
           _hiveAutocompleteSelectedIndex--;
         }
         }
       }
       }
-      if (e.keyCode == 40) {
-        if (_hiveAutocompleteSelectedIndex == $("#jHueGenericAutocomplete ul li:visible").length - 1) {
+      if (e.keyCode === 40) {
+        if (_hiveAutocompleteSelectedIndex === $("#jHueGenericAutocomplete ul li:visible").length - 1) {
           _hiveAutocompleteSelectedIndex = 0;
           _hiveAutocompleteSelectedIndex = 0;
-        }
-        else {
+        } else {
           _hiveAutocompleteSelectedIndex++;
           _hiveAutocompleteSelectedIndex++;
         }
         }
       }
       }
-      if (e.keyCode == 38 || e.keyCode == 40) {
+      if (e.keyCode === 38 || e.keyCode === 40) {
         smartTooltipMaker();
         smartTooltipMaker();
         $("#jHueGenericAutocomplete ul li").removeClass("active");
         $("#jHueGenericAutocomplete ul li").removeClass("active");
         $("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).addClass("active");
         $("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).addClass("active");
         $("#jHueGenericAutocomplete .popover-content").scrollTop($("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).prevAll().length * $("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).outerHeight());
         $("#jHueGenericAutocomplete .popover-content").scrollTop($("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).prevAll().length * $("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).outerHeight());
       }
       }
-      if ((e.keyCode == 32 && e.ctrlKey) || e.keyCode == 191) {
+      if ((e.keyCode === 32 && e.ctrlKey) || e.keyCode === 191) {
         smartTooltipMaker();
         smartTooltipMaker();
         showAutocomplete();
         showAutocomplete();
       }
       }
-      if (e.keyCode == 13) {
+      if (e.keyCode === 13) {
         _pauseBlur = true;
         _pauseBlur = true;
         if (_hiveAutocompleteSelectedIndex > -1) {
         if (_hiveAutocompleteSelectedIndex > -1) {
           $("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).click();
           $("#jHueGenericAutocomplete ul li:visible").eq(_hiveAutocompleteSelectedIndex).click();
-        }
-        else {
+        } else {
           self.options.onEnter($(this));
           self.options.onEnter($(this));
         }
         }
         $("#jHueGenericAutocomplete").hide();
         $("#jHueGenericAutocomplete").hide();
@@ -231,19 +234,18 @@
     });
     });
 
 
     var BASE_PATH = "/beeswax/api/autocomplete/";
     var BASE_PATH = "/beeswax/api/autocomplete/";
-    if (self.options.serverType == "IMPALA") {
+    if (self.options.serverType === "IMPALA") {
       BASE_PATH = "/impala/api/autocomplete/";
       BASE_PATH = "/impala/api/autocomplete/";
     }
     }
-    if (self.options.serverType == "SOLR") {
+    if (self.options.serverType === "SOLR") {
       BASE_PATH = "/indexer/api/autocomplete/";
       BASE_PATH = "/indexer/api/autocomplete/";
     }
     }
     var _currentFiles = [];
     var _currentFiles = [];
 
 
     self.getDatabases = function (callback) {
     self.getDatabases = function (callback) {
       var self = this;
       var self = this;
-      self.activeContextNamespaceDeferred.done(function (namespace) {
-        // TODO: compute selection?
-        DataCatalog.getChildren({ sourceType: self.options.apiHelperType, namespace: namespace, compute: namespace.computes[0], path: [] }).done(function (dbEntries) {
+      $.when(self.namespaceDeferred, self.computeDeferred).done(function (namespace, compute) {
+        DataCatalog.getChildren({ sourceType: self.options.apiHelperType, namespace: namespace, compute: compute, path: [] }).done(function (dbEntries) {
           callback($.map(dbEntries, function (entry) { return entry.name }));
           callback($.map(dbEntries, function (entry) { return entry.name }));
         });
         });
       })
       })
@@ -251,9 +253,8 @@
 
 
     self.getTables = function (database, callback) {
     self.getTables = function (database, callback) {
       var self = this;
       var self = this;
-      self.activeContextNamespaceDeferred.done(function (namespace) {
-        // TODO: compute selection?
-        DataCatalog.getEntry({ sourceType: self.options.apiHelperType, namespace: namespace, compute: namespace.computes[0], path: [ database ] }).done(function (entry) {
+      $.when(self.namespaceDeferred, self.computeDeferred).done(function (namespace, compute) {
+        DataCatalog.getEntry({ sourceType: self.options.apiHelperType, namespace: namespace, compute: compute, path: [ database ] }).done(function (entry) {
           entry.getSourceMeta().done(callback)
           entry.getSourceMeta().done(callback)
         });
         });
       });
       });
@@ -261,16 +262,15 @@
 
 
     self.getColumns = function (database, table, callback) {
     self.getColumns = function (database, table, callback) {
       var self = this;
       var self = this;
-      self.activeContextNamespaceDeferred.done(function (namespace) {
-        // TODO: compute selection?
-        DataCatalog.getEntry({sourceType: self.options.apiHelperType, namespace: namespace, compute: namespace.computes[0], path: [ database, table ]}).done(function (entry) {
+      $.when(self.namespaceDeferred, self.computeDeferred).done(function (namespace, compute) {
+        DataCatalog.getEntry({ sourceType: self.options.apiHelperType, namespace: namespace, compute: compute, path: [ database, table ] }).done(function (entry) {
           entry.getSourceMeta().done(callback)
           entry.getSourceMeta().done(callback)
         });
         });
       });
       });
     };
     };
 
 
     function autocompleteLogic(autocompleteUrl, data) {
     function autocompleteLogic(autocompleteUrl, data) {
-      if (data.error == null) {
+      if (!data.error) {
         _currentFiles = [];
         _currentFiles = [];
 
 
         var _ico = "";
         var _ico = "";
@@ -278,32 +278,27 @@
         var _isSkipColumns = false;
         var _isSkipColumns = false;
         var _isSkipTables = false;
         var _isSkipTables = false;
 
 
-        if (self.options.serverType == "SOLR") {
+        if (self.options.serverType === "SOLR") {
           _iterable = data.collections;
           _iterable = data.collections;
           _ico = "fa-search";
           _ico = "fa-search";
-        }
-        else {
-          if (data.databases != null) { // it's a db
+        } else {
+          if (data.databases) { // it's a db
             _iterable = data.databases;
             _iterable = data.databases;
             _ico = "fa-database";
             _ico = "fa-database";
-          }
-          else if (data.tables_meta != null) { // it's a table
+          } else if (data.tables_meta) { // it's a table
             if (!self.options.skipTables) {
             if (!self.options.skipTables) {
               _iterable = $.map(data.tables_meta, function (tablesMeta) {
               _iterable = $.map(data.tables_meta, function (tablesMeta) {
                 return tablesMeta.name;
                 return tablesMeta.name;
               });
               });
               _ico = "fa-table";
               _ico = "fa-table";
-            }
-            else {
+            } else {
               _isSkipTables = true;
               _isSkipTables = true;
             }
             }
-          }
-          else {
+          } else {
             if (!self.options.skipColumns) {
             if (!self.options.skipColumns) {
               _iterable = data.columns;
               _iterable = data.columns;
               _ico = "fa-columns";
               _ico = "fa-columns";
-            }
-            else {
+            } else {
               _isSkipColumns = true;
               _isSkipColumns = true;
             }
             }
           }
           }
@@ -311,10 +306,10 @@
 
 
         var firstSolrCollection = false;
         var firstSolrCollection = false;
         var firstSolrConfig = false;
         var firstSolrConfig = false;
-
         if (!_isSkipColumns && !_isSkipTables) {
         if (!_isSkipColumns && !_isSkipTables) {
+
           $(_iterable).each(function (cnt, item) {
           $(_iterable).each(function (cnt, item) {
-            if (self.options.serverType == "SOLR") {
+            if (self.options.serverType === "SOLR") {
               if (item.isCollection && !firstSolrCollection) {
               if (item.isCollection && !firstSolrCollection) {
                 _currentFiles.push('<li class="hiveAutocompleteItem" data-value="collections.*" title="collections.*"><i class="fa fa-search-plus"></i> collections.*</li>');
                 _currentFiles.push('<li class="hiveAutocompleteItem" data-value="collections.*" title="collections.*"><i class="fa fa-search-plus"></i> collections.*</li>');
                 _currentFiles.push('<li class="hiveAutocompleteItem" data-value="admin.collections" title="admin.collections"><i class="fa fa-database"></i> admin.collections</li>');
                 _currentFiles.push('<li class="hiveAutocompleteItem" data-value="admin.collections" title="admin.collections"><i class="fa fa-database"></i> admin.collections</li>');
@@ -329,8 +324,7 @@
                 }
                 }
               }
               }
               _currentFiles.push('<li class="hiveAutocompleteItem" data-value="' + item.name + '" title="' + item.name + '"><i class="fa ' + _ico + '"></i> ' + item.name + '</li>');
               _currentFiles.push('<li class="hiveAutocompleteItem" data-value="' + item.name + '" title="' + item.name + '"><i class="fa ' + _ico + '"></i> ' + item.name + '</li>');
-            }
-            else {
+            } else {
               _currentFiles.push('<li class="hiveAutocompleteItem" data-value="' + item + '" title="' + item + '"><i class="fa ' + _ico + '"></i> ' + item + '</li>');
               _currentFiles.push('<li class="hiveAutocompleteItem" data-value="' + item + '" title="' + item + '"><i class="fa ' + _ico + '"></i> ' + item + '</li>');
             }
             }
           });
           });
@@ -346,13 +340,11 @@
             var path = autocompleteUrl.substring(BASE_PATH.length);
             var path = autocompleteUrl.substring(BASE_PATH.length);
 
 
             if ($(this).html().indexOf("search") > -1 || $(this).html().indexOf("cog") > -1 || $(this).html().indexOf("database") > -1) {
             if ($(this).html().indexOf("search") > -1 || $(this).html().indexOf("cog") > -1 || $(this).html().indexOf("database") > -1) {
-              if ($(this).html().indexOf("search") > -1 && $(this).html().indexOf("search-plus") == -1) {
+              if ($(this).html().indexOf("search") > -1 && $(this).html().indexOf("search-plus") === -1) {
                 $el.val("collections." + item);
                 $el.val("collections." + item);
-              }
-              else if ($(this).html().indexOf("cog") > -1 && $(this).html().indexOf("cogs") == -1) {
+              } else if ($(this).html().indexOf("cog") > -1 && $(this).html().indexOf("cogs") === -1) {
                 $el.val("configs." + item);
                 $el.val("configs." + item);
-              }
-              else {
+              } else {
                 $el.val(item);
                 $el.val(item);
               }
               }
               if (self.options.pathChangeLevel === '' || self.options.pathChangeLevel === 'database'){
               if (self.options.pathChangeLevel === '' || self.options.pathChangeLevel === 'database'){
@@ -367,8 +359,7 @@
               if (self.options.skipTables) {
               if (self.options.skipTables) {
                 $el.val(item);
                 $el.val(item);
                 $("#jHueGenericAutocomplete").hide();
                 $("#jHueGenericAutocomplete").hide();
-              }
-              else {
+              } else {
                 $el.val(item + ".");
                 $el.val(item + ".");
               }
               }
               if (self.options.pathChangeLevel === '' || self.options.pathChangeLevel === 'database') {
               if (self.options.pathChangeLevel === '' || self.options.pathChangeLevel === 'database') {
@@ -381,18 +372,15 @@
 
 
             if ($(this).html().indexOf("table") > -1) {
             if ($(this).html().indexOf("table") > -1) {
               if ($el.val().indexOf(".") > -1) {
               if ($el.val().indexOf(".") > -1) {
-                if ($el.val().match(/\./gi).length == 1) {
+                if ($el.val().match(/\./gi).length === 1) {
                   $el.val($el.val().substring(0, $el.val().lastIndexOf(".") + 1) + item);
                   $el.val($el.val().substring(0, $el.val().lastIndexOf(".") + 1) + item);
-                }
-                else {
+                } else {
                   $el.val($el.val().substring(0, $el.val().indexOf(".") + 1) + item);
                   $el.val($el.val().substring(0, $el.val().indexOf(".") + 1) + item);
                 }
                 }
-              }
-              else {
+              } else {
                 if (self.options.rewriteVal) {
                 if (self.options.rewriteVal) {
                   $el.val(item);
                   $el.val(item);
-                }
-                else {
+                } else {
                   $el.val($el.val() + item);
                   $el.val($el.val() + item);
                 }
                 }
               }
               }
@@ -404,8 +392,7 @@
               }
               }
               if (!self.options.skipColumns) {
               if (!self.options.skipColumns) {
                 showAutocomplete();
                 showAutocomplete();
-              }
-              else {
+              } else {
                 self.options.onEnter($el);
                 self.options.onEnter($el);
                 $("#jHueGenericAutocomplete").hide();
                 $("#jHueGenericAutocomplete").hide();
                 _hiveAutocompleteSelectedIndex = -1;
                 _hiveAutocompleteSelectedIndex = -1;
@@ -415,8 +402,7 @@
             if ($(this).html().indexOf("columns") > -1) {
             if ($(this).html().indexOf("columns") > -1) {
               if ($el.val().match(/\./gi).length > 1) {
               if ($el.val().match(/\./gi).length > 1) {
                 $el.val($el.val().substring(0, $el.val().lastIndexOf(".") + 1) + item);
                 $el.val($el.val().substring(0, $el.val().lastIndexOf(".") + 1) + item);
-              }
-              else {
+              } else {
                 $el.val($el.val() + "." + item);
                 $el.val($el.val() + "." + item);
               }
               }
               $("#jHueGenericAutocomplete").hide();
               $("#jHueGenericAutocomplete").hide();
@@ -429,7 +415,7 @@
           window.setTimeout(function () {
           window.setTimeout(function () {
             setHueBreadcrumbCaretAtEnd(self.element);
             setHueBreadcrumbCaretAtEnd(self.element);
           }, 100)
           }, 100)
-          if ("undefined" != typeof callback) {
+          if ("undefined" !== typeof callback) {
             callback();
             callback();
           }
           }
         }
         }
@@ -440,24 +426,24 @@
     function showAutocomplete(callback) {
     function showAutocomplete(callback) {
       $el.parent().find('.fa-spinner').show();
       $el.parent().find('.fa-spinner').show();
       var path = $el.val();
       var path = $el.val();
-      if (self.options.startingPath != '') {
+      if (self.options.startingPath !== '') {
         path = self.options.startingPath + path;
         path = self.options.startingPath + path;
       }
       }
       var autocompleteUrl = BASE_PATH;
       var autocompleteUrl = BASE_PATH;
 
 
-      if (path != "" && path.indexOf(".") == -1) {
+      if (path !== "" && path.indexOf(".") === -1) {
         path = "";
         path = "";
       }
       }
 
 
-      if (path != "" && path.lastIndexOf(".") != path.length - 1) {
+      if (path !== "" && path.lastIndexOf(".") !== path.length - 1) {
         path = path.substring(0, (self.options.startingPath + $el.val()).lastIndexOf("."));
         path = path.substring(0, (self.options.startingPath + $el.val()).lastIndexOf("."));
       }
       }
 
 
-      if (self.options.serverType != "SOLR") {
+      if (self.options.serverType !== "SOLR") {
         autocompleteUrl += path.replace(/\./g, "/");
         autocompleteUrl += path.replace(/\./g, "/");
       }
       }
 
 
-      if (self.options.serverType != "SOLR" && self.options.apiHelperUser !== '') {
+      if (self.options.serverType !== "SOLR" && self.options.apiHelperUser !== '') {
         var suffix = autocompleteUrl.substr(BASE_PATH.length);
         var suffix = autocompleteUrl.substr(BASE_PATH.length);
         if (suffix === '') {
         if (suffix === '') {
           self.getDatabases(function (data) {
           self.getDatabases(function (data) {
@@ -465,8 +451,7 @@
               databases: data
               databases: data
             });
             });
           });
           });
-        }
-        else {
+        } else {
           var details = suffix.split('/');
           var details = suffix.split('/');
           if (details.length > 1 && details[1] !== '') {
           if (details.length > 1 && details[1] !== '') {
             self.getColumns(details[0], details[1], function (data) {
             self.getColumns(details[0], details[1], function (data) {
@@ -476,15 +461,13 @@
                 })
                 })
               });
               });
             });
             });
-          }
-          else {
+          } else {
             self.getTables(details[0], function (data) {
             self.getTables(details[0], function (data) {
               autocompleteLogic(autocompleteUrl, data);
               autocompleteLogic(autocompleteUrl, data);
             });
             });
           }
           }
         }
         }
-      }
-      else {
+      } else {
         $.getJSON(autocompleteUrl, function (data) {
         $.getJSON(autocompleteUrl, function (data) {
           autocompleteLogic(autocompleteUrl, data);
           autocompleteLogic(autocompleteUrl, data);
         });
         });
@@ -503,18 +486,17 @@
     function guessHivePath(lastChars) {
     function guessHivePath(lastChars) {
       var possibleMatches = [];
       var possibleMatches = [];
       for (var i = 0; i < _currentFiles.length; i++) {
       for (var i = 0; i < _currentFiles.length; i++) {
-        if (($(_currentFiles[i]).text().trim().indexOf(lastChars) == 0 || lastChars == "") && $(_currentFiles[i]).text().trim() != "..") {
+        if (($(_currentFiles[i]).text().trim().indexOf(lastChars) === 0 || lastChars === "") && $(_currentFiles[i]).text().trim() !== "..") {
           possibleMatches.push(_currentFiles[i]);
           possibleMatches.push(_currentFiles[i]);
         }
         }
       }
       }
-      if (possibleMatches.length == 1) {
+      if (possibleMatches.length === 1) {
         $el.val($el.val() + $(possibleMatches[0]).text().trim().substr(lastChars.length));
         $el.val($el.val() + $(possibleMatches[0]).text().trim().substr(lastChars.length));
         if ($(possibleMatches[0]).html().indexOf("folder") > -1) {
         if ($(possibleMatches[0]).html().indexOf("folder") > -1) {
           $el.val($el.val() + "/");
           $el.val($el.val() + "/");
           showAutocomplete();
           showAutocomplete();
         }
         }
-      }
-      else if (possibleMatches.length > 1) {
+      } else if (possibleMatches.length > 1) {
         // finds the longest common prefix
         // finds the longest common prefix
         var possibleMatchesPlain = [];
         var possibleMatchesPlain = [];
         for (var z = 0; z < possibleMatches.length; z++) {
         for (var z = 0; z < possibleMatches.length; z++) {
@@ -523,7 +505,7 @@
         var arr = possibleMatchesPlain.slice(0).sort(),
         var arr = possibleMatchesPlain.slice(0).sort(),
           word1 = arr[0], word2 = arr[arr.length - 1],
           word1 = arr[0], word2 = arr[arr.length - 1],
           j = 0;
           j = 0;
-        while (word1.charAt(j) == word2.charAt(j))++j;
+        while (word1.charAt(j) === word2.charAt(j))++j;
         var match = word1.substring(0, j);
         var match = word1.substring(0, j);
         $el.val($el.val() + match.substr(lastChars.length));
         $el.val($el.val() + match.substr(lastChars.length));
       }
       }
@@ -539,15 +521,14 @@
     return this.each(function () {
     return this.each(function () {
       if (!$.data(this, 'plugin_' + pluginName)) {
       if (!$.data(this, 'plugin_' + pluginName)) {
         $.data(this, 'plugin_' + pluginName, new Plugin(this, options));
         $.data(this, 'plugin_' + pluginName, new Plugin(this, options));
-      }
-      else {
+      } else {
         $.data(this, 'plugin_' + pluginName).setOptions(options);
         $.data(this, 'plugin_' + pluginName).setOptions(options);
       }
       }
     });
     });
-  }
+  };
 
 
   $[pluginName] = function (options) {
   $[pluginName] = function (options) {
-    if (typeof console != "undefined") {
+    if (typeof console !== "undefined") {
       console.warn("$(elem).jHueGenericAutocomplete() is a preferred call method.");
       console.warn("$(elem).jHueGenericAutocomplete() is a preferred call method.");
     }
     }
     $(options.element).jHueGenericAutocomplete(options);
     $(options.element).jHueGenericAutocomplete(options);

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

@@ -3591,13 +3591,11 @@
       var complexConfiguration = false;
       var complexConfiguration = false;
       if (typeof options === 'function'){
       if (typeof options === 'function'){
         self.val(options());
         self.val(options());
-      }
-      else {
+      } else {
         if (options && options.data){
         if (options && options.data){
           self.val(options.data);
           self.val(options.data);
           complexConfiguration = true;
           complexConfiguration = true;
-        }
-        else {
+        } else {
           self.val(options);
           self.val(options);
         }
         }
       }
       }
@@ -3610,13 +3608,14 @@
           startingPath: options.database + '.',
           startingPath: options.database + '.',
           rewriteVal: true,
           rewriteVal: true,
           onPathChange: options.onChange,
           onPathChange: options.onChange,
+          namespace: ko.unwrap(options.namespace),
+          compute: ko.unwrap(options.compute),
           searchEverywhere : ko.unwrap(options.searchEverywhere) || false,
           searchEverywhere : ko.unwrap(options.searchEverywhere) || false,
           apiHelperUser: ko.unwrap(options.apiHelperUser) || '',
           apiHelperUser: ko.unwrap(options.apiHelperUser) || '',
           apiHelperType: ko.unwrap(options.apiHelperType) || '',
           apiHelperType: ko.unwrap(options.apiHelperType) || '',
           mainScrollable: ko.unwrap(options.mainScrollable) || $(window)
           mainScrollable: ko.unwrap(options.mainScrollable) || $(window)
         });
         });
-      }
-      else {
+      } else {
         options = allBindingsAccessor();
         options = allBindingsAccessor();
         function setPathFromAutocomplete(path) {
         function setPathFromAutocomplete(path) {
           self.val(path);
           self.val(path);
@@ -3638,6 +3637,8 @@
           home: "/",
           home: "/",
           skipColumns: ko.unwrap(options.skipColumns) || false,
           skipColumns: ko.unwrap(options.skipColumns) || false,
           skipTables: ko.unwrap(options.skipTables) || false,
           skipTables: ko.unwrap(options.skipTables) || false,
+          namespace: ko.unwrap(options.namespace),
+          compute: ko.unwrap(options.compute),
           pathChangeLevel: ko.unwrap(options.pathChangeLevel) || '',
           pathChangeLevel: ko.unwrap(options.pathChangeLevel) || '',
           apiHelperUser: ko.unwrap(options.apiHelperUser) || '',
           apiHelperUser: ko.unwrap(options.apiHelperUser) || '',
           apiHelperType: ko.unwrap(options.apiHelperType) || '',
           apiHelperType: ko.unwrap(options.apiHelperType) || '',

File diff suppressed because it is too large
+ 8 - 7
desktop/libs/indexer/src/indexer/templates/importer.mako


+ 1 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -489,8 +489,7 @@ var EditorViewModel = (function() {
         if (newNamespace) {
         if (newNamespace) {
           // When the namespace changes we set the corresponding compute and update the databases
           // When the namespace changes we set the corresponding compute and update the databases
           var found = self.availableComputes().some(function (compute) {
           var found = self.availableComputes().some(function (compute) {
-            // TODO: Remove name check once compute.namespace is a namespace ID
-            if (compute.namespace === newNamespace.name || compute.namespace === newNamespace.id) {
+            if (compute.namespace === newNamespace.id) {
               if (!self.compute() || self.compute().id !== compute.id) {
               if (!self.compute() || self.compute().id !== compute.id) {
                 self.compute(compute);
                 self.compute(compute);
                 self.updateDatabases();
                 self.updateDatabases();

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