|
|
|
@ -202,6 +202,20 @@ function draw_new_edge(edge) { |
|
|
|
|
return group; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function remove_canvas_edge(edge){ |
|
|
|
|
let konva_edge = stage.findOne('#' + edge["start"] + edge["end"]); |
|
|
|
|
if (!konva_edge){ |
|
|
|
|
konva_edge = stage.findOne('#' + edge["end"] + edge["start"]); |
|
|
|
|
} |
|
|
|
|
if (konva_edge){ |
|
|
|
|
konva_edges.splice(konva_edges.indexOf(konva_edge),1); |
|
|
|
|
graph_copy[edge["start"]].splice(graph_copy[edge["start"]].indexOf(edge["end"]),1); |
|
|
|
|
graph_copy[edge["end"]].splice(graph_copy[edge["end"]].indexOf(edge["start"]),1); |
|
|
|
|
konva_edge.remove(); |
|
|
|
|
edge_layer.draw(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function update_edge(konva_edge) { |
|
|
|
|
let line = konva_edge.children[0]; |
|
|
|
|
let text = konva_edge.children[1]; |
|
|
|
@ -404,6 +418,24 @@ function find_path(data) { |
|
|
|
|
.catch(error => console.error('Error:', error)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function delete_edge(data) { |
|
|
|
|
if (data.length < 2) { |
|
|
|
|
show_info("Select 2 nodes."); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
rest_req("DELETE", "edges/" + data[0].attrs.id + "/" + data[1].attrs.id, null) |
|
|
|
|
.then(function(res) { |
|
|
|
|
if (res["error"]) { |
|
|
|
|
show_info(res["error"]); |
|
|
|
|
} else { |
|
|
|
|
remove_canvas_edge(res); |
|
|
|
|
selected = []; |
|
|
|
|
draw_selected_nodes(); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
.catch(error => console.error('Error:', error)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
function save_graph() { |
|
|
|
|