Skip to content

Commit

Permalink
[frontend] Disable forces when adding a new entity (#7298)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gwendoline-FAVRE-FELIX committed Sep 23, 2024
1 parent c82cc87 commit be47033
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,28 @@ class ReportKnowledgeGraphComponent extends Component {

async handleAddEntity(stixCoreObject) {
if (R.map((n) => n.id, this.graphObjects).includes(stixCoreObject.id)) return;

this.graph.current.d3Force('link').distance(0);
this.graph.current.d3Force('charge').strength(0);
const currentPositions = R.indexBy(
R.prop('id'),
R.map((n) => ({ id: n.id, x: n.fx, y: n.fy }), this.graphData.nodes),
);

this.graphObjects = [...this.graphObjects, stixCoreObject];
this.graphData = buildGraphData(
this.graphObjects,
decodeGraphData(this.props.report.graph_data),
this.props.t,
);

this.graphData.nodes.forEach((node) => {
if (currentPositions[node.id]) {
node.fx = currentPositions[node.id].x;
node.fy = currentPositions[node.id].y;
}
});

await this.resetAllFilters();
const selectedTimeRangeInterval = computeTimeRangeInterval(
this.graphObjects,
Expand All @@ -548,6 +564,7 @@ class ReportKnowledgeGraphComponent extends Component {
},
() => {
setTimeout(() => this.handleZoomToFit(), 1500);
this.forceUpdate();
},
);
}
Expand Down

0 comments on commit be47033

Please sign in to comment.