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

[core] Assist should prompt for connection credetendials if there is no session

Romain Rigaux 10 жил өмнө
parent
commit
0850ec4

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/assistHelper.js

@@ -74,7 +74,7 @@ AssistHelper.prototype.load = function (snippet, callback) {
     }
   }, function(message) {
    if (message.status == 403) {
-      $(document).trigger("error", "Please login in the JDBC connection");
+      $(document).trigger("showAuthModal", {'type': self.type, 'callback': function() {self.loaded(false); self.load(snippet, callback) }});
     } else if (message.statusText) {
       $(document).trigger("error", "There was a problem loading the databases:" + message.statusText);
     } else if (message) {

+ 1 - 1
desktop/libs/notebook/src/notebook/connectors/jdbc.py

@@ -133,7 +133,7 @@ class JdbcApi(Api):
   def autocomplete(self, snippet, database=None, table=None, column=None, nested=None):
     if self.db is None:
       raise AuthenticationRequired()
-        
+
     assist = Assist(self.db)
     response = {'error': 0}
 

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

@@ -371,7 +371,7 @@ var Snippet = function (vm, notebook, snippet) {
     }
     else if (data.status == 403) { // Auth required
       self.status('expired');
-      $(document).trigger("showAuthModal", {'type': self.type(), 'snippet': self});
+      $(document).trigger("showAuthModal", {'type': self.type(), 'callback': self.execute});
     }
     else if (data.status == 1 || data.status == -1) {
       self.status('failed');
@@ -832,7 +832,7 @@ var Notebook = function (vm, notebook) {
             {'name': 'password', 'value': vm.authSessionPassword()}
           ]
         }),
-        vm.authSessionSnippet() ? vm.authSessionSnippet().execute : null  // On new session we don't automatically execute the snippet after the aut. On session expiration we do.
+        vm.authSessionCallback()  // On new session we don't automatically execute the snippet after the aut. On session expiration we do or we refresh assist DB when login-in.
     );
   };
 
@@ -968,7 +968,7 @@ function EditorViewModel(notebooks, options) {
   self.authSessionUsername = ko.observable(); // UI popup
   self.authSessionPassword = ko.observable();
   self.authSessionType = ko.observable();
-  self.authSessionSnippet = ko.observable();
+  self.authSessionCallback = ko.observable();
 
   self.removeSnippetConfirmation = ko.observable();
 

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

@@ -1858,7 +1858,7 @@ from desktop.views import _ko
     viewModel.authSessionUsername('${ user.username }');
     viewModel.authSessionPassword('');
     viewModel.authSessionType(data['type']);
-    viewModel.authSessionSnippet(data['snippet']);
+    viewModel.authSessionCallback(data['callback']);
     $("#authModal").modal("show");
   });
 </script>