@@ -24,6 +24,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
24
24
private readonly downloadButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
25
25
private readonly executeButtonRef = FSComponent . createRef < HTMLButtonElement > ( )
26
26
private readonly inputRef = FSComponent . createRef < Input > ( )
27
+ private readonly outputRef = FSComponent . createRef < HTMLPreElement > ( )
27
28
28
29
private cancelSource = CancelToken . source ( )
29
30
@@ -59,21 +60,32 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
59
60
< div class = "auth-container" >
60
61
< div class = "horizontal" >
61
62
< div class = "vertical" >
63
+ < h4 > Step 1 - Sign in</ h4 >
62
64
< div ref = { this . textRef } > Loading</ div >
63
65
< div ref = { this . loginButtonRef } class = "button" />
64
66
< div ref = { this . navigationDataTextRef } />
65
67
< img ref = { this . qrCodeRef } class = "qr-code" />
66
68
</ div >
67
69
< div class = "vertical" >
70
+ < h4 > Step 2 - Select Database</ h4 >
68
71
< Dropdown ref = { this . dropdownRef } />
69
72
< div ref = { this . downloadButtonRef } class = "button" >
70
73
Download
71
74
</ 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" >
72
81
< Input ref = { this . inputRef } type = "text" value = "ESSA" class = "text-field" />
73
82
< div ref = { this . executeButtonRef } class = "button" >
74
83
Fetch Airport
75
84
</ div >
76
85
</ div >
86
+ < pre ref = { this . outputRef } id = "output" >
87
+ The output of the query will show up here
88
+ </ pre >
77
89
</ div >
78
90
</ div >
79
91
)
@@ -89,7 +101,11 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
89
101
console . time ( "query" )
90
102
this . navigationDataInterface
91
103
. 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
+ } )
93
109
. catch ( e => console . error ( e ) )
94
110
. finally ( ( ) => console . timeEnd ( "query" ) )
95
111
} )
@@ -100,6 +116,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
100
116
this . qrCodeRef . instance . style . display = "none"
101
117
this . loginButtonRef . instance . textContent = "Log out"
102
118
this . textRef . instance . textContent = `Welcome, ${ user . preferred_username } `
119
+ this . displayMessage ( "" )
103
120
104
121
this . handleLogin ( )
105
122
} else {
@@ -115,6 +132,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
115
132
await AuthService . signOut ( )
116
133
} else {
117
134
this . cancelSource = CancelToken . source ( ) // Reset any previous cancellations
135
+ this . displayMessage ( "Authenticating.. Scan code (or click it) to sign in" )
118
136
await AuthService . signIn ( p => {
119
137
if ( p ) {
120
138
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> {
126
144
} , this . cancelSource . token )
127
145
}
128
146
} catch ( err ) {
147
+ this . qrCodeRef . instance . style . display = "none"
129
148
if ( err instanceof Error ) this . displayError ( err . message )
130
149
else this . displayError ( `Unknown error: ${ String ( err ) } ` )
131
150
}
0 commit comments