Pārlūkot izejas kodu

[editor] Support re-executing from the first statement with multi queries

Romain Rigaux 10 gadi atpakaļ
vecāks
revīzija
06ac3a5

+ 7 - 0
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -472,6 +472,13 @@
       });
     };
 
+    self.reexecute = function () {
+      self.result.handle()['statement_id'] = 0;
+      self.result.handle()['has_more'] = false;
+
+      self.execute();
+    };
+
     self.fetchResult = function (rows, startOver) {
       if (typeof startOver == "undefined") {
         startOver = true;

+ 8 - 10
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -856,13 +856,6 @@ ${ require.config() }
 </script>
 
 <script type ="text/html" id="snippet-execution-controls">
-  <!-- ko if: $root.editorMode -->
-  <div class="snippet-actions" style="position: absolute; bottom: 26px">
-    <a class="snippet-side-btn" data-bind="visible: $root.editorMode, click: function() { $parent.showHistory(! $parent.showHistory()); window.setTimeout(redrawFixedHeaders, 100); }, css: {'blue': $parent.showHistory}" title="${ _('Show history') }">
-      <i class="fa fa-fw fa-history"></i>
-    </a>
-  </div>
-  <!-- /ko -->
   <div class="snippet-actions" style="position: absolute; bottom: 0">
     <a class="snippet-side-btn" style="cursor: default;" data-bind="visible: status() == 'loading'" title="${ _('Creating session') }">
       <i class="fa fa-fw fa-spinner fa-spin"></i>
@@ -870,12 +863,17 @@ ${ require.config() }
     <a class="snippet-side-btn" data-bind="click: cancel, visible: status() == 'running'" title="${ _('Cancel') }">
       <i class="fa fa-fw fa-stop"></i>
     </a>
+    <a class="snippet-side-btn" data-bind="click: reexecute, visible: $root.editorMode && result && result.handle().has_more, css: {'blue': $parent.history().length == 0 || $root.editorMode, 'disabled': statement() === '' }" title="${ _('CTRL + ENTER') }">
+      <i class="fa fa-fw fa-cog"></i>
+    </a>    
     <a class="snippet-side-btn" data-bind="click: execute, visible: status() != 'running' && status() != 'loading', css: {'blue': $parent.history().length == 0 || $root.editorMode, 'disabled': statement() === '' }" title="${ _('CTRL + ENTER') }">
       <i class="fa fa-fw fa-play"></i>
     </a>
-    <a class="snippet-side-btn" data-bind="click: execute, visible: result && result.handle().has_more, css: {'blue': $parent.history().length == 0 || $root.editorMode, 'disabled': statement() === '' }" title="${ _('CTRL + ENTER') }">
-      <i class="fa fa-fw fa-cog"></i>
-    </a>
+    <!-- ko if: $root.editorMode -->
+      <a class="snippet-side-btn" data-bind="click: function() { $parent.showHistory(! $parent.showHistory()); window.setTimeout(redrawFixedHeaders, 100); }, css: {'blue': true}" title="${ _('Re-execute from the first statement') }">
+        <i class="fa fa-fw fa-history"></i>
+      </a>
+    <!-- /ko -->    
   </div>
 </script>