@@ -22,8 +22,10 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
22
22
private readonly qrCodeRef = FSComponent . createRef < HTMLImageElement > ( )
23
23
private readonly dropdownRef = FSComponent . createRef < Dropdown > ( )
24
24
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 > ( )
27
29
private readonly outputRef = FSComponent . createRef < HTMLPreElement > ( )
28
30
29
31
private cancelSource = CancelToken . source ( )
@@ -78,10 +80,20 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
78
80
< h4 style = "text-align: center;" > Step 3 - Query the database</ h4 >
79
81
< div class = "horizontal" >
80
82
< 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" >
83
85
Fetch Airport
84
86
</ 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 >
85
97
</ div >
86
98
< pre ref = { this . outputRef } id = "output" >
87
99
The output of the query will show up here
@@ -97,19 +109,30 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
97
109
this . loginButtonRef . instance . addEventListener ( "click" , ( ) => this . handleClick ( ) )
98
110
this . downloadButtonRef . instance . addEventListener ( "click" , ( ) => this . handleDownloadClick ( ) )
99
111
100
- this . executeButtonRef . instance . addEventListener ( "click" , ( ) => {
112
+ this . executeIcaoButtonRef . instance . addEventListener ( "click" , ( ) => {
101
113
console . time ( "query" )
102
114
this . navigationDataInterface
103
- . get_airport ( this . inputRef . instance . value )
115
+ . get_airport ( this . icaoInputRef . instance . value )
104
116
. then ( airport => {
105
117
console . info ( airport )
106
-
107
118
this . outputRef . instance . textContent = JSON . stringify ( airport , null , 2 )
108
119
} )
109
120
. catch ( e => console . error ( e ) )
110
121
. finally ( ( ) => console . timeEnd ( "query" ) )
111
122
} )
112
123
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
+
113
136
AuthService . user . sub ( user => {
114
137
if ( user ) {
115
138
this . qrCodeRef . instance . src = ""
0 commit comments