Browse Source

HUE-4833 [editor] Drop the old table stats popover

This also makes sure the old editor works with the new popover
Johan Ahlen 9 years ago
parent
commit
0ec3494

+ 0 - 3
apps/beeswax/src/beeswax/templates/create_database.mako

@@ -24,14 +24,12 @@ from django.utils.translation import ugettext as _
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_("Create database"), 'metastore', user) | n,unicode }
 ${layout.metastore_menubar()}
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -241,7 +239,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     "ko.charts",
     "desktop/js/apiHelper",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",

+ 0 - 3
apps/beeswax/src/beeswax/templates/create_table_manually.mako

@@ -24,14 +24,12 @@ from django.utils.translation import ugettext as _
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_("Create table manually"), 'metastore', user) | n,unicode }
 ${ layout.metastore_menubar() }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -564,7 +562,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     "ko.charts",
     "desktop/js/apiHelper",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",

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

@@ -27,7 +27,6 @@
 <%namespace name="dashboard" file="common_dashboard.mako" />
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_('Query'), app_name, user) | n,unicode }
 ${ layout.menubar(section='query') }
@@ -809,8 +808,8 @@ ${ commonshare() | n,unicode }
 <script src="${ static('desktop/js/ko.hue-bindings.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/sqlAutocompleter.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/hdfsAutocompleter.js') }" type="text/javascript" charset="utf-8"></script>
-<script src="${ static('desktop/js/assist/tableStats.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/apiHelper.js') }" type="text/javascript" charset="utf-8"></script>
+<script src="${ static('desktop/js/sqlFunctions.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/assist/assistHdfsEntry.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/assist/assistDbEntry.js') }" type="text/javascript" charset="utf-8"></script>
 <script src="${ static('desktop/js/assist/assistDbSource.js') }" type="text/javascript" charset="utf-8"></script>
@@ -879,7 +878,6 @@ ${ commonshare() | n,unicode }
 <script src="${ static('desktop/ext/select2/select2.min.js') }" type="text/javascript" charset="utf-8"></script>
 
 ${ assist.assistPanel() }
-${ tableStats.tableStats() }
 ${ sqlContextPopover.sqlContextPopover() }
 
 <style type="text/css">

+ 0 - 3
apps/beeswax/src/beeswax/templates/import_wizard_choose_delimiter.mako

@@ -24,7 +24,6 @@ from django.utils.translation import ugettext as _
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 <%namespace name="util" file="util.mako" />
 
 ${ commonheader(_('Create table from file'), 'metastore', user) | n,unicode }
@@ -32,7 +31,6 @@ ${ layout.metastore_menubar() }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -193,7 +191,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     "ko.charts",
     "desktop/js/apiHelper",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",

+ 0 - 3
apps/beeswax/src/beeswax/templates/import_wizard_choose_file.mako

@@ -24,14 +24,12 @@ from django.utils.translation import ugettext as _
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_('Create table from file'), 'metastore', user) | n,unicode }
 ${ layout.metastore_menubar() }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -215,7 +213,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     "ko.charts",
     "desktop/js/apiHelper",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",

+ 0 - 3
apps/beeswax/src/beeswax/templates/import_wizard_define_columns.mako

@@ -24,7 +24,6 @@ from django.utils.translation import ugettext as _
 <%namespace name="layout" file="layout.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 <%namespace name="util" file="util.mako" />
 
 
@@ -33,7 +32,6 @@ ${ layout.metastore_menubar() }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 
 
@@ -228,7 +226,6 @@ ${ assist.assistPanel() }
     "ko.charts",
     "desktop/js/apiHelper",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",

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

@@ -23,14 +23,12 @@
 <%namespace name="components" file="components.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_('Table Partitions: %(tableName)s') % dict(tableName=table.name), app_name, user) | n,unicode }
 ${ components.menubar() }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -179,7 +177,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     "ko.charts",
     "desktop/js/apiHelper",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",

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

@@ -29,14 +29,12 @@ from desktop.views import commonheader, commonfooter, _ko
 <%namespace name="components" file="components.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_("Metastore"), app_name, user) | n,unicode }
 ${ components.menubar() }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -1195,7 +1193,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     'metastore/js/metastore.ko',
     'ko.charts',
     'assistPanel',
-    'tableStats',
     'knockout-mapping',
     'knockout-sortable',
     'ko.editable',

