@@ -70,7 +70,6 @@ export default class NodeSecureNetwork {
7070 this . highlightEnabled = false ;
7171 this . isLoaded = false ;
7272
73- this . locked = false ;
7473 this . lastHighlightedIds = null ;
7574 const { nodes, edges } = secureDataSet . build ( ) ;
7675
@@ -107,24 +106,6 @@ export default class NodeSecureNetwork {
107106 this . network . stabilize ( 500 ) ;
108107 }
109108
110- lock ( ) {
111- if ( this . locked ) {
112- return ;
113- }
114-
115- this . locked = true ;
116- this . network . emit ( "lock" , this . locked ) ;
117- }
118-
119- unlock ( ) {
120- if ( ! this . locked ) {
121- return ;
122- }
123-
124- this . locked = false ;
125- this . network . emit ( "lock" , this . locked ) ;
126- }
127-
128109 /**
129110 * @param {!Set<string> } packages
130111 * @returns {IterableIterator<number> }
@@ -214,8 +195,8 @@ export default class NodeSecureNetwork {
214195 }
215196
216197 highlightMultipleNodes ( nodeIds ) {
217- if ( this . locked ) {
218- return ;
198+ if ( this . lastHighlightedIds !== null ) {
199+ this . resetHighlight ( ) ;
219200 }
220201 this . network . startSimulation ( ) ;
221202
@@ -266,6 +247,29 @@ export default class NodeSecureNetwork {
266247 this . network . stopSimulation ( ) ;
267248 }
268249
250+ resetHighlight ( ) {
251+ const allNodes = this . nodes . get ( ) ;
252+ const allEdges = this . edges . get ( ) ;
253+
254+ // reset all edge labels - even if user clicks on empty space
255+ for ( let id = 0 ; id < allEdges . length ; id ++ ) {
256+ Object . assign ( allEdges [ id ] , CONSTANTS . LABELS . NONE ) ;
257+ }
258+
259+ this . highlightEnabled = false ;
260+ for ( const node of allNodes ) {
261+ const { id, hasWarnings } = this . linker . get ( Number ( node . id ) ) ;
262+
263+ Object . assign ( node , utils . getNodeColor ( id , hasWarnings , this . theme ) ) ;
264+ }
265+
266+ this . lastHighlightedIds = null ;
267+ this . network . startSimulation ( ) ;
268+ this . nodes . update ( allNodes ) ;
269+ this . edges . update ( allEdges ) ;
270+ this . network . stopSimulation ( ) ;
271+ }
272+
269273 /**
270274 * Search for neighbours nodes of a given node
271275 *
@@ -287,6 +291,10 @@ export default class NodeSecureNetwork {
287291 }
288292
289293 lockedNeighbourHighlight ( params ) {
294+ if ( this . lastHighlightedIds === null ) {
295+ return false ;
296+ }
297+
290298 if ( ! params || params . nodes . length === 0 ) {
291299 return true ;
292300 }
@@ -296,7 +304,6 @@ export default class NodeSecureNetwork {
296304 return false ;
297305 }
298306
299- this . network . startSimulation ( ) ;
300307 const allNodes = this . nodes . get ( { returnType : "Object" } ) ;
301308 for ( const node of Object . values ( allNodes ) ) {
302309 if ( ! this . lastHighlightedIds . has ( node . id ) ) {
@@ -328,47 +335,25 @@ export default class NodeSecureNetwork {
328335 }
329336
330337
338+ this . network . startSimulation ( ) ;
331339 this . nodes . update ( Object . values ( allNodes ) ) ;
332340 this . network . focus ( selectedNode , {
333341 animation : true ,
334342 scale : 0.35 ,
335- offset : { x : 250 , y : 0 }
343+ offset : { x : 150 , y : 0 }
336344 } ) ;
337345 this . network . stopSimulation ( ) ;
338346
339347 return true ;
340348 }
341349
342- resetHighlight ( ) {
343- this . network . startSimulation ( ) ;
344-
345- const allNodes = this . nodes . get ( ) ;
346- const allEdges = this . edges . get ( ) ;
347-
348- // reset all edge labels - even if user clicks on empty space
349- for ( let id = 0 ; id < allEdges . length ; id ++ ) {
350- Object . assign ( allEdges [ id ] , CONSTANTS . LABELS . NONE ) ;
351- }
352-
353- this . highlightEnabled = false ;
354- for ( const node of allNodes ) {
355- const { id, hasWarnings } = this . linker . get ( Number ( node . id ) ) ;
356-
357- Object . assign ( node , utils . getNodeColor ( id , hasWarnings , this . theme ) ) ;
358- }
359-
360- this . locked = false ;
361- this . lastHighlightedIds = null ;
362-
363- this . nodes . update ( allNodes ) ;
364- this . edges . update ( allEdges ) ;
365- this . network . stopSimulation ( ) ;
366- }
367-
368350 neighbourHighlight ( params ) {
369- if ( this . lastHighlightedIds !== null && this . locked && this . lockedNeighbourHighlight ( params ) ) {
351+ if ( this . lockedNeighbourHighlight ( params ) ) {
352+ console . log ( "[NETWORK] locked, stop neighbour highlight" ) ;
353+
370354 return ;
371355 }
356+ console . log ( "[NETWORK] neighbour highlight start" ) ;
372357
373358 const allNodes = this . nodes . get ( { returnType : "Object" } ) ;
374359 const allEdges = this . edges . get ( ) ;
@@ -425,11 +410,10 @@ export default class NodeSecureNetwork {
425410 }
426411 }
427412
428- // offset set to 250 to compensate for the package info slide in on the left of screen
429413 this . network . focus ( selectedNode , {
430414 animation : true ,
431415 scale : 0.35 ,
432- offset : { x : 250 , y : 0 }
416+ offset : { x : 150 , y : 0 }
433417 } ) ;
434418 }
435419 else if ( this . highlightEnabled ) {
@@ -441,10 +425,7 @@ export default class NodeSecureNetwork {
441425 }
442426 }
443427
444- // transform the object into an array
445428 this . lastHighlightedIds = null ;
446- this . locked = false ;
447-
448429 this . nodes . update ( Object . values ( allNodes ) ) ;
449430 this . edges . update ( allEdges ) ;
450431 this . network . stopSimulation ( ) ;
0 commit comments