Ver Fonte

HUE-9100 [editor] Update session after execute

Jean-Francois Desjeans Gauthier há 6 anos atrás
pai
commit
1797ecc88d

+ 16 - 0
desktop/core/src/desktop/js/apps/notebook/snippet.js

@@ -1845,6 +1845,22 @@ class Snippet {
           }
 
           if (data.handle) {
+            if (data.handle.session_id) {
+              // Execute can update the session
+              if (!notebook.sessions().length) {
+                notebook.addSession(
+                  new Session(vm, {
+                    type: self.type(),
+                    session_id: data.handle.session_guid,
+                    id: data.handle.session_id,
+                    properties: {}
+                  })
+                );
+              } else {
+                notebook.sessions()[0].session_id(data.handle.session_guid);
+                notebook.sessions()[0].id(data.handle.session_id);
+              }
+            }
             if (vm.editorMode()) {
               if (vm.isNotificationManager()) {
                 // Update task status

+ 8 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/executable.js

@@ -173,6 +173,14 @@ export default class Executable {
         this.handle = response.handle;
         this.history = response.history;
         this.operationId = response.history.uuid;
+        if (response.handle.session_id) {
+          sessionManager.updateSession({
+            type: response.handle.session_type,
+            id: response.handle.session_id,
+            session_id: response.handle.session_guid,
+            properties: []
+          });
+        }
       } catch (err) {
         const match = ERROR_REGEX.exec(err);
         if (match) {

+ 6 - 0
desktop/core/src/desktop/js/apps/notebook2/execution/sessionManager.js

@@ -101,6 +101,12 @@ class SessionManager {
     });
   }
 
+  updateSession(options) {
+    this.knownSessionPromises[options.type] = new Promise((resolve, reject) => {
+      resolve(options);
+    });
+  }
+
   async getAllSessions() {
     const promises = Object.keys(this.knownSessionPromises).map(
       key => this.knownSessionPromises[key]