fix frontend crash when node missing
This commit is contained in:
parent
30c5154d16
commit
3725a22c1c
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Removed
|
||||
|
||||
### Fixed
|
||||
- Fixed frontend crash when instance node missing
|
||||
|
||||
### Security
|
||||
|
||||
|
|
|
@ -57,8 +57,8 @@ config :backend, Backend.Repo,
|
|||
pool_size: 10
|
||||
|
||||
config :backend, :crawler,
|
||||
status_age_limit_days: 28,
|
||||
status_count_limit: 1000,
|
||||
status_age_limit_days: 14,
|
||||
status_count_limit: 500,
|
||||
personal_instance_threshold: 5,
|
||||
crawl_interval_mins: 60,
|
||||
crawl_workers: 10,
|
||||
|
|
|
@ -40,7 +40,7 @@ class Cytoscape extends React.PureComponent<ICytoscapeProps> {
|
|||
this.cy = cytoscape({
|
||||
autoungrabify: true,
|
||||
container: container as any,
|
||||
elements: this.props.elements,
|
||||
elements: this.cleanElements(this.props.elements),
|
||||
hideEdgesOnViewport: true,
|
||||
hideLabelsOnViewport: true,
|
||||
layout: {
|
||||
|
@ -341,6 +341,16 @@ class Cytoscape extends React.PureComponent<ICytoscapeProps> {
|
|||
}
|
||||
this.cy.edges().addClass("hidden");
|
||||
};
|
||||
|
||||
/* Helper function to remove edges if source or target node is missing */
|
||||
private cleanElements = (elements: cytoscape.ElementsDefinition): cytoscape.ElementsDefinition => {
|
||||
const domains = new Set(elements.nodes.map(n => n.data.id));
|
||||
const edges = elements.edges.filter(e => domains.has(e.data.source) && domains.has(e.data.target));
|
||||
return {
|
||||
edges,
|
||||
nodes: elements.nodes
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export default Cytoscape;
|
||||
|
|
Loading…
Reference in a new issue