Browse Source

HUE-6532 [assist] Add a document type filter to the assist documents panel

Johan Ahlen 8 years ago
parent
commit
e74c3b6

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


+ 48 - 5
desktop/core/src/desktop/static/desktop/js/document/hueFileEntry.js

@@ -89,12 +89,57 @@ var HueFileEntry = (function () {
     self.selectedDocsWithDependents = ko.observable([]);
     self.importedDocSummary = ko.observable();
     self.showTable = ko.observable();
+    self.entries = ko.observableArray([]);
 
 
     // Filter is only used in the assist panel at the moment
     self.isFilterVisible = ko.observable(false);
     self.filter = ko.observable('').extend({ rateLimit: 400 });
 
+    self.availableTypeFilters = ko.pureComputed(function () {
+      var filters = {};
+
+      self.entries().forEach(function (entry) {
+        var type = entry.definition().type;
+        if (!filters[type] && type !== 'directory') {
+
+          var label = DocumentTypeGlobals[type];
+          if (!label) {
+            if (type.indexOf('query-') === 0) {
+              label = type.substring(6);
+            } else {
+              label = type
+            }
+            if (label.length > 0) {
+              label = label.charAt(0).toUpperCase() + label.slice(1);
+            }
+          }
+          if (label) {
+            filters[type] = {
+              type: type,
+              label: label
+            }
+          }
+        }
+      });
+      var result = [];
+      Object.keys(filters).forEach(function (key) {
+        result.push(filters[key]);
+      });
+      result.sort(function (a, b) {
+        return a.label.localeCompare(b.label);
+      });
+
+      result.unshift({
+        type: 'all',
+        label: DocumentTypeGlobals['all']
+      });
+
+      return result;
+    });
+
+    self.typeFilter = ko.observable(self.availableTypeFilters()[0]); // First one is always 'all'
+
     self.isFilterVisible.subscribe(function (newValue) {
       if (!newValue && self.filter()) {
         self.filter('');
@@ -103,9 +148,10 @@ var HueFileEntry = (function () {
 
     self.filteredEntries = ko.pureComputed(function () {
       var filter = self.filter().toLowerCase();
-      if (filter) {
+      var typeFilter = self.typeFilter().type;
+      if (filter || typeFilter !== 'all') {
         return self.entries().filter(function (entry) {
-          return entry.definition().name.toLowerCase().indexOf(filter) !== -1;
+          return (typeFilter === 'all' || entry.definition().type === typeFilter) && (!filter || entry.definition().name.toLowerCase().indexOf(filter) !== -1);
         })
       }
       return self.entries();
@@ -203,9 +249,6 @@ var HueFileEntry = (function () {
       return self.selectedImportFile() !== '';
     });
 
-
-    self.entries = ko.observableArray([]);
-
     self.activeSort = options.activeSort;
 
     self.selectedEntries = ko.pureComputed(function () {

+ 1 - 1
desktop/core/src/desktop/static/desktop/less/hue-cross-version.less

@@ -404,7 +404,7 @@ ul.errorlist {
 
 .hue-drop-down-container {
   position: fixed;
-  z-index: 2;
+  z-index: 900;
 }
 
 .hue-drop-down-active span {

+ 4 - 1
desktop/core/src/desktop/templates/assist.mako

@@ -512,7 +512,10 @@ from notebook.conf import get_ordered_interpreters
 
   <script type="text/html" id="assist-document-header-actions">
     <div class="assist-db-header-actions">
-      <a class="inactive-action" href="javascript:void(0)" data-bind="toggle: isFilterVisible, css: { 'blue': isFilterVisible }" title="Filter"><i class="pointer fa fa-filter"></i></a>
+      <!-- ko if: !loading() && availableTypeFilters().length > 1 -->
+      <div data-bind="component: { name: 'hue-drop-down', params: { value: typeFilter, entries: availableTypeFilters, linkTitle: '${ _ko('Document type') }' } }" style="display: inline-block"></div>
+      <!-- /ko -->
+      <a class="inactive-action" href="javascript:void(0)" data-bind="visible: !loading(), toggle: isFilterVisible, css: { 'blue': isFilterVisible }" title="Filter"><i class="pointer fa fa-filter"></i></a>
       <a class="inactive-action" href="javascript:void(0)" data-bind="click: function () { huePubSub.publish('assist.file.refresh'); }"><i class="pointer fa fa-refresh" data-bind="css: { 'fa-spin blue' : loading }" title="${_('Manual refresh')}"></i></a>
     </div>
   </script>

+ 13 - 0
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -69,6 +69,19 @@ from metadata.conf import has_optimizer, OPTIMIZER
 
     var AUTOCOMPLETE_TIMEOUT = ${ conf.EDITOR_AUTOCOMPLETE_TIMEOUT.get() }
 
+    DocumentTypeGlobals = {
+      'all': '${_('All')}',
+      'link-pigscript': '${_('Pig')}',
+      'link-workflow': '${_('Workflow')}',
+      'notebook': '${_('Notebook')}',
+      'oozie-bundle2': '${_('Bundle')}',
+      'oozie-coordinator2': '${_('Coordinator')}',
+      'oozie-workflow2': '${_('Workflow')}',
+      'query-hive': '${_('Hive')}',
+      'query-impala': '${_('Impala')}',
+      'search-dashboard': '${_('Dashboard')}'
+    };
+
     // jHue plugins global configuration
     jHueFileChooserGlobals = {
       labels: {

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

@@ -27,7 +27,7 @@ from desktop.views import _ko
     <!-- ko if: !dropDownVisible() || !searchable -->
     <a class="inactive-action hue-drop-down-active" href="javascript:void(0)" data-bind="toggle: dropDownVisible, css: { 'blue': dropDownVisible }">
       <!-- ko if: icon --><i class="fa" data-bind="css: icon"></i><!-- /ko -->
-      <span data-bind="text: value, visible: ! dropDownVisible() || !searchable, attr: { 'title': linkTitle }" ></span>
+      <span data-bind="text: typeof value().label !== 'undefined' ? value().label : value(), visible: ! dropDownVisible() || !searchable, attr: { 'title': linkTitle }" ></span>
       <i class="fa fa-caret-down"></i>
     </a>
     <!-- /ko -->
@@ -39,12 +39,12 @@ from desktop.views import _ko
       <div class="dropdown-menu" data-bind="visible: filteredEntries().length > 0" style="overflow-y: scroll; width: 190px; margin-left: 10px; min-height: 34px; max-height: 200px;">
         <!-- ko if: foreachVisible -->
         <ul class="hue-inner-drop-down" data-bind="foreachVisible: { data: filteredEntries, minHeight: 34, container: '.dropdown-menu' }">
-          <li><a href="javascript:void(0)" data-bind="text: $data, click: function () { $parent.value($data); }"></a></li>
+          <li><a href="javascript:void(0)" data-bind="text: typeof $data.label !== 'undefined' ? $data.label : $data, click: function () { $parent.value($data); }"></a></li>
         </ul>
         <!-- /ko -->
         <!-- ko ifnot: foreachVisible -->
         <ul class="hue-inner-drop-down" data-bind="foreach: filteredEntries">
-          <li><a href="javascript:void(0)" data-bind="text: $data, click: function () { $parent.value($data); }"></a></li>
+          <li><a href="javascript:void(0)" data-bind="text: typeof $data.label !== 'undefined' ? $data.label : $data, click: function () { $parent.value($data); }"></a></li>
         </ul>
         <!-- /ko -->
       </div>

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


+ 1 - 1
desktop/libs/notebook/src/notebook/static/notebook/less/notebook.less

@@ -1294,7 +1294,7 @@
 
   .hue-drop-down-container {
    position: fixed;
-    z-index: 2;
+    z-index: 900;
     &.open {
       position: absolute;
     }

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