浏览代码

HUE-4242 [editor] Show a modal to retry the query

Enrico Berti 9 年之前
父节点
当前提交
5fda503

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

@@ -648,11 +648,15 @@
         self.status('expired');
       }
       else if (data.status == -4) { // Operation timed out
-        self.status('failed'); // to remove when below ready
-        ///
-        console.log('Operation timed out, do you want to retry or cancel?'); // cf. 401 modal below for popup or inline message same place as usual error message? (nicer than popup)
-        // if yes, if (callback) { callback(); };
-        // if no, self.status('failed');
+        notebook.retryModalCancel = function () {
+          self.status('failed');
+          huePubSub.publish('hide.retry.modal');
+        }
+        notebook.retryModalConfirm = function () {
+          self.execute();
+          huePubSub.publish('hide.retry.modal');
+        }
+        huePubSub.publish('show.retry.modal');
       }
       else if (data.status == 401) { // Auth required
         self.status('expired');
@@ -1242,6 +1246,9 @@
 
     self.schedulerViewModel;
 
+    self.retryModalConfirm = null;
+    self.retryModalCancel = null;
+
     self.loadingHistory = ko.observable(self.history().length == 0);
     // TODO: Move fetchHistory and clearHistory into the Snippet and drop self.selectedSnippet. Actually, history should go in the assist in Hue 4.
     self.getSession = function (session_type) {

+ 24 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -2026,6 +2026,22 @@ ${ hueIcons.symbols() }
   </div>
 </div>
 
+<!-- ko if: $root.selectedNotebook() -->
+  <!-- ko with: $root.selectedNotebook() -->
+  <div id="retryModal" class="modal hide fade" data-keyboard="false" data-backdrop="static">
+    <div class="modal-header">
+      <h3>${_('Operation timed out')}</h3>
+    </div>
+    <div class="modal-body">
+      <p>${_('The operation timed out. Do you want to retry?')}</p>
+    </div>
+    <div class="modal-footer">
+      <a class="btn" data-bind="click: retryModalCancel">${_('No')}</a>
+      <a class="btn btn-primary disable-feedback" data-bind="click: retryModalConfirm">${_('Yes, retry')}</a>
+    </div>
+  </div>
+  <!-- /ko -->
+<!-- /ko -->
 
 <div class="submit-modal modal hide"></div>
 
@@ -2965,7 +2981,6 @@ ${ hueIcons.symbols() }
     }
 
 
-
     $(document).ready(function () {
       var i18n = {
         errorLoadingDatabases: "${ _('There was a problem loading the databases') }"
@@ -3045,6 +3060,14 @@ ${ hueIcons.symbols() }
         $("#clearHistoryModal").modal("hide");
       });
 
+      huePubSub.subscribe('show.retry.modal', function (data) {
+        $('#retryModal').modal('show');
+      });
+
+      huePubSub.subscribe('hide.retry.modal', function (data) {
+        $('#retryModal').modal('hide');
+      });
+
       // Close the notebook snippets when leaving the page
       window.onbeforeunload = function (e) {
         viewModel.selectedNotebook().close();