Преглед изворни кода

[metastore] Added navigation settings to the assist and openItem functionality

Enrico Berti пре 10 година
родитељ
комит
0ed77be333

+ 6 - 1
apps/beeswax/src/beeswax/templates/execute.mako

@@ -50,7 +50,12 @@ ${ layout.menubar(section='query') }
               params: {
                 user: HIVE_AUTOCOMPLETE_USER,
                 sourceTypes: editorViewModel.sqlSourceTypes,
-                activeSourceType: snippetType
+                activeSourceType: snippetType,
+                navigationSettings: {
+                  openItem: false,
+                  showPreview: true,
+                  showStats: true
+                }
               }
             }"></div>
           </div>

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

@@ -188,11 +188,16 @@ ${ assist.assistPanel() }
           <div class="assist" data-bind="component: {
               name: 'assist-panel',
               params: {
-              sourceTypes: [{
+                sourceTypes: [{
                   name: 'hive',
                   type: 'hive'
                 }],
-                user: '${user.username}'
+                user: '${user.username}',
+                navigationSettings: {
+                  openItem: true,
+                  showPreview: true,
+                  showStats: false
+                }
               }
             }"></div>
         </div>
@@ -514,6 +519,10 @@ ${ assist.assistPanel() }
 
       ko.applyBindings(viewModel);
 
+      huePubSub.subscribe('assist.openItem', function(item){
+        console.log(item);
+      });
+
       window.hueDebug = {
         viewModel: viewModel,
         ko: ko

+ 10 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistEntry.js

@@ -35,9 +35,10 @@
    * @param {function} [filter] - ko.observable
    * @param {Object} i18n
    * @param {string} i18n.errorLoadingTablePreview
+   * @param {Object} navigationSettings
    * @constructor
    */
-  function AssistEntry (definition, parent, assistSource, filter, i18n) {
+  function AssistEntry (definition, parent, assistSource, filter, i18n, navigationSettings) {
     var self = this;
     self.i18n = i18n;
     self.definition = definition;
@@ -55,6 +56,8 @@
     self.entries = ko.observableArray([]);
     self.statsVisible = ko.observable(false);
 
+    self.navigationSettings = navigationSettings;
+
     self.open.subscribe(function(newValue) {
       if (newValue && self.entries().length == 0) {
         self.loadEntries();
@@ -234,7 +237,7 @@
    */
   AssistEntry.prototype.createEntry = function (definition) {
     var self = this;
-    return new AssistEntry(definition, self, self.assistSource, null, self.i18n)
+    return new AssistEntry(definition, self, self.assistSource, null, self.i18n, self.navigationSettings)
   };
 
   AssistEntry.prototype.getHierarchy = function () {
@@ -259,6 +262,11 @@
     self.open(!self.open());
   };
 
+  AssistEntry.prototype.openItem = function () {
+    var self = this;
+    huePubSub.publish('assist.openItem', self);
+  };
+
   AssistEntry.prototype.showPreview = function () {
     var self = this;
     var $assistQuickLook = $("#assistQuickLook");

+ 5 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistSource.js

@@ -28,11 +28,14 @@
    * @param {AssistHelper} options.assistHelper
    * @param {string} options.type
    * @param {string} options.name
+   * @param {Object} options.navigationSettings
    * @constructor
    */
   function AssistSource (options) {
+
     var self = this;
     self.i18n = options.i18n;
+    self.navigationSettings = options.navigationSettings;
     self.assistHelper = options.assistHelper;
     self.type = options.type;
     self.name = options.name;
@@ -89,8 +92,8 @@
           name: name,
           displayName: name,
           title: name,
-          isDatabase: true
-        }, null, self, self.filter, self.i18n);
+          isDatabase: true,
+        }, null, self, self.filter, self.i18n, self.navigationSettings);
         dbIndex[name] = database;
         if (name === lastSelectedDb) {
           self.selectedDatabase(database);

+ 9 - 3
desktop/core/src/desktop/templates/assist.mako

@@ -138,8 +138,8 @@ from desktop.views import _ko
 
   <script type="text/html" id="assist-entry-actions">
     <div class="assist-actions" data-bind="css: { 'table-actions' : definition.isTable, 'column-actions': definition.isColumn } " style="opacity: 0">
-      <a class="inactive-action" href="javascript:void(0)" data-bind="visible: definition.isTable, click: showPreview"><i class="fa fa-list" title="${_('Preview Sample data')}"></i></a>
-      <span data-bind="component: { name: 'table-stats', params: {
+      <a class="inactive-action" href="javascript:void(0)" data-bind="visible: definition.isTable && navigationSettings.showPreview, click: showPreview"><i class="fa fa-list" title="${_('Preview Sample data')}"></i></a>
+      <span data-bind="visible: navigationSettings.showStats, component: { name: 'table-stats', params: {
           statsVisible: statsVisible,
           sourceType: assistSource.type,
           snippet: assistSource.snippet,
@@ -149,6 +149,7 @@ from desktop.views import _ko
           fieldType: definition.type,
           assistHelper: assistSource.assistHelper
         } }"></span>
+      <a class="inactive-action" href="javascript:void(0)" data-bind="visible: navigationSettings.openItem, click: openItem"><i class="fa fa-long-arrow-right" title="${_('Open')}"></i></a>
     </div>
   </script>
 
@@ -285,6 +286,10 @@ from desktop.views import _ko
        * @param {string} params.sourceTypes[].type - Example: hive
        * @param {string} [params.activeSourceType] - Example: hive
        * @param {string} params.user
+       * @param {Object} params.navigationSettings - enable/disable the links
+       * @param {boolean} params.navigationSettings.openItem - Example: true
+       * @param {boolean} params.navigationSettings.showPreview - Example: true
+       * @param {boolean} params.navigationSettings.showStats - Example: true
        * @constructor
        */
       function AssistPanel (params) {
@@ -302,7 +307,8 @@ from desktop.views import _ko
             assistHelper: assistHelper,
             i18n: i18n,
             type: sourceType.type,
-            name: sourceType.name
+            name: sourceType.name,
+            navigationSettings: params.navigationSettings
           });
           self.sources.push(sourceIndex[sourceType.type]);
         });

+ 6 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -315,7 +315,12 @@ ${ require.config() }
         params: {
           user: $root.user,
           sourceTypes: $root.sqlSourceTypes,
-          activeSourceType: $root.activeSqlSourceType
+          activeSourceType: $root.activeSqlSourceType,
+          navigationSettings: {
+            openItem: false,
+            showPreview: true,
+            showStats: true
+          }
         }
       }"></div>
   </div>