浏览代码

HUE-4206 [notebook] Ignore history and other calls in notebook mode

Romain Rigaux 9 年之前
父节点
当前提交
574fd75fca

+ 3 - 3
desktop/libs/notebook/src/notebook/connectors/spark_shell.py

@@ -192,7 +192,7 @@ class SparkApi(Api):
       }
     except Exception, e:
       message = force_unicode(str(e)).lower()
-      if 'session not found' in message or 'connection refused' in message or 'session is in state busy' in message:
+      if re.search("session ('\d+' )?not found", message) or 'connection refused' in message or 'session is in state busy' in message:
         raise SessionExpired(e)
       else:
         raise e
@@ -209,7 +209,7 @@ class SparkApi(Api):
       }
     except Exception, e:
       message = force_unicode(str(e)).lower()
-      if 'session not found' in message:
+      if re.search("session ('\d+' )?not found", message):
         raise SessionExpired(e)
       else:
         raise e
@@ -223,7 +223,7 @@ class SparkApi(Api):
       response = api.fetch_data(session['id'], cell)
     except Exception, e:
       message = force_unicode(str(e)).lower()
-      if 'session not found' in message:
+      if re.search("session ('\d+' )?not found", message):
         raise SessionExpired(e)
       else:
         raise e

+ 16 - 12
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -712,16 +712,18 @@
           self._ajaxError(data, self.execute);
         }
 
-        notebook.history.unshift(
-          notebook._makeHistoryRecord(
-            url,
-            data.handle.statement,
-            self.lastExecuted(),
-            self.status(),
-            notebook.name(),
-            notebook.uuid()
-          )
-        );
+        if (vm.editorMode()) {
+          notebook.history.unshift(
+            notebook._makeHistoryRecord(
+              url,
+              data.handle.statement,
+              self.lastExecuted(),
+              self.status(),
+              notebook.name(),
+              notebook.uuid()
+            )
+          );
+        }
 
         if (data.handle.statements_count != null) {
           self.result.statements_count(data.handle.statements_count);
@@ -931,7 +933,9 @@
         if (self.statusForButtons() == 'canceling' || self.status() == 'canceled') {
           // Query was canceled in the meantime, do nothing
         } else {
-          self.getLogs();
+          if (vm.editorMode()) {
+            self.getLogs();
+          }
 
           if (data.status == 0) {
             self.status(data.query_status.status);
@@ -1107,7 +1111,7 @@
     self.availableNewProperties = ko.computed(function() {
       var addedIndex = {};
       $.each(self.properties(), function(index, property) {
-        addedIndex[property.key()] = true;
+        addedIndex[property.key] = true;
       });
       var result = $.grep(vm.availableSessionProperties(), function(property) {
         return ! addedIndex[property.name];

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

@@ -279,7 +279,7 @@ ${ hueIcons.symbols() }
       <div class="nav-collapse">
         <ul class="nav editor-nav">
           <li class="currentApp">
-            <!-- ko if: editorMode() == 'editor' -->
+            <!-- ko if: editorMode() -->
               <a data-bind="attr: { href: '${ url('notebook:editor') }?type=' + editorType(), title: editorTypeTitle() + '${ _(' Editor') }' }" style="cursor: pointer">
               <!-- ko if: editorType() == 'impala' -->
                 <img src="${ static('impala/art/icon_impala_48.png') }" class="app-icon" />
@@ -303,7 +303,7 @@ ${ hueIcons.symbols() }
               <!-- /ko -->
               </a>
             <!-- /ko -->
-            <!-- ko if: editorMode() != 'editor' -->
+            <!-- ko ifnot: editorMode() -->
               <i class="fa fa-file-text-o app-icon" style="vertical-align: middle"></i>
                 Notebook
             <!-- /ko -->            
@@ -1048,7 +1048,7 @@ ${ hueIcons.symbols() }
     </div>
 
     % if ENABLE_QUERY_SCHEDULING.get():
-    <!-- ko if: editorMode() == 'editor' -->
+    <!-- ko if: editorMode() -->
     <div class="tab-pane" id="scheduleTab">
 
       <!-- ko if: $root.selectedNotebook() -->