@@ -39,7 +39,7 @@ export class TestPage extends DisplayComponent<TestPageProps> {
3939 index : 0 ,
4040 arguments : [ "url: string" ] ,
4141 name : "DownloadNavigationData" ,
42- functionCallback : input => this . props . interface . download_navigation_data ( input ?? "" ) ,
42+ functionCallback : input => this . props . interface . download_navigation_data ( input || "" ) ,
4343 } ,
4444 {
4545 index : 1 ,
@@ -51,163 +51,172 @@ export class TestPage extends DisplayComponent<TestPageProps> {
5151 index : 2 ,
5252 arguments : [ "ident: string" ] ,
5353 name : "GetAirport" ,
54- functionCallback : input => this . props . interface . get_airport ( input ?? "" ) ,
54+ functionCallback : input => this . props . interface . get_airport ( input || "" ) ,
5555 } ,
5656 {
5757 index : 3 ,
5858 arguments : [ "ident: string" ] ,
5959 name : "GetWaypoints" ,
60- functionCallback : input => this . props . interface . get_waypoints ( input ?? "" ) ,
60+ functionCallback : input => this . props . interface . get_waypoints ( input || "" ) ,
6161 } ,
6262 {
6363 index : 4 ,
6464 arguments : [ "ident: string" ] ,
6565 name : "GetVhfNavaids" ,
66- functionCallback : input => this . props . interface . get_vhf_navaids ( input ?? "" ) ,
66+ functionCallback : input => this . props . interface . get_vhf_navaids ( input || "" ) ,
6767 } ,
6868 {
6969 index : 5 ,
7070 arguments : [ "ident: string" ] ,
7171 name : "GetNdbNavaids" ,
72- functionCallback : input => this . props . interface . get_ndb_navaids ( input ?? "" ) ,
72+ functionCallback : input => this . props . interface . get_ndb_navaids ( input || "" ) ,
7373 } ,
7474 {
7575 index : 6 ,
7676 arguments : [ "ident: string" ] ,
7777 name : "GetAirways" ,
78- functionCallback : input => this . props . interface . get_airways ( input ?? "" ) ,
78+ functionCallback : input => this . props . interface . get_airways ( input || "" ) ,
7979 } ,
8080 {
8181 index : 7 ,
8282 arguments : [ "fixIdent: string" , "fixIcao: string" ] ,
8383 name : "GetAirwaysAtFix" ,
84- functionCallback : ( input , inputAlt ) => this . props . interface . get_airways_at_fix ( input ?? "" , inputAlt ?? "" ) ,
84+ functionCallback : ( input , inputAlt ) => this . props . interface . get_airways_at_fix ( input || "" , input || "" ) ,
8585 } ,
8686 {
8787 index : 8 ,
8888 arguments : [ "center: (lat, long)" , "range: nm" ] ,
8989 name : "GetAirportsInRange" ,
9090 functionCallback : ( input , inputAlt ) =>
91- this . props . interface . get_airports_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
91+ this . props . interface . get_airports_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
9292 } ,
9393 {
9494 index : 9 ,
9595 arguments : [ "center: (lat, long)" , "range: nm" ] ,
9696 name : "GetWaypointsInRange" ,
9797 functionCallback : ( input , inputAlt ) =>
98- this . props . interface . get_waypoints_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
98+ this . props . interface . get_waypoints_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
9999 } ,
100100 {
101101 index : 10 ,
102102 arguments : [ "center: (lat, long)" , "range: nm" ] ,
103103 name : "GetVhfNavaidsInRange" ,
104104 functionCallback : ( input , inputAlt ) =>
105- this . props . interface . get_vhf_navaids_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
105+ this . props . interface . get_vhf_navaids_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
106106 } ,
107107 {
108108 index : 11 ,
109109 arguments : [ "center: (lat, long)" , "range: nm" ] ,
110110 name : "GetNdbNavaidsInRange" ,
111111 functionCallback : ( input , inputAlt ) =>
112- this . props . interface . get_ndb_navaids_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
112+ this . props . interface . get_ndb_navaids_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
113113 } ,
114114 {
115115 index : 12 ,
116116 arguments : [ "center: (lat, long)" , "range: nm" ] ,
117117 name : "GetAirwaysInRange" ,
118118 functionCallback : ( input , inputAlt ) =>
119- this . props . interface . get_airways_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
119+ this . props . interface . get_airways_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
120120 } ,
121121 {
122122 index : 13 ,
123123 arguments : [ "center: (lat, long)" , "range: nm" ] ,
124124 name : "GetControlledAirspacesInRange" ,
125125 functionCallback : ( input , inputAlt ) =>
126- this . props . interface . get_controlled_airspaces_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
126+ this . props . interface . get_controlled_airspaces_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
127127 } ,
128128 {
129129 index : 14 ,
130130 arguments : [ "center: (lat, long)" , "range: nm" ] ,
131131 name : "GetRestrictiveAirspacesInRange" ,
132132 functionCallback : ( input , inputAlt ) =>
133- this . props . interface . get_restrictive_airspaces_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
133+ this . props . interface . get_restrictive_airspaces_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
134134 } ,
135135 {
136136 index : 15 ,
137137 arguments : [ "center: (lat, long)" , "range: nm" ] ,
138138 name : "GetCommunicationsInRange" ,
139139 functionCallback : ( input , inputAlt ) =>
140- this . props . interface . get_communications_in_range ( this . strToCoords ( input ) , Number ( inputAlt ?? 0 ) ) ,
140+ this . props . interface . get_communications_in_range ( this . strToCoords ( input || "" ) , Number ( inputAlt || 0 ) ) ,
141141 } ,
142142 {
143143 index : 16 ,
144144 arguments : [ "airportIdent: string" ] ,
145145 name : "GetRunwaysAtAirport" ,
146- functionCallback : input => this . props . interface . get_runways_at_airport ( input ?? "" ) ,
146+ functionCallback : input => this . props . interface . get_runways_at_airport ( input || "" ) ,
147147 } ,
148148 {
149149 index : 17 ,
150150 arguments : [ "airportIdent: string" ] ,
151151 name : "GetDeparturesAtAirport" ,
152- functionCallback : input => this . props . interface . get_departures_at_airport ( input ?? "" ) ,
152+ functionCallback : input => this . props . interface . get_departures_at_airport ( input || "" ) ,
153153 } ,
154154 {
155155 index : 18 ,
156156 arguments : [ "airportIdent: string" ] ,
157157 name : "GetArrivalsAtAirport" ,
158- functionCallback : input => this . props . interface . get_arrivals_at_airport ( input ?? "" ) ,
158+ functionCallback : input => this . props . interface . get_arrivals_at_airport ( input || "" ) ,
159159 } ,
160160 {
161161 index : 19 ,
162162 arguments : [ "airportIdent: string" ] ,
163163 name : "GetApproachesAtAirport" ,
164- functionCallback : input => this . props . interface . get_approaches_at_airport ( input ?? "" ) ,
164+ functionCallback : input => this . props . interface . get_approaches_at_airport ( input || "" ) ,
165165 } ,
166166 {
167167 index : 20 ,
168168 arguments : [ "airportIdent: string" ] ,
169169 name : "GetWaypointsAtAirport" ,
170- functionCallback : input => this . props . interface . get_waypoints_at_airport ( input ?? "" ) ,
170+ functionCallback : input => this . props . interface . get_waypoints_at_airport ( input || "" ) ,
171171 } ,
172172 {
173173 index : 21 ,
174174 arguments : [ "airportIdent: string" ] ,
175175 name : "GetNdbNavaidsAtAirport" ,
176- functionCallback : input => this . props . interface . get_ndb_navaids_at_airport ( input ?? "" ) ,
176+ functionCallback : input => this . props . interface . get_ndb_navaids_at_airport ( input || "" ) ,
177177 } ,
178178 {
179179 index : 22 ,
180180 arguments : [ "airportIdent: string" ] ,
181181 name : "GetGatesAtAirport" ,
182- functionCallback : input => this . props . interface . get_gates_at_airport ( input ?? "" ) ,
182+ functionCallback : input => this . props . interface . get_gates_at_airport ( input || "" ) ,
183183 } ,
184184 {
185185 index : 23 ,
186186 arguments : [ "airportIdent: string" ] ,
187187 name : "GetCommunicationsAtAirport" ,
188- functionCallback : input => this . props . interface . get_communications_at_airport ( input ?? "" ) ,
188+ functionCallback : input => this . props . interface . get_communications_at_airport ( input || "" ) ,
189189 } ,
190190 {
191191 index : 24 ,
192192 arguments : [ "airportIdent: string" ] ,
193193 name : "GetGlsNavaidsAtAirport" ,
194- functionCallback : input => this . props . interface . get_gls_navaids_at_airport ( input ?? "" ) ,
194+ functionCallback : input => this . props . interface . get_gls_navaids_at_airport ( input || "" ) ,
195195 } ,
196196 {
197197 index : 25 ,
198198 arguments : [ "airportIdent: string" ] ,
199199 name : "GetPathPointsAtAirport" ,
200- functionCallback : input => this . props . interface . get_path_points_at_airport ( input ?? "" ) ,
200+ functionCallback : input => this . props . interface . get_path_points_at_airport ( input || "" ) ,
201201 } ,
202202 {
203203 index : 26 ,
204204 arguments : [ "sql: string" , "params: string[]" ] ,
205205 name : "ExecuteSQLQuery" ,
206- functionCallback : ( input , inputAlt ) =>
207- this . props . interface . execute_sql (
208- input ?? "" ,
209- inputAlt ?. replace ( "[" , "" ) . replace ( "]" , "" ) . replace ( '"' , "" ) . split ( "," ) ?? [ ] ,
210- ) ,
206+ functionCallback : ( input , inputAlt ) => {
207+ // Try to parse the argument as a JSON formatted array, falling back to an empty array if needed. We also force all values to strings since that is what the backend expects
208+ let argsList : string [ ] = [ ] ;
209+ if ( inputAlt ) {
210+ try {
211+ const parsed = JSON . parse ( inputAlt ) ;
212+ argsList = Array . isArray ( parsed ) ? parsed . map ( v => String ( v ) ) : [ ] ;
213+ } catch ( e ) {
214+ console . error ( `Error parsing argument input: ${ e } . Falling back to empty list` ) ;
215+ }
216+ }
217+
218+ return this . props . interface . execute_sql ( input || "" , argsList ) ;
219+ } ,
211220 } ,
212221 {
213222 index : 27 ,
@@ -240,12 +249,8 @@ export class TestPage extends DisplayComponent<TestPageProps> {
240249 this . input2State ,
241250 ) ;
242251
243- private strToBool ( input ?: string ) : boolean {
244- return input == "true" ? true : false ;
245- }
246-
247- private strToCoords ( input ?: string ) : Coordinates {
248- const splitInput = ( input ?? "" ) . replace ( / [ ( ) { } \s ] / g, "" ) . split ( "," ) ;
252+ private strToCoords ( input : string ) : Coordinates {
253+ const splitInput = input . replace ( / [ ( ) { } \s ] / g, "" ) . split ( "," ) ;
249254
250255 const coords : Coordinates = {
251256 lat : Number ( splitInput [ 0 ] ?? 0.0 ) ,
@@ -257,8 +262,8 @@ export class TestPage extends DisplayComponent<TestPageProps> {
257262
258263 private handleFunction = ( ) => {
259264 const functionObj = this . selectedFunctionObj . get ( ) ;
260- const input1 = this . input1 . get ( ) ;
261- const input2 = this . input2 . get ( ) ;
265+ const input1 = this . input1 . get ( ) || undefined ;
266+ const input2 = this . input2 . get ( ) || undefined ;
262267
263268 functionObj
264269 . functionCallback ( input1 , input2 )
0 commit comments