فهرست منبع

[metastore] Wired in queries tab

Enrico Berti 10 سال پیش
والد
کامیت
a5fcf3877c
1فایلهای تغییر یافته به همراه28 افزوده شده و 6 حذف شده
  1. 28 6
      apps/metastore/src/metastore/templates/describe_table.mako

+ 28 - 6
apps/metastore/src/metastore/templates/describe_table.mako

@@ -341,7 +341,21 @@ ${ assist.assistPanel() }
               </div>
 
               <div class="tab-pane" id="queries">
-                <pre id="queriesTable"></pre>
+                <i class="fa fa-spinner fa-spin" data-bind="visible: loadingQueries"></i>
+                <table data-bind="visible: !loadingQueries()" class="table table-condensed">
+                  <thead>
+                    <tr>
+                      <th width="30%">${ _('Name') }</th>
+                      <th>${ _('Query') }</th>
+                    </tr>
+                  </thead>
+                  <tbody data-bind="foreach: queries">
+                    <tr class="pointer" data-bind="click: function(){ location.href=doc.absoluteUrl; }">
+                      <td data-bind="text: doc.name"></td>
+                      <td><code data-bind="text: data.snippets[0].statement_raw"></code></td>
+                    </tr>
+                  </tbody>
+                </table>
               </div>
 
               <div class="tab-pane" id="analysis">
@@ -527,6 +541,9 @@ ${ assist.assistPanel() }
       self.isLeftPanelVisible.subscribe(function(newValue) {
         $.totalStorage('spark_left_panel_visible', newValue);
       });
+
+      self.loadingQueries = ko.observable(false);
+      self.queries = ko.observableArray([]);
     }
 
     $(document).ready(function () {
@@ -546,6 +563,16 @@ ${ assist.assistPanel() }
         console.log(item);
       });
 
+      $('a[data-toggle="tab"]').on('shown', function (e) {
+        if ($(e.target).attr("href") == "#queries") {
+          viewModel.loadingQueries(true);
+          $.getJSON("${ url('metastore:table_queries', database=database, table=table.name) }", function (data) {
+            viewModel.queries(data.queries);
+            viewModel.loadingQueries(false);
+          });
+        }
+      });
+
       window.hueDebug = {
         viewModel: viewModel,
         ko: ko
@@ -583,11 +610,6 @@ ${ assist.assistPanel() }
       });
     % endif
 
-    // Lazy loading?
-    $.getJSON("${ url('metastore:table_queries', database=database, table=table.name) }", function (data) {
-      $("#queriesTable").text(data.queries);
-    });
-
     $('a[data-toggle="tab"]').on('shown', function (e) {
       var sortables = [];
       $(".sampleTable").not('.initialized').each(function () {