web app added node position updates
This commit is contained in:
parent
0ee3fca97c
commit
10486dfe1a
3 changed files with 64 additions and 0 deletions
|
@ -155,6 +155,7 @@ class CoreNetwork {
|
|||
};
|
||||
this.network = new vis.Network(this.container, this.networkData, this.networkOptions);
|
||||
this.network.on('doubleClick', this.addNode.bind(this));
|
||||
this.network.on('dragEnd', this.dragEnd.bind(this));
|
||||
this.edges.on('add', this.addEdge.bind(this));
|
||||
this.nodesEnabled = false;
|
||||
}
|
||||
|
@ -173,6 +174,25 @@ class CoreNetwork {
|
|||
return session;
|
||||
}
|
||||
|
||||
getCoreNode(nodeId) {
|
||||
return this.nodes.get(nodeId).coreNode;
|
||||
}
|
||||
|
||||
async dragEnd(properties) {
|
||||
console.log('drag end properties: ', properties);
|
||||
if (properties.nodes.length == 1) {
|
||||
const nodeId = properties.nodes[0];
|
||||
const networkNode = this.nodes.get(nodeId);
|
||||
const coreNode = networkNode.coreNode;
|
||||
coreNode.x = properties.pointer.canvas.x;
|
||||
coreNode.y = properties.pointer.canvas.y;
|
||||
if (await this.coreRest.isRunning()) {
|
||||
console.log('updated core node location: ', coreNode.x, coreNode.y);
|
||||
await this.coreRest.editNode(coreNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.nodeId = 0;
|
||||
this.nodes.clear();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue