Просмотр исходного кода

HUE-8768 [editor] Add result size to notebook 2

Johan Ahlen 6 лет назад
Родитель
Сommit
01acf59c02

+ 23 - 10
desktop/core/src/desktop/js/apps/notebook2/execution/executionResult.js

@@ -52,15 +52,29 @@ class ExecutionResult {
         reject();
         return;
       }
-      apiHelper
-        .fetchResultSize({
-          executable: this.executable
-        })
-        .then(resultSizeResponse => {
-          console.log(resultSizeResponse);
-          resolve(resultSizeResponse);
-        })
-        .catch(reject);
+
+      let attempts = 0;
+      const waitForRows = () => {
+        attempts++;
+        if (attempts < 10) {
+          apiHelper
+            .fetchResultSize({
+              executable: this.executable
+            })
+            .then(resultSizeResponse => {
+              if (resultSizeResponse.rows !== null) {
+                resolve(resultSizeResponse);
+              } else {
+                window.setTimeout(waitForRows, 1000);
+              }
+            })
+            .catch(reject);
+        } else {
+          reject();
+        }
+      };
+
+      waitForRows();
     });
   }
 
@@ -92,7 +106,6 @@ class ExecutionResult {
           } else {
             this.status = RESULT_STATUS.done;
           }
-          console.log(resultResponse);
           resolve(resultResponse);
         })
         .catch(error => {

+ 5 - 4
desktop/core/src/desktop/js/apps/notebook2/result.js

@@ -245,15 +245,16 @@ class Result {
    */
   async update(executionResult) {
     this.executionResult = executionResult;
+    this.handle(this.executionResult.executable.handle);
+
+    await this.fetchMoreRows(100, false);
 
     window.setTimeout(() => {
-      this.executionResult.fetchResultSize().then(rows => {
-        console.log(rows);
+      this.executionResult.fetchResultSize().then(resultSize => {
+        this.rows(resultSize.rows);
       });
     }, 2000);
 
-    await this.fetchMoreRows(100, false);
-
     // TODO: load additional 100 in background
     /*