浏览代码

HUE-3468 [editor] Show queries for editor type on the queries page instead of all notebooks

Johan Ahlen 9 年之前
父节点
当前提交
1193621d4e

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -214,7 +214,7 @@ ${ hueIcons.symbols() }
         </a>
         % endif
 
-        <a class="btn" href="${ url('notebook:notebooks') }" title="${ _('Queries' if mode == 'editor' else 'Notebooks') }" rel="tooltip" data-placement="bottom">
+        <a class="btn" href="${ url('notebook:notebooks') }?type=${ editor_type }" title="${ _('Queries' if mode == 'editor' else 'Notebooks') }" rel="tooltip" data-placement="bottom">
           <i class="fa fa-tags"></i>
         </a>
       </div>

+ 9 - 3
desktop/libs/notebook/src/notebook/templates/notebooks.mako

@@ -26,7 +26,13 @@ ${ commonheader(_("Notebooks"), "spark", user, "60px") | n,unicode }
 
 <div class="container-fluid">
   <div class="card card-small">
-  <h1 class="card-heading simple">${ _('Notebooks') }</h1>
+  % if editor_type == 'impala':
+    <h1 class="card-heading simple">${ _('Impala Queries') }</h1>
+  % elif editor_type == 'hive':
+    <h1 class="card-heading simple">${ _('Hive Queries') }</h1>
+  % else:
+    <h1 class="card-heading simple">${ _('Notebooks') }</h1>
+  % endif
 
   <%actionbar:render>
     <%def name="search()">
@@ -152,14 +158,14 @@ ${ commonshare() | n,unicode }
 
     self.handleSelect = function(notebook) {
       notebook.isSelected(! notebook.isSelected());
-    }
+    };
 
     self.selectAll = function() {
       self.allSelected(! self.allSelected());
       ko.utils.arrayForEach(self.jobs(), function (job) {
         job.isSelected(self.allSelected());
       });
-    }
+    };
 
     self.datatable = null;
 

+ 8 - 2
desktop/libs/notebook/src/notebook/views.py

@@ -40,10 +40,16 @@ LOG = logging.getLogger(__name__)
 
 
 def notebooks(request):
-  notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook') | Q(extra__startswith='query')) if not d.content_object.is_history]
+  editor_type = request.GET.get('type')
+
+  if editor_type:
+    notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook') | Q(extra__startswith='query')) if not d.content_object.is_history and d.content_object.type == 'query-' + editor_type]
+  else:
+    notebooks = [d.content_object.to_dict() for d in Document.objects.get_docs(request.user, Document2, qfilter=Q(extra='notebook') | Q(extra__startswith='query')) if not d.content_object.is_history]
 
   return render('notebooks.mako', request, {
-      'notebooks_json': json.dumps(notebooks, cls=JSONEncoderForHTML)
+      'notebooks_json': json.dumps(notebooks, cls=JSONEncoderForHTML),
+      'editor_type': editor_type
   })