@@ -56,6 +56,10 @@ type State = {
5656 firstWhere : boolean ;
5757 whereOperators : SelectableValue < string > [ ] ;
5858 groupBy : string ;
59+ useAsyncFunction : boolean ;
60+ asyncField : string ;
61+ useCustomPostback : boolean ;
62+ postbackFunction : string ;
5963} ;
6064
6165type WhereSegment = {
@@ -175,6 +179,10 @@ export class QueryEditor extends PureComponent<Props, State> {
175179 firstWhere : true ,
176180 selectSegments : selectSegments ,
177181 groupBy : query . groupingField ,
182+ asyncField : query . asyncProcTypes ,
183+ useAsyncFunction : query . useAsyncFunction ,
184+ useCustomPostback : query . useCustomPostback ,
185+ postbackFunction : query . postbackFunction ,
178186 } ;
179187 // run the default query immediately to get default look
180188 onRunQuery ( ) ;
@@ -809,7 +817,40 @@ export class QueryEditor extends PureComponent<Props, State> {
809817
810818 return values ;
811819}
820+ useAsyncFunction ( checked ) {
821+ const { onChange, query, onRunQuery } = this . props ;
822+ if ( ! checked ) {
823+ onChange ( { ...query , useAsyncFunction : checked } ) ;
824+ onRunQuery ( ) ;
825+ this . setState ( { useAsyncFunction : checked } ) ;
826+ } else {
827+ onChange ( { ...query , useAsyncFunction : checked , asyncProcTypes : '' } ) ;
828+ onRunQuery ( ) ;
829+ this . setState ( { useAsyncFunction : checked , asyncField : '' } ) ;
830+ }
831+ }
832+
833+ asyncFieldChanged ( asyncField ) {
834+ const { onChange, query, onRunQuery } = this . props ;
835+
836+ onChange ( { ...query , asyncProcTypes : asyncField } ) ;
837+ onRunQuery ( ) ;
838+
839+ this . setState ( { asyncField : asyncField } )
840+ }
812841
842+ useCustomPostback ( checked ) {
843+ const { onChange, query, onRunQuery } = this . props ;
844+ if ( ! checked ) {
845+ onChange ( { ...query , useCustomPostback : checked } ) ;
846+ onRunQuery ( ) ;
847+ this . setState ( { useCustomPostback : checked } ) ;
848+ } else {
849+ onChange ( { ...query , useCustomPostback : checked , postbackFunction : '' } ) ;
850+ onRunQuery ( ) ;
851+ this . setState ( { useCustomPostback : checked , postbackFunction : '' } ) ;
852+ }
853+ }
813854
814855 render ( ) {
815856
@@ -1108,10 +1149,63 @@ export class QueryEditor extends PureComponent<Props, State> {
11081149 ) }
11091150 { this . state . queryTypeStr && this . state . queryTypeStr !== 'kdbSideQuery' && (
11101151 < div >
1152+ { this . state . queryTypeStr && this . state . queryTypeStr == 'functionQuery' && (
1153+ < div >
1154+ < div className = "gf-form-inline" >
1155+ < div className = "gf-form" >
1156+ < InlineFormLabel className = "gf-form-label query-keyword width-15" tooltip = "This allows use of asynchronous functions provided they utilise a postback function. Enable 'Custom Postback' if using non-TorQ Gateway." >
1157+ < span >
1158+ < input type = "checkbox" className = "width-2" checked = { this . state . useAsyncFunction } onChange = { ( e ) => this . useAsyncFunction ( e . currentTarget . checked ) } />
1159+ </ span > Use Async with Postback</ InlineFormLabel >
1160+ </ div >
1161+ { this . state . useAsyncFunction && (
1162+ < div className = "gf-form" >
1163+ < InlineFormLabel className = "query-keyword" > Proc Types:</ InlineFormLabel >
1164+ < SegmentInput
1165+ placeholder = "Proc"
1166+ value = { this . state . asyncField || '' }
1167+ onChange = { ( e : string ) => {
1168+ this . asyncFieldChanged ( e ) ;
1169+ } }
1170+ />
1171+ </ div >
1172+ ) }
1173+ { this . state . useAsyncFunction && (
1174+ < div className = "gf-form" >
1175+ < InlineFormLabel className = "gf-form-label query-keyword width-15" tooltip = "This allows use of asynchronous functions provided they utilise a postback function. Enable 'Custom Postback' if using non-TorQ Gateway." >
1176+ < span >
1177+ < input type = "checkbox" className = "width-2" checked = { this . state . useCustomPostback } onChange = { ( e ) => this . useCustomPostback ( e . currentTarget . checked ) } />
1178+ </ span > Custom Postback</ InlineFormLabel >
1179+ </ div >
1180+ ) }
1181+ < div className = "gf-form gf-form--grow" >
1182+ < div className = "gf-form-label gf-form-label--grow" > </ div >
1183+ </ div >
1184+ </ div >
1185+ { this . state . useAsyncFunction && this . state . useCustomPostback && (
1186+ < div className = "gf-form-inline" style = { { height : '111px;' } } >
1187+ < span className = "gf-form-label query-keyword width-10" style = { { height : '111px' } } />
1188+ < div style = { { height : '111px;' } } >
1189+ < textarea
1190+ className = "gf-form-textarea width-30"
1191+ rows = { 5 }
1192+ style = { { background : '#0b0c0e' } }
1193+ value = { this . state . postbackFunction }
1194+ placeholder = "Enter custom postback function"
1195+ onChange = { this . asyncFieldChanged }
1196+ />
1197+ </ div >
1198+ < div className = "gf-form gf-form--grow" >
1199+ < div className = "gf-form-label gf-form-label--grow" style = { { height : '111px' } } > </ div >
1200+ </ div >
1201+ </ div >
1202+ ) }
1203+ </ div >
1204+ ) }
11111205 { this . state . formatAs && this . state . formatAs !== 'table' && (
11121206 < div className = "gf-form-inline" >
11131207 < div className = "gf-form" >
1114- < InlineFormLabel className = "gf-form-label query-keyword width-13 " tooltip = "Used to separate selected data into relevant groups. The column specified is the one which contains the groups by which you wish to separate your data." >
1208+ < InlineFormLabel className = "gf-form-label query-keyword width-15 " tooltip = "Used to separate selected data into relevant groups. The column specified is the one which contains the groups by which you wish to separate your data." >
11151209 < span >
11161210 < input type = "checkbox" className = "width-2" checked = { this . state . useGrouping } onChange = { ( e ) => this . useGrouping ( e . currentTarget . checked ) } />
11171211 </ span > Use Grouping</ InlineFormLabel >
@@ -1134,7 +1228,7 @@ export class QueryEditor extends PureComponent<Props, State> {
11341228 ) }
11351229 < div className = "gf-form-inline" >
11361230 < div className = "gf-form" style = { { wordBreak : 'break-word' , textAlign : 'right' } } >
1137- < InlineFormLabel className = "gf-form-label query-keyword width-13 " tooltip = "Used to enable a date/time column, acting as a key for each record." >
1231+ < InlineFormLabel className = "gf-form-label query-keyword width-15 " tooltip = "Used to enable a date/time column, acting as a key for each record." >
11381232 < span >
11391233 < input type = "checkbox" className = "width-2" checked = { this . state . useTemporalField } onChange = { ( e ) => this . useTemporalField ( e . currentTarget . checked ) } />
11401234 </ span > Use Temporal Field</ InlineFormLabel >
@@ -1155,7 +1249,7 @@ export class QueryEditor extends PureComponent<Props, State> {
11551249 { this . state . useTemporalField && (
11561250 < div className = "gf-form-inline" >
11571251 < div className = "gf-form" >
1158- < InlineFormLabel className = "gf-form-label query-keyword width-13 " tooltip = "The time series data is divided into 'buckets' of time, then reduced to a single point for each interval bucket." >
1252+ < InlineFormLabel className = "gf-form-label query-keyword width-15 " tooltip = "The time series data is divided into 'buckets' of time, then reduced to a single point for each interval bucket." >
11591253 < span >
11601254 < input type = "checkbox" className = "width-2" checked = { this . state . useConflation } onChange = { ( e ) => this . useConflation ( e . currentTarget . checked ) } />
11611255 </ span > Use Conflation</ InlineFormLabel >
@@ -1305,7 +1399,7 @@ export class QueryEditor extends PureComponent<Props, State> {
13051399 // <div className="gf-form">
13061400 // <pre className="gf-form-pre alert alert-error">{error.message}</pre>
13071401 // </div>
1308- ) }
1402+ ) }
13091403 </ div >
13101404 ) ;
13111405 }
0 commit comments