@@ -17,24 +17,27 @@ import TableViewGroupNodes from "../table-view-group-nodes/table-view-group-node
1717type Props = {
1818 entityTypeInstances : any ;
1919 graphView : any ;
20- coords : any [ ] ;
21- setCoords : ( coords : any [ ] ) => void ;
2220 hubCentralConfig : any ;
2321 viewRelationshipLabels : any ;
2422 exportPngButtonClicked : boolean ;
2523 setExportPngButtonClicked : any ;
24+ setGraphPageInfo : ( pageInfo : any ) => void ;
2625} ;
2726
2827const GraphVisExplore : React . FC < Props > = ( props ) => {
28+ const {
29+ entityTypeInstances,
30+ graphView,
31+ hubCentralConfig,
32+ viewRelationshipLabels,
33+ exportPngButtonClicked,
34+ setExportPngButtonClicked,
35+ setGraphPageInfo
36+ } = props ;
2937 const [ expandedNodeData , setExpandedNodeData ] = useState ( { } ) ;
3038 let graphData = { nodes : [ ] , edges : [ ] } ;
31-
32- const coordinatesExist = ( ) => {
33- let coordsExist = ! ! props . coords ;
34- return coordsExist ;
35- } ;
3639 const [ menuPosition , setMenuPosition ] = useState < { x : number , y : number } > ( { x : 0 , y : 0 } ) ;
37- const [ physicsEnabled , setPhysicsEnabled ] = useState ( ! coordinatesExist ( ) ) ;
40+ const [ physicsEnabled , setPhysicsEnabled ] = useState ( false ) ;
3841 const [ contextMenuVisible , setContextMenuVisible ] = useState ( false ) ;
3942 const [ clickedNode , setClickedNode ] = useState ( { } ) ;
4043 const [ hasStabilized , setHasStabilized ] = useState ( false ) ;
@@ -108,7 +111,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
108111 } ;
109112
110113 useEffect ( ( ) => {
111- if ( Object . keys ( props . entityTypeInstances ) . length && network ) {
114+ if ( Object . keys ( entityTypeInstances ) . length && network ) {
112115
113116 initializeGraphData ( ) ;
114117
@@ -125,10 +128,10 @@ const GraphVisExplore: React.FC<Props> = (props) => {
125128 setGraphDataLoaded ( false ) ;
126129 } ;
127130
128- } , [ props . entityTypeInstances , props . viewRelationshipLabels ] ) ;
131+ } , [ entityTypeInstances , viewRelationshipLabels ] ) ;
129132
130133 useEffect ( ( ) => {
131- if ( network && props . graphView ) {
134+ if ( network && graphView ) {
132135 let nodes = getNodes ( ) || [ ] ;
133136 let edges = getEdges ( ) || [ ] ;
134137 updateNodesData ( nodes ) ;
@@ -147,19 +150,19 @@ const GraphVisExplore: React.FC<Props> = (props) => {
147150 setExpandedNodeData ( { } ) ;
148151 } ;
149152
150- } , [ network , props . graphView ] ) ;
153+ } , [ network , graphView ] ) ;
151154
152155 useEffect ( ( ) => {
153- if ( props . exportPngButtonClicked ) {
156+ if ( exportPngButtonClicked ) {
154157 let canvas = document . getElementsByClassName ( "vis-network" ) [ 0 ] [ "canvas" ] ;
155158 let link = document . createElement ( "a" ) ;
156159 link . href = canvas . toDataURL ( ) ;
157160 link . setAttribute ( "download" , "graph-view-explore" ) ;
158161 document . body . appendChild ( link ) ;
159162 link . click ( ) ;
160- props . setExportPngButtonClicked ( false ) ;
163+ setExportPngButtonClicked ( false ) ;
161164 }
162- } , [ props . exportPngButtonClicked ] ) ;
165+ } , [ exportPngButtonClicked ] ) ;
163166
164167 useLayoutEffect ( ( ) => {
165168 if ( network ) {
@@ -173,11 +176,11 @@ const GraphVisExplore: React.FC<Props> = (props) => {
173176 } , [ network , graphData ] ) ;
174177
175178 const iconExistsForEntity = ( entityName ) => {
176- return ( ! props . hubCentralConfig ?. modeling ?. entities [ entityName ] ?. icon ? false : true ) ;
179+ return ( ! hubCentralConfig ?. modeling ?. entities [ entityName ] ?. icon ? false : true ) ;
177180 } ;
178181
179182 const colorExistsForEntity = ( entityName ) => {
180- return ( ! props . hubCentralConfig ?. modeling ?. entities [ entityName ] ?. color ? false : true ) ;
183+ return ( ! hubCentralConfig ?. modeling ?. entities [ entityName ] ?. color ? false : true ) ;
181184 } ;
182185
183186 const setUserPreferences = ( ) => {
@@ -206,7 +209,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
206209 if ( parentNode && expandedNodeData [ expandId ] ) {
207210 selectedEntityExists = expandedNodeData [ expandId ] ?. nodes ?. some ( node => node . id === entityInstanceId ) ;
208211 } else {
209- selectedEntityExists = props . entityTypeInstances ?. nodes ?. some ( node => node . id === entityInstanceId ) ;
212+ selectedEntityExists = entityTypeInstances ?. nodes ?. some ( node => node . id === entityInstanceId ) ;
210213 }
211214 if ( selectedEntityExists ) {
212215 setPhysicsEnabled ( false ) ;
@@ -216,7 +219,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
216219 }
217220 } else if ( network && entityInstanceId && ! graphDataLoaded && savedNode ) { //case where exploring from table/snippet view
218221 let instanceId = entityInstanceId . split ( "-" ) [ 1 ] ;
219- let selectedEntity = props . entityTypeInstances ?. nodes ?. find ( node => node . id . includes ( instanceId ) ) ;
222+ let selectedEntity = entityTypeInstances ?. nodes ?. find ( node => node . id . includes ( instanceId ) ) ;
220223 if ( selectedEntity ) {
221224 setPhysicsEnabled ( false ) ;
222225 network . selectNodes ( [ selectedEntity . id ] ) ;
@@ -260,11 +263,11 @@ const GraphVisExplore: React.FC<Props> = (props) => {
260263 let nodes ;
261264 let nodeObj = groupNodes ;
262265 let leafNodesObj = leafNodes ;
263- let entityInstNodes = props . entityTypeInstances ?. nodes ?. slice ( ) ;
266+ let entityInstNodes = entityTypeInstances ?. nodes ?. slice ( ) ;
264267 entityInstNodes = ! nodesToExpand ? entityInstNodes : nodesToExpand ;
265268 nodes = entityInstNodes ?. map ( ( e ) => {
266269 let entityType = e . group . split ( "/" ) . pop ( ) ;
267- let entity = props . hubCentralConfig ?. modeling ?. entities [ entityType ] ;
270+ let entity = hubCentralConfig ?. modeling ?. entities [ entityType ] ;
268271 let nodeId = e . id ;
269272 if ( e . count > 1 ) {
270273 if ( ! nodeObj . hasOwnProperty ( nodeId ) ) {
@@ -410,7 +413,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
410413 const getEdges = ( edgesToExpand ?: any ) => {
411414 let edges : any = [ ] ;
412415 let predicatesObject = predicates ;
413- let edgesFinal : any = props . entityTypeInstances ?. edges ?. slice ( ) ;
416+ let edgesFinal : any = entityTypeInstances ?. edges ?. slice ( ) ;
414417 edgesFinal = ! edgesToExpand ? edgesFinal : edgesToExpand ;
415418 edges = edgesFinal ?. map ( ( edge , i ) => {
416419 if ( ! predicatesObject . hasOwnProperty ( edge . id ) ) {
@@ -419,7 +422,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
419422 return {
420423 ...edge ,
421424 id : edge . id ,
422- label : props . viewRelationshipLabels ? edge . label : "" ,
425+ label : viewRelationshipLabels ? edge . label : "" ,
423426 arrows : {
424427 to : {
425428 enabled : false ,
@@ -474,6 +477,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
474477 network . body . data . nodes . remove ( graphDataTemp . nodes ) ;
475478 updateNodesData ( graphDataTemp . nodes ) ;
476479 updateEdgesData ( graphDataTemp . edges ) ;
480+ updateGraphPageInfo ( ) ;
477481 } ;
478482
479483 const handleTableViewRecords = ( exceededThreshold ?: string ) => {
@@ -514,6 +518,14 @@ const GraphVisExplore: React.FC<Props> = (props) => {
514518 setLeafNodes ( leafNodeObj ) ;
515519 } ;
516520
521+ const updateGraphPageInfo = ( ) => {
522+ let pageInfo = {
523+ pageLength : network . body . data . nodes . length ,
524+ total : entityTypeInstances ?. total
525+ } ;
526+ setGraphPageInfo ( pageInfo ) ;
527+ } ;
528+
517529 const handleGroupNodeExpand = async ( payloadData ) => {
518530 setContextMenuVisible ( false ) ;
519531 let payload = {
@@ -577,6 +589,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
577589 network . body . data . edges . remove ( graphEdgesDataTemp ) ;
578590 let removedNode = getNodes ( [ groupNodes [ removedNodeIRI ] ] ) ;
579591 updateNodesData ( removedNode ) ;
592+ updateGraphPageInfo ( ) ;
580593 } catch ( error ) {
581594 handleError ( error ) ;
582595 }
@@ -635,6 +648,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
635648 network . body . data . nodes . remove ( graphNodesDataTemp ) ;
636649 network . body . data . nodes . remove ( nodesToDelete ) ;
637650 network . body . data . edges . remove ( graphEdgesDataTemp ) ;
651+ updateGraphPageInfo ( ) ;
638652 } catch ( error ) {
639653 handleError ( error ) ;
640654 }
@@ -669,6 +683,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
669683 network . body . data . nodes . update ( nodes ) ;
670684 network . body . data . edges . update ( edges ) ;
671685 await updateGroupAndLeafNodesDataset ( response . data . nodes ) ;
686+ updateGraphPageInfo ( ) ;
672687 }
673688 } catch ( error ) {
674689 handleError ( error ) ;
@@ -820,8 +835,8 @@ const GraphVisExplore: React.FC<Props> = (props) => {
820835 expandedInstanceInfo [ "edgeObject" ] = expandedNodeData [ parentNodeExpandId ] . edges . find ( edge => edge . id === edgeIdFrom ) ;
821836 expandedInstanceInfo [ "parentNodeExpandId" ] = parentNodeExpandId ;
822837 } else {
823- expandedInstanceInfo [ "nodeObject" ] = props . entityTypeInstances . nodes . find ( node => node . id === nodeId ) ;
824- expandedInstanceInfo [ "edgeObject" ] = props . entityTypeInstances . edges . find ( edge => edge . id === edgeIdFrom ) ;
838+ expandedInstanceInfo [ "nodeObject" ] = entityTypeInstances . nodes . find ( node => node . id === nodeId ) ;
839+ expandedInstanceInfo [ "edgeObject" ] = entityTypeInstances . edges . find ( edge => edge . id === edgeIdFrom ) ;
825840 }
826841 return expandedInstanceInfo ;
827842 } ;
@@ -989,9 +1004,7 @@ const GraphVisExplore: React.FC<Props> = (props) => {
9891004 let positions = network . getPositions ( ) ;
9901005 // When graph is stabilized, nodePositions no longer empty
9911006 if ( positions && Object . keys ( positions ) . length ) {
992- // saveUnsavedCoords();
9931007 setHasStabilized ( true ) ;
994- //props.setCoords(positions);
9951008 if ( physicsEnabled ) {
9961009 setPhysicsEnabled ( false ) ;
9971010 return false ;
0 commit comments