@@ -181,6 +181,10 @@ export class SparqlEditor extends HTMLElement {
181181 // Load current endpoint in the YASGUI input box
182182 async loadCurrentEndpoint ( endpoint : string = this . endpointUrl ( ) ) {
183183 // console.log("Switching endpoint", endpoint);
184+ const statusLight = this . querySelector ( "#status-light" ) as HTMLElement ;
185+ const statusLink = this . querySelector ( "#status-link" ) as HTMLAnchorElement ;
186+ statusLight . style . backgroundColor = "purple" ;
187+ statusLink . title = "Loading..." ;
184188 await this . getMetadata ( endpoint ) ;
185189 if ( this . yasgui ) {
186190 // @ts -ignore set default query when new tab
@@ -189,7 +193,6 @@ export class SparqlEditor extends HTMLElement {
189193 }
190194 Yasgui . Yasr . defaults . prefixes = this . meta [ endpoint ] . prefixes ;
191195 // Update the statusLight
192- const statusLight = this . querySelector ( "#status-light" ) as HTMLElement ;
193196 let metaScore = 0 ;
194197 let statusMsg = `📡 Endpoint ${ endpoint } \n\n` ;
195198 if ( Object . keys ( this . meta [ endpoint ] . void ) . length > 0 ) {
@@ -222,7 +225,6 @@ export class SparqlEditor extends HTMLElement {
222225 if ( metaScore === 3 ) statusLight . style . backgroundColor = "green" ;
223226 else if ( metaScore > 0 ) statusLight . style . backgroundColor = "orange" ;
224227 else statusLight . style . backgroundColor = "red" ;
225- const statusLink = this . querySelector ( "#status-link" ) as HTMLAnchorElement ;
226228 statusLink . title = statusMsg ;
227229 statusLink . href = `https://sib-swiss.github.io/sparql-editor/check?url=${ endpoint } ` ;
228230 }
@@ -245,15 +247,15 @@ export class SparqlEditor extends HTMLElement {
245247 if ( spinEl ) spinEl . style . display = "none" ;
246248
247249 this . yasgui ?. on ( "tabSelect" , ( ) => {
248- setTimeout ( ( ) => {
249- this . loadCurrentEndpoint ( ) ;
250- this . showExamples ( ) ;
250+ setTimeout ( async ( ) => {
251+ await this . loadCurrentEndpoint ( ) ;
252+ await this . showExamples ( ) ;
251253 } ) ;
252254 } ) ;
253255 this . yasgui ?. on ( "endpointHistoryChange" , ( ) => {
254- setTimeout ( ( ) => {
255- this . loadCurrentEndpoint ( ) ;
256- this . showExamples ( true ) ;
256+ setTimeout ( async ( ) => {
257+ await this . loadCurrentEndpoint ( ) ;
258+ await this . showExamples ( true ) ;
257259 } ) ;
258260 } ) ;
259261 this . yasgui ?. on ( "tabAdd" , ( ) => {
@@ -262,10 +264,11 @@ export class SparqlEditor extends HTMLElement {
262264
263265 // Button to clear and update cache of SPARQL endpoints metadata
264266 const clearCacheBtnEl = this . querySelector ( "#sparql-clear-cache-btn" ) ;
265- clearCacheBtnEl ?. addEventListener ( "click" , ( ) => {
267+ clearCacheBtnEl ?. addEventListener ( "click" , async ( ) => {
266268 localStorage . removeItem ( "sparql-editor-metadata" ) ;
267269 this . meta = { } ;
268- this . loadCurrentEndpoint ( ) ;
270+ await this . loadCurrentEndpoint ( ) ;
271+ await this . showExamples ( true ) ;
269272 } ) ;
270273
271274 // Button to add all prefixes to the query
0 commit comments