Browse Source

HUE-1116 [catalog] Create a table from a file or loading data are broken

Was due to a mismatch with Impala and HS2
Restyle breadcrumbs
Romain Rigaux 12 năm trước cách đây
mục cha
commit
d381b14

+ 9 - 6
apps/beeswax/src/beeswax/views.py

@@ -513,7 +513,8 @@ def view_results(request, id, first_row=0):
   app_name = get_app_name(request)
 
   query_history = authorized_get_history(request, id, must_exist=True)
-  db = dbms.get(request.user, query_history.get_query_server_config())
+  query_server = query_history.get_query_server_config()
+  db = dbms.get(request.user, query_server)
 
   handle, state = _get_query_handle_and_state(query_history)
   context_param = request.GET.get('context', '')
@@ -531,7 +532,7 @@ def view_results(request, id, first_row=0):
 
   # Retrieve query results or use empty result if no result set
   try:
-    if not handle.has_result_set:
+    if query_server['server_name'] == 'impala' and not handle.has_result_set:
       downloadable = False
     elif not download:
       results = db.fetch(handle, start_over, 100)
@@ -1127,13 +1128,15 @@ def _get_query_handle_and_state(query_history):
   if handle is None:
     raise PopupException(_("Failed to retrieve query state from the Query Server."))
 
-  if handle.has_result_set:
-    state = dbms.get(query_history.owner, query_history.get_query_server_config()).get_state(handle)
-  else:
+  query_server = query_history.get_query_server_config()
+
+  if query_server['server_name'] == 'impala' and not handle.has_result_set:
     state = QueryHistory.STATE.available
+  else:
+    state = dbms.get(query_history.owner, query_history.get_query_server_config()).get_state(handle)
 
   if state is None:
-    raise PopupException(_("Failed to contact Beeswax Server to check query status."))
+    raise PopupException(_("Failed to contact Server to check query status."))
   return (handle, state)
 
 

+ 22 - 15
apps/catalog/src/catalog/templates/components.mako

@@ -19,21 +19,28 @@
 %>
 
 <%def name="breadcrumbs(breadcrumbs)">
-<ul class="nav nav-pills hueBreadcrumbBar" id="breadcrumbs">
-  <li><a href="${url('catalog:index')}"><i class="icon-home"></i> ${_('Home')}</a></li>
-  <li>
-    <ul class="hueBreadcrumb">
-      % for crumb in breadcrumbs:
-        <li>
-          <a href="${ crumb['url'] }">${ crumb['name'] }</a>
-          % if not loop.last:
-            <span class="divider">/</span>
-          % endif
-        </li>
-      % endfor
-    </ul>
-  </li>
-</ul>
+
+
+
+  <ul class="nav nav-pills hueBreadcrumbBar" id="breadcrumbs">
+    <li>
+      <a href="${url('catalog:index')}"><i class="icon-sitemap"></i> ${_('Catalog')}</a>
+    </li>
+    <li>
+      <ul class="hueBreadcrumb">
+        % for crumb in breadcrumbs:
+          <li>
+            <a href="${ crumb['url'] }">${ crumb['name'] }</a>
+            % if not loop.last:
+              <span class="divider">/</span>
+            % endif
+          </li>
+        % endfor
+      </ul>
+    </li>
+  </ul>
+
+
 </%def>
 
 <%def name="bootstrapLabel(field)">

+ 1 - 1
apps/catalog/src/catalog/templates/describe_partitions.mako

@@ -22,10 +22,10 @@
 <%namespace name="components" file="components.mako" />
 
 ${ commonheader(_('Table Partitions: %(tableName)s') % dict(tableName=table.name), app_name, user) | n,unicode }
-${ components.breadcrumbs(breadcrumbs) }
 
 <div class="container-fluid">
 <h1>${_('Partitions')}</h1>
+${ components.breadcrumbs(breadcrumbs) }
 
 <table class="table table-striped table-condensed datatables">
   % if partitions:

+ 7 - 5
apps/catalog/src/catalog/templates/describe_table.mako

@@ -14,6 +14,7 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 <%!
+from desktop.lib.i18n import smart_unicode
 from desktop.views import commonheader, commonfooter
 from django.utils.translation import ugettext as _
 %>
@@ -26,8 +27,7 @@ from django.utils.translation import ugettext as _
   else:
     view_or_table_noun = _("Table")
 %>
-${ commonheader(_("%s Metadata: %s") % (view_or_table_noun, table.name), app_name, user) | n,unicode }
-${ components.breadcrumbs(breadcrumbs) }
+${ commonheader(_("%s : %s") % (view_or_table_noun, table.name), app_name, user) | n,unicode }
 
 <%def name="column_table(cols)">
     <table class="table table-striped table-condensed datatables">
@@ -52,7 +52,9 @@ ${ components.breadcrumbs(breadcrumbs) }
 </%def>
 
 <div class="container-fluid">
-    <h1>${_('Table Metadata:')} ${table.name}</h1>
+    <h1>${_('Table')} ${table.name}</h1>
+    ${ components.breadcrumbs(breadcrumbs) }
+
     <div class="row-fluid">
         <div class="span3">
             <div class="well sidebar-nav">
@@ -67,7 +69,7 @@ ${ components.breadcrumbs(breadcrumbs) }
         </div>
         <div class="span9">
             % if table.comment is not None:
-                <h5>${ table.comment }</h5>
+                <div class="alert alert-info">${ _('Comment:') } ${ table.comment }</div>
             % endif
 
             <ul class="nav nav-tabs">
