1616 </ div >
1717</ div >
1818< aside class ="sidebar govuk-body ">
19+ < button id ="list-view-btn " class ="govuk-button govuk-button--secondary " style ="margin-bottom: 20px; "> Show in list view</ button >
1920 < h2 id ="sidebar-title "> No node selected</ h2 >
2021 < div id ="node-details "> < p > Select a node to view details.</ p > </ div >
2122</ aside >
@@ -27,6 +28,29 @@ <h2 id="sidebar-title">No node selected</h2>
2728 const sidebarTitle = document . getElementById ( 'sidebar-title' ) ;
2829 const details = document . getElementById ( 'node-details' ) ;
2930 const filterInput = document . getElementById ( 'graph-filter-input' ) ;
31+ const listViewBtn = document . getElementById ( 'list-view-btn' ) ;
32+
33+ let selectedNodeData = null ;
34+
35+ listViewBtn . addEventListener ( 'click' , ( ) => {
36+ let url = `/metrics?run_path={{ run_path }}` ;
37+ if ( selectedNodeData ) {
38+ const data = selectedNodeData . data ( ) ;
39+ const query = data . label ;
40+ url += `&q=${ encodeURIComponent ( query ) } ` ;
41+
42+ if ( data . type === 'entity' ) {
43+ url += `&entity_id=${ encodeURIComponent ( data . id ) } ` ;
44+ } else if ( data . type === 'alias' ) {
45+ url += `&alias_id=${ encodeURIComponent ( data . id ) } ` ;
46+ const parentEntities = selectedNodeData . incomers ( 'node[type="entity"]' ) ;
47+ if ( parentEntities . length > 0 ) {
48+ url += `&entity_id=${ encodeURIComponent ( parentEntities [ 0 ] . id ( ) ) } ` ;
49+ }
50+ }
51+ }
52+ window . location . href = url ;
53+ } ) ;
3054
3155 const BASE_NODE_SIZE = 10 ;
3256
@@ -70,8 +94,7 @@ <h2 id="sidebar-title">No node selected</h2>
7094 function renderEntityDetails ( node ) {
7195 const data = node . data ( ) ;
7296
73- const aliasEdges = node . connectedEdges ( 'edge[edge_type="alias"]' ) ;
74- const aliasNodes = aliasEdges . connectedNodes ( 'node[type="alias"]' ) ;
97+ const aliasNodes = node . outgoers ( 'node[type="alias"]' ) ;
7598 const aliasCount = aliasNodes . length ;
7699
77100 sidebarTitle . textContent =
@@ -144,7 +167,7 @@ <h2 id="sidebar-title">No node selected</h2>
144167
145168 function calculateEntityNodeSize ( node ) {
146169 const data = node . data ( ) ;
147- const aliasCount = node . connectedEdges ( 'edge[edge_type ="alias"]') . length ;
170+ const aliasCount = node . outgoers ( 'node[type ="alias"]') . length ;
148171 return BASE_NODE_SIZE + aliasCount * 2 ;
149172 }
150173
@@ -155,6 +178,7 @@ <h2 id="sidebar-title">No node selected</h2>
155178 }
156179
157180 function resetSidebar ( ) {
181+ selectedNodeData = null ;
158182 sidebarTitle . textContent = 'No node selected' ;
159183 details . innerHTML = '<p>Select a node to view details.</p>' ;
160184 }
@@ -280,6 +304,7 @@ <h2 id="sidebar-title">No node selected</h2>
280304 } ) ;
281305
282306 cy . on ( 'select' , 'node' , ( event ) => {
307+ selectedNodeData = event . target ;
283308 renderNodeDetails ( event . target ) ;
284309 } ) ;
285310
0 commit comments