瀏覽代碼

HUE-3294 [editor] Avoid double loading of JS files

Enrico Berti 9 年之前
父節點
當前提交
2228b6a190

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

@@ -495,4 +495,8 @@ h6 {
   margin: 9px 0;
   overflow: hidden;
   background-color: #e5e5e5;
+}
+
+.page-content .navbar.navbar-inverse.navbar-fixed-top {
+  position: static;
 }

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

@@ -372,13 +372,18 @@ ${ assist.assistPanel() }
       if (typeof self.embeddable_cache[newVal] === 'undefined'){
         $.ajax({
           url: self.EMBEDDABLE_PAGE_URLS[newVal],
+          cache: false,
           beforeSend:function (xhr) {
             xhr.setRequestHeader('X-Requested-With', 'Hue');
           },
           dataType:'html',
           success:function (response) {
-            self.embeddable_cache[newVal] = response;
-            $('#embeddable').html(response);
+            // TODO: remove the next lines
+            // hack to avoid css caching for development
+            var r = $(response);
+            r.find('link').each(function(){ $(this).attr('href', $(this).attr('href') + '?' + Math.random()) });
+            self.embeddable_cache[newVal] = r;
+            $('#embeddable').html(r);
             self.isLoadingEmbeddable(false);
           }
         });

+ 95 - 0
desktop/libs/notebook/src/notebook/static/notebook/css/notebook-layout.css

@@ -0,0 +1,95 @@
+/*
+ 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.
+*/
+
+html {
+  height: 100%;
+}
+body {
+  height:100%;
+  margin: 0;
+  padding: 0;
+  background-color: #FFF;
+  overflow-y: hidden;
+}
+
+.vertical-full {
+  height:100%;
+  padding-right: 1px;
+}
+
+.main-content {
+  height: auto;
+  width: 100%;
+  position: absolute;
+  top: 82px;
+  bottom: 0;
+  background-color: #FFF;
+}
+
+.panel-container {
+  position: relative;
+}
+
+.left-panel {
+  position: absolute;
+  height: 100%;
+  overflow: hidden;
+  outline: none !important;
+}
+
+.context-panel {
+  position: fixed;
+  background: #fff;
+  height: calc(100% - 70px);
+  top: 70px;
+  transition: all;
+  -webkit-transition-duration: .3s;
+  transition-duration: .3s;
+  z-index: 401;
+  overflow-y: auto;
+  padding: 10px 0;
+  width: 420px;
+  right: -440px;
+  box-shadow: 0 0 20px rgba(14, 18, 21, .38);
+  outline: none !important;
+}
+
+.context-panel.visible {
+  right: 0;
+}
+
+.context-panel .nav-tabs {
+  padding-left: 10px;
+}
+
+.context-panel .tab-content {
+  padding: 12px;
+  min-height: calc(100% - 90px);
+}
+
+.context-panel .tab-pane {
+  height: 100%;
+}
+
+.content-panel {
+  position: absolute;
+  height: 100%;
+  overflow: auto;
+  outline: none !important;
+}
+

+ 0 - 77
desktop/libs/notebook/src/notebook/static/notebook/css/notebook.css

@@ -16,31 +16,6 @@
  limitations under the License.
 */
 
-html {
-  height: 100%;
-}
-body {
-  height:100%;
-  margin: 0;
-  padding: 0;
-  background-color: #FFF;
-  overflow-y: hidden;
-}
-
-.vertical-full {
-  height:100%;
-  padding-right: 1px;
-}
-
-.main-content {
-  height: auto;
-  width: 100%;
-  position: absolute;
-  top: 82px;
-  bottom: 0;
-  background-color: #FFF;
-}
-
 .snippet-move-placeholder {
   margin: 10px;
   height: 100px;
@@ -54,51 +29,6 @@ body {
   border: 1px solid #F1F1F1;
 }
 
-.panel-container {
-  position: relative;
-}
-
-.left-panel {
-  position: absolute;
-  height: 100%;
-  overflow: hidden;
-  outline: none !important;
-}
-
-.context-panel {
-  position: fixed;
-  background: #fff;
-  height: calc(100% - 70px);
-  top: 70px;
-  transition: all;
-  -webkit-transition-duration: .3s;
-  transition-duration: .3s;
-  z-index: 401;
-  overflow-y: auto;
-  padding: 10px 0;
-  width: 420px;
-  right: -440px;
-  box-shadow: 0 0 20px rgba(14, 18, 21, .38);
-  outline: none !important;
-}
-
-.context-panel.visible {
-  right: 0;
-}
-
-.context-panel .nav-tabs {
-  padding-left: 10px;
-}
-
-.context-panel .tab-content {
-  padding: 12px;
-  min-height: calc(100% - 90px);
-}
-
-.context-panel .tab-pane {
-  height: 100%;
-}
-
 .resizer {
   position: absolute;
   height: 100%;
@@ -113,13 +43,6 @@ body {
   background-color: #F1F1F1;
 }
 
-.content-panel {
-  position: absolute;
-  height: 100%;
-  overflow: auto;
-  outline: none !important;
-}
-
 .question {
   margin: 10px;
 }

+ 19 - 12
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -27,8 +27,11 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 
 <%namespace name="hueIcons" file="/hue_icons.mako" />
 
-<%def name="includes()">
+<%def name="includes(is_responsive=False)">
 <link rel="stylesheet" href="${ static('desktop/css/common_dashboard.css') }">
+% if not is_responsive:
+<link rel="stylesheet" href="${ static('notebook/css/notebook-layout.css') }">
+% endif
 <link rel="stylesheet" href="${ static('notebook/css/notebook.css') }">
 <link rel="stylesheet" href="${ static('desktop/ext/css/bootstrap-editable.css') }">
 <link rel="stylesheet" href="${ static('desktop/ext/chosen/chosen.min.css') }">
@@ -42,22 +45,26 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <link rel="stylesheet" href="${ static('desktop/css/bootstrap-medium-editor.css') }">
 <link rel="stylesheet" href="${ static('desktop/ext/css/jquery.mCustomScrollbar.min.css') }">
 
-
+% if not is_responsive:
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.custom.min.js') }"></script>
 <script src="${ static('desktop/ext/js/knockout.min.js') }"></script>
-<script src="${ static('desktop/ext/js/selectize.min.js') }"></script>
+<script src="${ static('desktop/ext/js/knockout-mapping.min.js') }"></script>
+<script src="${ static('desktop/ext/js/knockout-sortable.min.js') }"></script>
+<script src="${ static('desktop/js/ko.hue-bindings.js') }"></script>
 <script src="${ static('desktop/js/apiHelper.js') }"></script>
 <script src="${ static('desktop/js/ko.charts.js') }"></script>
+<script src="${ static('desktop/js/ko.editable.js') }"></script>
+% endif
+
+<script src="${ static('desktop/ext/js/selectize.min.js') }"></script>
 <script src="${ static('notebook/js/notebook.ko.js') }"></script>
+
 % if ENABLE_QUERY_SCHEDULING.get():
 <script src="${ static('oozie/js/coordinator-editor.ko.js') }"></script>
 <script src="${ static('oozie/js/list-oozie-coordinator.ko.js') }"></script>
 % endif
-<script src="${ static('desktop/ext/js/knockout-mapping.min.js') }"></script>
-<script src="${ static('desktop/ext/js/knockout-sortable.min.js') }"></script>
+
 <script src="${ static('desktop/ext/js/knockout-selectize.js') }"></script>
-<script src="${ static('desktop/js/ko.editable.js') }"></script>
-<script src="${ static('desktop/js/ko.hue-bindings.js') }"></script>
 <script src="${ static('desktop/js/ko.switch-case.js') }"></script>
 <script src="${ static('desktop/js/sqlFunctions.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sql.js') }"></script>
@@ -75,7 +82,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script src="${ static('desktop/js/document/documentChooser.js') }"></script>
 
 % if ENABLE_QUERY_SCHEDULING.get():
-<script src="${ static('oozie/js/dashboard-utils.js') }" type="text/javascript" charset="utf-8"></script>
+
 % endif
 
 %if ENABLE_QUERY_BUILDER.get():
@@ -1180,8 +1187,8 @@ ${ hueIcons.symbols() }
         <!-- ko if: schedulerViewModelIsLoaded() && ! schedulerViewModel.coordinator.isDirty() -->
           <a data-bind="click: showSubmitPopup">${ _('Start') }</a>
         <!-- /ko -->
-        </br>
-        </br>
+        <br>
+        <br>
         <div id="schedulerEditor">
         </div>
       <!-- /ko -->
@@ -1586,11 +1593,11 @@ ${ hueIcons.symbols() }
       <!-- /ko -->
       <!-- ko if: errorDetail.errorString -->
         ${ _('Query is not compatible with Impala') }.
-        </br>
+        <br>
         <span style="font-weight: bold;"></span><span data-bind="text: errorDetail.errorString"></span>
       <!-- /ko -->
       <!-- ko if: clauseStatus.From -->
-        </br>
+        <br>
         <!-- ko if: clauseStatus.From.category -->
           <span style="font-weight: bold;"></span><span data-bind="text: clauseStatus.From.category"></span>
         <!-- /ko -->

+ 1 - 3
desktop/libs/notebook/src/notebook/templates/editor_embeddable.mako

@@ -25,7 +25,7 @@
 <%namespace name="notebookKoComponents" file="notebook_ko_components.mako" />
 
 <span id="editorComponents">
-${ editorComponents.includes() }
+${ editorComponents.includes(is_responsive=True) }
 
 <style type="text/css">
   .snippet {
@@ -36,8 +36,6 @@ ${ editorComponents.includes() }
 ${ editorComponents.topBar() }
 ${ editorComponents.commonHTML(with_assist=False) }
 
-${ assist.assistPanel() }
-${ assist.assistJSModels() }
 ${ configKoComponents.config() }
 ${ notebookKoComponents.downloadSnippetResults() }
 ${ notebookKoComponents.snippetDbSelection() }