Browse Source

HUE-8292 [metastore] Improve the relationships presentation in the table browser

- Add count to tab
- Switch side of source and target in foreign keys
- Add source table name for clarity
Johan Ahlen 7 years ago
parent
commit
2c4d3b8035

+ 3 - 3
apps/metastore/src/metastore/static/metastore/js/metastore.model.js

@@ -369,7 +369,7 @@ var MetastoreTable = (function () {
 
     self.optimizerStats = ko.observable();
     self.optimizerDetails = ko.observable();
-    self.topJoins = ko.observable();
+    self.topJoins = ko.observableArray();
     self.navigatorMeta = ko.observable();
     self.relationshipsDetails = ko.observable();
 
@@ -528,10 +528,10 @@ var MetastoreTable = (function () {
                       joinCol.columns.forEach(function (col) {
                         var colLower = col.toLowerCase();
                         if (colLower.indexOf(ownQidLower + '.') === 0) {
-                          cleanCols.source = colLower.substring(ownQidLower.length + 1);
+                          cleanCols.source = colLower.substring(ownDbNameLower.length + 1);
                           cleanCols.sourcePath = col.split('.');
                         } else if (colLower.indexOf(ownNameLower + '.') === 0) {
-                          cleanCols.source = colLower.substring(ownNameLower.length + 1);
+                          cleanCols.source = colLower;
                           cleanCols.sourcePath = col.split('.');
                           cleanCols.sourcePath.unshift(ownDbNameLower);
                         } else if (colLower.indexOf(ownDbNameLower + '.') === 0) {

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

@@ -867,9 +867,9 @@ ${ components.menubar(is_embeddable) }
         <table class="metastore-join-column-table">
           <tbody data-bind="foreach: joinCols">
           <tr>
-            <td><a href="javscript:void(0);" data-bind="text: source, sqlContextPopover: { sourceType: $parents[2].catalogEntry.getSourceType(), path: sourcePath, offset: { top: -3, left: 3 }}"></a></td>
-            <td class="metastore-join-arrow"><i class="fa fa-long-arrow-right"></i></td>
             <td><a href="javscript:void(0);" data-bind="text: target, sqlContextPopover: { sourceType: $parents[2].catalogEntry.getSourceType(), path: targetPath, offset: { top: -3, left: 3 }}"></a></td>
+            <td class="metastore-join-arrow"><i class="fa fa-arrows-h"></i></td>
+            <td><a href="javscript:void(0);" data-bind="text: source, sqlContextPopover: { sourceType: $parents[2].catalogEntry.getSourceType(), path: sourcePath, offset: { top: -3, left: 3 }}"></a></td>
           </tr>
           </tbody>
         </table>
@@ -891,7 +891,7 @@ ${ components.menubar(is_embeddable) }
   <ul class="nav nav-tabs nav-tabs-border margin-top-10">
     <li data-bind="css: { 'active': $root.currentTab() === 'overview' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('overview'); }">${_('Overview')}</a></li>
     <!-- ko if: $root.optimizerEnabled() -->
-      <li data-bind="css: { 'active': $root.currentTab() === 'relationships' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('relationships'); }">${_('Relationships')}</a></li>
+      <li data-bind="css: { 'active': $root.currentTab() === 'relationships' }"><a href="javascript: void(0);" data-bind="click: function() { $root.currentTab('relationships'); }">${_('Relationships')} (<span data-bind="text: topJoins().length"></span>)</a></li>
 ##       <!-- ko if: $root.database().table().optimizerDetails() -->
 ##       <li data-bind="css: { 'active': $root.currentTab() === 'permissions' }"><a href="javascript: void(0);" data-bind="click: function(){ $root.currentTab('permissions'); }">${_('Permissions')}</a></li>
 ##       <li data-bind="css: { 'active': $root.currentTab() === 'queries' }"><a href="javascript: void(0);" data-bind="click: function(){ $root.currentTab('queries'); }">${_('Queries')} (<span data-bind="text: $root.database().table().optimizerDetails().queryCount"></span>)</a></li>