浏览代码

HUE-5502 [responsive] Embeddable report

Enrico Berti 9 年之前
父节点
当前提交
50514f4e22

+ 4 - 4
desktop/core/src/desktop/static/desktop/css/responsive.css

@@ -995,16 +995,16 @@ h6 {
   box-shadow: none;
 }
 
-/* editor */
-#editorComponents .progress {
+/* editor and report */
+.editorComponents .progress {
   border: none;
 }
 
-#editorComponents .context-panel {
+.editorComponents .context-panel {
   display: none;
 }
 
-#editorComponents .snippet {
+.editorComponents .snippet {
   margin-right: 0;
 }
 

+ 2 - 0
desktop/core/src/desktop/templates/responsive.mako

@@ -356,6 +356,7 @@ ${ hueIcons.symbols() }
     <div class="page-content" data-bind="niceScroll: {horizrailenabled: false}">
       <!-- ko hueSpinner: { spin: isLoadingEmbeddable, center: true, size: 'xlarge' } --><!-- /ko -->
       <div id="embeddable_editor" class="embeddable"></div>
+      <div id="embeddable_notebook" class="embeddable"></div>
       <div id="embeddable_metastore" class="embeddable"></div>
       <div id="embeddable_search" class="embeddable"></div>
       <div id="embeddable_oozie_workflow" class="embeddable"></div>
