Skip to content

Commit

Permalink
Only updating graph position if connected
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-noel committed Oct 19, 2021
1 parent 60a15ef commit 8254186
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/components/commons/ModelGraphRaw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {Button } from "reactstrap";
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
import {faSyncAlt} from "@fortawesome/free-solid-svg-icons";
import MyDropdown from "./buttons/MyDropdown";
import { isConnected } from "./sessionVariables";

import avsdf from 'cytoscape-avsdf';
import dagre from 'cytoscape-dagre';
import spread from 'cytoscape-spread';
Expand Down Expand Up @@ -95,8 +97,10 @@ class ModelGraphRaw extends React.Component {
this.cy = cy;
this.cy.on('dragfree', 'node',
(node) => {
console.log(node.target.id() + " position changed");
this.updatePosition(this.props.project, this.props.modelId, node.target.id(), node.target.position());
if (isConnected()) {
console.log(node.target.id() + " position changed");
this.updatePosition(this.props.project, this.props.modelId, node.target.id(), node.target.position());
}
}
);

Expand All @@ -107,7 +111,7 @@ class ModelGraphRaw extends React.Component {
this.cy.on('layoutstop', (event) => {
console.log("Layout stopped")
let raw_layout = event.target.options.eles;
if (raw_layout !== undefined) {
if ( isConnected() && raw_layout !== undefined) {
let new_layout = Object.values(raw_layout).reduce((result, node)=>{

if (typeof node === 'object' && typeof node.data === "function" && typeof node.position === "function") {
Expand Down

0 comments on commit 8254186

Please sign in to comment.