@@ -67,7 +67,7 @@ import { JSONObject, JSONValue } from "../../util/jsonTypes";
6767import { BoolPureControl } from "../controls/boolControl" ;
6868import { millisecondsControl } from "../controls/millisecondControl" ;
6969import { paramsMillisecondsControl } from "../controls/paramsControl" ;
70- import { NameConfig , withExposingConfigs } from "../generators/withExposing" ;
70+ import { DepsConfig , NameConfig , withExposingConfigs } from "../generators/withExposing" ;
7171import { HttpQuery } from "./httpQuery/httpQuery" ;
7272import { StreamQuery } from "./httpQuery/streamQuery" ;
7373import { QueryConfirmationModal } from "./queryComp/queryConfirmationModal" ;
@@ -135,7 +135,6 @@ const childrenMap = {
135135data :stateComp < JSONValue > ( null ) ,
136136extra :stateComp < JSONValue > ( { } ) ,
137137isFetching :stateComp < boolean > ( false ) ,
138- variable :stateComp < JSONObject > ( { } ) ,
139138lastQueryStartTime :stateComp < number > ( - 1 ) , // The last execution time of the query, in order to avoid multiple executions overwriting each other, not persistent
140139latestEndTime :stateComp < number > ( 0 ) , // The time when the query was last executed
141140runTime :stateComp < number > ( 0 ) , // query run time
@@ -364,14 +363,8 @@ QueryCompTmp = class extends QueryCompTmp {
364363}
365364if ( action . type === CompActionTypes . EXECUTE_QUERY ) {
366365if ( 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+
375368return this . executeQuery ( action ) ;
376369}
377370if ( action . type === CompActionTypes . CHANGE_VALUE ) {
@@ -486,6 +479,7 @@ QueryCompTmp = class extends QueryCompTmp {
486479applicationId :applicationId ,
487480applicationPath :parentApplicationPath ,
488481args :action . args ,
482+ variables :action . args ,
489483timeout :this . children . timeout ,
490484callback :( result ) => this . processResult ( result , action , startTime )
491485} ) ;
@@ -669,7 +663,23 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
669663new NameConfig ( "isFetching" , trans ( "query.isFetchingExportDesc" ) ) ,
670664new NameConfig ( "runTime" , trans ( "query.runTimeExportDesc" ) ) ,
671665new 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+ ) ,
673683new NameConfig ( "triggerType" , trans ( "query.triggerTypeExportDesc" ) ) ,
674684] ) ;
675685