@@ -46,8 +46,9 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
4646 private readonly authContainerRef = FSComponent . createRef < HTMLDivElement > ( )
4747
4848 private readonly activeDatabase = Subject . create < PackageInfo | null > ( null )
49- private readonly databases = Subject . create < PackageInfo [ ] > ( [ ] )
49+ private readonly databases = ArraySubject . create < PackageInfo > ( [ ] )
5050 private readonly mainPageIndex = Subject . create ( 0 )
51+ private readonly selectedDatabase = Subject . create < PackageInfo | null > ( null )
5152
5253 private cancelSource = CancelToken . source ( )
5354
@@ -102,7 +103,16 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
102103 class = "bg-ng-background-400"
103104 active = { this . mainPageIndex }
104105 pages = { [
105- [ 0 , < Dashboard activeDatabase = { this . activeDatabase } databases = { this . databases } /> ] ,
106+ [
107+ 0 ,
108+ < Dashboard
109+ activeDatabase = { this . activeDatabase }
110+ databases = { this . databases }
111+ selectedDatabase = { this . selectedDatabase }
112+ setSelectedDatabase = { database => this . selectedDatabase . set ( database ) }
113+ interface = { this . navigationDataInterface }
114+ /> ,
115+ ] ,
106116 [ 1 , < TestPage /> ] ,
107117 [ 2 , < AuthPage /> ] ,
108118 ] }
@@ -166,7 +176,10 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
166176
167177 // Populate status when ready
168178 this . navigationDataInterface . onReady ( async ( ) => {
169- this . activeDatabase . set ( await this . navigationDataInterface . get_active_package ( ) )
179+ const activePackage = await this . navigationDataInterface . get_active_package ( )
180+
181+ this . activeDatabase . set ( activePackage )
182+ this . selectedDatabase . set ( activePackage )
170183 this . navigationDataInterface
171184 . list_available_packages ( true )
172185 . then ( pkgs => {
@@ -179,49 +192,49 @@ export class InterfaceSample extends DisplayComponent<InterfaceSampleProps> {
179192 this . loadingRef . instance . style . display = "none"
180193 } )
181194
182- this . loginButtonRef . instance . addEventListener ( "click" , ( ) => this . handleClick ( ) )
183- this . downloadButtonRef . instance . addEventListener ( "click" , ( ) => this . handleDownloadClick ( ) )
184-
185- this . executeIcaoButtonRef . instance . addEventListener ( "click" , ( ) => {
186- console . time ( "query" )
187- this . navigationDataInterface
188- . get_arrivals_at_airport ( this . icaoInputRef . instance . value )
189- . then ( procedures => {
190- console . info ( procedures )
191- this . outputRef . instance . textContent = JSON . stringify ( procedures , null , 2 )
192- } )
193- . catch ( e => console . error ( e ) )
194- . finally ( ( ) => console . timeEnd ( "query" ) )
195- } )
196-
197- this . loadDbRef . instance . addEventListener ( "click" , ( ) => this . handleLoadDbClick ( ) )
198-
199- this . executeSqlButtonRef . instance . addEventListener ( "click" , ( ) => {
200- console . time ( "query" )
201- this . navigationDataInterface
202- . execute_sql ( this . sqlInputRef . instance . value , [ ] )
203- . then ( result => {
204- console . info ( result )
205- this . outputRef . instance . textContent = JSON . stringify ( result , null , 2 )
206- } )
207- . catch ( e => console . error ( e ) )
208- . finally ( ( ) => console . timeEnd ( "query" ) )
209- } )
210-
211- AuthService . user . sub ( user => {
212- if ( user ) {
213- this . qrCodeRef . instance . src = ""
214- this . qrCodeRef . instance . style . display = "none"
215- this . loginButtonRef . instance . textContent = "Log out"
216- this . textRef . instance . textContent = `Welcome, ${ user . preferred_username } `
217- this . displayMessage ( "" )
218-
219- this . handleLogin ( )
220- } else {
221- this . loginButtonRef . instance . textContent = "Sign in"
222- this . textRef . instance . textContent = "Not logged in"
223- }
224- } , true )
195+ // this.loginButtonRef.instance.addEventListener("click", () => this.handleClick())
196+ // this.downloadButtonRef.instance.addEventListener("click", () => this.handleDownloadClick())
197+
198+ // this.executeIcaoButtonRef.instance.addEventListener("click", () => {
199+ // console.time("query")
200+ // this.navigationDataInterface
201+ // .get_arrivals_at_airport(this.icaoInputRef.instance.value)
202+ // .then(procedures => {
203+ // console.info(procedures)
204+ // this.outputRef.instance.textContent = JSON.stringify(procedures, null, 2)
205+ // })
206+ // .catch(e => console.error(e))
207+ // .finally(() => console.timeEnd("query"))
208+ // })
209+
210+ // this.loadDbRef.instance.addEventListener("click", () => this.handleLoadDbClick())
211+
212+ // this.executeSqlButtonRef.instance.addEventListener("click", () => {
213+ // console.time("query")
214+ // this.navigationDataInterface
215+ // .execute_sql(this.sqlInputRef.instance.value, [])
216+ // .then(result => {
217+ // console.info(result)
218+ // this.outputRef.instance.textContent = JSON.stringify(result, null, 2)
219+ // })
220+ // .catch(e => console.error(e))
221+ // .finally(() => console.timeEnd("query"))
222+ // })
223+
224+ // AuthService.user.sub(user => {
225+ // if (user) {
226+ // this.qrCodeRef.instance.src = ""
227+ // this.qrCodeRef.instance.style.display = "none"
228+ // this.loginButtonRef.instance.textContent = "Log out"
229+ // this.textRef.instance.textContent = `Welcome, ${user.preferred_username}`
230+ // this.displayMessage("")
231+
232+ // this.handleLogin()
233+ // } else {
234+ // this.loginButtonRef.instance.textContent = "Sign in"
235+ // this.textRef.instance.textContent = "Not logged in"
236+ // }
237+ // }, true)
225238 }
226239
227240 private async handleClick ( ) {
0 commit comments