@@ -22,8 +22,10 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
2222 private readonly qrCodeRef = FSComponent . createRef < HTMLImageElement > ( )
2323 private readonly dropdownRef = FSComponent . createRef < Dropdown > ( )
2424 private readonly downloadButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
25- private readonly executeButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
26- private readonly inputRef = FSComponent . createRef < Input > ( )
25+ private readonly icaoInputRef = FSComponent . createRef < Input > ( )
26+ private readonly executeIcaoButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
27+ private readonly sqlInputRef = FSComponent . createRef < Input > ( )
28+ private readonly executeSqlButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
2729 private readonly outputRef = FSComponent . createRef < HTMLPreElement > ( )
2830
2931 private cancelSource = CancelToken . source ( )
@@ -78,10 +80,20 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
7880 < h4 style = "text-align: center;" > Step 3 - Query the database</ h4 >
7981 < div class = "horizontal" >
8082 < div class = "vertical" >
81- < Input ref = { this . inputRef } type = "text" value = "ESSA" class = "text-field" />
82- < div ref = { this . executeButtonRef } class = "button" >
83+ < Input ref = { this . icaoInputRef } value = "ESSA" class = "text-field" />
84+ < div ref = { this . executeIcaoButtonRef } class = "button" >
8385 Fetch Airport
8486 </ div >
87+ < div style = "height:30px;" > </ div >
88+ < Input
89+ ref = { this . sqlInputRef }
90+ textarea
91+ value = "SELECT airport_name FROM tbl_airports WHERE airport_identifier = 'ESSA'"
92+ class = "text-field"
93+ />
94+ < div ref = { this . executeSqlButtonRef } class = "button" >
95+ Execute SQL
96+ </ div >
8597 </ div >
8698 < pre ref = { this . outputRef } id = "output" >
8799 The output of the query will show up here
@@ -97,19 +109,30 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
97109 this . loginButtonRef . instance . addEventListener ( "click" , ( ) => this . handleClick ( ) )
98110 this . downloadButtonRef . instance . addEventListener ( "click" , ( ) => this . handleDownloadClick ( ) )
99111
100- this . executeButtonRef . instance . addEventListener ( "click" , ( ) => {
112+ this . executeIcaoButtonRef . instance . addEventListener ( "click" , ( ) => {
101113 console . time ( "query" )
102114 this . navigationDataInterface
103- . get_airport ( this . inputRef . instance . value )
115+ . get_airport ( this . icaoInputRef . instance . value )
104116 . then ( airport => {
105117 console . info ( airport )
106-
107118 this . outputRef . instance . textContent = JSON . stringify ( airport , null , 2 )
108119 } )
109120 . catch ( e => console . error ( e ) )
110121 . finally ( ( ) => console . timeEnd ( "query" ) )
111122 } )
112123
124+ this . executeSqlButtonRef . instance . addEventListener ( "click" , ( ) => {
125+ console . time ( "query" )
126+ this . navigationDataInterface
127+ . execute_sql ( this . sqlInputRef . instance . value , [ ] )
128+ . then ( result => {
129+ console . info ( result )
130+ this . outputRef . instance . textContent = JSON . stringify ( result , null , 2 )
131+ } )
132+ . catch ( e => console . error ( e ) )
133+ . finally ( ( ) => console . timeEnd ( "query" ) )
134+ } )
135+
113136 AuthService . user . sub ( user => {
114137 if ( user ) {
115138 this . qrCodeRef . instance . src = ""
0 commit comments