+ 0 - 246
desktop/core/src/desktop/static/desktop/js/assist/tableStats.js

@@ -1,246 +0,0 @@
-// Licensed to Cloudera, Inc. under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  Cloudera, Inc. licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define(['knockout'], factory);
-  } else {
-    root.TableStats = factory(ko);
-  }
-}(this, function (ko) {
-
-  /**
-   *
-   * @param {Object} options
-   * @param {Object} options.i18n
-   * @param {string} options.i18n.errorLoadingStats
-   * @param {string} options.i18n.errorLoadingTerms
-   * @param {string} options.i18n.errorRefreshingStats
-   * @param {ApiHelper} options.apiHelper
-   * @param {string} options.sourceType
-   * @param {string} options.databaseName
-   * @param {string} options.tableName
-   * @param {string} options.columnName
-   * @param {string} options.type
-   * @constructor
-   */
-  function TableStats (options) {
-    var self = this;
-    self.i18n = options.i18n;
-    self.sourceType = options.sourceType;
-    self.database = options.databaseName;
-    self.table = options.tableName;
-    self.column = options.columnName || null;
-    self.apiHelper = options.apiHelper;
-    self.type = options.type;
-    self.showViewMore = options.showViewMore;
-    self.isComplexType = /^(map|array|struct)/i.test(options.type);
-    self.isView = /view/i.test(options.type);
-
-    self.loadingStats = ko.observable(false);
-    self.statsHasError = ko.observable(false);
-    self.refreshing = ko.observable(false);
-    self.loadingTerms = ko.observable(false);
-    self.inaccurate = ko.observable(false);
-    self.statRows = ko.observableArray();
-    self.terms = ko.observableArray();
-    self.termsTabActive = ko.observable(false);
-    self.prefixFilter = ko.observable().extend({'throttle': 500});
-
-    self.activeTab = ko.observable('sample');
-    self.loadingSamples = ko.observable(false);
-    self.samples = ko.observable(null);
-
-    self.showAnalysis = ko.observable(false);
-
-    if (self.column === null) {
-      self.apiHelper.fetchTableDetails({
-        tableName: ko.isObservable(self.table) ? self.table() : self.table,
-        databaseName: ko.isObservable(self.database) ? self.database() : self.database,
-        sourceType: self.sourceType,
-        successCallback: function (data) {
-          self.showAnalysis(data.partition_keys.length === 0);
-        },
-        silenceErrors: true,
-        errorCallback: function () {
-          self.showAnalysis(true);
-        }
-      });
-    } else {
-      self.showAnalysis(true);
-    }
-
-    self.activeTab.subscribe(function (newValue) {
-      if (newValue === 'analysis' && self.statRows().length === 0) {
-        self.fetchData();
-      }
-    });
-
-    self.prefixFilter.subscribe(function (newValue) {
-      self.fetchTerms();
-    });
-
-    self.termsTabActive.subscribe(function (newValue) {
-      if (self.terms().length == 0 && newValue) {
-        self.fetchTerms();
-      }
-    });
-
-    self.fetchSamples();
-  }
-
-  TableStats.prototype.fetchData = function () {
-    var self = this;
-    self.loadingStats(true);
-    self.statsHasError(false);
-
-    var successCallback = function (data) {
-      if (data && data.status == 0) {
-        self.statRows(data.stats);
-        var inaccurate = true;
-        for(var i = 0; i < data.stats.length; i++) {
-          if (data.stats[i].data_type == "COLUMN_STATS_ACCURATE" && data.stats[i].comment == "true") {
-            inaccurate = false;
-            break;
-          }
-        }
-        self.inaccurate(inaccurate);
-      } else if (data && data.message) {
-        $(document).trigger("error", data.message);
-        self.statsHasError(true);
-      } else {
-        $(document).trigger("error", self.i18n.errorLoadingStats);
-        self.statsHasError(true);
-      }
-      self.loadingStats(false);
-    };
-
-    var errorCallback = function (e) {
-      self.statsHasError(true);
-      self.loadingStats(false);
-    };
-
-    self.apiHelper.fetchStats({
-      sourceType: self.sourceType === "hive" ? "beeswax" : self.sourceType,
-      databaseName: ko.isObservable(self.database) ? self.database() : self.database,
-      tableName: ko.isObservable(self.table) ? self.table() : self.table,
-      columnName: ko.isObservable(self.column) ? self.column() : self.column,
-      successCallback: successCallback,
-      errorCallback: errorCallback
-    });
-  };
-
-  TableStats.prototype.refresh = function () {
-    var self = this;
-    if (self.refreshing()) {
-      return;
-    }
-    self.refreshing(true);
-
-    if (self.activeTab() === "sample") {
-      self.samples(null);
-      self.fetchSamples();
-    } else {
-      var shouldFetchTerms = self.termsTabActive() || self.terms().length > 0;
-      self.apiHelper.refreshTableStats({
-        sourceType: self.sourceType === "hive" ? "beeswax" : self.sourceType,
-        databaseName: ko.isObservable(self.database) ? self.database() : self.database,
-        tableName: ko.isObservable(self.table) ? self.table() : self.table,
-        columnName: ko.isObservable(self.column) ? self.column() : self.column,
-        successCallback: function() {
-          self.refreshing(false);
-          self.fetchData();
-          if (shouldFetchTerms) {
-            self.fetchTerms();
-          }
-        },
-        errorCallback: function(message) {
-          self.refreshing(false);
-          $(document).trigger("error", message || self.i18n.errorRefreshingStats);
-        }
-      });
-    }
-  };
-
-  TableStats.prototype.fetchTerms = function () {
-    var self = this;
-    if ((ko.isObservable(self.column) && self.column() == null) || self.column == null || (self.isComplexType && self.sourceType == "impala")) {
-      return;
-    }
-
-    self.loadingTerms(true);
-    self.apiHelper.fetchTerms({
-      sourceType: self.sourceType === "hive" ? "beeswax" : self.sourceType,
-      databaseName: ko.isObservable(self.database) ? self.database() : self.database,
-      tableName: ko.isObservable(self.table) ? self.table() : self.table,
-      columnName: ko.isObservable(self.column) ? self.column() : self.column,
-      prefixFilter: self.prefixFilter(),
-      successCallback: function (data) {
-        if (data && data.status == 0) {
-          self.terms($.map(data.terms, function (term) {
-            return {
-              name: term[0],
-              count: term[1],
-              percent: (parseFloat(term[1]) / parseFloat(data.terms[0][1])) * 100
-            }
-          }));
-        } else if (data && data.message) {
-          $(document).trigger("error", data.message);
-        } else {
-          $(document).trigger("error", self.i18n.errorLoadingTerms);
-        }
-        self.loadingTerms(false);
-      },
-      errorCallback: function (e) {
-        self.loadingTerms(false);
-      }
-    });
-  };
-
-  TableStats.prototype.fetchSamples = function () {
-    var self = this;
-    if (self.loadingSamples()) {
-      return;
-    }
-
-    self.loadingSamples(true);
-    self.samples({});
-
-    self.apiHelper.fetchTableSample({
-      sourceType: self.sourceType,
-      databaseName: ko.isObservable(self.database) ? self.database() : self.database,
-      tableName: ko.isObservable(self.table) ? self.table() : self.table,
-      columnName: ko.isObservable(self.column) ? self.column() : self.column,
-      successCallback: function(data) {
-        if (! data.rows) {
-          data.rows = [];
-        } else if (! data.headers) {
-          data.headers = [];
-        }
-        self.samples(data);
-        self.loadingSamples(false);
-        self.refreshing(false);
-        huePubSub.publish('sample.rendered', data);
-      },
-      errorCallback: function() {
-        self.loadingSamples(false);
-        self.refreshing(false);
-      }
-    });
-  };
-
-  return TableStats;
-}));

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

