瀏覽代碼

HUE-3187 [metastore] Fixed search section

Enrico Berti 9 年之前
父節點
當前提交
04c567c

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

@@ -34,7 +34,7 @@
             % if is_optimizer_enabled:
             <div class="pull-right">
               <a class="pointer" data-bind="click: function() { optimizerEnabled(! optimizerEnabled()); }">
-                <i class="fa" data-bind="css: {'fa-toggle-off': ! optimizerEnabled(), 'fa-toggle-on': optimizerEnabled() }" style="margin-top:15px"></i> Enrich
+                <i class="fa" data-bind="css: {'fa-toggle-off': ! optimizerEnabled(), 'fa-toggle-on': optimizerEnabled() }" style="margin-top:15px"></i> ${ _('Enhance') }
               </a>
             </div>
             % endif

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

@@ -295,7 +295,7 @@ ${ assist.assistPanel() }
 </a>
 
 <script type="text/html" id="metastore-databases">
-  <div class="actionbar-actions">
+  <div class="actionbar-actions" data-bind="dockable: { scrollable: '.right-panel', nicescroll: true, jumpCorrection: 5 }">
     <input class="input-xlarge search-query margin-left-10" type="text" placeholder="${ _('Search for a database...') }" data-bind="clearable: databaseQuery, value: databaseQuery, valueUpdate: 'afterkeydown'"/>
     % if has_write_access:
       <button class="btn toolbarBtn margin-left-20" title="${_('Drop the selected databases')}" data-bind="click: function () { $('#dropDatabase').modal('show'); }, disable: selectedDatabases().length === 0"><i class="fa fa-times"></i>  ${_('Drop')}</button>
@@ -405,7 +405,7 @@ ${ assist.assistPanel() }
     <div class="row-fluid">
       <div class="span12 tile">
         <h4>${ _('Tables') }</h4>
-        <div class="actionbar-actions" data-bind="visible: tables().length > 0">
+        <div class="actionbar-actions" data-bind="visible: tables().length > 0, dockable: { scrollable: '.right-panel', nicescroll: true, jumpCorrection: 5 }">
           <input class="input-xlarge search-query margin-left-10" type="text" placeholder="${ _('Search for a table...') }" data-bind="clearable: tableQuery, value: tableQuery, valueUpdate: 'afterkeydown'"/>
           <button class="btn toolbarBtn margin-left-20" title="${_('Browse the selected table')}" data-bind="click: function () { setTable(selectedTables()[0]); selectedTables([]); }, disable: selectedTables().length !== 1"><i class="fa fa-eye"></i> ${_('View')}</button>
           <button class="btn toolbarBtn" title="${_('Browse the selected table')}" data-bind="click: function () { location.href = '/notebook/browse/' + name + '/' + selectedTables()[0].name; }, disable: selectedTables().length !== 1">

+ 1 - 1
desktop/conf.dist/hue.ini

@@ -1396,7 +1396,7 @@
 ###########################################################################
 
 [metadata]
-  # For metadata tagging and enrichment features
+  # For metadata tagging and enhancement features
 
   [[optimizer]]
     # For SQL query and table analysis

+ 1 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1398,7 +1398,7 @@
 ###########################################################################
 
 [metadata]
-  # For metadata tagging and enrichment features
+  # For metadata tagging and enhancement features
 
   [[optimizer]]
     # For SQL query and table analysis

+ 6 - 0
desktop/core/src/desktop/static/desktop/css/hue3.css

@@ -2583,3 +2583,9 @@ body {
   pointer-events: none;
   height: 130px;
 }
+
+.dockable {
+  background-color: #FFF;
+  z-index: 10000;
+  padding-bottom: 2px;
+}

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

@@ -3515,6 +3515,8 @@
 
 
       $parent.parents(scrollable).off('scroll');
+      huePubSub.publish('scrollable.scroll.off', scrollable);
+
       $parent.parents(scrollable).on('scroll', render);
 
       if ($parent.parents('.hueach').length > 0) {
@@ -3566,6 +3568,7 @@
           cursorminheight: options.cursorminheight || 20,
           horizrailenabled: options.horizrailenabled || true
         });
+        $(element).addClass('nicescrollified');
       }
     }
   };
@@ -3580,4 +3583,59 @@
     }
   };
 
+  ko.bindingHandlers.dockable = {
+    init: function (element, valueAccessor, allBindings) {
+      var options = valueAccessor() || {};
+      var scrollable = options.scrollable ? options.scrollable : window;
+
+      $(element).addClass('dockable');
+
+      var initialTopPosition = -1;
+      var initialSize = {
+        w: $(element).width(),
+        h: $(element).outerHeight() + (options.jumpCorrection || 0)
+      };
+
+      var ghost = $('<div>').css({'display': 'none', 'height': initialSize.h}).insertBefore($(element));
+
+      function dock() {
+        if (initialTopPosition == -1) {
+          initialTopPosition = $(element).position().top;
+        }
+        if ($(scrollable).scrollTop() > initialTopPosition) {
+          $(element).css({
+            'position': 'fixed',
+            'top': '82px',
+            'width': initialSize.w + 'px'
+          });
+          ghost.show();
+        }
+        else {
+          $(element).removeAttr('style');
+          ghost.hide();
+        }
+      }
+
+      if (options.nicescroll) {
+        var checkForNicescrollInit = -1;
+        checkForNicescrollInit = window.setInterval(function () {
+          if ($(scrollable).hasClass('nicescrollified')) {
+            window.clearTimeout(checkForNicescrollInit);
+            $(scrollable).on('scroll', dock);
+          }
+        }, 200);
+      }
+      else {
+        $(scrollable).on('scroll', dock);
+      }
+
+      huePubSub.subscribe('scrollable.scroll.off', function (scrollElement) {
+        if (scrollElement === scrollable) {
+          $(scrollable).on('scroll', dock);
+        }
+      });
+
+    }
+  };
+
 }));