浏览代码

HUE-9291 [editor] Append streaming results in the result grid component

Johan Ahlen 5 年之前
父节点
当前提交
84c50fdde2

+ 4 - 1
desktop/core/src/desktop/js/apps/notebook2/components/resultGrid/ko.resultGrid.js

@@ -440,7 +440,10 @@ class ResultGrid extends DisposableComponent {
     });
 
     const dataScroll = () => {
-      if (!$resultTable.is(':visible')) {
+      if (
+        !$resultTable.is(':visible') ||
+        (this.activeExecutable().result && this.activeExecutable().result.streaming)
+      ) {
         return;
       }
 

+ 2 - 2
desktop/core/src/desktop/js/apps/notebook2/components/resultGrid/ko.simpleResultGrid.js

@@ -32,7 +32,7 @@ import {
 import { trackResult } from 'apps/notebook2/components/executableStateHandler';
 import { EXECUTION_STATUS } from 'apps/notebook2/execution/executable';
 
-export const NAME = 'simple-result-grid';
+export const SIMPLE_RESULT_GRID_COMPONENT = 'simple-result-grid';
 
 // prettier-ignore
 const TEMPLATE = `
@@ -369,7 +369,7 @@ class SimpleResultGrid extends DisposableComponent {
 }
 
 componentUtils.registerComponent(
-  NAME,
+  SIMPLE_RESULT_GRID_COMPONENT,
   {
     createViewModel: (params, componentInfo) => new SimpleResultGrid(params, componentInfo.element)
   },

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

@@ -295,6 +295,11 @@ export default class Executable {
           case EXECUTION_STATUS.streaming:
             if (window.WEB_SOCKETS_ENABLED) {
               huePubSub.publish('editor.ws.query.fetch_result', queryStatus);
+            } else {
+              if (!this.result) {
+                this.result = new ExecutionResult(this, true);
+              }
+              this.result.handleResultResponse(queryStatus);
             }
           case EXECUTION_STATUS.running:
           case EXECUTION_STATUS.starting:

+ 3 - 1
desktop/core/src/desktop/js/apps/notebook2/execution/executionResult.js

@@ -78,11 +78,13 @@ export default class ExecutionResult {
   /**
    *
    * @param {Executable} executable
+   * @param {boolean} [streaming] (default false)
    */
-  constructor(executable) {
+  constructor(executable, streaming) {
     this.executable = executable;
 
     this.type = RESULT_TYPE.TABLE;
+    this.streaming = streaming;
     this.rows = [];
     this.meta = [];
 

+ 2 - 2
desktop/core/src/desktop/js/ko/components/contextPopover/ko.quickQueryContext.js

@@ -20,7 +20,7 @@ import { MULTI_NAME as SIMPLE_ACE_MULTI } from 'ko/components/simpleAceEditor/ko
 import { CONTEXT_SELECTOR_COMPONENT } from 'ko/components/ko.contextSelector';
 import { NAME as DROP_DOWN } from 'ko/components/ko.dropDown';
 import { NAME as EXECUTABLE_ACTIONS } from 'apps/notebook2/components/ko.executableActions';
-import { NAME as SIMPLE_RESULT_GRID } from 'apps/notebook2/components/resultGrid/ko.simpleResultGrid';
+import { SIMPLE_RESULT_GRID_COMPONENT } from 'apps/notebook2/components/resultGrid/ko.simpleResultGrid';
 
 import componentUtils from 'ko/components/componentUtils';
 import DisposableComponent from 'ko/components/DisposableComponent';
@@ -91,7 +91,7 @@ const TEMPLATE = `
       "></div>
       <div data-bind="
         component: {
-          name: '${ SIMPLE_RESULT_GRID }',
+          name: '${ SIMPLE_RESULT_GRID_COMPONENT }',
           params: { activeExecutable: $parent.activeExecutable }
         }
       "></div>