@@ -907,8 +907,7 @@ from metadata.conf import has_navigator
           'desktop/js/assist/assistDbSource',
           'desktop/js/assist/assistHdfsEntry',
           'desktop/js/apiHelper',
-          'desktop/js/fileBrowser/hueFileEntry',
-          'tableStats'
+          'desktop/js/fileBrowser/hueFileEntry'
         ], factory);
       } else {
         factory(ko, AssistDbSource, AssistHdfsEntry, ApiHelper, HueFileEntry);

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

@@ -22,13 +22,11 @@
 <%namespace name="fileBrowser" file="/file_browser.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_('Welcome Home'), "home", user) | n,unicode }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 ${ fileBrowser.fileBrowser() }
@@ -228,12 +226,11 @@ ${ fileBrowser.fileBrowser() }
     'knockout',
     'desktop/js/home2.vm',
     'assistPanel',
-    'tableStats',
     'fileBrowser',
     'knockout-mapping',
     'knockout-sortable',
     'ko.hue-bindings'
-  ], function (ko, HomeViewModel, ShareViewModel) {
+  ], function (ko, HomeViewModel) {
 
     ko.options.deferUpdates = true;
 

+ 14 - 9
desktop/core/src/desktop/templates/sql_context_popover.mako

@@ -435,12 +435,17 @@ from metadata.conf import has_navigator
     </div>
   </script>
   <script type="text/javascript" charset="utf-8">
-    require([
-      'knockout',
-      'desktop/js/apiHelper',
-      'desktop/js/assist/tableStats',
-      'desktop/js/sqlFunctions'
-    ], function (ko, ApiHelper, TableStats, sqlFunctions) {
+    (function (factory) {
+      if(typeof require === "function") {
+        require([
+          'knockout',
+          'desktop/js/apiHelper',
+          'desktop/js/sqlFunctions'
+        ], factory);
+      } else {
+        factory(ko, ApiHelper, SqlFunctions);
+      }
+    }(function (ko, ApiHelper, sqlFunctions) {
 
       var preventHide = false;
 
@@ -921,8 +926,8 @@ from metadata.conf import has_navigator
           var query = self.searchInput().toLowerCase();
           return columns.filter(function (column) {
             return column.name.toLowerCase().indexOf(query) != -1
-              || column.type.toLowerCase().indexOf(query) != -1
-              || column.comment.toLowerCase().indexOf(query) != -1;
+                || column.type.toLowerCase().indexOf(query) != -1
+                || column.comment.toLowerCase().indexOf(query) != -1;
           })
         });
       }
@@ -931,6 +936,6 @@ from metadata.conf import has_navigator
         viewModel: SqlColumnsTable,
         template: { element: 'sql-columns-table-template' }
       });
-    });
+    }));
   </script>
 </%def>

