Frontend SitePage Element - GraphNavigation: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 35: Line 35:
= Initial Data Query =
= Initial Data Query =


* The initial query to begin populating the graph can be either a specific node, or a graph query to find multiple nodes
* Initial nodes may come from props or from the GraphNavigation config
* Will be an array of node identifiers, or a sorted search result


== Single Node ==
== Array of node identifiers ==


* Is handled the same as [Querying Backend per Node]
* first node is the initial focus
* will need to send request for InitialNodeDetails to get eg node properties
* also send request to getRelNodes for each initial node to begin populating the graph


== Multiple Nodes ==
== Sorted Search Result ==


* Begins a SortResult request for nodes that match the initial query
* Begins a SortResult request for nodes that match the initial query
* All nodes will show, and will begin populating the graph using [Querying Backend per Node] requests according to [[GraphNavigation Config]]
* All nodes will show, and will begin populating the graph using getRelNodes requests
* sortField/s are required, the first node found will be the focus
* sortField/s are required, the first node found will be the focus


= Interaction with sitePageConfig =
= Interaction with sitePageConfig =


* sitePage can set a starting node, or have a popup to input the starting node
* sitePage can set a starting node/s/sorted query, or have a popup to input the starting node
* Need some way to wrap in conversations presentation that shows most recent, most commented (within timerange) etc
* Need some way to wrap in conversations presentation that shows most recent, most commented (within timerange) etc
* Maybe that could be a popup settin for the GraphNavigation, or an element that pops up and allows for a search that returns a range of nodes (might not be related) that match the search
* Maybe that could be a popup settin for the GraphNavigation, or an element that pops up and allows for a search that returns a range of nodes (might not be related) that match the search
Line 58: Line 61:
* Probably cluster by node label, to allow for easy presentation adjustments by type
* Probably cluster by node label, to allow for easy presentation adjustments by type
* Also add clusters according to viewed this session, or previously viewed (would need supporting backend data)
* Also add clusters according to viewed this session, or previously viewed (would need supporting backend data)
= Component Structure =
== GraphNavigation ==
* top level component
== GraphNav ==
* Each graph presentation element
* do not update graphNodes / graphRelationships / nodesRequested in this child component
== GraphDetail ==
* Detail about the graph and/or focused node
* do not update graphNodes / graphRelationships / nodesRequested in this child component


= Code Structure =  
= Code Structure =  
Line 73: Line 92:
* variable name: graphNodes
* variable name: graphNodes
* React State
* React State
* object where index is graphNodeId
* in top level GraphNavigation compenent
* is an object, index is graphNodeId
* relationships property contains list of graphRelId
* relationships property contains list of graphRelId
* perhaps set relationships to null prior to getting backend response of relNodes
* perhaps set relationships to null prior to getting backend response of relNodes
Line 82: Line 102:
* variable name: graphRelationships
* variable name: graphRelationships
* React State
* React State
* object where index is graphRelId
* in top level GraphNavigation compenent
* is an object, index is graphRelId
* contains nodeA/nodeB properties containing graphNodeIds
* contains nodeA/nodeB properties containing graphNodeIds


Line 88: Line 109:


* variable name: nodesRequested
* variable name: nodesRequested
* in top level GraphNavigation compenent
* useRef because want to update immediately and not need to render after change
* useRef because want to update immediately and not need to render after change
* used to stop duplicate requests to backend
* used to stop duplicate requests to backend
Line 94: Line 116:


* have standard recursive function that receives graphNodeId, name: getRelNodes(graphNode, hops)
* have standard recursive function that receives graphNodeId, name: getRelNodes(graphNode, hops)
* in top level GraphNavigation compenent
* graphNodeId object has a property storing how many hops this node is from currently focused node
* graphNodeId object has a property storing how many hops this node is from currently focused node
* probably not reference any state in getRelNodes because state might not be updated or coule be state, send all required values as params
* probably not reference any state in getRelNodes because state might not be updated or could be stale, send all required values as params
* if reached limit of hops stop
* if reached limit of hops stop
* if graphNodeId already exists in nodesRequested can stop processing
* if graphNodeId already exists in nodesRequested can stop processing
Line 115: Line 138:
== Change focused node ==
== Change focused node ==


* handled in GraphNav compenent so all elements do nto re-render when traversing graph
* if detect more must request more nodes using getRelNodes, have a state prop passed down from GraphNavigation compenent that triggers getRelNodes function
* reset all nodes to 0 hops from focused node
* reset all nodes to 0 hops from focused node
* traverse graph from focused node using graphRelationships
* traverse graph from focused node using graphRelationships

Revision as of 02:25, 24 October 2023

Querying Backend per Node

  • After the GraphNavigation Config is received from the backend an initial SortResult request is sent to the backend to find data to populate the graph
  • One request per node found
  • Config will specify how many hops to request data for, from currently focused node or from floating nodes (case of multiple initial nodes)
  • Could move some of this processing to a backend endpoint that combines a number of hops into one request
  • SortFields will normally be the weight of the relationships, but this can be controlled by settings
  • Paginate the sorted results to get the list of relationships to show for any node
  • If user requests more nodes, request additional pages from SortResult
  • As user navigates the graph, continue sending requests to backend for more nodes/relationships
  • Have setting to control how to make additional requests, automatic, when reach leaf node, or manual button to request more

