瀏覽代碼

HUE-5651 [responsive] Add skeleton for statement details in the right assist panel

Johan Ahlen 8 年之前
父節點
當前提交
38d997b0b6

+ 3 - 2
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -180,9 +180,10 @@ var AssistDbSource = (function () {
       activeEditorTables: ko.observableArray([])
     };
 
-    huePubSub.subscribe('editor.active.locations', function (locations) {
+    huePubSub.subscribe('editor.active.locations', function (activeLocations) {
       var activeTables = [];
-      locations.forEach(function (location) {
+      // TODO: Test multiple snippets
+      activeLocations.locations.forEach(function (location) {
         if (location.type === 'table') {
           activeTables.push(location.identifierChain.length == 2 ? { table: location.identifierChain[1].name, db: location.identifierChain[0].name} : { table: location.identifierChain[0].name });
         }

+ 3 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3239,7 +3239,9 @@
               }
             });
           }
-          huePubSub.publish('editor.active.locations', e.data.locations);
+
+          huePubSub.publish('editor.active.locations', { type: snippet.type(), locations: e.data.locations });
+
           e.data.locations.forEach(function (location) {
             if ((location.type === 'table' && location.identifierChain.length > 1) || (location.type === 'column' && location.identifierChain.length > 2)) {
               var clonedChain = location.identifierChain.concat();

+ 39 - 0
desktop/core/src/desktop/templates/assist.mako

@@ -2237,4 +2237,43 @@ from notebook.conf import ENABLE_QUERY_BUILDER
       });
     })();
   </script>
+
+  <script type="text/html" id="assistant-panel-template">
+    <pre data-bind="text: ko.mapping.toJSON(activeLocations)"></pre>
+  </script>
+
+  <script type="text/javascript" charset="utf-8">
+    (function () {
+      function AssistantPanel(params) {
+        var self = this;
+
+        self.activeType = ko.observable();
+
+        self.lastLocationsPerType = ko.observable({});
+
+        self.activeLocations = ko.pureComputed(function () {
+          return self.lastLocationsPerType()[self.activeType()];
+        });
+
+        huePubSub.subscribe('active.snippet.type', function (type) {
+          if (self.activeType() !== type) {
+            self.activeType(type);
+          }
+        });
+
+        huePubSub.publish('get.active.snippet.type');
+
+        huePubSub.subscribe('editor.active.locations', function (activeLocations) {
+          var locationsIndex = self.lastLocationsPerType();
+          locationsIndex[activeLocations.type] = activeLocations.locations;
+          self.lastLocationsPerType(locationsIndex);
+        });
+      }
+
+      ko.components.register('assistant-panel', {
+        viewModel: AssistantPanel,
+        template: { element: 'assistant-panel-template' }
+      });
+    })();
+  </script>
 </%def>

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

@@ -389,11 +389,11 @@ ${ hueIcons.symbols() }
 
         <div class="right-panel-tab-content tab-content">
           <!-- ko if: activeRightTab() === 'assistant' -->
-          <div>Assistant</div>
+          <div data-bind="component: { name: 'assistant-panel' }"></div>
           <!-- /ko -->
 
           <!-- ko if: activeRightTab() === 'functions' -->
-          <div style="" data-bind="component: { name: 'functions-panel' }"></div>
+          <div data-bind="component: { name: 'functions-panel' }"></div>
           <!-- /ko -->
 
           <!-- ko if: activeRightTab() === 'schedules' -->
@@ -754,7 +754,7 @@ ${ assist.assistPanel() }
         self.apiHelper = ApiHelper.getInstance();
         self.leftAssistVisible = ko.observable();
         self.rightAssistVisible = ko.observable();
-        self.activeRightTab = ko.observable('functions');
+        self.activeRightTab = ko.observable('assistant');
         self.apiHelper.withTotalStorage('assist', 'left_assist_panel_visible', self.leftAssistVisible, true);
         self.apiHelper.withTotalStorage('assist', 'right_assist_panel_visible', self.rightAssistVisible, true);
       }