@@ -24,6 +24,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
2424 private readonly downloadButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
2525 private readonly executeButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
2626 private readonly inputRef = FSComponent . createRef < Input > ( )
27+ private readonly outputRef = FSComponent . createRef < HTMLPreElement > ( )
2728
2829 private cancelSource = CancelToken . source ( )
2930
@@ -59,21 +60,32 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
5960 < div class = "auth-container" >
6061 < div class = "horizontal" >
6162 < div class = "vertical" >
63+ < h4 > Step 1 - Sign in</ h4 >
6264 < div ref = { this . textRef } > Loading</ div >
6365 < div ref = { this . loginButtonRef } class = "button" />
6466 < div ref = { this . navigationDataTextRef } />
6567 < img ref = { this . qrCodeRef } class = "qr-code" />
6668 </ div >
6769 < div class = "vertical" >
70+ < h4 > Step 2 - Select Database</ h4 >
6871 < Dropdown ref = { this . dropdownRef } />
6972 < div ref = { this . downloadButtonRef } class = "button" >
7073 Download
7174 </ div >
75+ </ div >
76+ </ div >
77+
78+ < h4 style = "text-align: center;" > Step 3 - Query the database</ h4 >
79+ < div class = "horizontal" >
80+ < div class = "vertical" >
7281 < Input ref = { this . inputRef } type = "text" value = "ESSA" class = "text-field" />
7382 < div ref = { this . executeButtonRef } class = "button" >
7483 Fetch Airport
7584 </ div >
7685 </ div >
86+ < pre ref = { this . outputRef } id = "output" >
87+ The output of the query will show up here
88+ </ pre >
7789 </ div >
7890 </ div >
7991 )
@@ -89,7 +101,11 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
89101 console . time ( "query" )
90102 this . navigationDataInterface
91103 . get_airport ( this . inputRef . instance . value )
92- . then ( airport => console . info ( airport ) )
104+ . then ( airport => {
105+ console . info ( airport )
106+
107+ this . outputRef . instance . textContent = JSON . stringify ( airport , null , 2 )
108+ } )
93109 . catch ( e => console . error ( e ) )
94110 . finally ( ( ) => console . timeEnd ( "query" ) )
95111 } )
@@ -100,6 +116,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
100116 this . qrCodeRef . instance . style . display = "none"
101117 this . loginButtonRef . instance . textContent = "Log out"
102118 this . textRef . instance . textContent = `Welcome, ${ user . preferred_username } `
119+ this . displayMessage ( "" )
103120
104121 this . handleLogin ( )
105122 } else {
@@ -115,6 +132,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
115132 await AuthService . signOut ( )
116133 } else {
117134 this . cancelSource = CancelToken . source ( ) // Reset any previous cancellations
135+ this . displayMessage ( "Authenticating.. Scan code (or click it) to sign in" )
118136 await AuthService . signIn ( p => {
119137 if ( p ) {
120138 this . qrCodeRef . instance . src = `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${ p . verification_uri_complete } `
@@ -126,6 +144,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
126144 } , this . cancelSource . token )
127145 }
128146 } catch ( err ) {
147+ this . qrCodeRef . instance . style . display = "none"
129148 if ( err instanceof Error ) this . displayError ( err . message )
130149 else this . displayError ( `Unknown error: ${ String ( err ) } ` )
131150 }
0 commit comments