@@ -112,7 +114,7 @@ ${ components.breadcrumbs(breadcrumbs) }
                             % for i, row in enumerate(sample):
                               <tr>
                                 % for item in row:
-                                  <td>${ item }</td>
+                                  <td>${ smart_unicode(item, errors='ignore') }</td>
                                 % endfor
                               </tr>
                             % endfor

+ 0 - 38
apps/catalog/src/catalog/templates/layout.mako

@@ -1,38 +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.
-##
-##
-## no spaces in this method please; we're declaring a CSS class, and ART uses this value for stuff, and it splits on spaces, and
-## multiple spaces and line breaks cause issues
-<%!
-from django.utils.translation import ugettext as _
-
-def is_selected(section, matcher):
-  if section == matcher:
-    return "active"
-  else:
-    return ""
-%>
-
-<%def name="menubar(section='')">
-<div class="subnav subnav-fixed">
-  <div class="container-fluid">
-    <ul class="nav nav-pills">
-      <li class="${is_selected(section, 'tables')}"><a href="${ url(app_name + ':show_tables') }">${_('Tables')}</a></li>
-    </ul>
-  </div>
-</div>
-</%def>

+ 1 - 2
apps/catalog/src/catalog/templates/tables.mako

@@ -19,13 +19,12 @@ from django.utils.translation import ugettext as _
 %>
 <%namespace name="actionbar" file="actionbar.mako" />
 <%namespace name="components" file="components.mako" />
-<%namespace name="layout" file="layout.mako" />
 
 ${ commonheader(_('Tables'), 'catalog', user) | n,unicode }
-${ components.breadcrumbs(breadcrumbs) }
 
 <div class="container-fluid" id="tables">
     <h1>${_('Tables')}</h1>
+    ${ components.breadcrumbs(breadcrumbs) }
     <div class="row-fluid">
         <div class="span3">
             <div class="well sidebar-nav">

+ 1 - 1
apps/catalog/src/catalog/tests.py

@@ -100,7 +100,7 @@ class TestCatalogWithHadoop(BeeswaxSampleProvider):
     resp = self.client.get('/catalog/table/default/myview')
     assert_equal(None, resp.context['sample'])
     assert_true(resp.context['table'].is_view)
-    assert_true("View Metadata" in resp.content)
+    assert_true("View" in resp.content)
     assert_true("Drop View" in resp.content)
     # Breadcrumbs
     assert_true("default" in resp.content)

+ 15 - 15
apps/catalog/src/catalog/views.py

@@ -186,18 +186,18 @@ def describe_partitions(request, database, table):
   partitions = db.get_partitions(database, table_obj, max_parts=None)
 
   return render("describe_partitions.mako", request,
-                dict(breadcrumbs=[
-                  {
-                    'name': database,
-                    'url': reverse('catalog:show_tables', kwargs={'database': database})
-                  },
-                  {
-                    'name': table,
-                    'url': reverse('catalog:describe_table', kwargs={'database': database, 'table': table})
-                  },
-                  {
-                    'name': 'partitions',
-                    'url': reverse('catalog:describe_partitions', kwargs={'database': database, 'table': table})
-                  },
-                ],
-                table=table_obj, partitions=partitions, request=request))
+      {'breadcrumbs': [
+        {
+          'name': database,
+          'url': reverse('catalog:show_tables', kwargs={'database': database})
+        },
+        {
+          'name': table,
+          'url': reverse('catalog:describe_table', kwargs={'database': database, 'table': table})
+        },
+        {
+          'name': 'partitions',
+          'url': reverse('catalog:describe_partitions', kwargs={'database': database, 'table': table})
+        },
+      ],
+      'table': table_obj, 'partitions': partitions, 'request': request})

+ 1 - 15
apps/filebrowser/src/filebrowser/templates/fb_components.mako

@@ -17,6 +17,7 @@
 from django.template.defaultfilters import urlencode
 from django.utils.translation import ugettext as _
 %>
+
 <%def name="breadcrumbs(path, breadcrumbs, from_listdir=False)">
     % if from_listdir:
         <ul class="nav nav-pills hueBreadcrumbBar">
@@ -51,19 +52,4 @@ from django.utils.translation import ugettext as _
             </li>
         </ul>
     % endif
-
-    <style type="text/css">
-        .hueBreadcrumbBar {
-            padding: 8px 15px;
-            margin: 0 0 20px;
-            list-style: none;
-            border: 1px solid #E5E5E5;
-            -webkit-border-radius: 4px;
-            -moz-border-radius: 4px;
-            border-radius: 4px;
-        }
-        .hueBreadcrumb {
-            margin: 0!important;
-        }
-    </style>
 </%def>

+ 12 - 2
desktop/core/static/css/hue2.css

@@ -378,8 +378,7 @@ ul.errorlist li {
 
 .hueBreadcrumb {
     list-style: none outside none;
-    margin: 0 0 18px;
-    padding: 9px 14px;
+    padding: 9px 9px;
 }
 .hueBreadcrumb li {
     display: inline-block;
@@ -409,6 +408,17 @@ ul.errorlist li {
     padding-bottom:0;
 }
 
+.hueBreadcrumbBar {
+    padding: 8px 15px;
+    margin: 0 0 20px;
+    list-style: none;
+    border: 1px solid #E5E5E5;
+    -webkit-border-radius: 4px;
+    -moz-border-radius: 4px;
+    border-radius: 4px;
+}
+
+
 /*********************************************************
  * From: http://datatables.net/blog/Twitter_Bootstrap
  */