Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions client/scripts/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ let last_selected_node_id // layer's drawflow id
let last_changed_parameters_layer_id
let layer_drag_offset_X = 0
let layer_drag_offset_Y = 0

let is_id_on_paths = false // Is there written id's on connections
let input_selection_layer_id
let input_selection_layer_dbid
76 changes: 46 additions & 30 deletions client/templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ <h3></h3>
}
}
click(e) {
deleteIdOnConnections()
hideLayerInfo()
super.click(e)
}
Expand Down Expand Up @@ -538,7 +537,7 @@ <h3></h3>
if (response.ok) {
editor.updateNodeDataFromId(connection.input_id, {
DBID: data2.DBID,
Connections: data2.Connections.concat(`${data1.DBID};${connection.output_id}`), // "db_id;drawflow_id"
Connections: [].concat(`${data1.DBID};${connection.output_id}`, data2.Connections), // "db_id;drawflow_id"
Parameters: data2.Parameters,
})
} else {
Expand Down Expand Up @@ -1160,14 +1159,20 @@ <h3></h3>
const tmp = addLabelText(htmlConnection, connection.split(";")[0]) // Writes id on connection
pathsWithWrittenID.push(tmp)
}
is_id_on_paths = true
}

// Remove id written on connection
function deleteIdOnConnections() {
for (let path of pathsWithWrittenID) {
path.setAttribute("display", "none")
try {
path.setAttribute("display", "none")
} catch (e) {
console.error(e)
}
}
pathsWithWrittenID = []
is_id_on_paths = false
}

function getSortableInputList(layer) {
Expand All @@ -1187,7 +1192,36 @@ <h3></h3>
function hideResult() {
document.getElementById("predict-result-wrapper").style.display = "none"
}

function matchConnectionsAfterSelection(new_input_order) {
let newConnections = []
let connections = editor.getNodeFromId(input_selection_layer_id).data.Connections
for (let input of new_input_order) {
for (let connection of connections) {
if (input == connection.split(";")[0]) {
newConnections.push(connection)
}
}
}
let new_inputs_object = {
new_parents: new_input_order,
layer_id: input_selection_layer_dbid,
}
updateParentOrder(new_inputs_object).then(response => {
if (response.ok) {
editor.updateNodeDataFromId(input_selection_layer_id, {
DBID: input_selection_layer_dbid,
Connections: newConnections,
Parameters: editor.getNodeFromId(input_selection_layer_id).data.Parameters,
})
} else {
errorNotification("Failed to update input order.\n Server is not responding now.")
}
})
}

function showLayerInfo(id) {
hideLayerInfo()
// id format "node-<id>"
let correct_id = id
if (id.includes("node")) {
Expand All @@ -1196,10 +1230,13 @@ <h3></h3>
const node = editor.getNodeFromId(correct_id)
const connections = editor.getNodeFromId(correct_id).data.Connections
const layer_dbid = editor.getNodeFromId(correct_id).data.DBID
input_selection_layer_id = correct_id
input_selection_layer_dbid = layer_dbid

// Input selection
writeIdOnConnections(correct_id)
let sortable_list = getSortableInputList(node)
writeIdOnConnections(input_selection_layer_id)
let sortable_list = getSortableInputList(node.class)

let child = sortable_list.lastElementChild

while (child) {
Expand Down Expand Up @@ -1233,30 +1270,7 @@ <h3></h3>
continue
}
}

let newConnections = []
for (let i = 0; i < new_input_order.length; i++) {
for (let connection of connections) {
if (new_input_order[i] == connection.split(";")[0]) {
newConnections[i] = connection
}
}
}
let new_inputs_object = {
new_parents: new_input_order,
layer_id: layer_dbid,
}
updateParentOrder(new_inputs_object).then(response => {
if (response.ok) {
editor.updateNodeDataFromId(correct_id, {
DBID: layer_dbid,
Connections: newConnections,
Parameters: editor.getNodeFromId(correct_id).data.Parameters,
})
} else {
errorNotification("Failed to update input order.\n Server is not responding now.")
}
})
matchConnectionsAfterSelection(new_input_order)
},
})

Expand Down Expand Up @@ -1333,7 +1347,9 @@ <h3></h3>
document.querySelector("#relu-layer-parameters").style.display = "none"
document.querySelector("#loss-layer-parameters").style.display = "none"

deleteIdOnConnections()
if (is_id_on_paths) {
deleteIdOnConnections()
}
}

function addLabelText(path, labelText) {
Expand Down