@@ -6,6 +6,7 @@ const DATA_FOLDER = "simtools";
66var SIMULATORS = [ ] ;
77var TOOL_DESCRIPTIONS = { } ;
88const selected = [ ] ;
9+ var url_highlighted_node ;
910
1011// If params are null, show a default message
1112function showDetails ( data , connected ) {
@@ -183,6 +184,7 @@ function resetSearch() {
183184 updateHighlights ( ) ;
184185}
185186
187+ // INIT
186188// Load style and data from JSON files
187189Promise . all ( [
188190 fetch ( 'assets/cy-style.json' )
@@ -221,6 +223,45 @@ Promise.all([
221223 selected . push ( simulator ) ;
222224 create_cy_elements ( data , style ) ;
223225 create_filters ( ) ;
224- showDetails ( null , null ) ;
226+
227+ // showDetails of node selected in URL
228+ // Note: do not change layout here to select node, because we need to wait
229+ // for the initial layout to finish running
230+ const providedURL = new URL ( window . location . href ) ;
231+ const params = new URLSearchParams ( providedURL . search ) ;
232+
233+ if ( params . size === 0 )
234+ {
235+ console . log ( "No parameters passed, no op" ) ;
236+ showDetails ( null , null ) ;
237+ url_highlighted_node = null ;
238+ }
239+ // We only process the first value of "selected" if there are multiples
240+ else
241+ {
242+ var simulator = params . get ( 'selected' ) ;
243+ console . log ( "Simulator selected in url param list: " + simulator ) ;
244+
245+ url_highlighted_node = cy . nodes ( "[id='" + simulator + "']" )
246+
247+ if ( url_highlighted_node . empty ( ) ) {
248+ console . log ( "Provided parameter not in simulator list. No op" ) ;
249+ showDetails ( null , null ) ;
250+ }
251+ else
252+ {
253+ var node = url_highlighted_node [ 0 ] ;
254+ console . log ( "Selecting provided parameter: " + simulator ) ;
255+ showDetails ( url_highlighted_node . data ( ) , url_highlighted_node . outgoers ( "edge" ) . map ( ( edge ) => {
256+ return { type : "outgoing" , target : edge . target ( ) . id ( ) , label : edge . data ( "label" ) , source : edge . source ( ) . id ( ) } ;
257+ } ) . concat (
258+ url_highlighted_node . incomers ( "edge" ) . map ( ( edge ) => {
259+ return { type : "incoming" , target : edge . target ( ) . id ( ) , label : edge . data ( "label" ) , source : edge . source ( ) . id ( ) }
260+ } )
261+ )
262+ ) ;
263+ }
264+ }
265+
225266 }
226267) ;
0 commit comments