@@ -479,6 +480,7 @@ ${ assist.assistPanel() }
 
         self.EMBEDDABLE_PAGE_URLS = {
           editor: '/notebook/editor_embeddable',
+          notebook: '/notebook/notebook_embeddable',
           metastore: '/metastore/tables/?is_embeddable=true',
           search: '/search/embeddable/new_search',
           oozie_workflow: '/oozie/editor/workflow/new/?is_embeddable=true',

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

@@ -26,7 +26,7 @@
 
 ${ commonheader(_('Editor'), editor_type, user, request, "68px") | n,unicode }
 
-<span id="editorComponents" class="notebook">
+<span id="editorComponents" class="editorComponents notebook">
 ${ editorComponents.includes() }
 
 <style type="text/css">

+ 4 - 7
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -77,9 +77,6 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery.mousewheel.min.js') }"></script>
 <script src="${ static('desktop/ext/js/jquery.mCustomScrollbar.concat.min.js') }"></script>
 
-% if ENABLE_QUERY_SCHEDULING.get():
-
-% endif
 
 %if ENABLE_QUERY_BUILDER.get():
 <!-- For query builder -->
@@ -403,7 +400,7 @@ ${ hueIcons.symbols() }
 </%def>
 
 
-<%def name="commonHTML(with_assist=True)">
+<%def name="commonHTML(with_assist='true')">
 
 <div id="detailsModal" class="modal transparent-modal hide" data-backdrop="true" style="width:980px;margin-left:-510px!important">
   <div class="modal-header">
@@ -978,7 +975,7 @@ ${ hueIcons.symbols() }
 </div>
 % endif
 
-% if with_assist:
+% if with_assist == 'true':
 <a title="${_('Toggle Assist')}" class="pointer show-assist" data-bind="visible: !$root.isLeftPanelVisible() && $root.assistAvailable(), click: function() { $root.isLeftPanelVisible(true); huePubSub.publish('assist.set.manual.visibility'); }">
   <i class="fa fa-chevron-right"></i>
 </a>
@@ -995,7 +992,7 @@ ${ hueIcons.symbols() }
 </div>
 
 <script type="text/html" id="notebook">
-  % if with_assist:
+  % if with_assist == 'true':
   <div class="assist-container left-panel" data-bind="visible: isLeftPanelVisible() && assistAvailable()">
     <a title="${_('Toggle Assist')}" class="pointer hide-assist" data-bind="click: function() { isLeftPanelVisible(false); huePubSub.publish('assist.set.manual.visibility'); }">
       <i class="fa fa-chevron-left"></i>
@@ -3578,7 +3575,7 @@ ${ hueIcons.symbols() }
       % else:
       viewModel = new EditorViewModel(${ editor_id or 'null' }, ${ notebooks_json | n,unicode }, VIEW_MODEL_OPTIONS);
       % endif
-      ko.applyBindings(viewModel, $('#editorComponents')[0]);
+      ko.applyBindings(viewModel, $('.editorComponents')[0]);
       viewModel.init();
 
       if (location.getParameter("github_status") != "") {

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

@@ -24,7 +24,7 @@
 <%namespace name="editorComponents" file="editor_components.mako" />
 <%namespace name="notebookKoComponents" file="notebook_ko_components.mako" />
 
-<span id="editorComponents" class="notebook">
+<span id="editorComponents" class="editorComponents notebook">
 ${ editorComponents.includes(is_embeddable=True) }
 
 <style type="text/css">
@@ -34,7 +34,7 @@ ${ editorComponents.includes(is_embeddable=True) }
 </style>
 
 ${ editorComponents.topBar() }
-${ editorComponents.commonHTML(with_assist=False) }
+${ editorComponents.commonHTML(with_assist='false') }
 
 ${ configKoComponents.config() }
 ${ notebookKoComponents.downloadSnippetResults() }

+ 55 - 0
desktop/libs/notebook/src/notebook/templates/notebook_embeddable.mako

@@ -0,0 +1,55 @@
+## 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.views import commonheader, commonfooter
+  from desktop import conf
+  from django.utils.translation import ugettext as _
+%>
+
+<%namespace name="assist" file="/assist.mako" />
+<%namespace name="configKoComponents" file="/config_ko_components.mako" />
+<%namespace name="editorComponents" file="editor_components.mako" />
+<%namespace name="notebookKoComponents" file="notebook_ko_components.mako" />
+
+<span id="notebookComponents" class="editorComponents notebook">
+${ editorComponents.includes(is_embeddable=True) }
+${ editorComponents.topBar() }
+<%editorComponents:commonHTML with_assist='false'>
+  <%def name="addSnippetHTML()">
+    <h1 class="empty" data-bind="visible: $root.availableSnippets().length == 0">${ _('There are no snippets configured.') }</h1>
+
+    <!-- ko if: $root.availableSnippets().length > 0 -->
+    <h1 class="empty" data-bind="visible: snippets().length == 0">${ _('Add a snippet to start your new notebook') }</h1>
+
+    <div class="add-snippet" data-bind="component: {
+      name: 'add-snippet-menu',
+      params: {
+        notebook: $data,
+        availableSnippets: $root.availableSnippets
+      }
+    }">
+    </div>
+    <!-- /ko -->
+  </%def>
+</%editorComponents:commonHTML>
+
+${ configKoComponents.config() }
+${ notebookKoComponents.addSnippetMenu() }
+${ notebookKoComponents.downloadSnippetResults() }
+
+${ editorComponents.commonJS(is_embeddable=True) }
+
+</span>

+ 1 - 0
desktop/libs/notebook/src/notebook/urls.py

@@ -33,6 +33,7 @@ import notebook.monkey_patches
 urlpatterns = patterns('notebook.views',
   url(r'^$', 'notebook', name='index'),
   url(r'^notebook/?$', 'notebook', name='notebook'),
+  url(r'^notebook_embeddable/?$', 'notebook_embeddable', name='notebook_embeddable'),
   url(r'^notebooks/?$', 'notebooks', name='notebooks'),
   url(r'^new/?$', 'new', name='new'),
   url(r'^download/?$', 'download', name='download'),

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

@@ -63,7 +63,7 @@ def notebooks(request):
 
 
 @check_document_access_permission()
-def notebook(request):
+def notebook(request, is_embeddable=False):
   notebook_id = request.GET.get('notebook')
 
   is_yarn_mode = False
@@ -73,7 +73,11 @@ def notebook(request):
   except:
     LOG.exception('Spark is not enabled')
 
-  return render('notebook.mako', request, {
+  template = 'notebook.mako'
+  if is_embeddable:
+    template = 'notebook_embeddable.mako'
+
+  return render(template, request, {
       'editor_id': notebook_id or None,
       'notebooks_json': '{}',
       'options_json': json.dumps({
@@ -86,6 +90,9 @@ def notebook(request):
       'is_yarn_mode': is_yarn_mode,
   })
 
+@check_document_access_permission()
+def notebook_embeddable(request):
+  return notebook(request, True)
 
 @check_document_access_permission()
 def editor(request, is_mobile=False, is_embeddable=False):