From e3829418b1d8614c741041cfd01eee42062ee005 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 10 Sep 2020 21:44:45 +0200 Subject: [PATCH] Bug Fixed References --- .../FunctionLibraries/UiObjectsFromNodes.js | 23 +++++++++++++++---- EventsServerClient.js | 2 +- FloatingSpace/UiObjectConstructor.js | 20 ++++++++-------- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index cc7b25ab2..372dbe01f 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -32,7 +32,7 @@ function newUiObjectsFromNodes() { let blobService = newFileStorage() // if (node.config === undefined) { - node.config = '{ \n"includeDataMines": ["Masters", "Sparta", "Masters-Trading"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' + node.config = '{ \n"includeDataMines": ["Masters", "Sparta", "Masters-Trading"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' // } let config = JSON.parse(node.config) @@ -63,7 +63,7 @@ function newUiObjectsFromNodes() { } } receivedNode.isIncluded = true - node.rootNodes.push(receivedNode) + node.rootNodes.unshift(receivedNode) totalIncluded++ if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) { addUserDefinedNodes() @@ -92,7 +92,7 @@ function newUiObjectsFromNodes() { } } receivedNode.isIncluded = true - node.rootNodes.push(receivedNode) + node.rootNodes.unshift(receivedNode) totalIncluded++ if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) { addUserDefinedNodes() @@ -121,7 +121,7 @@ function newUiObjectsFromNodes() { } } receivedNode.isIncluded = true - node.rootNodes.push(receivedNode) + node.rootNodes.unshift(receivedNode) totalIncluded++ if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) { addUserDefinedNodes() @@ -167,10 +167,16 @@ function newUiObjectsFromNodes() { function tryToConnectChildrenWithReferenceParents() { /* We reconstruct here the reference relationships. */ for (const [key, node] of mapOfNodes) { + if (node.id === "54854f90-d121-4365-8f40-9a26e7af1097") { + console.log('ACA') + } if (node.payload === undefined) { continue } if (node.payload.referenceParent !== undefined) { if (node.payload.referenceParent.cleaned === true) { node.payload.referenceParent = mapOfNodes.get(node.payload.referenceParent.id) + if (node.payload.referenceParent === undefined) { + console.log(node.type + ' ' + node.name + ' reference parent lost during re-binding phase.') + } continue // We were referencing a deleted node, so we replace it potentially with a newly created one. } else { continue // In this case the reference is already good. @@ -179,6 +185,9 @@ function newUiObjectsFromNodes() { if (node.savedPayload !== undefined) { if (node.savedPayload.referenceParent !== undefined) { // these are children recreated node.payload.referenceParent = mapOfNodes.get(node.savedPayload.referenceParent.id) + if (node.payload.referenceParent === undefined) { + console.log(node.type + ' ' + node.name + ' reference parent lost during re-binding phase.') + } } } } @@ -460,8 +469,13 @@ function newUiObjectsFromNodes() { if (node.id === undefined) { node.id = newUniqueId() } else { + /* + We need to avoid nodes having the same id. If we add nodes to a workspace that already exist with the same Id, + the nodes being added will get a new id at this moment. + */ let testNode = mapOfNodes.get(node.id) if (testNode !== undefined && testNode.cleaned !== true) { + console.log(testNode.name + ' already have the id of the node ' + node.name + ' being added.') node.id = newUniqueId() } } @@ -587,6 +601,7 @@ function newUiObjectsFromNodes() { /* Now we mount the floating object where the UIOBject will be laying on top of */ canvas.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload) + /* This is the point where we build a map with all nodes present at the workspace */ mapOfNodes.set(node.id, node) /* Check if there are tasks to run */ diff --git a/EventsServerClient.js b/EventsServerClient.js index e76d3f545..520d095a7 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -87,7 +87,7 @@ function newEventsServerClient(networkNode) { if (WEB_SOCKETS_CONNECTION.readyState === 1) { WEB_SOCKETS_CONNECTION.send(messageToWebSocketServer) } else { - console.log('WebSocket message could not be sent because the connection was not ready. Will retry soon. Message = ' + JSON.stringify(command)) + //console.log('WebSocket message could not be sent because the connection was not ready. Will retry soon. Message = ' + JSON.stringify(command)) } } diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 4443ea708..643fde2a0 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -229,8 +229,8 @@ function newUiObjectConstructor() { currentStatus: false, label: undefined, visible: true, - iconPathOn: 'menu-fix-pinned', - iconPathOff: 'menu-fix-unpinned', + iconPathOn: 'pinned', + iconPathOff: 'unpinned', rawRadius: 12, targetRadius: 0, currentRadius: 0, @@ -290,8 +290,8 @@ function newUiObjectConstructor() { currentStatus: true, label: undefined, visible: true, - iconPathOn: 'menu-mobility-unfreeze', - iconPathOff: 'menu-mobility-freeze', + iconPathOn: 'unfreeze', + iconPathOff: 'freeze', rawRadius: 12, targetRadius: 0, currentRadius: 0, @@ -306,8 +306,8 @@ function newUiObjectConstructor() { currentStatus: false, label: undefined, visible: true, - iconPathOn: 'menu-tree-plus', - iconPathOff: 'menu-tree-minus', + iconPathOn: 'expand', + iconPathOff: 'collapse', rawRadius: 12, targetRadius: 0, currentRadius: 0, @@ -320,8 +320,8 @@ function newUiObjectConstructor() { actionFunction: floatingObject.payload.onMenuItemClick, label: undefined, visible: true, - iconPathOn: 'menu-backup', - iconPathOff: 'menu-backup', + iconPathOn: 'backup', + iconPathOff: 'backup', rawRadius: 12, targetRadius: 0, currentRadius: 0, @@ -349,8 +349,8 @@ function newUiObjectConstructor() { actionFunction: floatingObject.payload.onMenuItemClick, label: undefined, visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', + iconPathOn: 'share', + iconPathOff: 'share', rawRadius: 12, targetRadius: 0, currentRadius: 0,