Browse Source

HUE-3111 [editor] Improve performances for query files of 20k+ rows

Enrico Berti 9 years ago
parent
commit
6408c01

+ 5 - 3
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -1359,9 +1359,11 @@
       var autoExpandTimeout = window.setInterval(function () {
         var chunks = Math.floor((Math.max(ace().session.getLength(), 4) - lastEditorHeight) / 4);
         if (chunks !== 0) {
-          $target.height($target.height() + 64 * chunks);
-          ace().resize();
-          lastEditorHeight += 4 * chunks;
+          if ($target.height() + 64 * chunks < $(window).height() - $target.position().top - 90) {
+            $target.height($target.height() + 64 * chunks);
+            ace().resize();
+            lastEditorHeight += 4 * chunks;
+          }
         }
       }, 300);
 

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

@@ -1710,7 +1710,10 @@ ${ require.config() }
 
   function saveTemporarySnippet($element, value) {
     if ($element.data('last-active-editor')) {
-      $.totalStorage('hue.notebook.lastWrittenSnippet', value);
+      try {
+        $.totalStorage('hue.notebook.lastWrittenSnippet', value);
+      }
+      catch (e){} // storage quota exceeded with enormous editor content
     }
   }
 
@@ -1905,14 +1908,8 @@ ${ require.config() }
     }
 
     function replaceAce(content) {
-      var snip = viewModel.notebooks()[0].snippets()[0],
-          contentLines = content.split('\n');
-      if (contentLines.length > 5000) {
-        $.jHueNotify.warn("${ _('The content you are trying to import is too big and it has been truncated for performance reasons.') }");
-        snip.statement_raw(contentLines.slice(0, 5000).join('\n'));
-        snip.ace().setValue(contentLines.slice(0, 5000).join('\n'));
-      }
-      else {
+      var snip = viewModel.notebooks()[0].snippets()[0];
+      if (snip) {
         snip.statement_raw(content);
         snip.ace().setValue(content);
       }
@@ -2016,6 +2013,7 @@ ${ require.config() }
       }
       catch (e) {
         hideHoverMsg(viewModel);
+        replaceAce(raw);
       }
     }