+ 0 - 379
desktop/core/src/desktop/templates/table_stats.mako

@@ -1,379 +0,0 @@
-## Licensed to Cloudera, Inc. under one
-## or more contributor license agreements.  See the NOTICE file
-## distributed with this work for additional information
-## regarding copyright ownership.  Cloudera, Inc. licenses this file
-## to you under the Apache License, Version 2.0 (the
-## "License"); you may not use this file except in compliance
-## with the License.  You may obtain a copy of the License at
-##
-##     http://www.apache.org/licenses/LICENSE-2.0
-##
-## Unless required by applicable law or agreed to in writing, software
-## distributed under the License is distributed on an "AS IS" BASIS,
-## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-## See the License for the specific language governing permissions and
-## limitations under the License.
-
-<%!
-from desktop import conf
-from desktop.lib.i18n import smart_unicode
-from django.utils.translation import ugettext as _
-from desktop.views import _ko
-%>
-
-<%def name="tableStats()">
-
-  <style>
-    .more-link:focus,
-    .more-link:hover {
-      background-color: #FFF !important;
-      border-top: 1px solid transparent !important;
-      border-right: 1px solid transparent !important;
-      border-left: 1px solid transparent !important;
-    }
-
-    .samples-table th {
-      background-color: #FFF !important;
-      border: none !important;
-    }
-
-    .samples-table tr td {
-      white-space: nowrap;
-    }
-  </style>
-
-  <script type="text/html" id="table-stats">
-    <div class="content" data-bind="niceScroll">
-      <!-- ko if: statRows().length -->
-      <table class="table table-striped">
-        <tbody data-bind="foreach: statRows">
-          <tr><th data-bind="text: data_type, style:{'border-top-color': $index() == 0 ? '#ffffff' : '#e5e5e5'}" style="background-color: #FFF"></th><td data-bind="text: $root.formatAnalysisValue(data_type, comment), style:{'border-top-color': $index() == 0 ? '#ffffff' : '#e5e5e5'}" style="background-color: #FFF"></td></tr>
-        </tbody>
-      </table>
-      <!-- /ko -->
-    </div>
-  </script>
-
-  <script type="text/html" id="column-stats">
-    <div class="pull-right filter" data-bind="visible: termsTabActive" style="display:none;">
-      <input type="text" data-bind="textInput: prefixFilter" placeholder="${ _('Prefix filter...') }"/>
-    </div>
-    <div class="tab-content" style="border: none; margin-top: 10px">
-      <div class="tab-pane active" id="columnAnalysisStats" style="text-align: left">
-        <div class="alert" data-bind="visible: isComplexType" style="margin: 5px">${ _('Column stats are currently not supported for columns of type:') } <span data-bind="text: type"></span></div>
-        <div class="content" data-bind="ifnot: isComplexType">
-          <table class="table table-condensed">
-            <tbody data-bind="foreach: statRows">
-              <tr><th data-bind="text: Object.keys($data)[0], style:{'border-top-color': $index() == 0 ? '#ffffff' : '#e5e5e5'}" style="background-color: #FFF"></th><td data-bind="text: $data[Object.keys($data)[0]], style:{'border-top-color': $index() == 0 ? '#ffffff' : '#e5e5e5'}" style="background-color: #FFF"></td></tr>
-            </tbody>
-          </table>
-        </div>
-      </div>
-      <div class="tab-pane" id="columnAnalysisTerms" style="text-align: left">
-        <i style="margin: 5px;" data-bind="visible: loadingTerms" class='fa fa-spinner fa-spin'></i>
-        <div class="alert" data-bind="visible: ! loadingTerms() && terms().length == 0">${ _('There are no terms to be shown') }</div>
-        <div class="content">
-          <table class="table table-striped" data-bind="visible: ! loadingTerms()">
-            <tbody data-bind="foreach: terms">
-              <tr><td data-bind="text: name"></td><td style="width: 40px"><div class="progress"><div class="bar-label" data-bind="text: count"></div><div class="bar bar-info" style="margin-top: -20px;" data-bind="style: { 'width' : percent + '%' }"></div></div></td></tr>
-            </tbody>
-          </table>
-        </div>
-      </div>
-    </div>
-  </script>
-
-  <script type="text/html" id="stats-popover">
-    <div style="position: fixed; display: none; z-index: 5000;" class="popover show mega-popover right" data-bind="style: { 'top': popoverTop() + 'px', 'left': popoverLeft() + 'px' }, visible: analysisStats, with: analysisStats">
-      <div class="arrow" data-bind="style: { 'top': $parent.popoverArrowTop() + 'px'}"></div>
-      <h3 class="popover-title" style="text-align: left">
-        <a class="pull-right pointer close-popover" style="margin-left: 8px" data-bind="click: $parent.toggleStats"><i class="fa fa-times"></i></a>
-        <!-- ko if: activeTab() === 'analysis' && !isComplexType && !isView -->
-        <a class="pull-right pointer stats-refresh" style="margin-left: 8px" data-bind="click: refresh"><i class="fa fa-refresh" data-bind="css: { 'fa-spin' : refreshing }"></i></a>
-        <!-- /ko -->
-        <i data-bind="visible: loadingStats" class='fa fa-spinner fa-spin'></i>
-        <!-- ko if: column == null -->
-        <i class="pull-left fa fa-table muted" style="margin-top: 3px"></i>
-        <div class="pull-left stats-popover-name"><strong class="table-name" data-bind="text: table, attr: {title: table}"></strong></div>
-        <!-- /ko -->
-        <!-- ko ifnot: column == null -->
-        <i class="pull-left fa fa-column muted" style="margin-top: 3px"></i>
-        <div class="inline-block stats-popover-name"><strong class="table-name" data-bind="text: column, attr: {title: column}"></strong></div>
-        <!-- /ko -->
-        <div class="clearfix"></div>
-      </h3>
-      <div class="popover-content">
-        <ul class="nav nav-tabs">
-          <li data-bind="click: function () { activeTab('sample'); }, css: { 'active' : activeTab() === 'sample' }">
-            <a class="inactive-action" href="#sampleTab" data-toggle="tab">${_('Sample')}</a>
-          </li>
-          <li data-bind="click: function () { activeTab('analysis'); }, css: { 'active' : activeTab() === 'analysis' }, visible: showAnalysis">
-            <a class="inactive-action" href="#analysisTab" data-toggle="tab"><span class="pull-right stats-warning muted" data-bind="visible: inaccurate() && column == null && !isComplexType && !isView" rel="tooltip" data-placement="top" title="${ _('The column stats for this table are not accurate') }" style="margin-left: 8px"><i class="fa fa-exclamation-triangle"></i></span>${_('Analysis')} </a>
-          </li>
-          <!-- ko if: showViewMore && (sourceType === 'hive' || sourceType === 'impala') -->
-          <li class="pull-right">
-            <a class="more-link" target="_blank" data-bind="attr: { 'href': '/metastore/table/' + database + '/' + table }">
-              <span class="fa fa-external-link" ></span> ${ _('View more...') }
-            </a>
-          </li>
-          <!-- /ko -->
-        </ul>
-        <div class="tab-content" style="border: none; overflow: hidden">
-          <div class="tab-pane" id="sampleTab" data-bind="css: { 'active' : activeTab() === 'sample' }" style="overflow: hidden">
-            <!-- ko hueSpinner: { spin: loadingSamples, center: true, size: 'large' } --><!-- /ko -->
-            <!-- ko ifnot: loadingSamples -->
-            <div class="sample-scroll" style="text-align: left; padding: 3px; overflow: hidden">
-              <!-- ko with: samples -->
-              <!-- ko if: rows.length == 0 -->
-              <div class="alert">${ _('The selected table has no data.') }</div>
-              <!-- /ko -->
-              <!-- ko if: rows.length > 0 -->
-              <table id="samples-table" class="samples-table table table-striped table-condensed">
-                <thead>
-                <tr>
-                  <th style="width: 10px">&nbsp;</th>
-                  <!-- ko foreach: headers -->
-                  <th data-bind="text: $data"></th>
-                  <!-- /ko -->
-                </tr>
-                </thead>
-                <tbody>
-                </tbody>
-              </table>
-              <!-- /ko -->
-              <!-- /ko -->
-            </div>
-            <!-- /ko -->
-          </div>
-          <div class="tab-pane" id="analysisTab" data-bind="css: { 'active' : activeTab() === 'analysis' }">
-            <!-- ko hueSpinner: { spin: loadingStats, center: true, size: 'large' } --><!-- /ko -->
-            <!-- ko ifnot: loadingStats -->
-            <div class="alert" style="text-align: left; display:none" data-bind="visible: statsHasError">${ _('There is no analysis available') }</div>
-            <!-- ko if: isComplexType && sourceType == 'impala' -->
-            <div class="alert" style="text-align: left">${ _('Column analysis is currently not supported for columns of type:') } <span data-bind="text: type"></span></div>
-            <!-- /ko -->
-            <!-- ko template: {if: column == null && ! statsHasError() && ! (isComplexType && sourceType == 'impala'), name: 'table-stats' } --><!-- /ko -->
-            <!-- ko template: {if: column != null && ! statsHasError() && ! (isComplexType && sourceType == 'impala'), name: 'column-stats' } --><!-- /ko -->
-            <!-- /ko -->
-          </div>
-        </div>
-      </div>
-    </div>
-  </script>
-
-  <script type="text/html" id="table-stats-link">
-    <a class="inactive-action" href="javascript:void(0)" data-bind="visible: enabled, click: toggleStats, css: { 'blue': analysisStats() || alwaysActive }, "><i class='fa fa-bar-chart' title="${_('View statistics') }"></i></a>
-  </script>
-
-  <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        define("tableStats", ['knockout', 'desktop/js/assist/tableStats'], factory);
-      } else {
-        factory(ko, TableStats);
-      }
-    }(function (ko, TableStats) {
-
-
-      function TableStatsViewModel(params, element) {
-        var self = this;
-        self.params = params;
-        var $targetElement = $(element);
-        var $statsContainer = $('#statsContainer');
-        if ($statsContainer.length === 0) {
-          $statsContainer = $('<div>').attr('id', 'statsContainer').appendTo($('body'));
-        }
-
-        self.i18n = {
-          errorLoadingStats: "${ _('There was a problem loading the stats.') }",
-          errorRefreshingStats: "${ _('There was a problem refreshing the stats.') }",
-          errorLoadingTerms: "${ _('There was a problem loading the terms.') }"
-        };
-
-        self.enabled = params.tableName || params.columnName;
-        self.alwaysActive = params.alwaysActive || false;
-        self.analysisStats = ko.observable(null);
-        self.formatAnalysisValue = function (type, val) {
-          if (type === 'last_modified_time' || type === 'transient_lastDdlTime') {
-            return localeFormat(val * 1000);
-          }
-          if (type.toLowerCase().indexOf('size') > -1) {
-            return filesize(val);
-          }
-          return val;
-        }
-
-        if (ko.isObservable(self.params.statsVisible)) {
-          self.analysisStats.subscribe(function (newValue) {
-            self.params.statsVisible(newValue !== null);
-          })
-        }
-
-        self.popoverTop = ko.observable(0);
-        self.popoverArrowTop = ko.observable(0);
-        self.popoverLeft = ko.observable(0);
-
-        var lastOffset = { top: -1, left: -1 };
-        self.refreshPopoverPosition = function () {
-          var $popover = $statsContainer.find(".popover");
-          if ($targetElement.is(":visible")) {
-            var newTop = $targetElement.offset().top - $(window).scrollTop();
-            if (lastOffset.left != $targetElement.offset().left || lastOffset.top != newTop) {
-              lastOffset.left = $targetElement.offset().left + $targetElement.outerWidth();
-              if ($popover.length) {
-                lastOffset.top = newTop - ($popover.outerHeight() / 2) + ($targetElement.outerHeight() / 2)
-              } else {
-                lastOffset.top = newTop - 210;
-              }
-              self.popoverArrowTop($popover.outerHeight() / 2 + (lastOffset.top < 0 ? lastOffset.top - 10 : 0) + (lastOffset.top > $(window).height() - $popover.outerHeight() ? lastOffset.top - ($(window).height() - $popover.outerHeight()) : 0));
-
-              lastOffset.top = Math.min(Math.max(lastOffset.top, 10), $(window).height() - $popover.outerHeight());
-              self.popoverTop(lastOffset.top);
-              self.popoverLeft(lastOffset.left);
-              var $t = $('.samples-table');
-              if ($t.data('plugin_jHueTableExtender')) {
-                $t.data('plugin_jHueTableExtender').drawHeader();
-                $t.data('plugin_jHueTableExtender').drawFirstColumn();
-              }
-              $t.parents('.dataTables_wrapper').getNiceScroll().resize();
-              if (self.popoverArrowTop() < 80) {
-                $popover.hide();
-              } else {
-                $popover.show();
-              }
-            }
-          } else {
-            $popover.hide();
-          }
-        };
-
-        var refreshInterval = -1;
-
-        self.analysisStats.subscribe(function (newValue) {
-          if (newValue && self.enabled) {
-            refreshInterval = window.setInterval(self.refreshPopoverPosition, 200);
-          } else {
-            window.clearInterval(refreshInterval);
-          }
-        });
-
-        self.analysisStats.subscribe(function (newValue) {
-          if (newValue) {
-            self.refreshPopoverPosition();
-          }
-        });
-
-        self.toggleStats = function (data, event) {
-          $statsContainer.empty();
-          if (self.analysisStats()) {
-            self.analysisStats(null);
-          } else {
-            self.analysisStats(new TableStats({
-              i18n: self.i18n,
-              sourceType: self.params.sourceType,
-              databaseName: self.params.databaseName,
-              tableName: self.params.tableName,
-              columnName: self.params.columnName,
-              apiHelper: self.params.apiHelper,
-              showViewMore: typeof self.params.showViewMore === 'undefined' || self.params.showViewMore,
-              type: self.params.fieldType
-            }));
-
-            var $popover = $('<div>');
-            $statsContainer.append($popover)
-
-            ko.renderTemplate('stats-popover', self, {
-              afterRender: function(renderedElement) {
-
-                huePubSub.subscribe('sample.rendered', function (data) {
-                  window.setTimeout(function () {
-                    var $t = $('.samples-table');
-                    if ($t.parent().hasClass('dataTables_wrapper')) {
-                      if ($t.parent().data('scrollFnDt')) {
-                        $t.parent().off('scroll', $t.parent().data('scrollFnDt'));
-                      }
-                      $t.unwrap();
-                      if ($t.children('tbody').length > 0) {
-                        $t.children('tbody').empty();
-                      }
-                      else {
-                        $t.children('tr').remove();
-                      }
-                      $t.data('isScrollAttached', null);
-                      $t.data('data', []);
-                    }
-                    var dt = $t.hueDataTable({
-                      i18n: {
-                        NO_RESULTS: "${_('No results found.')}",
-                        OF: "${_('of')}"
-                      },
-                      fnDrawCallback: function (oSettings) {
-                      },
-                      scrollable: '.dataTables_wrapper',
-                      forceInvisible: 10
-                    });
-
-                    $t.parents('.dataTables_wrapper').height(350);
-                    $t.jHueTableExtender({
-                      fixedHeader: true,
-                      fixedFirstColumn: true,
-                      fixedFirstColumnTopMargin: -1,
-                      headerSorting: false,
-                      includeNavigator: false,
-                      parentId: 'sampleTab',
-                      classToRemove: 'samples-table',
-                      clonedContainerPosition: 'fixed'
-                    });
-
-                    $t.parents('.dataTables_wrapper').niceScroll({
-                      cursorcolor: "#CCC",
-                      cursorborder: "1px solid #CCC",
-                      cursoropacitymin: 0,
-                      cursoropacitymax: 0.75,
-                      scrollspeed: 100,
-                      mousescrollstep: 60,
-                      cursorminheight: 20,
-                      horizrailenabled: true
-                    });
-
-                    if (data && data.rows) {
-                      var _tempData = [];
-                      $.each(data.rows, function (index, row) {
-                        var _row = row.slice(0); // need to clone the array otherwise it messes with the caches
-                        _row.unshift(index + 1);
-                        _tempData.push(_row);
-                      });
-                      if (_tempData.length > 0) {
-                        dt.fnAddData(_tempData);
-                      }
-                    }
-                  }, 0);
-                });
-
-                var hideWhenClickOutside = function (event) {
-                  if(!$(event.target).closest($statsContainer).length) {
-                    self.analysisStats(null)
-                    $(document).off('click', hideWhenClickOutside);
-                  }
-                }
-
-                window.setTimeout(function () {
-                  $(document).on('click', hideWhenClickOutside);
-                }, 0)
-              }
-            }, $popover[0]);
-          }
-        };
-      }
-
-      ko.components.register('table-stats', {
-        viewModel: {
-          createViewModel: function(params, componentInfo) {
-            return new TableStatsViewModel(params, componentInfo.element);
-          }
-        },
-        template: { element: 'table-stats-link' }
-      });
-    }));
-  </script>
-</%def>