SortResult request

  • has additional Param identifying the source node
  • also include all filters, requiredData, sortFields
  • sent to websocket in SortResult service (?) that notifies when the SortResult is complete, or if using a persistent websocket might be handed by GraphNavigation service

SearchResult request

  • Can find any arbritary node/rel properties or versioned data
  • Uses the RelNodeId to build the identifiers to query the graph
  • requested property/fieldnames are probably a requestParam for a range of filterTags, like findNodeProperty, findRelationshipProperty, findNodeVersionedDataProperty

Complex Filter

  • Requires source node identifiers and objType
  • builds graph query from request to find relationship and target node, any combination of Node Label / Node property / Relationship Type / Relationship property filters
  • query auto adds relUuid and all node properties so can find identifiers for building RelNodeId

Connection to Backend

  • Consider a persistent WebSocket recieving requests from frontend for new nodes and sending results to frontend

Initial Data Query

  • Initial nodes may come from props or from the GraphNavigation config
  • Will be an array of node identifiers, or a sorted search result

Array of node identifiers

  • first node is the initial focus
  • will need to send request for InitialNodeDetails to get eg node properties
  • also send request to getRelNodes for each initial node to begin populating the graph

Sorted Search Result

  • Begins a SortResult request for nodes that match the initial query
  • All nodes will show, and will begin populating the graph using getRelNodes requests
  • sortField/s are required, the first node found will be the focus

Interaction with sitePageConfig

  • sitePage can set a starting node/s/sorted query, or have a popup to input the starting node
  • Need some way to wrap in conversations presentation that shows most recent, most commented (within timerange) etc
  • Maybe that could be a popup settin for the GraphNavigation, or an element that pops up and allows for a search that returns a range of nodes (might not be related) that match the search
  • GraphNavigation could be set to default to showing that popup for initial seeding of graph data

Grouping/Clustering of Nodes

  • Probably cluster by node label, to allow for easy presentation adjustments by type
  • Also add clusters according to viewed this session, or previously viewed (would need supporting backend data)

Component Structure

GraphNavigation

  • top level component

GraphNav

  • Each graph presentation element
  • do not update graphNodes / graphRelationships / nodesRequested in this child component

GraphDetail

  • Detail about the graph and/or focused node
  • do not update graphNodes / graphRelationships / nodesRequested in this child component

Code Structure

Identifying Nodes

  • graphNodeId: hash objType and nodeIdentifiers should create a unique id for specific node

Identifying Relationships

  • graphRelId: use relationships identifier

List of Nodes

  • variable name: graphNodes
  • React State
  • in top level GraphNavigation compenent
  • is an object, index is graphNodeId
  • relationships property contains list of graphRelId
  • perhaps set relationships to null prior to getting backend response of relNodes
  • after have relNodes set relationships to an array, will be empty array if none found, can test for leaf nodes

List of Relationships

  • variable name: graphRelationships
  • React State
  • in top level GraphNavigation compenent
  • is an object, index is graphRelId
  • contains nodeA/nodeB properties containing graphNodeIds

List of Nodes requested from backend

  • variable name: nodesRequested
  • in top level GraphNavigation compenent
  • useRef because want to update immediately and not need to render after change
  • used to stop duplicate requests to backend

requesting relNodes from backend

  • have standard recursive function that receives graphNodeId, name: getRelNodes(graphNode, hops)
  • in top level GraphNavigation compenent
  • graphNodeId object has a property storing how many hops this node is from currently focused node
  • probably not reference any state in getRelNodes because state might not be updated or could be stale, send all required values as params
  • if reached limit of hops stop
  • if graphNodeId already exists in nodesRequested can stop processing
  • set graphNodeId in nodesRequested
  • send request to backend
  • after get response do most processing inside setGraphNodes and setGraphRelationships so working with latest State
  • use cancelToken on backend request, maybe need code to check if cancelled so not adjust state on cancelled/unmounted request

setGraphNodes

  • check in graphNodes if hops for node still matches, if not use updated hops from State
  • add new nodes to graphNodes
  • if not yet reached hops limit, invoke getRelNodes for new nodes

setGraphRelationships

  • add new relationship to graphRelationships if not already exist

Change focused node

  • handled in GraphNav compenent so all elements do nto re-render when traversing graph
  • if detect more must request more nodes using getRelNodes, have a state prop passed down from GraphNavigation compenent that triggers getRelNodes function
  • reset all nodes to 0 hops from focused node
  • traverse graph from focused node using graphRelationships
  • update hops property
  • if reach node that has not yet requested relationships (set to null) and not reached hop limit, invoke getRelNodes
  • (later) can remove nodes too distant from focused node here if want to cleanup ram