@@ -26,7 +26,12 @@ export const NETWORK_OPTIONS = {
2626 arrows : "from" ,
2727 hoverWidth : 3 ,
2828 selectionWidth : 3 ,
29- width : 2
29+ width : 2 ,
30+ font : {
31+ align : "middle" ,
32+ face : "Roboto" ,
33+ size : 40
34+ }
3035 } ,
3136 physics : {
3237 forceAtlas2Based : {
@@ -197,6 +202,11 @@ export default class NodeSecureNetwork {
197202 const allNodes = this . nodes . get ( { returnType : "Object" } ) ;
198203 const allEdges = this . edges . get ( ) ;
199204
205+ // reset all edge labels - even if user clicks on empty space
206+ for ( let id = 0 ; id < allEdges . length ; id ++ ) {
207+ Object . assign ( allEdges [ id ] , CONSTANTS . LABELS . NONE ) ;
208+ }
209+
200210 // if something is selected:
201211 if ( params . nodes . length > 0 ) {
202212 this . highlightEnabled = true ;
@@ -230,7 +240,21 @@ export default class NodeSecureNetwork {
230240 // the main node gets its own color and its label back.
231241 Object . assign ( allNodes [ selectedNode ] , this . colors . SELECTED ) ;
232242
233- this . network . focus ( selectedNode , { animation : true , scale : 0.35 } ) ;
243+ // select and label edges connected to the selected node
244+ const connectedEdges = this . network . getConnectedEdges ( selectedNode ) ;
245+ this . network . selectEdges ( connectedEdges ) ;
246+ for ( let id = 0 ; id < connectedEdges . length ; id ++ ) {
247+ const edgeIndex = allEdges . findIndex ( edge => edge . id === connectedEdges [ id ] ) ;
248+ // the arrow on the edge is set to point into the 'from' node
249+ if ( allEdges [ edgeIndex ] . from === selectedNode ) {
250+ Object . assign ( allEdges [ edgeIndex ] , CONSTANTS . LABELS . INCOMING ) ;
251+ } else if ( allEdges [ edgeIndex ] . to === selectedNode ) {
252+ Object . assign ( allEdges [ edgeIndex ] , CONSTANTS . LABELS . OUTGOING ) ;
253+ }
254+ }
255+
256+ // offset set to 250 to compensate for the package info slide in on the left of screen
257+ this . network . focus ( selectedNode , { animation : true , scale : 0.35 , offset : { x :250 , y :0 } } ) ;
234258 }
235259 else if ( this . highlightEnabled ) {
236260 this . highlightEnabled = false ;
@@ -243,6 +267,7 @@ export default class NodeSecureNetwork {
243267
244268 // transform the object into an array
245269 this . nodes . update ( Object . values ( allNodes ) ) ;
270+ this . edges . update ( allEdges ) ;
246271 this . network . stopSimulation ( ) ;
247272 }
248273}
0 commit comments