+ 1 - 4
desktop/libs/indexer/src/indexer/templates/indexer.mako

@@ -24,13 +24,11 @@
 <%namespace name="assist" file="/assist.mako" />
 <%namespace name="require" file="/require.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_("Solr Indexes"), "search", user, "60px") | n,unicode }
 
 ${ require.config() }
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 
@@ -506,7 +504,6 @@ ${ sqlContextPopover.sqlContextPopover() }
     "desktop/js/apiHelper",
     "notebook/js/notebook.ko",
     "assistPanel",
-    "tableStats",
     "knockout-mapping",
     "knockout-sortable",
     "ko.editable",
@@ -520,7 +517,7 @@ ${ sqlContextPopover.sqlContextPopover() }
     var getNewFieldName = function () {
       fieldNum++;
       return "new_field_" + fieldNum
-    }
+    };
 
     var createDefaultField = function () {
       var defaultField = ko.mapping.fromJS(${default_field_type | n});

+ 0 - 2
desktop/libs/notebook/src/notebook/templates/editor.mako

@@ -24,7 +24,6 @@
 <%namespace name="editorComponents" file="editor_components.mako" />
 <%namespace name="notebookKoComponents" file="notebook_ko_components.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_('Editor'), editor_type, user, "68px") | n,unicode }
 
@@ -39,7 +38,6 @@ ${ editorComponents.includes() }
 ${ editorComponents.topBar() }
 ${ editorComponents.commonHTML() }
 
-${ tableStats.tableStats() }
 ${ sqlContextPopover.sqlContextPopover() }
 ${ assist.assistPanel() }
 ${ configKoComponents.config() }

+ 0 - 2
desktop/libs/notebook/src/notebook/templates/notebook.mako

@@ -24,7 +24,6 @@
 <%namespace name="editorComponents" file="editor_components.mako" />
 <%namespace name="notebookKoComponents" file="notebook_ko_components.mako" />
 <%namespace name="sqlContextPopover" file="/sql_context_popover.mako" />
-<%namespace name="tableStats" file="/table_stats.mako" />
 
 ${ commonheader(_('Notebook'), app_name, user, "68px") | n,unicode }
 
@@ -49,7 +48,6 @@ ${ editorComponents.topBar() }
   </%def>
 </%editorComponents:commonHTML>
 
-${ tableStats.tableStats() }
 ${ assist.assistPanel() }
 ${ sqlContextPopover.sqlContextPopover() }
 ${ configKoComponents.config() }