6
6
MappedSubject ,
7
7
ObjectSubject ,
8
8
Subject ,
9
+ SubscribableMapFunctions ,
9
10
VNode ,
10
11
} from "@microsoft/msfs-sdk"
11
12
import { CancelToken } from "navigraph/auth"
@@ -39,6 +40,7 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
39
40
private readonly outputRef = FSComponent . createRef < HTMLPreElement > ( )
40
41
41
42
private readonly navigationDataStatus = Subject . create < NavigationDataStatus | null > ( null )
43
+ private readonly interfaceInitialized = Subject . create ( false )
42
44
43
45
private cancelSource = CancelToken . source ( )
44
46
@@ -49,6 +51,18 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
49
51
50
52
this . navigationDataInterface = new NavigraphNavigationDataInterface ( )
51
53
54
+ // Populate status when ready
55
+ this . navigationDataInterface . onReady ( ( ) => {
56
+ this . navigationDataInterface
57
+ . get_navigation_data_install_status ( )
58
+ . then ( status => {
59
+ this . navigationDataStatus . set ( status )
60
+ } )
61
+ . catch ( e => console . error ( e ) )
62
+
63
+ this . interfaceInitialized . set ( true )
64
+ } )
65
+
52
66
this . navigationDataInterface . onEvent ( NavigraphEventType . DownloadProgress , data => {
53
67
switch ( data . phase ) {
54
68
case DownloadProgressPhase . Downloading :
@@ -101,48 +115,54 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
101
115
102
116
public render ( ) : VNode {
103
117
return (
104
- < div class = "auth-container" >
105
- < div class = "horizontal" >
106
- < div class = "vertical" >
107
- < h4 > Step 1 - Sign in</ h4 >
108
- < div ref = { this . textRef } > Loading</ div >
109
- < div ref = { this . loginButtonRef } class = "button" />
110
- < div ref = { this . navigationDataTextRef } />
111
- < img ref = { this . qrCodeRef } class = "qr-code" />
112
- </ div >
113
- < div class = "vertical" >
114
- < h4 > Step 2 - Select Database</ h4 >
115
- < Dropdown ref = { this . dropdownRef } />
116
- < div ref = { this . downloadButtonRef } class = "button" >
117
- Download
118
+ < >
119
+ < div class = "loading-container" hidden = { this . interfaceInitialized } >
120
+ Waiting for navigation data interface to initialize... If building for the first time, this may take a few
121
+ minutes
122
+ </ div >
123
+ < div class = "auth-container" hidden = { this . interfaceInitialized . map ( SubscribableMapFunctions . not ( ) ) } >
124
+ < div class = "horizontal" >
125
+ < div class = "vertical" >
126
+ < h4 > Step 1 - Sign in</ h4 >
127
+ < div ref = { this . textRef } > Loading</ div >
128
+ < div ref = { this . loginButtonRef } class = "button" />
129
+ < div ref = { this . navigationDataTextRef } />
130
+ < img ref = { this . qrCodeRef } class = "qr-code" />
131
+ </ div >
132
+ < div class = "vertical" >
133
+ < h4 > Step 2 - Select Database</ h4 >
134
+ < Dropdown ref = { this . dropdownRef } />
135
+ < div ref = { this . downloadButtonRef } class = "button" >
136
+ Download
137
+ </ div >
138
+ { this . renderDatabaseStatus ( ) }
118
139
</ div >
119
- { this . renderDatabaseStatus ( ) }
120
140
</ div >
121
- </ div >
122
141
123
- < h4 style = "text-align: center;" > Step 3 - Query the database</ h4 >
124
- < div class = "horizontal" >
125
- < div class = "vertical" >
126
- < Input ref = { this . icaoInputRef } value = "ESSA" class = "text-field" />
127
- < div ref = { this . executeIcaoButtonRef } class = "button" >
128
- Fetch Airport
129
- </ div >
130
- < div style = "height:30px;" > </ div >
131
- < Input
132
- ref = { this . sqlInputRef }
133
- textarea
134
- value = "SELECT airport_name FROM tbl_airports WHERE airport_identifier = 'ESSA'"
135
- class = "text-field"
136
- />
137
- < div ref = { this . executeSqlButtonRef } class = "button" >
138
- Execute SQL
142
+ < h4 style = "text-align: center;" > Step 3 - Query the database</ h4 >
143
+ < div class = "horizontal" >
144
+ < div class = "vertical" >
145
+ < Input ref = { this . icaoInputRef } value = "ESSA" class = "text-field" />
146
+ < div ref = { this . executeIcaoButtonRef } class = "button" >
147
+ Fetch Airport
148
+ </ div >
149
+ < div style = "height:30px;" > </ div >
150
+ < Input
151
+ ref = { this . sqlInputRef }
152
+ textarea
153
+ value = "SELECT airport_name FROM tbl_airports WHERE airport_identifier = 'ESSA'"
154
+ class = "text-field"
155
+ />
156
+ < div ref = { this . executeSqlButtonRef } class = "button" >
157
+ Execute SQL
158
+ </ div >
139
159
</ div >
160
+ < pre ref = { this . outputRef } id = "output" >
161
+ The output of the query will show up here
162
+ </ pre >
140
163
</ div >
141
- < pre ref = { this . outputRef } id = "output" >
142
- The output of the query will show up here
143
- </ pre >
144
164
</ div >
145
- </ div >
165
+ </ >
146
166
)
147
167
}
148
168
@@ -152,16 +172,6 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
152
172
this . loginButtonRef . instance . addEventListener ( "click" , ( ) => this . handleClick ( ) )
153
173
this . downloadButtonRef . instance . addEventListener ( "click" , ( ) => this . handleDownloadClick ( ) )
154
174
155
- // Populate status when ready
156
- this . navigationDataInterface . onReady ( ( ) => {
157
- this . navigationDataInterface
158
- . get_navigation_data_install_status ( )
159
- . then ( status => {
160
- this . navigationDataStatus . set ( status )
161
- } )
162
- . catch ( e => console . error ( e ) )
163
- } )
164
-
165
175
this . executeIcaoButtonRef . instance . addEventListener ( "click" , ( ) => {
166
176
console . time ( "query" )
167
177
this . navigationDataInterface
0 commit comments