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
|
### Removed
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- Fixed frontend crash when instance node missing
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,8 @@ config :backend, Backend.Repo,
|
||||||
pool_size: 10
|
pool_size: 10
|
||||||
|
|
||||||
config :backend, :crawler,
|
config :backend, :crawler,
|
||||||
status_age_limit_days: 28,
|
status_age_limit_days: 14,
|
||||||
status_count_limit: 1000,
|
status_count_limit: 500,
|
||||||
personal_instance_threshold: 5,
|
personal_instance_threshold: 5,
|
||||||
crawl_interval_mins: 60,
|
crawl_interval_mins: 60,
|
||||||
crawl_workers: 10,
|
crawl_workers: 10,
|
||||||
|
|
|
@ -40,7 +40,7 @@ class Cytoscape extends React.PureComponent<ICytoscapeProps> {
|
||||||
this.cy = cytoscape({
|
this.cy = cytoscape({
|
||||||
autoungrabify: true,
|
autoungrabify: true,
|
||||||
container: container as any,
|
container: container as any,
|
||||||
elements: this.props.elements,
|
elements: this.cleanElements(this.props.elements),
|
||||||
hideEdgesOnViewport: true,
|
hideEdgesOnViewport: true,
|
||||||
hideLabelsOnViewport: true,
|
hideLabelsOnViewport: true,
|
||||||
layout: {
|
layout: {
|
||||||
|
@ -341,6 +341,16 @@ class Cytoscape extends React.PureComponent<ICytoscapeProps> {
|
||||||
}
|
}
|
||||||
this.cy.edges().addClass("hidden");
|
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;
|
export default Cytoscape;
|
||||||
|
|
Loading…
Reference in a new issue