@@ -67,7 +67,7 @@ import { JSONObject, JSONValue } from "../../util/jsonTypes";
67
67
import { BoolPureControl } from "../controls/boolControl" ;
68
68
import { millisecondsControl } from "../controls/millisecondControl" ;
69
69
import { paramsMillisecondsControl } from "../controls/paramsControl" ;
70
- import { NameConfig , withExposingConfigs } from "../generators/withExposing" ;
70
+ import { DepsConfig , NameConfig , withExposingConfigs } from "../generators/withExposing" ;
71
71
import { HttpQuery } from "./httpQuery/httpQuery" ;
72
72
import { StreamQuery } from "./httpQuery/streamQuery" ;
73
73
import { QueryConfirmationModal } from "./queryComp/queryConfirmationModal" ;
@@ -135,7 +135,6 @@ const childrenMap = {
135
135
data : stateComp < JSONValue > ( null ) ,
136
136
extra : stateComp < JSONValue > ( { } ) ,
137
137
isFetching : stateComp < boolean > ( false ) ,
138
- variable : stateComp < JSONObject > ( { } ) ,
139
138
lastQueryStartTime : stateComp < number > ( - 1 ) , // The last execution time of the query, in order to avoid multiple executions overwriting each other, not persistent
140
139
latestEndTime : stateComp < number > ( 0 ) , // The time when the query was last executed
141
140
runTime : stateComp < number > ( 0 ) , // query run time
@@ -364,14 +363,8 @@ QueryCompTmp = class extends QueryCompTmp {
364
363
}
365
364
if ( action . type === CompActionTypes . EXECUTE_QUERY ) {
366
365
if ( getReduceContext ( ) . disableUpdateState ) return this ;
367
- let variableVal = { } ;
368
- if ( action . args ) variableVal = action . args ;
369
- else variableVal = this . children . variables . children . variables . toJsonValue ( ) . reduce ( ( acc , curr ) => Object . assign ( acc , { [ curr . key as string ] :curr . value } ) , { } ) ;
370
- //Update query.variable
371
- const changeValAction = this . children . variable . changeValueAction ( variableVal ) ;
372
- const changeValAction2 = this . changeChildAction ( "variable" , variableVal )
373
- this . dispatch ( changeValAction2 ) ;
374
- console . log ( "changed value: " , this . children . variable . toJsonValue ( ) ) ;
366
+ if ( ! action . args ) action . args = this . children . variables . children . variables . toJsonValue ( ) . reduce ( ( acc , curr ) => Object . assign ( acc , { [ curr . key as string ] :curr . value } ) , { } ) ;
367
+
375
368
return this . executeQuery ( action ) ;
376
369
}
377
370
if ( action . type === CompActionTypes . CHANGE_VALUE ) {
@@ -486,6 +479,7 @@ QueryCompTmp = class extends QueryCompTmp {
486
479
applicationId : applicationId ,
487
480
applicationPath : parentApplicationPath ,
488
481
args : action . args ,
482
+ variables : action . args ,
489
483
timeout : this . children . timeout ,
490
484
callback : ( result ) => this . processResult ( result , action , startTime )
491
485
} ) ;
@@ -669,7 +663,23 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
669
663
new NameConfig ( "isFetching" , trans ( "query.isFetchingExportDesc" ) ) ,
670
664
new NameConfig ( "runTime" , trans ( "query.runTimeExportDesc" ) ) ,
671
665
new NameConfig ( "latestEndTime" , trans ( "query.latestEndTimeExportDesc" ) ) ,
672
- new NameConfig ( "variable" , trans ( "query.variables" ) ) ,
666
+ new DepsConfig (
667
+ "variable" ,
668
+ ( children : any ) => {
669
+ return { data : children . variables . children . variables . node ( ) } ;
670
+ } ,
671
+ ( input ) => {
672
+ if ( ! input . data ) {
673
+ return undefined ;
674
+ }
675
+ const newNode = Object . values ( input . data )
676
+ . filter ( ( kvNode : any ) => kvNode . key . text . value )
677
+ . map ( ( kvNode : any ) => ( { [ kvNode . key . text . value ] : kvNode . value . text . value } ) )
678
+ . reduce ( ( prev , obj ) => ( { ...prev , ...obj } ) , { } ) ;
679
+ return newNode ;
680
+ } ,
681
+ trans ( "query.variables" )
682
+ ) ,
673
683
new NameConfig ( "triggerType" , trans ( "query.triggerTypeExportDesc" ) ) ,
674
684
] ) ;
675
685
0 commit comments