Эх сурвалжийг харах

HUE-3408 [editor] Reloading a canceled query will show an error

Romain Rigaux 9 жил өмнө
parent
commit
5ef7b42

+ 2 - 0
desktop/libs/notebook/src/notebook/api.py

@@ -86,6 +86,8 @@ def execute(request):
     response['handle'] = get_api(request, snippet).execute(notebook, snippet)
   finally:
     if notebook['type'].startswith('query-'):
+      _snippet = [s for s in notebook['snippets'] if s['id'] == snippet['id']][0]
+      _snippet['result']['handle'] = response['handle']
       history = _historify(notebook, request.user)
       response['history_id'] = history.id
 

+ 6 - 6
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -287,7 +287,7 @@
     self.aceSize = ko.observable(typeof snippet.aceSize != "undefined" && snippet.aceSize != null ? snippet.aceSize : 100);
     // self.statement_raw.extend({ rateLimit: 150 }); // Should prevent lag from typing but currently send the old query when using the key shortcut
     self.status = ko.observable(typeof snippet.status != "undefined" && snippet.status != null ? snippet.status : 'loading');
-    self.statusForButtons = ko.observable(typeof snippet.statusForButtons != "undefined" && snippet.statusForButtons != null ? snippet.statusForButtons : '');
+    self.statusForButtons = ko.observable('executed');
 
     self.properties = ko.observable(ko.mapping.fromJS(typeof snippet.properties != "undefined" && snippet.properties != null ? snippet.properties : getDefaultSnippetProperties(self.type())));
     self.hasProperties = ko.computed(function() {
@@ -580,6 +580,10 @@
         snippet: ko.mapping.toJSON(self.getContext())
       }, function (data) {
         self.statusForButtons('executed');
+        if (vm.editorMode && data.history_id) {
+          hueUtils.changeURL('/notebook/editor?editor=' + data.history_id);
+          notebook.id(data.history_id);
+        }
         if (data.status == 0) {
           self.result.clear();
           self.result.handle(data.handle);
@@ -607,10 +611,6 @@
         } else {
           self._ajaxError(data, self.execute);
         }
-        if (vm.editorMode && data.history_id) {
-          hueUtils.changeURL('/notebook/editor?editor=' + data.history_id);
-          self.id(data.history_id);
-        }
       }).fail(function (xhr, textStatus, errorThrown) {
         $(document).trigger("error", xhr.responseText);
         self.status('failed');
@@ -915,7 +915,7 @@
     });
 
     self.init = function () {
-      if (self.status() == 'running') {
+      if (self.status() == 'running' || self.status() == 'available') {
         self.checkStatus();
       }
       else if (self.status() == 'loading') {