diff --git a/Canvas.js b/Canvas.js index 113cd3047..9726c9d46 100644 --- a/Canvas.js +++ b/Canvas.js @@ -133,8 +133,8 @@ function newCanvas () { animation.addCallBackFunction('Panels Space', thisObject.panelsSpace.draw) animation.addCallBackFunction('ViewPort Animate', viewPort.animate) animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw) + animation.addCallBackFunction('Designer Space Draw', thisObject.designerSpace.draw) animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) - animation.addCallBackFunction('Strategy Space Draw', thisObject.designerSpace.draw) animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw) animation.start() } catch (err) { @@ -195,6 +195,21 @@ function newCanvas () { return } } + if (nodeOnFocus.payload.uiObject.configEditor !== undefined) { + if (nodeOnFocus.payload.uiObject.configEditor.visible === true) { + return + } + } + if (nodeOnFocus.payload.uiObject.formulaEditor !== undefined) { + if (nodeOnFocus.payload.uiObject.formulaEditor.visible === true) { + return + } + } + if (nodeOnFocus.payload.uiObject.conditionEditor !== undefined) { + if (nodeOnFocus.payload.uiObject.conditionEditor.visible === true) { + return + } + } if (nodeOnFocus.payload.uiObject.uiObjectTitle !== undefined) { if (nodeOnFocus.payload.uiObject.uiObjectTitle.editMode === true) { return @@ -209,6 +224,19 @@ function newCanvas () { } } + if ((event.ctrlKey === true || event.metaKey === true) && event.altKey === true && event.shiftKey === true && event.keyCode === 122) { // Regenerates APP SCHEMA FILE + /* + for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { + let schemaNode = APP_SCHEMA_ARRAY[i] + schemaNode.addLeftIcons = true + } + */ + let text = JSON.stringify(APP_SCHEMA_ARRAY) + let fileName = 'AppSchema.json' + download(fileName, text) + return + } + if (event.altKey === true && event.code === 'ArrowUp') { thisObject.cockpitSpace.toTop() return diff --git a/ChartsSpace/TimeMachine.js b/ChartsSpace/TimeMachine.js index 8b35c71fe..13add3ae8 100644 --- a/ChartsSpace/TimeMachine.js +++ b/ChartsSpace/TimeMachine.js @@ -64,10 +64,16 @@ function newTimeMachine () { } thisObject.charts = [] - thisObject.timeScale.finalize() - thisObject.timeScale = undefined - thisObject.rateScale.finalize() - thisObject.rateScale = undefined + + if (thisObject.timeScale !== undefined) { + thisObject.timeScale.finalize() + thisObject.timeScale = undefined + } + if (thisObject.rateScale !== undefined) { + thisObject.rateScale.finalize() + thisObject.rateScale = undefined + } + thisObject.fitFunction = undefined thisObject.container.finalize() diff --git a/ChartsSpace/ViewPort.js b/ChartsSpace/ViewPort.js index b96904c80..129fe0071 100644 --- a/ChartsSpace/ViewPort.js +++ b/ChartsSpace/ViewPort.js @@ -290,6 +290,8 @@ function newViewPort () { x: 0, y: 0 } + + thisObject.eventHandler.raiseEvent('Zoom Changed') } function zoomFontSize (baseSize, level) { diff --git a/Dashboard.js b/Dashboard.js index ff9e3d493..230c680bb 100644 --- a/Dashboard.js +++ b/Dashboard.js @@ -45,7 +45,7 @@ function newDashboard () { } APP_SCHEMA_MAP.set(key, nodeDefinition) } - console.log(APP_SCHEMA_MAP) + startCanvas() } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index e4c5e9e04..c945827e6 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -199,17 +199,6 @@ function newChainAttachDetach () { completeDetachment(node, rootNodes) return } - case 'Plotter Panel': { - let payload = node.payload - for (let i = 0; i < payload.parentNode.panels.length; i++) { - let panel = payload.parentNode.panels[i] - if (panel.id === node.id) { - payload.parentNode.panels.splice(i, 1) - } - } - completeDetachment(node, rootNodes) - return - } case 'Network Node': { let payload = node.payload for (let i = 0; i < payload.parentNode.networkNodes.length; i++) { @@ -549,6 +538,43 @@ function newChainAttachDetach () { } return } + default: { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* Detach from parent */ + if (node.payload.parentNode !== undefined) { + let parentNodeDefinition = APP_SCHEMA_MAP.get(node.payload.parentNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] + if (nodeDefinition.propertyNameAtParent === property.name) { + switch (property.type) { + case 'node': { + node.payload.parentNode[property.name] = undefined + } + break + case 'array': { + let nodePropertyArray = node.payload.parentNode[property.name] + if (nodePropertyArray !== undefined) { + for (let j = 0; j < nodePropertyArray.length; j++) { + let arrayItem = nodePropertyArray[j] + if (arrayItem.id === node.id) { + nodePropertyArray.splice(j, 1) + } + } + } + } + break + } + } + } + } + } + } + completeDetachment(node, rootNodes) + } + } } } @@ -708,13 +734,6 @@ function newChainAttachDetach () { completeAttachment(node, rootNodes) } break - case 'Plotter Panel': { - node.payload.parentNode = attachToNode - node.payload.chainParent = attachToNode - node.payload.parentNode.panels.push(node) - completeAttachment(node, rootNodes) - } - break case 'Network Node': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode @@ -1107,6 +1126,41 @@ function newChainAttachDetach () { completeAttachment(node, rootNodes) } break + default: { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + /* Attach to new parent */ + if (node.payload.parentNode !== undefined) { + let parentNodeDefinition = APP_SCHEMA_MAP.get(node.payload.parentNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] + if (nodeDefinition.propertyNameAtParent === property.name) { + switch (property.type) { + case 'node': { + node.payload.parentNode[property.name] = node + } + break + case 'array': { + if (node.payload.parentNode[property.name] === undefined) { + node.payload.parentNode[property.name] = [] + } + let nodePropertyArray = node.payload.parentNode[property.name] + nodePropertyArray.push(node) + } + break + } + } + } + } + } + } + completeAttachment(node, rootNodes) + } + } } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js index 1eb525cd0..e27991ae5 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js @@ -83,9 +83,6 @@ function newNodeChildren () { case 'Plotter Module': { return countChildrenPlotterModule(parentNode, childNode) } - case 'Plotter Panel': { - return countChildrenPlotterPanel(parentNode, childNode) - } case 'Network Node': { return countChildrenNetworkNode(parentNode, childNode) } @@ -231,11 +228,50 @@ function newNodeChildren () { return countChildrenJavascriptCode(parentNode, childNode) } default: { - console.log('WARNING this parentNode type is not listed at NodeChildren: ' + parentNode.type) + return countChildrenUiObject(parentNode, childNode) } } } + function countChildrenUiObject (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } + let nodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + if (parentNode[property.name] !== undefined) { + switch (property.type) { + case 'node': { + response.childrenCount++ + if (parentNode[property.name].id === childNode.id) { + response.childIndex = response.childrenCount + } + } + break + case 'array': { + let nodePropertyArray = parentNode[property.name] + for (let j = 0; j < nodePropertyArray.length; j++) { + let child = nodePropertyArray[j] + response.childrenCount++ + if (child.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + } + break + } + } + } + } + } + + return response + } + function countChildrenDefinition (parentNode, childNode) { let response = { childrenCount: 0, @@ -545,9 +581,9 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } - if (parentNode.code !== undefined) { + if (parentNode.javascriptCode !== undefined) { response.childrenCount++ - if (parentNode.code.id === childNode.id) { + if (parentNode.javascriptCode.id === childNode.id) { response.childIndex = response.childrenCount } } @@ -559,9 +595,9 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } - if (parentNode.code !== undefined) { + if (parentNode.javascriptCode !== undefined) { response.childrenCount++ - if (parentNode.code.id === childNode.id) { + if (parentNode.javascriptCode.id === childNode.id) { response.childIndex = response.childrenCount } } @@ -691,9 +727,15 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } - if (parentNode.code !== undefined) { + if (parentNode.javascriptCode !== undefined) { response.childrenCount++ - if (parentNode.code.id === childNode.id) { + if (parentNode.javascriptCode.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.shapes !== undefined) { + response.childrenCount++ + if (parentNode.shapes.id === childNode.id) { response.childIndex = response.childrenCount } } @@ -709,20 +751,6 @@ function newNodeChildren () { return response } - function countChildrenPlotterPanel (parentNode, childNode) { - let response = { - childrenCount: 0, - childIndex: undefined - } - if (parentNode.code !== undefined) { - response.childrenCount++ - if (parentNode.code.id === childNode.id) { - response.childIndex = response.childrenCount - } - } - return response - } - function countChildrenNetworkNode (parentNode, childNode) { let response = { childrenCount: 0, @@ -1474,9 +1502,9 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } - if (parentNode.code !== undefined) { + if (parentNode.javascriptCode !== undefined) { response.childrenCount++ - if (parentNode.code.id === childNode.id) { + if (parentNode.javascriptCode.id === childNode.id) { response.childIndex = response.childrenCount } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js new file mode 100644 index 000000000..79a791f6b --- /dev/null +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -0,0 +1,167 @@ +function newNodeCloning () { + const MODULE_NAME = 'Node Cloning' + const ERROR_LOG = true + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + thisObject = { + getNodeClone: getNodeClone + } + return thisObject + + function getNodeClone (node) { + let idConversionMap = new Map() + + let inmatureClone = cloneNode(node) + let matureClone = redirectReferenceParents(inmatureClone) + + return matureClone + + function cloneNode (node) { + if (node === undefined) { return } + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + + /* Children Nodes */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + object[property.name] = cloneNode(node[property.name]) + } + break + } + case 'array': { + if (node[property.name] !== undefined) { + let nodePropertyArray = node[property.name] + object[property.name] = [] + for (let m = 0; m < nodePropertyArray.length; m++) { + let protocolNode = cloneNode(nodePropertyArray[m]) + if (protocolNode !== undefined) { + object[property.name].push(protocolNode) + } + } + } + break + } + } + } + } + + object.id = newUniqueId() + idConversionMap.set(node.id, object.id) + + object.savedPayload = getSavedPayload(node) + + return object + } + } + + function redirectReferenceParents (node) { + if (node === undefined) { return } + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code + } + + /* Children Nodes */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + object[property.name] = redirectReferenceParents(node[property.name]) + } + break + } + case 'array': { + if (node[property.name] !== undefined) { + let nodePropertyArray = node[property.name] + object[property.name] = [] + for (let m = 0; m < nodePropertyArray.length; m++) { + let protocolNode = redirectReferenceParents(nodePropertyArray[m]) + if (protocolNode !== undefined) { + object[property.name].push(protocolNode) + } + } + } + break + } + } + } + } + + object.id = node.id + + object.savedPayload = node.savedPayload + + if (object.savedPayload !== undefined) { + if (object.savedPayload.referenceParent !== undefined) { + let newId = idConversionMap.get(object.savedPayload.referenceParent.id) + if (newId !== undefined) { + object.savedPayload.referenceParent.id = newId + } + } + } + + return object + } + } + } + + function getSavedPayload (node) { + if (node.payload === undefined) { return } + let savedPayload = { + position: { + x: node.payload.position.x, + y: node.payload.position.y + }, + targetPosition: { + x: node.payload.targetPosition.x, + y: node.payload.targetPosition.y + }, + floatingObject: { + isPinned: node.payload.floatingObject.isPinned, + isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually), + isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually), + isTensed: (node.payload.floatingObject.isTensed && node.payload.floatingObject.tensedManually) + }, + uiObject: { + isRunning: node.payload.uiObject.isRunning, + shortcutKey: node.payload.uiObject.shortcutKey + } + } + + /* Next for the ones that have a reference parent, we include it */ + if (node.payload.referenceParent !== undefined) { + savedPayload.referenceParent = { + type: node.payload.referenceParent.type, + subType: node.payload.referenceParent.subType, + name: node.payload.referenceParent.name, + id: node.payload.referenceParent.id + } + } else { + /* The referenceParent property can be inherited from the previous saved payload. */ + if (node.savedPayload !== undefined) { + savedPayload.referenceParent = node.savedPayload.referenceParent + } + } + + return savedPayload + } +} diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js index da06b462f..c5765dc79 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -1,5 +1,6 @@ function newNodeDeleter () { thisObject = { + deleteUIObject: deleteUIObject, deleteDefinition: deleteDefinition, deleteNetwork: deleteNetwork, deleteNetworkNode: deleteNetworkNode, @@ -25,7 +26,6 @@ function newNodeDeleter () { deleteDatasetDefinition: deleteDatasetDefinition, deletePlotter: deletePlotter, deletePlotterModule: deletePlotterModule, - deletePlotterPanel: deletePlotterPanel, deleteSocialBots: deleteSocialBots, deleteSocialBot: deleteSocialBot, deleteAnnouncement: deleteAnnouncement, @@ -188,10 +188,6 @@ function newNodeDeleter () { deletePlotterModule(rootNode, rootNodes) break } - case 'Plotter Panel': { - deletePlotterPanel(rootNode, rootNodes) - break - } case 'Social Bots': { deleteSocialBots(rootNode, rootNodes) break @@ -378,7 +374,7 @@ function newNodeDeleter () { } default: { - console.log('WARNING this node type is not listed at NodeDeleter: ' + rootNode.type) + deleteUIObject(rootNode, rootNodes) } } } @@ -389,6 +385,72 @@ function newNodeDeleter () { cleanNode(node) } + function deleteUIObject (node, rootNodes) { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* Remove all of its own children nodes. */ + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + deleteUIObject(node[property.name], rootNodes) + } + } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + while (nodePropertyArray.length > 0) { + deleteUIObject(nodePropertyArray[0], rootNodes) + } + } + } + break + } + } + } + + /* Remove node from parent */ + if (node.payload.parentNode !== undefined) { + let parentNodeDefinition = APP_SCHEMA_MAP.get(node.payload.parentNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] + if (nodeDefinition.propertyNameAtParent === property.name) { + switch (property.type) { + case 'node': { + node.payload.parentNode[property.name] = undefined + } + break + case 'array': { + let nodePropertyArray = node.payload.parentNode[property.name] + if (nodePropertyArray !== undefined) { + for (let j = 0; j < nodePropertyArray.length; j++) { + let arrayItem = nodePropertyArray[j] + if (arrayItem.id === node.id) { + nodePropertyArray.splice(j, 1) + } + } + } + } + break + } + } + } + } + } + } + + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + } + function deleteDefinition (node, rootNodes) { let payload = node.payload @@ -398,10 +460,6 @@ function newNodeDeleter () { if (node.personalData !== undefined) { deletePersonalData(node.personalData, rootNodes) } - for (let i = 0; i < node.referenceChildren.length; i++) { - let child = node.referenceChildren[i] - child.payload.referenceParent = undefined - } completeDeletion(node, rootNodes) destroyUiObject(node) cleanNode(node) @@ -923,9 +981,13 @@ function newNodeDeleter () { deleteJavascriptCode(node.javascriptCode, rootNodes) } + if (node.shapes !== undefined) { + deleteUIObject(node.shapes, rootNodes) + } + if (node.panels !== undefined) { while (node.panels.length > 0) { - deletePlotterPanel(node.panels[0], rootNodes) + deleteUIObject(node.panels[0], rootNodes) } } @@ -934,27 +996,6 @@ function newNodeDeleter () { cleanNode(node) } - function deletePlotterPanel (node, rootNodes) { - let payload = node.payload - - if (payload.parentNode !== undefined) { - for (let j = 0; j < payload.parentNode.panels.length; j++) { - let panel = payload.parentNode.panels[j] - if (panel.id === node.id) { - payload.parentNode.panels.splice(j, 1) - } - } - } - - if (node.javascriptCode !== undefined) { - deleteJavascriptCode(node.javascriptCode, rootNodes) - } - - completeDeletion(node, rootNodes) - destroyUiObject(node) - cleanNode(node) - } - function deleteSocialBots (node, rootNodes) { let payload = node.payload if (payload.parentNode !== undefined) { @@ -1163,15 +1204,6 @@ function newNodeDeleter () { if (node.socialBots !== undefined) { deleteSocialBots(node.socialBots, rootNodes) } - if (node.payload.referenceParent !== undefined) { - for (let i = 0; i < node.payload.referenceParent.referenceChildren.length; i++) { - let child = node.payload.referenceParent.referenceChildren[i] - if (child.id === node.id) { - node.payload.referenceParent.referenceChildren.splice(i, 1) - return - } - } - } completeDeletion(node, rootNodes) destroyUiObject(node) diff --git a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js index 353eb3723..481e3983b 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js @@ -11,14 +11,12 @@ function newOnFocus () { { if (node.payload.uiObject.isOnFocus === true) { return node - } else { - return } } case 'Condition': { let child - child = getNodeThatIsOnFocus(node.code) + child = getNodeThatIsOnFocus(node.javascriptCode) if (child !== undefined) { return child } @@ -939,7 +937,7 @@ function newOnFocus () { } case 'Procedure Initialization': { let child - child = getNodeThatIsOnFocus(node.code) + child = getNodeThatIsOnFocus(node.javascriptCode) if (child !== undefined) { return child } @@ -951,7 +949,7 @@ function newOnFocus () { } case 'Procedure Loop': { let child - child = getNodeThatIsOnFocus(node.code) + child = getNodeThatIsOnFocus(node.javascriptCode) if (child !== undefined) { return child } @@ -1057,7 +1055,11 @@ function newOnFocus () { } case 'Plotter Module': { let child - child = getNodeThatIsOnFocus(node.code) + child = getNodeThatIsOnFocus(node.javascriptCode) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.shapes) if (child !== undefined) { return child } @@ -1073,16 +1075,48 @@ function newOnFocus () { return } } - case 'Plotter Panel': { - let child - child = getNodeThatIsOnFocus(node.code) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.isOnFocus === true) { - return node - } else { - return + default: { + if (node.payload === undefined) { return } + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* First we ask the question to ourself */ + if (node.payload.uiObject.isOnFocus === true) { + return node + } + + /* Then we check all of its own children nodes. */ + if (node.payload.floatingObject.isCollapsed !== true) { + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let child + child = getNodeThatIsOnFocus(node[property.name]) + if (child !== undefined) { + return child + } + } + } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let m = 0; m < nodePropertyArray.length; m++) { + child = getNodeThatIsOnFocus(nodePropertyArray[m]) + if (child !== undefined) { + return child + } + } + } + } + break + } + } + } + } } } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 68482972f..10038442a 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -1,4 +1,9 @@ function newProtocolNode () { + const MODULE_NAME = 'Protocol Node' + const ERROR_LOG = true + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + thisObject = { getProtocolNode: getProtocolNode } @@ -459,6 +464,9 @@ function newProtocolNode () { name: node.name, code: node.code } + if (parseCode) { + object.code = JSON.parse(node.code) + } if (includeIds) { object.id = node.id } @@ -622,6 +630,9 @@ function newProtocolNode () { name: node.name, code: node.code } + if (parseCode) { + object.code = JSON.parse(node.code) + } if (includeIds) { object.id = node.id } @@ -1621,14 +1632,19 @@ function newProtocolNode () { subType: node.subType, name: node.name, code: node.code, - javascriptCode: getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), - shapes: getProtocolNode(node.shapes, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType), panels: [] } + if (excludeChildren !== true) { + object.javascriptCode = getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object.shapes = getProtocolNode(node.shapes, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + } + if (includeParent) { followAncestors = true excludeChildren = true object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + followAncestors = false + includeParent = false } if (node.panels !== undefined) { for (let m = 0; m < node.panels.length; m++) { @@ -1646,21 +1662,6 @@ function newProtocolNode () { } return object } - case 'Plotter Panel': { - let object = { - type: node.type, - subType: node.subType, - name: node.name, - javascriptCode: getProtocolNode(node.javascriptCode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) - } - if (includeIds) { - object.id = node.id - } - if (includePayload) { - object.savedPayload = getSavedPayload(node, includeReferences) - } - return object - } default: { let nodeDefinition = APP_SCHEMA_MAP.get(node.type) @@ -1676,14 +1677,14 @@ function newProtocolNode () { if (excludeChildren !== true) { /* Children Nodes */ if (nodeDefinition.properties !== undefined) { - for (i = 0; i < nodeDefinition.properties.length; i++) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { if (node[property.name] !== undefined) { if (excludeType !== property.childType) { - object[property.name] = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) } } break @@ -1730,8 +1731,18 @@ function newProtocolNode () { object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferences, followReferenceParent, includeParent, followAncestors, excludeChildren, excludeType) } - if (parseCode) { - object.code = JSON.parse(node.code) + if (parseCode && object.code !== undefined && nodeDefinition.editors !== undefined) { + if (nodeDefinition.editors.config === true) { + try { + object.code = JSON.parse(node.code) + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.type = ' + node.type) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.name = ' + node.name) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.code = ' + node.code) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) } + } + } } if (includeIds) { @@ -1750,6 +1761,7 @@ function newProtocolNode () { } function getSavedPayload (node, includeReferences) { + if (node.payload === undefined) { return } let savedPayload = { position: { x: node.payload.position.x, @@ -1772,24 +1784,6 @@ function newProtocolNode () { } if (includeReferences) { - /* For the ones that have reference children, we include them. */ - if (node.referenceChildren !== undefined) { - let referenceChildren = [] - for (let i = 0; i < node.referenceChildren.length; i++) { - let child = node.referenceChildren[i] - if (child !== undefined) { - let referencedChild = { - type: child.type, - subType: child.subType, - name: child.name, - id: child.id - } - referenceChildren.push(referencedChild) - } - } - savedPayload.referenceChildren = referenceChildren - } - /* Next for the ones that have a reference parent, we include it */ if (node.payload.referenceParent !== undefined) { savedPayload.referenceParent = { @@ -1798,6 +1792,11 @@ function newProtocolNode () { name: node.payload.referenceParent.name, id: node.payload.referenceParent.id } + } else { + /* The referenceParent property can be inherited from the previous saved payload. */ + if (node.savedPayload !== undefined) { + savedPayload.referenceParent = node.savedPayload.referenceParent + } } } return savedPayload diff --git a/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js index ad9ed3e4f..cdf5385dc 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js @@ -7,108 +7,18 @@ function newReferenceAttachDetach () { return thisObject function referenceDetachNode (node) { - switch (node.type) { - case 'Backtesting Session': { - completeDetachment(node) - return - } - case 'Live Trading Session': { - completeDetachment(node) - return - } - case 'Fordward Testing Session': { - completeDetachment(node) - return - } - case 'Paper Trading Session': { - completeDetachment(node) - return - } - case 'Output Dataset': { - completeDetachment(node) - return - } - case 'Data Dependency': { - completeDetachment(node) - return - } - case 'Status Dependency': { - completeDetachment(node) - return - } - case 'Execution Started Event': { - completeDetachment(node) - return - } - case 'Process Instance': { - completeDetachment(node) - return - } - case 'Product Definition': { - completeDetachment(node) - return - } - } + completeDetachment(node) } function referenceAttachNode (node, attachToNode, rootNodes) { - switch (node.type) { - case 'Backtesting Session': { - completeAttachment(node, attachToNode) - } - break - case 'Live Trading Session': { - completeAttachment(node, attachToNode) - } - break - case 'Fordward Testing Session': { - completeAttachment(node, attachToNode) - } - break - case 'Paper Trading Session': { - completeAttachment(node, attachToNode) - } - break - case 'Output Dataset': { - completeAttachment(node, attachToNode) - } - break - case 'Data Dependency': { - completeAttachment(node, attachToNode) - } - break - case 'Status Dependency': { - completeAttachment(node, attachToNode) - } - break - case 'Execution Started Event': { - completeAttachment(node, attachToNode) - } - break - case 'Process Instance': { - completeAttachment(node, attachToNode) - } - break - case 'Product Definition': { - completeAttachment(node, attachToNode) - } - break - } + completeAttachment(node, attachToNode) } function completeAttachment (node, attachToNode) { node.payload.referenceParent = attachToNode - attachToNode.referenceChildren.push(node) } function completeDetachment (node) { - for (let i = 0; i < node.payload.referenceParent.referenceChildren.length; i++) { - let child = node.payload.referenceParent.referenceChildren[i] - if (child.id === node.id) { - node.payload.referenceParent.referenceChildren.splice(i, 1) - return - } - } node.payload.referenceParent = undefined } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js index 31e3c7070..532d19bbe 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -18,7 +18,7 @@ function newShortcutKeys () { case 'Condition': { let child - child = getNodeByShortcutKey(node.code, searchingKey) + child = getNodeByShortcutKey(node.javascriptCode, searchingKey) if (child !== undefined) { return child } @@ -916,7 +916,7 @@ function newShortcutKeys () { } case 'Procedure Initialization': { let child - child = getNodeByShortcutKey(node.code, searchingKey) + child = getNodeByShortcutKey(node.javascriptCode, searchingKey) if (child !== undefined) { return child } @@ -928,7 +928,7 @@ function newShortcutKeys () { } case 'Procedure Loop': { let child - child = getNodeByShortcutKey(node.code, searchingKey) + child = getNodeByShortcutKey(node.javascriptCode, searchingKey) if (child !== undefined) { return child } @@ -1034,7 +1034,11 @@ function newShortcutKeys () { } case 'Plotter Module': { let child - child = getNodeByShortcutKey(node.code, searchingKey) + child = getNodeByShortcutKey(node.javascriptCode, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.shapes, searchingKey) if (child !== undefined) { return child } @@ -1050,19 +1054,50 @@ function newShortcutKeys () { return } } - case 'Plotter Panel': { - let child - child = getNodeByShortcutKey(node.code, searchingKey) - if (child !== undefined) { - return child - } - if (node.payload.uiObject.shortcutKey === searchingKey) { - return node - } else { - return + + default: { + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + if (nodeDefinition !== undefined) { + /* Check Self first */ + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } + + /* Check all of its own children nodes. */ + if (node.payload.floatingObject.isCollapsed !== true) { + if (nodeDefinition.properties !== undefined) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (node[property.name] !== undefined) { + let child + child = getNodeByShortcutKey(node[property.name], searchingKey) + if (child !== undefined) { + return child + } + } + } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let m = 0; m < nodePropertyArray.length; m++) { + child = getNodeByShortcutKey(nodePropertyArray[m], searchingKey) + if (child !== undefined) { + return child + } + } + } + } + break + } + } + } + } } } - } } } diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index e2a05c867..e0217f098 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -1,6 +1,7 @@ function newUiObjectsFromNodes () { thisObject = { recreateWorkspace: recreateWorkspace, + tryToConnectChildrenWithReferenceParents: tryToConnectChildrenWithReferenceParents, createUiObjectFromNode: createUiObjectFromNode, addUIObject: addUIObject, addTeam: addTeam, @@ -28,7 +29,6 @@ function newUiObjectsFromNodes () { addDatasetDefinition: addDatasetDefinition, addPlotter: addPlotter, addPlotterModule: addPlotterModule, - addPlotterPanel: addPlotterPanel, addDefinition: addDefinition, addNetwork: addNetwork, addNetworkNode: addNetworkNode, @@ -69,47 +69,130 @@ function newUiObjectsFromNodes () { addJavascriptCode: addJavascriptCode } - let mapOfReferenceParents - let mapOfReferenceChildren + let mapOfReferenceChildren = new Map() + let mapOfNodes return thisObject function recreateWorkspace (node) { - mapOfReferenceParents = new Map() - mapOfReferenceChildren = new Map() - let workspace = node - createUiObject(false, 'Workspace', workspace.name, workspace, undefined, undefined, 'Workspace') + mapOfNodes = new Map() + + /* Create the workspace UI OBject and then continue with the root nodes. */ + createUiObject(false, 'Workspace', node.name, node, undefined, undefined, 'Workspace') if (node.rootNodes !== undefined) { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] createUiObjectFromNode(rootNode, undefined, undefined) } } + + tryToConnectChildrenWithReferenceParents() + } + + function tryToConnectChildrenWithReferenceParents () { /* We reconstruct here the reference relationships. */ - for (const [key, childNode] of mapOfReferenceChildren) { - childNode.payload.referenceParent = mapOfReferenceParents.get(childNode.savedPayload.referenceParent.id) - childNode.savedPayload = undefined - } - for (const [key, parentNode] of mapOfReferenceParents) { - if (parentNode.referenceChildren === undefined) { - parentNode.referenceChildren = [] + for (const [key, node] of mapOfNodes) { + 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) + 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. + } } - for (let i = 0; i < parentNode.savedPayload.referenceChildren.length; i++) { - let savedChild = parentNode.savedPayload.referenceChildren[i] - if (savedChild.id !== undefined) { - let referenceChild = mapOfReferenceChildren.get(savedChild.id) - parentNode.referenceChildren.push(referenceChild) + if (node.savedPayload !== undefined) { + if (node.savedPayload.referenceParent !== undefined) { // these are children recreated + node.payload.referenceParent = mapOfNodes.get(node.savedPayload.referenceParent.id) } } - parentNode.savedPayload = undefined } - mapOfReferenceChildren = undefined - mapOfReferenceParents = undefined - - return } function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { + /* + Object.keys(node).forEach(function (key, index) { + // key: the name of the object key + // index: the ordinal position of the key within the object + if (key !== 'savedPayload') { + if (node.type === 'Indicator Bot') { + console.log('HERE') + } + if (Array.isArray(node[key]) === false) { + if ((typeof node[key] === 'object') && (node[key] !== null)) { + // this property is an object + + for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { + let schemaNode = APP_SCHEMA_ARRAY[i] + if (schemaNode.type === node.type) { + if (schemaNode.properties === undefined) { + schemaNode.properties = [] + } + + let properties = schemaNode.properties + let found = false + for (let j = 0; j < properties.length; j++) { + let property = properties[j] + if (property.name === key && property.childType === node[key].type) { + found = true + } + } + if (found === false) { + let newProperty = { + name: key, + type: 'node', + childType: node[key].type + } + properties.push(newProperty) + } + setPropertyNameAtParent(node[key], key) + } + } + } + } else { + let childArray = node[key] + if (childArray.length > 0) { + let childType = childArray[0].type + for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { + let schemaNode = APP_SCHEMA_ARRAY[i] + if (schemaNode.type === node.type) { + if (schemaNode.properties === undefined) { + schemaNode.properties = [] + } + + let properties = schemaNode.properties + let found = false + for (let j = 0; j < properties.length; j++) { + let property = properties[j] + if (property.name === key && property.childType === childType) { + found = true + } + } + if (found === false) { + let newProperty = { + name: key, + type: 'array', + childType: childType + } + properties.push(newProperty) + } + setPropertyNameAtParent(childArray[0], key) + } + } + } + } + } + }) + + function setPropertyNameAtParent (node, propName) { + for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { + let schemaNode = APP_SCHEMA_ARRAY[i] + if (schemaNode.type === node.type) { + schemaNode.propertyNameAtParent = propName + } + } + } +*/ switch (node.type) { case 'Javascript Code': { @@ -445,14 +528,6 @@ function newUiObjectsFromNodes () { return } case 'Definition': { - let referenceChildren - if (mapOfReferenceParents !== undefined) { - if (node.savedPayload.referenceChildren !== undefined) { - referenceChildren = [] - mapOfReferenceParents.set(node.id, node) - referenceChildren = node.savedPayload.referenceChildren - } - } createUiObject(false, 'Definition', node.name, node, parentNode, chainParent, 'Definition', positionOffset) if (node.tradingSystem !== undefined) { createUiObjectFromNode(node.tradingSystem, node, node, positionOffset) @@ -460,16 +535,6 @@ function newUiObjectsFromNodes () { if (node.personalData !== undefined) { createUiObjectFromNode(node.personalData, node, node, positionOffset) } - if (node.referenceChildren === undefined) { - node.referenceChildren = [] - } - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } else { - node.referenceChildren = [] - } return } case 'Network': { @@ -567,15 +632,6 @@ function newUiObjectsFromNodes () { return } case 'Process Instance': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } if (parentNode !== undefined) { switch (parentNode.type) { case 'Sensor Bot Instance': { @@ -596,23 +652,9 @@ function newUiObjectsFromNodes () { if (node.session !== undefined) { createUiObjectFromNode(node.session, node, node, positionOffset) } - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Backtesting Session': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, 'Backtesting Session', node.name, node, parentNode, chainParent, 'Backtesting Session', positionOffset) if (node.parameters !== undefined) { createUiObjectFromNode(node.parameters, node, node, positionOffset) @@ -623,23 +665,9 @@ function newUiObjectsFromNodes () { if (node.socialBots !== undefined) { createUiObjectFromNode(node.socialBots, node, node, positionOffset) } - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Live Trading Session': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, 'Live Trading Session', node.name, node, parentNode, chainParent, 'Live Trading Session', positionOffset) if (node.parameters !== undefined) { createUiObjectFromNode(node.parameters, node, node, positionOffset) @@ -650,23 +678,9 @@ function newUiObjectsFromNodes () { if (node.socialBots !== undefined) { createUiObjectFromNode(node.socialBots, node, node, positionOffset) } - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Fordward Testing Session': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, 'Fordward Testing Session', node.name, node, parentNode, chainParent, 'Fordward Testing Session', positionOffset) if (node.parameters !== undefined) { createUiObjectFromNode(node.parameters, node, node, positionOffset) @@ -677,23 +691,9 @@ function newUiObjectsFromNodes () { if (node.socialBots !== undefined) { createUiObjectFromNode(node.socialBots, node, node, positionOffset) } - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Paper Trading Session': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, 'Paper Trading Session', node.name, node, parentNode, chainParent, 'Paper Trading Session', positionOffset) if (node.parameters !== undefined) { createUiObjectFromNode(node.parameters, node, node, positionOffset) @@ -704,11 +704,6 @@ function newUiObjectsFromNodes () { if (node.socialBots !== undefined) { createUiObjectFromNode(node.socialBots, node, node, positionOffset) } - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } @@ -769,14 +764,6 @@ function newUiObjectsFromNodes () { return } case 'Process Definition': { - let referenceChildren - if (mapOfReferenceParents !== undefined) { - if (node.savedPayload.referenceChildren !== undefined) { - referenceChildren = [] - mapOfReferenceParents.set(node.id, node) - referenceChildren = node.savedPayload.referenceChildren - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) if (node.processOutput !== undefined) { createUiObjectFromNode(node.processOutput, node, node, positionOffset) @@ -793,13 +780,6 @@ function newUiObjectsFromNodes () { if (node.executionFinishedEvent !== undefined) { createUiObjectFromNode(node.executionFinishedEvent, node, node, positionOffset) } - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } else { - node.referenceChildren = [] - } return } case 'Process Output': { @@ -823,59 +803,15 @@ function newUiObjectsFromNodes () { return } case 'Status Report': { - let referenceChildren - if (mapOfReferenceParents !== undefined) { - if (node.savedPayload.referenceChildren !== undefined) { - referenceChildren = [] - mapOfReferenceParents.set(node.id, node) - referenceChildren = node.savedPayload.referenceChildren - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } else { - node.referenceChildren = [] - } return } case 'Execution Started Event': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Execution Finished Event': { - let referenceChildren - if (mapOfReferenceParents !== undefined) { - if (node.savedPayload.referenceChildren !== undefined) { - referenceChildren = [] - mapOfReferenceParents.set(node.id, node) - referenceChildren = node.savedPayload.referenceChildren - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } else { - node.referenceChildren = [] - } return } case 'Calculations Procedure': { @@ -915,69 +851,18 @@ function newUiObjectsFromNodes () { return } case 'Output Dataset': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Status Dependency': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Data Dependency': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Product Definition': { - let referenceParent - if (mapOfReferenceChildren !== undefined) { - if (node.savedPayload.referenceParent !== undefined) { - if (node.savedPayload.referenceParent.id !== undefined) { - mapOfReferenceChildren.set(node.id, node) - referenceParent = node.savedPayload.referenceParent - } - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) if (node.record !== undefined) { createUiObjectFromNode(node.record, node, node, positionOffset) @@ -992,11 +877,6 @@ function newUiObjectsFromNodes () { if (node.dataBuilding !== undefined) { createUiObjectFromNode(node.dataBuilding, node, node, positionOffset) } - if (referenceParent !== undefined) { - node.savedPayload = { - referenceParent: referenceParent - } - } return } case 'Record Definition': { @@ -1015,22 +895,7 @@ function newUiObjectsFromNodes () { return } case 'Dataset Definition': { - let referenceChildren - if (mapOfReferenceParents !== undefined) { - if (node.savedPayload.referenceChildren !== undefined) { - referenceChildren = [] - mapOfReferenceParents.set(node.id, node) - referenceChildren = node.savedPayload.referenceChildren - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } else { - node.referenceChildren = [] - } return } case 'Plotter': { @@ -1042,14 +907,6 @@ function newUiObjectsFromNodes () { return } case 'Plotter Module': { - let referenceChildren - if (mapOfReferenceParents !== undefined) { - if (node.savedPayload.referenceChildren !== undefined) { - referenceChildren = [] - mapOfReferenceParents.set(node.id, node) - referenceChildren = node.savedPayload.referenceChildren - } - } createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) if (node.javascriptCode !== undefined) { @@ -1064,30 +921,28 @@ function newUiObjectsFromNodes () { let panel = node.panels[m] createUiObjectFromNode(panel, node, node, positionOffset) } - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } else { - node.referenceChildren = [] - } return } - case 'Plotter Panel': { - createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) - if (node.javascriptCode !== undefined) { - createUiObjectFromNode(node.javascriptCode, node, node, positionOffset) - } - return - } default: { + /* Get node definition */ let nodeDefinition = APP_SCHEMA_MAP.get(node.type) if (nodeDefinition !== undefined) { + /* Resolve Initial Values */ + if (nodeDefinition.initialValues !== undefined) { + if (nodeDefinition.initialValues.code !== undefined) { + if (node.code === undefined) { + node.code = nodeDefinition.initialValues.code + } + } + } + + /* Create Self */ createUiObject(false, node.type, node.name, node, parentNode, chainParent, node.type, positionOffset) + /* Create Children */ if (nodeDefinition.properties !== undefined) { - for (i = 0; i < nodeDefinition.properties.length; i++) { + for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] if (node[property.name] !== undefined) { switch (property.type) { @@ -1108,6 +963,7 @@ function newUiObjectsFromNodes () { } } } + return } } @@ -1118,13 +974,25 @@ function newUiObjectsFromNodes () { name: 'New ' + type, type: type } + createUiObject(true, object.type, object.name, object, parent, parent) - let nodeDefinition = APP_SCHEMA_MAP.get(parent.type) - if (nodeDefinition !== undefined) { - if (nodeDefinition.properties !== undefined) { - for (i = 0; i < nodeDefinition.properties.length; i++) { - let property = nodeDefinition.properties[i] + let parentNodeDefinition = APP_SCHEMA_MAP.get(parent.type) + if (parentNodeDefinition !== undefined) { + /* Resolve Initial Values */ + let nodeDefinition = APP_SCHEMA_MAP.get(object.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.initialValues !== undefined) { + if (nodeDefinition.initialValues.code !== undefined) { + object.code = nodeDefinition.initialValues.code + } + } + } + + /* Connect to Parent */ + if (parentNodeDefinition.properties !== undefined) { + for (let i = 0; i < parentNodeDefinition.properties.length; i++) { + let property = parentNodeDefinition.properties[i] if (property.childType === type) { switch (property.type) { case 'node': { @@ -1132,6 +1000,9 @@ function newUiObjectsFromNodes () { } break case 'array': { + if (parent[property.name] === undefined) { + parent[property.name] = [] + } parent[property.name].push(object) } break @@ -1213,8 +1084,7 @@ function newUiObjectsFromNodes () { let object = { type: 'Process Definition', name: 'New Process Definition', - code: '{}', - referenceChildren: [] + code: '{}' } if (node.processes === undefined) { node.processes = [] @@ -1267,8 +1137,7 @@ function newUiObjectsFromNodes () { if (node.statusReport === undefined) { node.statusReport = { type: 'Status Report', - name: 'New Status Report', - referenceChildren: [] + name: 'New Status Report' } createUiObject(true, node.statusReport.type, node.statusReport.name, node.statusReport, node, node) } @@ -1290,8 +1159,7 @@ function newUiObjectsFromNodes () { if (node.executionFinishedEvent === undefined) { node.executionFinishedEvent = { type: 'Execution Finished Event', - name: 'New Execution Finished Event', - referenceChildren: [] + name: 'New Execution Finished Event' } createUiObject(true, node.executionFinishedEvent.type, node.executionFinishedEvent.name, node.executionFinishedEvent, node, node) } @@ -1360,7 +1228,7 @@ function newUiObjectsFromNodes () { let object = { type: 'Status Dependency', name: 'New Status Dependency', - code: '{ \n\"mainUtility\": \"Self Reference|Market Starting Point|Market Ending Point.\"\n}' + code: '{ \n\"mainUtility\": \"Self Reference|Market Starting Point|Market Ending Point\"\n}' } if (node.statusDependencies === undefined) { node.statusDependencies = [] @@ -1436,8 +1304,7 @@ function newUiObjectsFromNodes () { let object = { type: 'Dataset Definition', name: 'New Dataset Definition', - code: '{}', - referenceChildren: [] + code: '{}' } if (node.datasets === undefined) { node.datasets = [] @@ -1480,20 +1347,6 @@ function newUiObjectsFromNodes () { return object } - function addPlotterPanel (node) { - let object = { - type: 'Plotter Panel', - name: 'New Plotter Panel' - } - if (node.panels === undefined) { - node.panels = [] - } - node.panels.push(object) - createUiObject(true, object.type, object.name, object, node, node) - - return object - } - function addNetwork (node) { let network = { name: 'Superalgos' @@ -1711,8 +1564,7 @@ function newUiObjectsFromNodes () { function addDefinition (node) { let definition = { - name: 'New Definition', - referenceChildren: [] + name: 'New Definition' } node.rootNodes.push(definition) createUiObject(true, 'Definition', definition.name, definition, node, undefined, 'Definition') @@ -1769,9 +1621,14 @@ function newUiObjectsFromNodes () { let exchangeAccount = parentNode let key = { name: 'New Key', - code: 'Paste your exchange API secret key here and the put the key name as this key object title. Secret keys are filtered out and NOT exported when using the SHARE menu option on any object at your workspace. Secret keys ARE downloaded when using the download button.' + code: '{ \n\"name\": \"Paste your exchange API here\",\n"secret\": \"Paste your exchange API secret key here. Exchange keys are filtered out and NOT exported when using the SHARE menu option on any node at your workspace. Exchange keys ARE downloaded when using the DOWNLOAD button or the CLONE button.\"\n}' } - exchangeAccount.keys.push(key) + if (exchangeAccount.keys !== undefined) { + exchangeAccount.keys.push(key) + } else { + exchangeAccount.key = key + } + createUiObject(true, 'Exchange Account Key', key.name, key, exchangeAccount, exchangeAccount, 'Account Key') return key @@ -1873,7 +1730,7 @@ function newUiObjectsFromNodes () { if (node.timePeriod === undefined) { node.timePeriod = { name: 'Time Period', - code: '01-hs' + code: '{ \n\"value\": \"01-hs\"\n}' } createUiObject(true, 'Time Period', '', node.timePeriod, node, node) } @@ -2103,7 +1960,7 @@ function newUiObjectsFromNodes () { node.javascriptCode = { code: DEFAULT_CODE_TEXT } - createUiObject(true, 'Javascript Code', '', node.code, node, node) + createUiObject(true, 'Javascript Code', '', node.javascriptCode, node, node) } return node.javascriptCode @@ -2177,6 +2034,15 @@ function newUiObjectsFromNodes () { function createUiObject (userAddingNew, uiObjectType, name, node, parentNode, chainParent, title, positionOffset) { let payload = {} + if (node.id === undefined) { + node.id = newUniqueId() + } else { + let testNode = mapOfNodes.get(node.id) + if (testNode !== undefined && testNode.cleaned !== true) { + node.id = newUniqueId() + } + } + if (name === '' || name === undefined) { name = 'My ' + uiObjectType } if (node.savedPayload !== undefined) { /* If there is a position offset, we apply it here. */ @@ -2196,6 +2062,15 @@ function newUiObjectsFromNodes () { if (payload.targetPosition.x === null) { payload.targetPosition.x = spawnPosition.x } if (payload.targetPosition.y === null) { payload.targetPosition.y = spawnPosition.y } + + /* Reference children connection to parents */ + if (node.savedPayload.referenceParent !== undefined) { + payload.referenceParent = mapOfNodes.get(node.savedPayload.referenceParent.id) + + if (payload.referenceParent !== undefined) { + mapOfReferenceChildren.set(node.id, node) + } + } } else { if (chainParent === undefined) { payload.targetPosition = { @@ -2229,11 +2104,10 @@ function newUiObjectsFromNodes () { payload.chainParent = chainParent payload.onMenuItemClick = canvas.designerSpace.workspace.onMenuItemClick - if (node.id === undefined) { - node.id = newUniqueId() - } node.payload = payload node.type = uiObjectType canvas.floatingSpace.uiObjectConstructor.createUiObject(userAddingNew, payload) + + mapOfNodes.set(node.id, node) } } diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index ed8f1f339..21b84ffd5 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -17,6 +17,7 @@ function newWorkspace () { stopAllRunningTasks: stopAllRunningTasks, onMenuItemClick: onMenuItemClick, physics: physics, + draw: draw, spawn: spawn, chainDetachNode: chainDetachNode, chainAttachNode: chainAttachNode, @@ -51,6 +52,7 @@ function newWorkspace () { let functionLibraryNodeDeleter = newNodeDeleter() let functionLibraryUiObjectsFromNodes = newUiObjectsFromNodes() let functionLibraryProtocolNode = newProtocolNode() + let functionLibraryNodeCloning = newNodeCloning() let functionLibraryTaskFunctions = newTaskFunctions() let functionLibrarySessionFunctions = newSessionFunctions() let functionLibraryShortcutKeys = newShortcutKeys() @@ -58,6 +60,11 @@ function newWorkspace () { thisObject.nodeChildren = newNodeChildren() + let workingAtTask = 0 + let circularProgressBar = newBusyProgressBar() + circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea + let droppedNode + return thisObject function finalize () { @@ -65,6 +72,8 @@ function newWorkspace () { thisObject.container.finalize() thisObject.container = undefined thisObject.workspaceNode = undefined + circularProgressBar.finalize() + circularProgressBar = undefined } function initialize () { @@ -102,15 +111,49 @@ function newWorkspace () { function physics () { if (thisObject.enabled !== true) { return } - /* Here we will save all the workspace related objects into the local storage */ - let user = window.localStorage.getItem(LOGGED_IN_USER_LOCAL_STORAGE_KEY) - if (user === null) { - return - } - user = JSON.parse(user) let textToSave = stringifyWorkspace() window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) + + if (workingAtTask > 0) { + circularProgressBar.physics() + + switch (workingAtTask) { + case 1: + stopAllRunningTasks() + workingAtTask++ + break + case 2: + functionLibraryNodeDeleter.deleteWorkspace(thisObject.workspaceNode, thisObject.workspaceNode.rootNodes) + workingAtTask++ + break + case 3: + thisObject.workspaceNode = droppedNode + droppedNode = undefined + workingAtTask++ + break + case 4: + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) + workingAtTask++ + break + case 5: + canvas.chartSpace.finalize() + workingAtTask++ + break + case 6: + canvas.chartSpace.initialize() + workingAtTask = 0 + circularProgressBar.visible = false + break + + } + } + } + + function draw () { + if (circularProgressBar !== undefined) { + circularProgressBar.draw() + } } function stringifyWorkspace (removePersonalData) { @@ -158,7 +201,7 @@ function newWorkspace () { let networkNode = rootNode.networkNodes[j] for (let i = 0; i < networkNode.taskManagers.length; i++) { let taskManager = networkNode.taskManagers[i] - for (k = 0; k < taskManager.tasks.length; k++) { + for (let k = 0; k < taskManager.tasks.length; k++) { let task = taskManager.tasks[k] if (task.bot !== undefined) { if (task.bot.type === 'Trading Bot Instance') { @@ -179,7 +222,6 @@ function newWorkspace () { function getNodeByShortcutKey (searchingKey) { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - let definition = rootNode let node = functionLibraryShortcutKeys.getNodeByShortcutKey(rootNode, searchingKey) if (node !== undefined) { return node } } @@ -188,61 +230,41 @@ function newWorkspace () { function getNodeThatIsOnFocus () { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - let definition = rootNode let node = functionLibraryOnFocus.getNodeThatIsOnFocus(rootNode) if (node !== undefined) { return node } } } - function spawn (nodeText, point) { + function spawn (nodeText, mousePointer) { try { + let point = { + x: mousePointer.x, + y: mousePointer.y + } point = canvas.floatingSpace.container.frame.unframeThisPoint(point) spawnPosition.x = point.x spawnPosition.y = point.y - let droppedNode = JSON.parse(nodeText) + droppedNode = JSON.parse(nodeText) if (droppedNode.type === 'Workspace') { - stopAllRunningTasks() - functionLibraryNodeDeleter.deleteWorkspace(thisObject.workspaceNode, thisObject.workspaceNode.rootNodes) - canvas.floatingSpace.warmUp() - thisObject.workspaceNode = droppedNode - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) - canvas.chartSpace.finalize() - canvas.chartSpace.initialize() + circularProgressBar.initialize(mousePointer) + circularProgressBar.visible = true + workingAtTask = 1 return - } else { - if ( - droppedNode.type === 'Definition' || - droppedNode.type === 'Network' || - droppedNode.type === 'Team' - ) { - /* We will only respect the state of each object on these structures, if the structure does not yet exist inside the workspace */ - let alreadyExists = false - for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { - let rootNode = thisObject.workspaceNode.rootNodes[i] - if (droppedNode.id === rootNode.id) { - alreadyExists = true - } - } - if (alreadyExists === false) { - /* It does not exist, so we recreeate it respecting the inner state of each object. */ - let positionOffset = { - x: spawnPosition.x - droppedNode.savedPayload.targetPosition.x, - y: spawnPosition.y - droppedNode.savedPayload.targetPosition.y - } - - thisObject.workspaceNode.rootNodes.push(droppedNode) - functionLibraryUiObjectsFromNodes.createUiObjectFromNode(droppedNode, undefined, undefined, positionOffset) - return - } - } } - /* This is the default behaviour, which consists of cleaning all nodes that are not supported and then creating the UIObjects that remains on the data structure. */ - let rootNode = functionLibraryProtocolNode.getProtocolNode(droppedNode) - thisObject.workspaceNode.rootNodes.push(rootNode) - functionLibraryUiObjectsFromNodes.createUiObjectFromNode(rootNode, undefined, undefined) + /* It does not exist, so we recreeate it respecting the inner state of each object. */ + let positionOffset = { + x: spawnPosition.x - droppedNode.savedPayload.targetPosition.x, + y: spawnPosition.y - droppedNode.savedPayload.targetPosition.y + } + + thisObject.workspaceNode.rootNodes.push(droppedNode) + functionLibraryUiObjectsFromNodes.createUiObjectFromNode(droppedNode, undefined, undefined, positionOffset) + functionLibraryUiObjectsFromNodes.tryToConnectChildrenWithReferenceParents() + + droppedNode = undefined } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] spawn -> err = ' + err.stack) } } @@ -255,6 +277,11 @@ function newWorkspace () { functionLibraryUiObjectsFromNodes.addUIObject(payload.node, relatedUiObject) } break + case 'Delete UI Object': + { + functionLibraryNodeDeleter.deleteUIObject(payload.node, thisObject.workspaceNode.rootNodes) + } + break case 'Share Workspace': { let text = stringifyWorkspace(true) @@ -274,16 +301,7 @@ function newWorkspace () { break case 'Share': { - let text - if ( - payload.node.type === 'Definition' || - payload.node.type === 'Network' || - payload.node.type === 'Team' - ) { - text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true, false, true, true, true)) - } else { - text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true)) - } + let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, true, false, true, true, true)) let nodeName = payload.node.name if (nodeName === undefined) { @@ -298,27 +316,33 @@ function newWorkspace () { break case 'Backup': { - let text - if ( - payload.node.type === 'Definition' || - payload.node.type === 'Network' || - payload.node.type === 'Team' - ) { - text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false, false, true, true, true)) - } else { - text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false)) - } + let text = JSON.stringify(functionLibraryProtocolNode.getProtocolNode(payload.node, false, false, true, true, true)) let nodeName = payload.node.name if (nodeName === undefined) { nodeName = '' } else { - nodeName = '.' + nodeName + nodeName = ' ' + nodeName } let fileName = 'Backup - ' + payload.node.type + ' - ' + nodeName + '.json' download(fileName, text) } + break + case 'Clone': + { + let text = JSON.stringify(functionLibraryNodeCloning.getNodeClone(payload.node)) + + let nodeName = payload.node.name + if (nodeName === undefined) { + nodeName = '' + } else { + nodeName = ' ' + nodeName + } + let fileName = 'Clone - ' + payload.node.type + ' - ' + nodeName + '.json' + download(fileName, text) + } + break case 'Run Task': { @@ -480,11 +504,6 @@ function newWorkspace () { functionLibraryUiObjectsFromNodes.addPlotterModule(payload.node) } break - case 'Add Plotter Panel': - { - functionLibraryUiObjectsFromNodes.addPlotterPanel(payload.node) - } - break case 'Add Network': { functionLibraryUiObjectsFromNodes.addNetwork(payload.node) @@ -762,10 +781,6 @@ function newWorkspace () { functionLibraryNodeDeleter.deletePlotterModule(payload.node, thisObject.workspaceNode.rootNodes) break } - case 'Delete Plotter Panel': { - functionLibraryNodeDeleter.deletePlotterPanel(payload.node, thisObject.workspaceNode.rootNodes) - break - } case 'Delete Network': { functionLibraryNodeDeleter.deleteNetwork(payload.node, thisObject.workspaceNode.rootNodes) break @@ -954,14 +969,4 @@ function newWorkspace () { } } - - function download (filename, text) { - let element = document.createElement('a') - element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)) - element.setAttribute('download', filename) - element.style.display = 'none' - document.body.appendChild(element) - element.click() - document.body.removeChild(element) - } } diff --git a/FloatingSpace/BusyProgressBar.js b/FloatingSpace/BusyProgressBar.js new file mode 100644 index 000000000..a3c846b38 --- /dev/null +++ b/FloatingSpace/BusyProgressBar.js @@ -0,0 +1,72 @@ + +function newBusyProgressBar () { + const MODULE_NAME = 'Circular Progress Bar' + + let thisObject = { + container: undefined, + isDeployed: undefined, + visible: undefined, + physics: physics, + draw: draw, + finalize: finalize, + initialize: initialize + } + + let position + let addRadius + + let eventSubscriptionHeartbeat + + return thisObject + + function finalize () { + thisObject.payload = undefined + thisObject.fitFunction = undefined + } + + function initialize (pPosition) { + position = pPosition + + addRadius = 0 + } + + function physics () { + addRadius = addRadius + 20 + } + + function draw () { + if (thisObject.visible !== true) { return } + + let visiblePosition = { + x: position.x, + y: position.y + } + + visiblePosition = thisObject.fitFunction(visiblePosition) + + const RADIUS = 10 + addRadius + let OPACITY = 1 + + let initialAngle = 0 + let finalAngle = Math.PI * 2 + + browserCanvasContext.beginPath() + + browserCanvasContext.arc(visiblePosition.x, visiblePosition.y, RADIUS, initialAngle, finalAngle, false) + browserCanvasContext.closePath() + + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', 1)' + + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GOLDEN_ORANGE + ', ' + OPACITY * 2 + ')' + browserCanvasContext.lineWidth = 15 + browserCanvasContext.setLineDash([3, 4]) + + browserCanvasContext.stroke() + + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.DARK_TURQUOISE + ', ' + OPACITY + ')' + browserCanvasContext.lineWidth = 10 + browserCanvasContext.setLineDash([3, 4]) + browserCanvasContext.stroke() + } +} + diff --git a/FloatingSpace/CircularMenu.js b/FloatingSpace/CircularMenu.js index 5a63f51a4..4e3efd955 100644 --- a/FloatingSpace/CircularMenu.js +++ b/FloatingSpace/CircularMenu.js @@ -47,6 +47,9 @@ function newCircularMenu () { function initialize (menuItemsInitialValues, payload) { /* Create the array of Menu Items */ + let iconAndTextArray = [] + let iconOnlyArray = [] + for (let i = 0; i < menuItemsInitialValues.length; i++) { let menuItem = newCircularMenuItem() let menuItemInitialValue = menuItemsInitialValues[i] @@ -81,8 +84,10 @@ function newCircularMenu () { if (menuItem.label === undefined) { menuItem.type = 'Icon Only' + iconOnlyArray.push(menuItem) } else { menuItem.type = 'Icon & Text' + iconAndTextArray.push(menuItem) } menuItem.initialize(payload) @@ -90,6 +95,36 @@ function newCircularMenu () { menuItems.push(menuItem) } + /* Here we calculate the angles for each menu item, and then apply it if it was not previously defined. */ + let amplitud = 100 + let initialAngle = 230 + let step = amplitud / (iconOnlyArray.length - 1) + + for (let i = 0; i < iconOnlyArray.length; i++) { + let menuItem = iconOnlyArray[i] + let angle = initialAngle - step * i + if (menuItem.angle === undefined) { + menuItem.angle = angle + } + } + + amplitud = 140 + initialAngle = -70 + step = amplitud / 7 + let currentItem = (7 - iconAndTextArray.length) / 2 + 1 + for (let i = 0; i < iconAndTextArray.length; i++) { + let menuItem = iconAndTextArray[i] + let angle = initialAngle + step * (currentItem - 0.5) + currentItem++ + if (menuItem.angle === undefined) { + menuItem.angle = angle + } + } + + iconOnlyArray = undefined + iconAndTextArray = undefined + + /* Listen to events */ selfFocusEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onFocus', onFocus) selfNotFocuskEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onNotFocus', onNotFocus) } diff --git a/FloatingSpace/CircularMenuItem.js b/FloatingSpace/CircularMenuItem.js index 92ff2d7c5..e8679ff6b 100644 --- a/FloatingSpace/CircularMenuItem.js +++ b/FloatingSpace/CircularMenuItem.js @@ -70,7 +70,7 @@ function newCircularMenuItem () { let temporaryStatus = 0 let temporaryStatusCounter = 0 - const EXTRA_MOUSE_OVER_ICON_SIZE = 2 + const EXTRA_MOUSE_OVER_ICON_SIZE = 6 const STATUS_NO_ACTION_TAKEN_YET = 0 const STATUS_PRIMARY_ACTION_WORKING = -1 @@ -144,8 +144,15 @@ function newCircularMenuItem () { } } - thisObject.container.frame.position.x = thisObject.container.frame.radius * 3 / 7 * Math.cos(toRadians(thisObject.angle)) - thisObject.currentRadius * 1.5 - thisObject.container.frame.position.y = thisObject.container.frame.radius * 3 / 7 * Math.sin(toRadians(thisObject.angle)) - thisObject.container.frame.height / 2 + let radiousGrowthFactor + if (thisObject.type === 'Icon Only') { + radiousGrowthFactor = 5 + } else { + radiousGrowthFactor = 4 + } + + thisObject.container.frame.position.x = thisObject.container.frame.radius * radiousGrowthFactor / 7 * Math.cos(toRadians(thisObject.angle)) - thisObject.currentRadius * 1.5 + thisObject.container.frame.position.y = thisObject.container.frame.radius * radiousGrowthFactor / 7 * Math.sin(toRadians(thisObject.angle)) - thisObject.container.frame.height / 2 /* Temporary Status impacts on the label to use and the background of that label */ if (temporaryStatusCounter > 0) { @@ -242,7 +249,7 @@ function newCircularMenuItem () { /* The first click ask for confirmation. */ if (temporaryStatus === STATUS_NO_ACTION_TAKEN_YET) { - setStatus(thisObject.confirmationLabel, UI_COLOR.GREY, 250, STATUS_WAITING_CONFIRMATION) + setStatus(thisObject.confirmationLabel, UI_COLOR.GOLDEN_ORANGE, 250, STATUS_WAITING_CONFIRMATION) return } /* A Click during confirmation executes the pre-defined action. */ diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 1fb58ce00..43a6e00c2 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -94,6 +94,8 @@ function newCircularProgressBar () { for (let i = 0; i < 60; i++) { let OPACITY = opacityCounters[i] / 1000 + if (OPACITY === 0) { continue } + let initialAngle = Math.PI * 2 / 60 * i - Math.PI / 2 let finalAngle = Math.PI * 2 / 60 * (i + 1) - Math.PI / 2 diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 70d4bc0f1..4c2eec098 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -245,7 +245,7 @@ function newFloatingObject () { thisObject.payload.angle = thisObject.payload.angle - 360 } - if (distanceToChainParent > 1000) { return } // this is introduced to avoid edges cases when importing workspaces. + if (distanceToChainParent > 2000) { return } // this is introduced to avoid edges cases when importing workspaces. newPosition = { x: parent.payload.position.x + distanceToChainParent * Math.cos(toRadians(thisObject.payload.angle)), @@ -318,6 +318,12 @@ function newFloatingObject () { } function someoneAquiredFocus (container) { + if (container === undefined) { + return + } + if (thisObject.container === undefined) { + return + } if (container.id !== thisObject.container.id) { removeFocus() } diff --git a/FloatingSpace/NoteSets.js b/FloatingSpace/NoteSets.js index f61a55c67..f9eaca6f4 100644 --- a/FloatingSpace/NoteSets.js +++ b/FloatingSpace/NoteSets.js @@ -100,7 +100,7 @@ function newNoteSets () { let i - for (i = 0; i < pNewNotes.length; i++) { + for (let i = 0; i < pNewNotes.length; i++) { let plotterNote = pNewNotes[i] let plotterNoteKey = plotterNote.date.toString() + plotterNote.rate.toString() diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 50eb1d391..1d4596695 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -254,308 +254,314 @@ function newUiObject () { if (thisObject.payload.chainParent !== undefined) { return } let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects - let compatibleType - let compatibleSubType + let compatibleTypes + let compatibleSubTypes switch (thisObject.payload.node.type) { case 'Sensor Bot': - compatibleType = '->' + 'Team' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Team' + '->' + compatibleSubTypes = undefined break case 'Indicator Bot': - compatibleType = '->' + 'Team' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Team' + '->' + compatibleSubTypes = undefined break case 'Trading Bot': - compatibleType = '->' + 'Team' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Team' + '->' + compatibleSubTypes = undefined break case 'Process Definition': - compatibleType = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' + compatibleSubTypes = undefined break case 'Process Output': - compatibleType = '->' + 'Process Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Definition' + '->' + compatibleSubTypes = undefined break case 'Process Dependencies': - compatibleType = '->' + 'Process Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Definition' + '->' + compatibleSubTypes = undefined break case 'Status Report': - compatibleType = '->' + 'Process Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Definition' + '->' + compatibleSubTypes = undefined break case 'Execution Started Event': - compatibleType = '->' + 'Process Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Definition' + '->' + compatibleSubTypes = undefined break case 'Execution Finished Event': - compatibleType = '->' + 'Process Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Definition' + '->' + compatibleSubTypes = undefined break case 'Calculations Procedure': - compatibleType = '->' + 'Product Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Product Definition' + '->' + compatibleSubTypes = undefined break case 'Data Building Procedure': - compatibleType = '->' + 'Product Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Product Definition' + '->' + compatibleSubTypes = undefined break case 'Procedure Initialization': - compatibleType = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' + compatibleSubTypes = undefined break case 'Procedure Loop': - compatibleType = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Calculations Procedure' + '->' + 'Data Building Procedure' + '->' + compatibleSubTypes = undefined break case 'Output Dataset': - compatibleType = '->' + 'Process Output' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Output' + '->' + compatibleSubTypes = undefined break case 'Status Dependency': - compatibleType = '->' + 'Process Dependencies' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Dependencies' + '->' + compatibleSubTypes = undefined break case 'Data Dependency': - compatibleType = '->' + 'Process Dependencies' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Dependencies' + '->' + compatibleSubTypes = undefined break case 'Product Definition': - compatibleType = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' + compatibleSubTypes = undefined break case 'Record Definition': - compatibleType = '->' + 'Product Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Product Definition' + '->' + compatibleSubTypes = undefined break case 'Record Property': - compatibleType = '->' + 'Record Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Record Definition' + '->' + compatibleSubTypes = undefined break case 'Dataset Definition': - compatibleType = '->' + 'Product Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Product Definition' + '->' + compatibleSubTypes = undefined break case 'Plotter': - compatibleType = '->' + 'Team' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Team' + '->' + compatibleSubTypes = undefined break case 'Plotter Module': - compatibleType = '->' + 'Plotter' + '->' - compatibleSubType = undefined - break - case 'Plotter Panel': - compatibleType = '->' + 'Plotter Module' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Plotter' + '->' + compatibleSubTypes = undefined break case 'Trading System': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Definition' + '->' + compatibleSubTypes = undefined break case 'Personal Data': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Definition' + '->' + compatibleSubTypes = undefined break case 'Network Node': - compatibleType = '->' + 'Network' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Network' + '->' + compatibleSubTypes = undefined break case 'Exchange Account': - compatibleType = '->' + 'Personal Data' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Personal Data' + '->' + compatibleSubTypes = undefined break case 'Exchange Account Asset': - compatibleType = '->' + 'Exchange Account' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Exchange Account' + '->' + compatibleSubTypes = undefined break case 'Exchange Account Key': - compatibleType = '->' + 'Exchange Account' + '->' + 'Parameters' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Exchange Account' + '->' + 'Parameters' + '->' + compatibleSubTypes = undefined break case 'Parameters': - compatibleType = '->' + 'Trading System' + '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubType = '->' + 'Trading Process Instance' + '->' + compatibleTypes = '->' + 'Trading System' + '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' + compatibleSubTypes = '->' + 'Trading Process Instance' + '->' break case 'Backtesting Session': - compatibleType = '->' + 'Process Instance' + '->' - compatibleSubType = '->' + 'Trading Process Instance' + '->' + compatibleTypes = '->' + 'Process Instance' + '->' + compatibleSubTypes = '->' + 'Trading Process Instance' + '->' break case 'Live Trading Session': - compatibleType = '->' + 'Process Instance' + '->' - compatibleSubType = '->' + 'Trading Process Instance' + '->' + compatibleTypes = '->' + 'Process Instance' + '->' + compatibleSubTypes = '->' + 'Trading Process Instance' + '->' break case 'Paper Trading Session': - compatibleType = '->' + 'Process Instance' + '->' - compatibleSubType = '->' + 'Trading Process Instance' + '->' + compatibleTypes = '->' + 'Process Instance' + '->' + compatibleSubTypes = '->' + 'Trading Process Instance' + '->' break case 'Fordward Testing Session': - compatibleType = '->' + 'Process Instance' + '->' - compatibleSubType = '->' + 'Trading Process Instance' + '->' + compatibleTypes = '->' + 'Process Instance' + '->' + compatibleSubTypes = '->' + 'Trading Process Instance' + '->' break case 'Base Asset': - compatibleType = '->' + 'Parameters' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Parameters' + '->' + compatibleSubTypes = undefined break case 'Time Range': - compatibleType = '->' + 'Parameters' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Parameters' + '->' + compatibleSubTypes = undefined break case 'Time Period': - compatibleType = '->' + 'Parameters' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Parameters' + '->' + compatibleSubTypes = undefined break case 'Slippage': - compatibleType = '->' + 'Parameters' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Parameters' + '->' + compatibleSubTypes = undefined break case 'Fee Structure': - compatibleType = '->' + 'Parameters' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Parameters' + '->' + compatibleSubTypes = undefined break case 'Layer Manager': - compatibleType = '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' + compatibleSubTypes = undefined break case 'Layer': - compatibleType = '->' + 'Layer Manager' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Layer Manager' + '->' + compatibleSubTypes = undefined break case 'Social Bots': - compatibleType = '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Backtesting Session' + '->' + 'Live Trading Session' + '->' + 'Paper Trading Session' + '->' + 'Fordward Testing Session' + '->' + compatibleSubTypes = undefined break case 'Telegram Bot': - compatibleType = '->' + 'Social Bots' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Social Bots' + '->' + compatibleSubTypes = undefined break case 'Announcement': - compatibleType = '->' + 'Telegram Bot' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Take Position Event' + '->' + 'Next Phase Event' + '->' + '->' + 'Phase' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Telegram Bot' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Take Position Event' + '->' + 'Next Phase Event' + '->' + '->' + 'Phase' + '->' + compatibleSubTypes = undefined break case 'Task Manager': - compatibleType = '->' + 'Network Node' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Network Node' + '->' + compatibleSubTypes = undefined break case 'Task': - compatibleType = '->' + 'Task Manager' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Task Manager' + '->' + compatibleSubTypes = undefined break case 'Sensor Bot Instance': - compatibleType = '->' + 'Task' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Task' + '->' + compatibleSubTypes = undefined break case 'Indicator Bot Instance': - compatibleType = '->' + 'Task' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Task' + '->' + compatibleSubTypes = undefined break case 'Trading Bot Instance': - compatibleType = '->' + 'Task' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Task' + '->' + compatibleSubTypes = undefined break case 'Process Instance': switch (thisObject.payload.node.subType) { case 'Sensor Process Instance': { - compatibleType = '->' + 'Sensor Bot Instance' + '->' + compatibleTypes = '->' + 'Sensor Bot Instance' + '->' break } case 'Indicator Process Instance': { - compatibleType = '->' + 'Indicator Bot Instance' + '->' + compatibleTypes = '->' + 'Indicator Bot Instance' + '->' break } case 'Trading Process Instance': { - compatibleType = '->' + 'Trading Bot Instance' + '->' + compatibleTypes = '->' + 'Trading Bot Instance' + '->' break } } - compatibleSubType = undefined + compatibleSubTypes = undefined break case 'Strategy': - compatibleType = '->' + 'Trading System' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Trading System' + '->' + compatibleSubTypes = undefined break case 'Trigger Stage': - compatibleType = '->' + 'Strategy' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Strategy' + '->' + compatibleSubTypes = undefined break case 'Open Stage': - compatibleType = '->' + 'Strategy' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Strategy' + '->' + compatibleSubTypes = undefined break case 'Manage Stage': - compatibleType = '->' + 'Strategy' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Strategy' + '->' + compatibleSubTypes = undefined break case 'Close Stage': - compatibleType = '->' + 'Strategy' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Strategy' + '->' + compatibleSubTypes = undefined break case 'Position Size': - compatibleType = '->' + 'Initial Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Initial Definition' + '->' + compatibleSubTypes = undefined break case 'Position Rate': - compatibleType = '->' + 'Initial Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Initial Definition' + '->' + compatibleSubTypes = undefined break case 'Take Position Event': - compatibleType = '->' + 'Trigger Stage' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Trigger Stage' + '->' + compatibleSubTypes = undefined break case 'Trigger Off Event': - compatibleType = '->' + 'Trigger Stage' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Trigger Stage' + '->' + compatibleSubTypes = undefined break case 'Trigger On Event': - compatibleType = '->' + 'Trigger Stage' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Trigger Stage' + '->' + compatibleSubTypes = undefined break case 'Initial Definition': - compatibleType = '->' + 'Open Stage' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Open Stage' + '->' + compatibleSubTypes = undefined break case 'Open Execution': - compatibleType = '->' + 'Open Stage' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Open Stage' + '->' + compatibleSubTypes = undefined break case 'Close Execution': - compatibleType = '->' + 'Close Stage' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Close Stage' + '->' + compatibleSubTypes = undefined break case 'Stop': - compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' + compatibleSubTypes = undefined break case 'Take Profit': - compatibleType = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Manage Stage' + '->' + 'Initial Definition' + '->' + compatibleSubTypes = undefined break case 'Phase': - compatibleType = '->' + 'Stop' + '->' + 'Take Profit' + '->' + 'Phase' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Stop' + '->' + 'Take Profit' + '->' + 'Phase' + '->' + compatibleSubTypes = undefined break case 'Formula': - compatibleType = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + '->' + 'Announcement' + '->' + 'Record Property' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Position Size' + '->' + 'Position Rate' + '->' + 'Phase' + '->' + 'Announcement' + '->' + 'Record Property' + '->' + compatibleSubTypes = undefined break case 'Next Phase Event': - compatibleType = '->' + 'Phase' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Phase' + '->' + compatibleSubTypes = undefined break case 'Situation': - compatibleType = '->' + 'Take Position Event' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Next Phase Event' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Take Position Event' + '->' + 'Trigger On Event' + '->' + 'Trigger Off Event' + '->' + 'Next Phase Event' + '->' + compatibleSubTypes = undefined break case 'Condition': - compatibleType = '->' + 'Situation' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Situation' + '->' + compatibleSubTypes = undefined break case 'Javascript Code': - compatibleType = '->' + 'Condition' + '->' + 'Procedure Initialization' + '->' + 'Procedure Loop' + '->' + 'Plotter Module' + '->' + 'Plotter Panel' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Condition' + '->' + 'Procedure Initialization' + '->' + 'Procedure Loop' + '->' + 'Plotter Module' + '->' + 'Plotter Panel' + '->' + compatibleSubTypes = undefined break default: - return + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.chainAttachesTo !== undefined) { + compatibleTypes = nodeDefinition.chainAttachesTo.compatibleTypes + compatibleSubTypes = nodeDefinition.chainAttachesTo.compatibleSubTypes + } else { + return + } + } else { + return + } } let foundCompatible = false chainAttachToNode = undefined @@ -566,8 +572,36 @@ function newUiObject () { let distance = nearby[0] let floatingObject = nearby[1] let nearbyNode = floatingObject.payload.node - if (compatibleType.indexOf('->' + nearbyNode.type + '->') >= 0) { - /* Discard objects with busy coonection ports */ + if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { + /* Discard App Schema defined objects with busy coonection ports */ + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + let mustContinue = false + let parentNodeDefinition = APP_SCHEMA_MAP.get(nearbyNode.type) + if (parentNodeDefinition !== undefined) { + if (parentNodeDefinition.properties !== undefined) { + for (let j = 0; j < parentNodeDefinition.properties.length; j++) { + let property = parentNodeDefinition.properties[j] + if (nodeDefinition.propertyNameAtParent === property.name) { + switch (property.type) { + case 'node': { + if (nearbyNode[property.name] !== undefined) { + mustContinue = true + } + } + break + case 'array': { + /* Nothing to worry about since an array can take more than one element. */ + } + break + } + } + } + } + } + if (mustContinue === true) { continue } + } + /* Discard legacy objects with busy coonection ports */ if (thisObject.payload.node.type === 'Status Report' && nearbyNode.statusReport !== undefined) { continue } if (thisObject.payload.node.type === 'Execution Started Event' && nearbyNode.executionStartedEvent !== undefined) { continue } if (thisObject.payload.node.type === 'Execution Finished Event' && nearbyNode.executionFinishedEvent !== undefined) { continue } @@ -611,8 +645,8 @@ function newUiObject () { if (thisObject.payload.node.type === 'Next Phase Event' && nearbyNode.nextPhaseEvent !== undefined) { continue } if (thisObject.payload.node.type === 'Javascript Code' && nearbyNode.javascriptCode !== undefined) { continue } /* Here we check if the subtypes are compatible. */ - if (nearbyNode.subType !== undefined && compatibleSubType !== undefined) { - if (compatibleSubType.indexOf('->' + nearbyNode.subType + '->') < 0) { + if (nearbyNode.subType !== undefined && compatibleSubTypes !== undefined) { + if (compatibleSubTypes.indexOf('->' + nearbyNode.subType + '->') < 0) { continue } } @@ -717,51 +751,61 @@ function newUiObject () { if (thisObject.payload.referenceParent !== undefined) { return } let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects - let compatibleType - let compatibleSubType + let compatibleTypes + let compatibleSubTypes switch (thisObject.payload.node.type) { case 'Backtesting Session': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Definition' + '->' + compatibleSubTypes = undefined break case 'Live Trading Session': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Definition' + '->' + compatibleSubTypes = undefined break case 'Paper Trading Session': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Definition' + '->' + compatibleSubTypes = undefined break case 'Fordward Testing Session': - compatibleType = '->' + 'Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Definition' + '->' + compatibleSubTypes = undefined break case 'Output Dataset': - compatibleType = '->' + 'Dataset Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Dataset Definition' + '->' + compatibleSubTypes = undefined break case 'Data Dependency': - compatibleType = '->' + 'Dataset Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Dataset Definition' + '->' + compatibleSubTypes = undefined break case 'Status Dependency': - compatibleType = '->' + 'Status Report' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Status Report' + '->' + compatibleSubTypes = undefined break case 'Execution Started Event': - compatibleType = '->' + 'Execution Finished Event' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Execution Finished Event' + '->' + compatibleSubTypes = undefined break case 'Process Instance': - compatibleType = '->' + 'Process Definition' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Process Definition' + '->' + compatibleSubTypes = undefined break case 'Product Definition': - compatibleType = '->' + 'Plotter Module' + '->' - compatibleSubType = undefined + compatibleTypes = '->' + 'Plotter Module' + '->' + compatibleSubTypes = undefined break default: - return + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.referenceAttachesTo !== undefined) { + compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes + compatibleSubTypes = nodeDefinition.referenceAttachesTo.compatibleSubTypes + } else { + return + } + } else { + return + } } let foundCompatible = false referenceAttachToNode = undefined @@ -772,10 +816,10 @@ function newUiObject () { let distance = nearby[0] let floatingObject = nearby[1] let nearbyNode = floatingObject.payload.node - if (compatibleType.indexOf('->' + nearbyNode.type + '->') >= 0) { + if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Here we check if the subtypes are compatible. */ - if (nearbyNode.subType !== undefined && compatibleSubType !== undefined) { - if (compatibleSubType.indexOf('->' + nearbyNode.subType + '->') < 0) { + if (nearbyNode.subType !== undefined && compatibleSubTypes !== undefined) { + if (compatibleSubTypes.indexOf('->' + nearbyNode.subType + '->') < 0) { continue } } @@ -1155,7 +1199,7 @@ function newUiObject () { browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' browserCanvasContext.setLineDash([3, 47]) - browserCanvasContext.lineWidth = 4 + browserCanvasContext.lineWidth = 3 browserCanvasContext.stroke() browserCanvasContext.setLineDash([0, 0]) @@ -1164,7 +1208,7 @@ function newUiObject () { browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' browserCanvasContext.setLineDash([1, 9]) - browserCanvasContext.lineWidth = 2 + browserCanvasContext.lineWidth = 1 browserCanvasContext.stroke() browserCanvasContext.setLineDash([0, 0]) } @@ -1211,7 +1255,7 @@ function newUiObject () { browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' browserCanvasContext.setLineDash([1, 9]) - browserCanvasContext.lineWidth = 1 + browserCanvasContext.lineWidth = 0.75 browserCanvasContext.stroke() browserCanvasContext.setLineDash([0, 0]) @@ -1219,7 +1263,7 @@ function newUiObject () { browserCanvasContext.moveTo(position.x, position.y) browserCanvasContext.lineTo(targetPoint.x, targetPoint.y) browserCanvasContext.strokeStyle = 'rgba(' + LINE_STYLE + ', 1)' - browserCanvasContext.setLineDash([1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 0, 100]) + browserCanvasContext.setLineDash([1, 9, 2, 8, 3, 7, 4, 6, 0, 500]) browserCanvasContext.lineWidth = 4 browserCanvasContext.stroke() browserCanvasContext.setLineDash([0, 0]) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index b05162849..00c0d4a65 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -68,6 +68,37 @@ function newUiObjectConstructor () { uiObject.fitFunction = canvas.floatingSpace.fitIntoVisibleArea uiObject.isVisibleFunction = canvas.floatingSpace.isThisPointVisible let menuItemsInitialValues = getMenuItemsInitialValues(uiObject, floatingObject, payload) + + for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { + let schemaNode = APP_SCHEMA_ARRAY[i] + if (schemaNode.type === payload.node.type) { + let menuItems = schemaNode.menuItems + for (let j = 0; j < menuItems.length; j++) { + let item = menuItems[j] + item.angle = undefined + if (item.action.indexOf('Add ') >= 0) { + // item.action = 'Add UI Object' + } + if (item.action.indexOf('Delete ') >= 0) { + // item.action = 'Delete UI Object' + } + if (item.action.indexOf('Configure ') >= 0) { + if (schemaNode.editors.config === true) { + // item.actionFunction = 'uiObject.configEditor.activate' + } + } + if (item.action.indexOf('Edit ') >= 0) { + if (schemaNode.editors.code === true) { + // item.actionFunction = 'uiObject.codeEditor.activate' + } + } + if (item.actionFunction === undefined) { + // item.actionFunction = 'payload.onMenuItemClick' + } + } + } + } + uiObject.initialize(payload, menuItemsInitialValues) uiObject.container.connectToParent(floatingObject.container, false, false, true, true, false, false, true, true, true, true, true) @@ -78,14 +109,13 @@ function newUiObjectConstructor () { payload.uiObject.shortcutKey = payload.node.savedPayload.uiObject.shortcutKey } } - payload.node.savedPayload = undefined floatingLayer.addFloatingObject(floatingObject) return } - function addLeftIcons (menuItemsInitialValues, floatingObject) { + function addLeftIcons (menuItemsInitialValues, floatingObject, isPersonalData) { menuItemsInitialValues.push( { action: 'Pin / Unpin', @@ -98,8 +128,7 @@ function newUiObjectConstructor () { iconPathOff: 'menu-fix-unpinned', rawRadius: 8, targetRadius: 0, - currentRadius: 0, - angle: -130 + currentRadius: 0 } ) menuItemsInitialValues.push( @@ -114,8 +143,7 @@ function newUiObjectConstructor () { iconPathOff: 'menu-tensor-free-angles', rawRadius: 8, targetRadius: 0, - currentRadius: 0, - angle: -155 + currentRadius: 0 } ) menuItemsInitialValues.push( @@ -130,8 +158,7 @@ function newUiObjectConstructor () { iconPathOff: 'menu-mobility-freeze', rawRadius: 8, targetRadius: 0, - currentRadius: 0, - angle: 180 + currentRadius: 0 } ) menuItemsInitialValues.push( @@ -146,8 +173,7 @@ function newUiObjectConstructor () { iconPathOff: 'menu-tree-minus', rawRadius: 8, targetRadius: 0, - currentRadius: 0, - angle: 155 + currentRadius: 0 } ) menuItemsInitialValues.push( @@ -160,4572 +186,110 @@ function newUiObjectConstructor () { iconPathOff: 'menu-backup', rawRadius: 8, targetRadius: 0, - currentRadius: 0, - angle: 130 + currentRadius: 0 } ) + menuItemsInitialValues.push( + { + action: 'Clone', + actionFunction: floatingObject.payload.onMenuItemClick, + label: undefined, + visible: true, + iconPathOn: 'clone', + iconPathOff: 'clone', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0 + } + ) + if (isPersonalData !== true) { + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: floatingObject.payload.onMenuItemClick, + label: undefined, + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0 + } + ) + } } function getMenuItemsInitialValues (uiObject, floatingObject, payload) { let menuItemsInitialValues = [] - switch (payload.node.type) { - case 'Workspace': { - floatingObject.isPinned = true - floatingObject.positionLocked = true - menuItemsInitialValues = [ - { - action: 'Pin / Unpin', - actionFunction: floatingObject.pinToggle, - actionStatus: floatingObject.getPinStatus, - currentStatus: true, - label: undefined, - visible: true, - iconPathOn: 'menu-fix-unpinned', - iconPathOff: 'menu-fix-pinned', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -135 - }, - { - action: 'Backup Workspace', - actionFunction: payload.onMenuItemClick, - label: undefined, - visible: true, - iconPathOn: 'menu-backup', - iconPathOff: 'menu-backup', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 130 - }, - { - action: 'Add Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Definition', - visible: true, - relatedUiObject: 'Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - }, - { - action: 'Add Network', - actionFunction: payload.onMenuItemClick, - label: 'Add Network', - visible: true, - relatedUiObject: 'Network', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -10 - }, - { - action: 'Add Team', - actionFunction: payload.onMenuItemClick, - label: 'Add Team', - visible: true, - relatedUiObject: 'Team', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 10 - }, - { - action: 'Share Workspace', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - }] - break - } - case 'Definition': { - floatingObject.isPinned = true - floatingObject.positionLocked = true - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Trading System', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'tradingSystem', - actionFunction: payload.onMenuItemClick, - label: 'Add Trading System', - visible: true, - relatedUiObject: 'Trading System', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Personal Data', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'personalData', - actionFunction: payload.onMenuItemClick, - label: 'Add Personal Data', - visible: true, - relatedUiObject: 'Personal Data', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -10 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Definition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Definition', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 10 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - break - } - case 'Team': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Team', - actionFunction: uiObject.configEditor.activate, - label: 'Configigure Team', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Sensor Bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Sensor Bot', - visible: true, - relatedUiObject: 'Sensor Bot', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Indicator Bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Indicator Bot', - visible: true, - relatedUiObject: 'Indicator Bot', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Trading Bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Trading Bot', - visible: true, - relatedUiObject: 'Trading Bot', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Plotter', - actionFunction: payload.onMenuItemClick, - label: 'Add Plotter', - visible: true, - relatedUiObject: 'Plotter', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Team', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Team', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - case 'Sensor Bot': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Bot', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Bot', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Process Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Process Definition', - visible: true, - relatedUiObject: 'Process Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Product Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Product Definition', - visible: true, - relatedUiObject: 'Product Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Sensor Bot', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Sensor Bot', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Indicator Bot': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Bot', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Bot', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Process Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Process Definition', - visible: true, - relatedUiObject: 'Process Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Product Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Product Definition', - visible: true, - relatedUiObject: 'Product Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Indicator Bot', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Indicator Bot', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Trading Bot': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Bot', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Bot', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Process Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Process Definition', - visible: true, - relatedUiObject: 'Process Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Product Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Product Definition', - visible: true, - relatedUiObject: 'Product Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Trading Bot', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Trading Bot', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Process Definition': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Process', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Process', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Missing Process Definition Items', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Items', - visible: true, - relatedUiObject: 'Calculations Procedure', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Process Definition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Process Definition', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Process Output': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Output Dataset', - actionFunction: payload.onMenuItemClick, - label: 'Add Output Dataset', - visible: true, - relatedUiObject: 'Output Dataset', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Process Output', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Process Output', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - break - } - case 'Process Dependencies': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Status Dependency', - actionFunction: payload.onMenuItemClick, - label: 'Add Status Dependency', - visible: true, - relatedUiObject: 'Status Dependency', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Data Dependency', - actionFunction: payload.onMenuItemClick, - label: 'Add Data Dependency', - visible: true, - relatedUiObject: 'Data Dependency', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Process Dependencies', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Process Dependencies', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Status Report': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Status Report', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Status Report', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - break - } - case 'Execution Started Event': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Execution Started Event', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Event', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - break - } - case 'Execution Finished Event': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Execution Finished Event', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Event', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - break - } - case 'Calculations Procedure': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Procedure Initialization', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'initialization', - actionFunction: payload.onMenuItemClick, - label: 'Add Procedure Initialization', - visible: true, - relatedUiObject: 'Procedure Initialization', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Procedure Loop', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'loop', - actionFunction: payload.onMenuItemClick, - label: 'Add Procedure Loop', - visible: true, - relatedUiObject: 'Procedure Loop', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Calculations Procedure', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Procedure', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Data Building Procedure': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Procedure Initialization', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'initialization', - actionFunction: payload.onMenuItemClick, - label: 'Add Procedure Initialization', - visible: true, - relatedUiObject: 'Procedure Initialization', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Procedure Loop', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'loop', - actionFunction: payload.onMenuItemClick, - label: 'Add Procedure Loop', - visible: true, - relatedUiObject: 'Procedure Loop', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Data Building Procedure', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Procedure', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Procedure Initialization': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Code', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'code', - actionFunction: payload.onMenuItemClick, - label: 'Add Code', - visible: true, - relatedUiObject: 'Javascript Code', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Procedure Initialization', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Initialization', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Procedure Loop': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Code', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'code', - actionFunction: payload.onMenuItemClick, - label: 'Add Code', - visible: true, - relatedUiObject: 'Javascript Code', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Procedure Loop', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Procedure Loop', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Output Dataset': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Output Dataset', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Output Dataset', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - break - } - case 'Status Dependency': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Status Dependency', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Status Dependency', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Status Dependency', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Status Dependency', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Data Dependency': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Data Dependency', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Data Dependency', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - break - } - case 'Product Definition': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Product', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Product', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Record Definition', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'record', - actionFunction: payload.onMenuItemClick, - label: 'Add Record Definition', - visible: true, - relatedUiObject: 'Record Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Dataset Definition', - actionFunction: payload.onMenuItemClick, - label: 'Add Dataset Definition', - visible: true, - relatedUiObject: 'Dataset Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -10 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Missing Product Definition Items', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Items', - visible: true, - relatedUiObject: 'Calculations Procedure', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 10 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Product Definition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Product Definition', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Record Definition': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Record Property', - actionFunction: payload.onMenuItemClick, - label: 'Add Record Property', - visible: true, - relatedUiObject: 'Record Property', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Record Definition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Record Definition', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - break - } - case 'Record Property': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Property', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Property', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Formula', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'formula', - actionFunction: payload.onMenuItemClick, - label: 'Add Formula', - visible: true, - relatedUiObject: 'Formula', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Record Property', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Record Property', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Dataset Definition': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Definition', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Definition', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Dataset Definition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Dataset', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - break - } - case 'Plotter': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Plotter', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Plotter', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Plotter Module', - actionFunction: payload.onMenuItemClick, - label: 'Add Plotter Module', - visible: true, - relatedUiObject: 'Plotter Module', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -10 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Plotter', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Plotter', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 10 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - break - } - case 'Plotter Module': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Plotter Module', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Plotter Module', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Code', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'code', - actionFunction: payload.onMenuItemClick, - label: 'Add Code', - visible: true, - relatedUiObject: 'Javascript Code', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - } - ) - menuItemsInitialValues.push( - { - action: 'Add UI Object', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'shapes', - actionFunction: payload.onMenuItemClick, - label: 'Add Shapes', - visible: true, - relatedUiObject: 'Shapes', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -10 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Plotter Panel', - actionFunction: payload.onMenuItemClick, - label: 'Add Plotter Panel', - visible: true, - relatedUiObject: 'Plotter Panel', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 10 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Plotter Module', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Plotter Module', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Plotter Panel': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Code', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'code', - actionFunction: payload.onMenuItemClick, - label: 'Add Code', - visible: true, - relatedUiObject: 'Javascript Code', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -30 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Plotter Panel', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Plotter Panel', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 30 - } - ) - break - } - case 'Network': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Network Node', - actionFunction: payload.onMenuItemClick, - label: 'Add Network Node', - visible: true, - relatedUiObject: 'Network Node', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Network', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Network', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Network Node': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Task Manager', - actionFunction: payload.onMenuItemClick, - label: 'Add Task Manager', - visible: true, - relatedUiObject: 'Task Manager', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Network Node', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Network Node', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Social Bots': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Telegram Bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Telegram Bot', - visible: true, - relatedUiObject: 'Telegram Bot', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Social Bots', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Social Bots', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Telegram Bot': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Announcement', - actionFunction: payload.onMenuItemClick, - label: 'Add Announcement', - visible: true, - relatedUiObject: 'Announcement', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - menuItemsInitialValues.push( - { - action: 'Configure Telegram Bot', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Telegram Bot', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Social Bot', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Telegram Bot', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Announcement': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Formula', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'formula', - actionFunction: payload.onMenuItemClick, - label: 'Add Formula', - visible: true, - relatedUiObject: 'Formula', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Announcement', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Announcement', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Announcement', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Announcement', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Layer Manager': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Layer', - actionFunction: payload.onMenuItemClick, - label: 'Add Layer', - visible: true, - relatedUiObject: 'Layer', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Layer Manager', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Layer Manager', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Layer': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Layer', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Layer', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Layer', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Layer', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Task Manager': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Run All Tasks', - actionFunction: payload.onMenuItemClick, - label: 'Run All Tasks', - visible: true, - iconPathOn: 'paper-plane', - iconPathOff: 'paper-plane', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - menuItemsInitialValues.push( - { - action: 'Stop All Tasks', - actionFunction: payload.onMenuItemClick, - label: 'Stop All Tasks', - visible: true, - iconPathOn: 'stop', - iconPathOff: 'stop', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Task', - actionFunction: payload.onMenuItemClick, - label: 'Add Task', - visible: true, - relatedUiObject: 'Task Manager', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Task Manager', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Task Manager', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Task': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Run Task', - actionFunction: payload.onMenuItemClick, - label: 'Run', - workingLabel: 'Stop', - workDoneLabel: 'Task Running', - workFailedLabel: 'Task Cannot be Run', - secondaryAction: 'Stop Task', - secondaryLabel: 'Stop', - secondaryWorkingLabel: 'Stopping...', - secondaryWorkDoneLabel: 'Task Stopped', - secondaryWorkFailedLabel: 'Task Cannot be Stopped', - secondaryIcon: 'stop', - visible: true, - iconPathOn: 'paper-plane', - iconPathOff: 'paper-plane', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Sensor Bot Instance', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Sensor Bot Instance', - visible: true, - relatedUiObject: 'Sensor Bot Instance', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -35 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Indicator Bot Instance', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Indicator Bot Instance', - visible: true, - relatedUiObject: 'Indicator Bot Instance', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -12 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Trading Bot Instance', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'bot', - actionFunction: payload.onMenuItemClick, - label: 'Add Trading Bot Instance', - visible: true, - relatedUiObject: 'Trading Bot Instance', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 12 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Task', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Task', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: +35 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - case 'Sensor Bot Instance': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Sensor Bot Instance', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Sensor Bot Instance', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Process Instance', - actionFunction: payload.onMenuItemClick, - label: 'Add Process Instance', - visible: true, - relatedUiObject: 'Process Instance', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Sensor Bot Instance', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Sensor Bot Instance', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Indicator Bot Instance': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Indicator Bot Instance', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Indicator Bot Instance', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Process Instance', - actionFunction: payload.onMenuItemClick, - label: 'Add Process Instance', - visible: true, - relatedUiObject: 'Process Instance', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Indicator Bot Instance', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Indicator Bot Instance', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Trading Bot Instance': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Trading Bot Instance', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Trading Bot Instance', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -45, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Process Instance', - actionFunction: payload.onMenuItemClick, - label: 'Add Process Instance', - visible: true, - relatedUiObject: 'Process Instance', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -15 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Trading Bot Instance', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Trading Bot Instance', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 15 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 45 - } - ) - break - } - case 'Process Instance': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - - switch (payload.node.subType) { - case 'Trading Process Instance': { - menuItemsInitialValues.push( - { - action: 'Add Backtesting Session', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'session', - actionFunction: payload.onMenuItemClick, - label: 'Add Backtesting', - visible: true, - relatedUiObject: 'Backtesting Session', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Live Trading Session', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'session', - actionFunction: payload.onMenuItemClick, - label: 'Add Live Trading', - visible: true, - relatedUiObject: 'Live Trading Session', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Fordward Testing Session', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'session', - actionFunction: payload.onMenuItemClick, - label: 'Add Fordward Testing', - visible: true, - relatedUiObject: 'Fordward Testing Session', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Paper Trading Session', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'session', - actionFunction: payload.onMenuItemClick, - label: 'Add Paper Trading', - visible: true, - relatedUiObject: 'Paper Trading Session', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Configure Process Instance', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Process Instance', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Process Instance', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Process Instance', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - default: { - menuItemsInitialValues.push( - { - action: 'Configure Process Instance', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Process Instance', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Process Instance', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Process Instance', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } + let nodeDefinition = APP_SCHEMA_MAP.get(payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.editors !== undefined) { + if (nodeDefinition.editors.config === true) { + uiObject.configEditor = newConfigEditor() + uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.configEditor.initialize() + uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) } - break - } - case 'Backtesting Session': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Run Session', - actionFunction: payload.onMenuItemClick, - label: 'Run', - workingLabel: 'Run Request Sent', - workDoneLabel: 'Session Running', - workFailedLabel: 'Session Cannot be Run', - secondaryAction: 'Stop Session', - secondaryLabel: 'Stop', - secondaryWorkingLabel: 'Stopping...', - secondaryWorkDoneLabel: 'Session Stopped', - secondaryWorkFailedLabel: 'Session Cannot be Stopped', - secondaryIcon: 'stop', - visible: true, - iconPathOn: 'paper-plane', - iconPathOff: 'paper-plane', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Layer Manager', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'layerManager', - actionFunction: payload.onMenuItemClick, - label: 'Add Layer Manager', - visible: true, - relatedUiObject: 'Layer Manager', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Parameters', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'parameters', - actionFunction: payload.onMenuItemClick, - label: 'Add Parameters', - visible: true, - relatedUiObject: 'Parameters', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Social Bots', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'socialBots', - actionFunction: payload.onMenuItemClick, - label: 'Add Social Bots', - visible: true, - relatedUiObject: 'Social Bots', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Configure Session', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Session', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Backtesting Session', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Session', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - case 'Live Trading Session': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Run Session', - actionFunction: payload.onMenuItemClick, - label: 'Run', - workingLabel: 'Run Request Sent', - workDoneLabel: 'Session Running', - workFailedLabel: 'Session Cannot be Run', - secondaryAction: 'Stop Session', - secondaryLabel: 'Stop', - secondaryWorkingLabel: 'Stopping...', - secondaryWorkDoneLabel: 'Session Stopped', - secondaryWorkFailedLabel: 'Session Cannot be Stopped', - secondaryIcon: 'stop', - visible: true, - iconPathOn: 'paper-plane', - iconPathOff: 'paper-plane', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Layer Manager', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'layerManager', - actionFunction: payload.onMenuItemClick, - label: 'Add Layer Manager', - visible: true, - relatedUiObject: 'Layer Manager', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Parameters', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'parameters', - actionFunction: payload.onMenuItemClick, - label: 'Add Parameters', - visible: true, - relatedUiObject: 'Parameters', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Social Bots', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'socialBots', - actionFunction: payload.onMenuItemClick, - label: 'Add Social Bots', - visible: true, - relatedUiObject: 'Social Bots', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Configure Session', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Session', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Live Trading Session', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Session', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - case 'Fordward Testing Session': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Run Session', - actionFunction: payload.onMenuItemClick, - label: 'Run', - workingLabel: 'Run Request Sent', - workDoneLabel: 'Session Running', - workFailedLabel: 'Session Cannot be Run', - secondaryAction: 'Stop Session', - secondaryLabel: 'Stop', - secondaryWorkingLabel: 'Stopping...', - secondaryWorkDoneLabel: 'Session Stopped', - secondaryWorkFailedLabel: 'Session Cannot be Stopped', - secondaryIcon: 'stop', - visible: true, - iconPathOn: 'paper-plane', - iconPathOff: 'paper-plane', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Layer Manager', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'layerManager', - actionFunction: payload.onMenuItemClick, - label: 'Add Layer Manager', - visible: true, - relatedUiObject: 'Layer Manager', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Parameters', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'parameters', - actionFunction: payload.onMenuItemClick, - label: 'Add Parameters', - visible: true, - relatedUiObject: 'Parameters', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Social Bots', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'socialBots', - actionFunction: payload.onMenuItemClick, - label: 'Add Social Bots', - visible: true, - relatedUiObject: 'Social Bots', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Configure Session', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Session', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Fordward Testing Session', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Session', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - case 'Paper Trading Session': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Run Session', - actionFunction: payload.onMenuItemClick, - label: 'Run', - workingLabel: 'Run Request Sent', - workDoneLabel: 'Session Running', - workFailedLabel: 'Session Cannot be Run', - secondaryAction: 'Stop Session', - secondaryLabel: 'Stop', - secondaryWorkingLabel: 'Stopping...', - secondaryWorkDoneLabel: 'Session Stopped', - secondaryWorkFailedLabel: 'Session Cannot be Stopped', - secondaryIcon: 'stop', - visible: true, - iconPathOn: 'paper-plane', - iconPathOff: 'paper-plane', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -75 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Layer Manager', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'layerManager', - actionFunction: payload.onMenuItemClick, - label: 'Add Layer Manager', - visible: true, - relatedUiObject: 'Layer Manager', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Parameters', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'parameters', - actionFunction: payload.onMenuItemClick, - label: 'Add Parameters', - visible: true, - relatedUiObject: 'Parameters', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Social Bots', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'socialBots', - actionFunction: payload.onMenuItemClick, - label: 'Add Social Bots', - visible: true, - relatedUiObject: 'Social Bots', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Configure Session', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Session', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Paper Trading Session', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Session', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 75 - } - ) - break - } - case 'Personal Data': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Exchange Account', - actionFunction: payload.onMenuItemClick, - label: 'Add Exchange Account', - visible: true, - relatedUiObject: 'Exchange Account', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Personal Data', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Personal Data', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: +20 - } - ) - break - } - case 'Exchange Account': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Exchange Account Asset', - actionFunction: payload.onMenuItemClick, - label: 'Add Asset', - visible: true, - relatedUiObject: 'Exchange Account Asset', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Exchange Account Key', - actionFunction: payload.onMenuItemClick, - label: 'Add Key', - visible: true, - relatedUiObject: 'Exchange Account Key', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Exchange Account', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Account', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Exchange Account Asset': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Exchange Account Asset', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Asset', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - break - } - case 'Exchange Account Key': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Key Value', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Key Value', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Exchange Account Key', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Key', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - break - } - case 'Trading System': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Strategy', - actionFunction: payload.onMenuItemClick, - label: 'Add Strategy', - visible: true, - relatedUiObject: 'Strategy', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Parameters', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'parameters', - actionFunction: payload.onMenuItemClick, - label: 'Add Parameters', - visible: true, - relatedUiObject: 'Parameters', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Trading System', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Trading System', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Parameters': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Missing Parameters', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Params', - visible: true, - relatedUiObject: 'Parameters', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Parameters', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Parameters', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Base Asset': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Base Asset', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Base Asset', - visible: true, - iconPathOn: 'settings', - iconPathOff: 'settings', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Base Asset', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Base Asset', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Time Range': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Time Range', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Time Range', - visible: true, - iconPathOn: 'settings', - iconPathOff: 'settings', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Time Range', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Time Range', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Time Period': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Time Period', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Time Period', - visible: true, - iconPathOn: 'settings', - iconPathOff: 'settings', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Time Period', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Time Period', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Slippage': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Slippage', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Slippage', - visible: true, - iconPathOn: 'settings', - iconPathOff: 'settings', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Slippage', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Slippage', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Fee Structure': { - uiObject.configEditor = newConfigEditor() - uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() - uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Configure Fee Structure', - actionFunction: uiObject.configEditor.activate, - label: 'Configure Fee Structure', - visible: true, - iconPathOn: 'settings', - iconPathOff: 'settings', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Fee Structure', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Fee Structure', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Strategy': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Missing Stages', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Stages', - visible: true, - relatedUiObject: 'Strategy', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Strategy', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Strategy', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Trigger Stage': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Missing Events', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Events', - visible: true, - relatedUiObject: 'Trigger Stage', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Trigger Stage', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Stage', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Open Stage': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Initial Definition', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'initialDefinition', - actionFunction: payload.onMenuItemClick, - label: 'Add Initial Definition', - visible: true, - relatedUiObject: 'Initial Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Open Execution', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'openExecution', - actionFunction: payload.onMenuItemClick, - label: 'Add Open Execution', - visible: true, - relatedUiObject: 'Open Execution', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Open Stage', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Stage', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Manage Stage': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Missing Items', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Items', - visible: true, - relatedUiObject: 'Manage Stage', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Manage Stage', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Stage', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Close Stage': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Close Execution', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'closeExecution', - actionFunction: payload.onMenuItemClick, - label: 'Add Close Execution', - visible: true, - relatedUiObject: 'Close Execution', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Close Stage', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Stage', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Position Size': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Formula', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'formula', - actionFunction: payload.onMenuItemClick, - label: 'Add Formula', - visible: true, - relatedUiObject: 'Formula', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Position Size', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Position Size', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Position Rate': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Formula', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'formula', - actionFunction: payload.onMenuItemClick, - label: 'Add Formula', - visible: true, - relatedUiObject: 'Formula', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Position Rate', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete Position Rate', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Trigger On Event': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Situation', - actionFunction: payload.onMenuItemClick, - label: 'Add Situation', - visible: true, - relatedUiObject: 'Situation', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Event', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Event', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Trigger Off Event': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Situation', - actionFunction: payload.onMenuItemClick, - label: 'Add Situation', - visible: true, - relatedUiObject: 'Situation', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Event', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Event', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Take Position Event': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Situation', - actionFunction: payload.onMenuItemClick, - label: 'Add Situation', - visible: true, - relatedUiObject: 'Situation', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Event', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Event', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Initial Definition': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Missing Items', - actionFunction: payload.onMenuItemClick, - label: 'Add Missing Items', - visible: true, - relatedUiObject: 'Initial Definition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Initial Definition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Definition', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Open Execution': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Open Execution', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - break - } - case 'Close Execution': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Delete Close Execution', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - break - } - case 'Stop': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Phase', - actionFunction: payload.onMenuItemClick, - label: 'Add Phase', - visible: true, - relatedUiObject: 'Phase', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Managed Item', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Item', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Take Profit': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Phase', - actionFunction: payload.onMenuItemClick, - label: 'Add Phase', - visible: true, - relatedUiObject: 'Phase', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Managed Item', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Item', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Phase': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Formula', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'formula', - actionFunction: payload.onMenuItemClick, - label: 'Add Formula', - visible: true, - relatedUiObject: 'Formula', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Next Phase Event', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'nextPhaseEvent', - actionFunction: payload.onMenuItemClick, - label: 'Add Next Phase Event', - visible: true, - relatedUiObject: 'Next Phase Event', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Phase', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Phase', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Formula': { - uiObject.formulaEditor = newFormulaEditor() - uiObject.formulaEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.formulaEditor.initialize() - uiObject.formulaEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Edit Formula', - actionFunction: uiObject.formulaEditor.activate, - label: 'Edit Formula', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Formula', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Formula', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Next Phase Event': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Situation', - actionFunction: payload.onMenuItemClick, - label: 'Add Situation', - visible: true, - relatedUiObject: 'Situation', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Event', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Event', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Situation': { - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Add Condition', - actionFunction: payload.onMenuItemClick, - label: 'Add Condition', - visible: true, - relatedUiObject: 'Condition', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Situation', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Situation', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - case 'Condition': { - uiObject.conditionEditor = newConditionEditor() - uiObject.conditionEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.conditionEditor.initialize() - uiObject.conditionEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Edit Condition', - actionFunction: uiObject.conditionEditor.activate, - label: 'Edit Condition', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -60, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Add Code', - disableIfPropertyIsDefined: true, - propertyToCheckFor: 'code', - actionFunction: payload.onMenuItemClick, - label: 'Add Code', - visible: true, - relatedUiObject: 'Javascript Code', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -20 - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Condition', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Condition', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 60 - } - ) - break - } - case 'Javascript Code': { - uiObject.codeEditor = newCodeEditor() - uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.codeEditor.initialize() - uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) - - addLeftIcons(menuItemsInitialValues, floatingObject) - menuItemsInitialValues.push( - { - action: 'Edit Code', - actionFunction: uiObject.codeEditor.activate, - label: 'Edit Code', - visible: true, - iconPathOn: 'html', - iconPathOff: 'html', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40, - dontShowAtFullscreen: true - } - ) - menuItemsInitialValues.push( - { - action: 'Delete Code', - askConfirmation: true, - confirmationLabel: 'Confirm to Delete', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Code', - visible: true, - iconPathOn: 'delete', - iconPathOff: 'delete', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Share', - actionFunction: payload.onMenuItemClick, - label: 'Share', - visible: true, - iconPathOn: 'menu-share', - iconPathOff: 'menu-share', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - } - ) - break - } - default: { - let nodeDefinition = APP_SCHEMA_MAP.get(payload.node.type) - if (nodeDefinition !== undefined) { - for (i = 0; i < nodeDefinition.menuItems.length; i++) { - let menutItemDefinition = nodeDefinition.menuItems[i] - let newMenuItem = JSON.parse(JSON.stringify(menutItemDefinition)) - - /* We need to reference the real function based on its name */ - if (menutItemDefinition.actionFunction !== undefined) { - newMenuItem.actionFunction = eval(menutItemDefinition.actionFunction) - } - menuItemsInitialValues.push(newMenuItem) - } - } else { - if (ERROR_LOG === true) { logger.write('[ERROR] getMenuItemsInitialValues -> UI Object Type not Recognized -> type = ' + payload.node.type) } + if (nodeDefinition.editors.code === true) { + uiObject.codeEditor = newCodeEditor() + uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.codeEditor.initialize() + uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + } + if (nodeDefinition.editors.formula === true) { + uiObject.formulaEditor = newFormulaEditor() + uiObject.formulaEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.formulaEditor.initialize() + uiObject.formulaEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + } + if (nodeDefinition.editors.condition === true) { + uiObject.conditionEditor = newConditionEditor() + uiObject.conditionEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.conditionEditor.initialize() + uiObject.conditionEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) } } + if (nodeDefinition.addLeftIcons === true) { + addLeftIcons(menuItemsInitialValues, floatingObject, nodeDefinition.isPersonalData) + } + if (nodeDefinition.isPinned === true) { + floatingObject.isPinned = true + } + if (nodeDefinition.positionLocked === true) { + floatingObject.positionLocked = true + } + + for (let i = 0; i < nodeDefinition.menuItems.length; i++) { + let menutItemDefinition = nodeDefinition.menuItems[i] + let newMenuItem = JSON.parse(JSON.stringify(menutItemDefinition)) + + /* We need to reference the real function based on its name */ + if (menutItemDefinition.actionFunction !== undefined) { + newMenuItem.actionFunction = eval(menutItemDefinition.actionFunction) + } + + /* Adding default values */ + if (newMenuItem.visible === undefined) { + newMenuItem.visible = true + } + + if (newMenuItem.rawRadius === undefined) { + newMenuItem.rawRadius = 8 + } + + if (newMenuItem.targetRadius === undefined) { + newMenuItem.targetRadius = 0 + } + + if (newMenuItem.currentRadius === undefined) { + newMenuItem.currentRadius = 0 + } + + menuItemsInitialValues.push(newMenuItem) + } + } else { + if (ERROR_LOG === true) { logger.write('[ERROR] getMenuItemsInitialValues -> UI Object Type not Recognized -> type = ' + payload.node.type) } } return menuItemsInitialValues @@ -4740,334 +304,37 @@ function newUiObjectConstructor () { level_0() break } - case 'Definition': { - level_0() - break - } - case 'Team': { - level_0() - break - } - case 'Sensor Bot': { - level_1() - break - } - case 'Indicator Bot': { - level_1() - break - } - case 'Trading Bot': { - level_1() - break - } - case 'Process Definition': { - level_2() - break - } - case 'Process Output': { - level_3() - break - } - case 'Process Dependencies': { - level_3() - break - } - case 'Status Report': { - level_3() - break - } - case 'Execution Started Event': { - level_3() - break - } - case 'Execution Finished Event': { - level_3() - break - } - case 'Calculations Procedure': { - level_3() - break - } - case 'Data Building Procedure': { - level_3() - break - } - case 'Procedure Initialization': { - level_4() - break - } - case 'Procedure Loop': { - level_4() - break - } - case 'Output Dataset': { - level_3() - break - } - case 'Status Dependency': { - level_3() - break - } - case 'Data Dependency': { - level_3() - break - } - case 'Product Definition': { - level_2() - break - } - case 'Record Definition': { - level_3() - break - } - case 'Record Property': { - level_4() - break - } - case 'Dataset Definition': { - level_3() - break - } - case 'Plotter': { - level_1() - break - } - case 'Plotter Module': { - level_2() - break - } - case 'Plotter Panel': { - level_3() - break - } - case 'Network': { - level_1() - break - } - case 'Network Node': { - level_1() - break - } - case 'Social Bots': { - level_3() - break - } - case 'Telegram Bot': { - level_2() - break - } - case 'Announcement': { - level_4() - break - } - case 'Layer Manager': { - level_3() - break - } - case 'Layer': { - level_4() - break - } - case 'Task Manager': { - level_1() - break - } - case 'Task': { - level_3() - break - } - case 'Sensor Bot Instance': { - level_3() - break - } - case 'Indicator Bot Instance': { - level_3() - break - } - case 'Trading Bot Instance': { - level_3() - break - } - case 'Process Instance': { - level_2() - break - } - case 'Backtesting Session': { - level_2() - break - } - case 'Live Trading Session': { - level_2() - break - } - case 'Fordward Testing Session': { - level_2() - break - } - case 'Paper Trading Session': { - level_2() - break - } - case 'Exchange Account': { - level_1() - break - } - case 'Exchange Account Asset': { - level_3() - break - } - case 'Exchange Account Key': { - level_3() - break - } - case 'Personal Data': { - level_1() - break - } - case 'Trading System': { - level_1() - break - } - case 'Parameters': { - level_3() - break - } - case 'Base Asset': { - level_3() - break - } - case 'Time Range': { - level_3() - break - } - case 'Time Period': { - level_3() - break - } - case 'Slippage': { - level_3() - break - } - case 'Fee Structure': { - level_3() - break - } - case 'Strategy': { - level_1() - break - } - case 'Trigger Stage': { - level_2() - break - } - case 'Open Stage': { - level_2() - break - } - case 'Manage Stage': { - level_2() - break - } - case 'Close Stage': { - level_2() - break - } - case 'Position Size': { - level_3() - break - } - case 'Position Rate': { - level_3() - break - } - case 'Trigger On Event': { - level_3() - break - } - case 'Trigger Off Event': { - level_3() - break - } - case 'Take Position Event': { - level_3() - break - } - case 'Initial Definition': { - level_3() - break - } - case 'Open Execution': { - level_3() - break - } - case 'Close Execution': { - level_3() - break - } - case 'Stop': { - level_3() - break - } - case 'Take Profit': { - level_3() - break - } - case 'Phase': { - level_2() - break - } - case 'Formula': { - level_5() - break - } - case 'Next Phase Event': { - level_4() - break - } - case 'Situation': { - level_4() - break - } - case 'Condition': { - level_5() - break - } - case 'Javascript Code': { - level_5() - break - } + default: { let nodeDefinition = APP_SCHEMA_MAP.get(payload.node.type) if (nodeDefinition !== undefined) { switch (nodeDefinition.level) { case 0: { level_0() - return + break } case 1: { level_1() - return + break } case 2: { level_2() - return + break } case 3: { level_3() - return + break } case 4: { level_4() - return + break } case 5: { level_5() - return + break } } } - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> UI Object Type not Recognized -> type = ' + payload.node.type) } - return } } @@ -5082,7 +349,6 @@ function newUiObjectConstructor () { floatingObject.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' } - function level_1 () { floatingObject.targetFriction = 0.94 floatingObject.friction = INITIAL_FRICTION @@ -5098,7 +364,6 @@ function newUiObjectConstructor () { // floatingObject.tensionToggle() } } - function level_2 () { floatingObject.targetFriction = FRICTION floatingObject.friction = INITIAL_FRICTION @@ -5114,7 +379,6 @@ function newUiObjectConstructor () { // floatingObject.tensionToggle() } } - function level_3 () { floatingObject.targetFriction = FRICTION floatingObject.friction = INITIAL_FRICTION @@ -5130,7 +394,6 @@ function newUiObjectConstructor () { // floatingObject.tensionToggle() } } - function level_4 () { floatingObject.targetFriction = FRICTION floatingObject.friction = INITIAL_FRICTION @@ -5146,7 +409,6 @@ function newUiObjectConstructor () { // floatingObject.tensionToggle() } } - function level_5 () { floatingObject.targetFriction = FRICTION floatingObject.friction = INITIAL_FRICTION @@ -5181,5 +443,10 @@ function newUiObjectConstructor () { payload.uiObject.finalize() payload.uiObject = undefined + + payload.referenceParent = undefined + payload.parent = undefined + payload.chainParent = undefined + payload.node.savedPayload = undefined } } diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index 25143c9a2..ace5efac0 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -47,6 +47,7 @@ function newUiObjectTitle () { function initialize (payload) { thisObject.payload = payload + thisObject.allwaysVisible = false // Default value switch (payload.node.type) { case 'Definition': { thisObject.allwaysVisible = true @@ -92,10 +93,6 @@ function newUiObjectTitle () { thisObject.allwaysVisible = true break } - case 'Plotter Panel': { - thisObject.allwaysVisible = true - break - } case 'Network': { thisObject.allwaysVisible = true break @@ -145,7 +142,12 @@ function newUiObjectTitle () { break } default: { - thisObject.allwaysVisible = false + let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + if (nodeDefinition !== undefined) { + if (nodeDefinition.isTitleAllwaysVisible === true) { + thisObject.allwaysVisible = true + } + } } } diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index 493c41a05..b2d33194b 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -21,6 +21,7 @@ function newPlotterPanel () { container.frame.containerName = 'Plotter Panel' + let heightFactor = 1 let currentRecord let panelTabButton let panelNode @@ -34,8 +35,8 @@ function newPlotterPanel () { thisObject.container.frame.width = UI_PANEL.WIDTH.NORMAL thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL - thisObject.container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width * 5 - thisObject.container.frame.position.y = viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height + thisObject.container.frame.position.x = viewPort.visibleArea.topRight.x - thisObject.container.frame.width - thisObject.container.frame.width * Math.random() * 8 + thisObject.container.frame.position.y = viewPort.visibleArea.bottomLeft.y - thisObject.container.frame.height - thisObject.container.frame.height * Math.random() * 1.5 panelTabButton = newPanelTabButton() panelTabButton.parentContainer = thisObject.container @@ -87,10 +88,60 @@ function newPlotterPanel () { if (currentRecord === undefined) { return } if (currentRecord.data === undefined) { return } - try { - eval(panelNode.javascriptCode.code) - } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) } + let record = currentRecord.data + + /* First we execute code if provided. */ + if (panelNode.javascriptCode !== undefined) { + try { + eval(panelNode.javascriptCode.code) + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> javascriptCode.code = ' + panelNode.javascriptCode.code) } + } + } + + /* Second we go through the panel data. */ + if (panelNode.panelData === undefined) { return } + for (let i = 0; i < panelNode.panelData.length; i++) { + let panelData = panelNode.panelData[i] + + let labelText = panelData.name + let labelPosition = i * 10 + 10 + let valuePosition = i * 10 + 15 + let value = 'No value defined.' + + if (valuePosition > 100) { + heightFactor = 2 + thisObject.container.frame.height = UI_PANEL.HEIGHT.NORMAL * heightFactor + } + + if (panelData.dataFormula !== undefined) { + try { + value = eval(panelData.dataFormula.code) + } catch (err) { + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotCurrentRecordData -> dataFormula.code = ' + panelNode.dataFormula.code) } + } + } + + if (panelData.code.valueDecimals !== undefined) { + value = value.toFixed(panelData.code.valueDecimals) + } + + if (panelData.code.labelText !== undefined) { + labelText = panelData.code.labelText + } + + if (panelData.code.labelPosition !== undefined) { + labelPosition = panelData.code.labelPosition + } + + if (panelData.code.valuePosition !== undefined) { + valuePosition = panelData.code.valuePosition + } + + printLabel(labelText, X_AXIS, PANEL_HEIGHT * labelPosition / 100 / heightFactor, '1') + printLabel(value, X_AXIS, PANEL_HEIGHT * valuePosition / 100 / heightFactor, '0.50') } function printLabel (labelToPrint, x, y, opacity) { @@ -119,4 +170,3 @@ function newPlotterPanel () { browserCanvasContext.fill() } } - diff --git a/Panels/ProductCard.js b/Panels/ProductCard.js index 49eba7250..0c51f0565 100644 --- a/Panels/ProductCard.js +++ b/Panels/ProductCard.js @@ -151,7 +151,10 @@ function newProductCard () { /* Add information that will later be needed. */ let team = ecosystem.getTeam(thisObject.product.plotter.devTeam) - let plotter = ecosystem.getPlotter(team, thisObject.product.plotter.codeName) + let plotter + if (team !== undefined) { + plotter = ecosystem.getPlotter(team, thisObject.product.plotter.codeName) + } if (plotter !== undefined) { let plotterModule = ecosystem.getPlotterModule(plotter, thisObject.product.plotter.moduleName) @@ -226,7 +229,15 @@ function newProductCard () { legacyPlotterBannerLoaded = true } - legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + PLOTTER_TEAM + '/' + PLOTTER_REPO + '/' + PLOTTER_PROFILE_PIC + if (PLOTTER_PROFILE_PIC !== undefined) { + legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + PLOTTER_TEAM + '/' + PLOTTER_REPO + '/' + PLOTTER_PROFILE_PIC + } else { + if (thisObject.product.plotter.banner !== undefined) { + legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + thisObject.product.plotter.banner + '-Banner.PNG' + } else { + legacyPlotterBanner.src = window.canvasApp.urlPrefix + 'Images/' + 'Default-Banner.PNG' + } + } const TEAM = thisObject.devTeam.codeName.toLowerCase() const BOT = thisObject.bot.codeName.toLowerCase() @@ -523,7 +534,7 @@ function newProductCard () { } } /* Third the Plotter's Profile Picture. */ - if (thisObject.product.plotter.profilePicture !== undefined) { + if (thisObject.product.plotter.profilePicture !== undefined || thisObject.product.plotter.legacy === false) { let plotterImagePoint = { x: thisObject.container.frame.width / 2 - plotterImageSize.width / 2, y: thisObject.container.frame.height / 2 - plotterImageSize.height / 2 diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 042560c73..a28de7171 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -131,6 +131,7 @@ function newProductsPanel () { try { let code = JSON.parse(plotterModuleNode.code) plotterModule.codeName = code.codeName + plotterModule.banner = code.banner } catch (err) { continue } @@ -159,13 +160,11 @@ function newProductsPanel () { continue } - if (plotterModuleNode.javascriptCode === undefined) { continue } - if (plotterModuleNode.javascriptCode.code === undefined) { continue } - /* Conversion to fit old format */ product.plotter = plotter product.plotter.devTeam = plotterTeam.codeName product.plotter.moduleName = plotterModule.codeName + product.plotter.banner = plotterModule.banner product.plotter.legacy = false product.plotter.module = { panels: [] } product.displayName = productNode.name diff --git a/Panels/TimeControlPanel.js b/Panels/TimeControlPanel.js index 2f650b65c..55d1baa11 100644 --- a/Panels/TimeControlPanel.js +++ b/Panels/TimeControlPanel.js @@ -58,7 +58,9 @@ function newTimeControlPanel () { } function onZoomChanged (event) { - timePeriod = recalculatePeriod(event.newLevel) + if (event !== undefined) { // it is undefined when the level is just being animated. + timePeriod = recalculatePeriod(event.newLevel) + } } function getContainer (point) { @@ -115,7 +117,7 @@ function newTimeControlPanel () { labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) @@ -132,7 +134,7 @@ function newTimeControlPanel () { labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) @@ -151,7 +153,7 @@ function newTimeControlPanel () { labelPoint = thisObject.container.frame.frameThisPoint(labelPoint) - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY browserCanvasContext.fillStyle = 'rgba(60, 60, 60, 0.50)' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } diff --git a/Plotter.js b/Plotter.js index de33a8f26..bf5265a6c 100644 --- a/Plotter.js +++ b/Plotter.js @@ -31,7 +31,13 @@ function newPlotter () { container.initialize() thisObject.container = container - let timeLineCoordinateSystem = newTimeLineCoordinateSystem() // Needed to be able to plot on the timeline, otherwise not. + let timeLineCoordinateSystem = newTimeLineCoordinateSystem() // Needed to be able to plot on the timeline. + let slotCoordinateSystem // Needed to be able to plot on a slot over the timeline. + let plotterModuleConfig + let slotHeight = (viewPort.visibleArea.bottomRight.y - viewPort.visibleArea.topLeft.y) / 10 // This is the amount of slots available + let mustRecalculateDataPoints = false + let atMousePositionFillStyles = new Map() + let atMousePositionStrokeStyles = new Map() let timePeriod // This will hold the current Time Period the user is at. let datetime // This will hold the current Datetime the user is at. @@ -53,6 +59,7 @@ function newPlotter () { let marketFilesUpdatedEventSubscriptionId let dailyFilesUpdatedEventSubscriptionId + let logged = false return thisObject function finalize () { @@ -74,8 +81,16 @@ function newPlotter () { marketFile = undefined fileCursor = undefined + + timeLineCoordinateSystem = undefined + slotCoordinateSystem = undefined + plotterModuleConfig = undefined + slotHeight = undefined + mustRecalculateDataPoints = undefined + atMousePositionFillStyles = undefined + atMousePositionStrokeStyles = undefined } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] finalize -> err = ' + err.stack.stack) } } } @@ -115,7 +130,7 @@ function newPlotter () { callBackFunction() } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) } } @@ -125,10 +140,11 @@ function newPlotter () { let newMarketFile = marketFiles.getFile(timePeriod) if (newMarketFile !== undefined) { marketFile = newMarketFile + mustRecalculateDataPoints = true recalculate() } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onMarketFilesUpdated -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] onMarketFilesUpdated -> err = ' + err.stack.stack) } } } @@ -137,10 +153,11 @@ function newPlotter () { let newFileCursor = dailyFiles.getFileCursor(timePeriod) if (newFileCursor !== undefined) { fileCursor = newFileCursor + mustRecalculateDataPoints = true recalculate() } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onDailyFilesUpdated -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] onDailyFilesUpdated -> err = ' + err.stack.stack) } } } @@ -155,7 +172,7 @@ function newPlotter () { return undefined } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] getContainer -> err = ' + err.stack) } } } @@ -163,7 +180,7 @@ function newPlotter () { try { if (timePeriod !== pTimePeriod) { timePeriod = pTimePeriod - + mustRecalculateDataPoints = true if (timePeriod >= _1_HOUR_IN_MILISECONDS) { let newMarketFile = marketFiles.getFile(pTimePeriod) @@ -181,7 +198,7 @@ function newPlotter () { } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] setTimePeriod -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] setTimePeriod -> err = ' + err.stack) } } } @@ -196,7 +213,7 @@ function newPlotter () { recalculate() } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onDailyFileLoaded -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] onDailyFileLoaded -> err = ' + err.stack) } } } @@ -205,7 +222,7 @@ function newPlotter () { this.container.frame.draw() plotChart() } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] draw -> err = ' + err.stack) } } } @@ -218,7 +235,7 @@ function newPlotter () { } thisObject.container.eventHandler.raiseEvent('CandleStairs Changed', records) // --> Check This } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] recalculate -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] recalculate -> err = ' + err.stack) } } } @@ -274,7 +291,7 @@ function newPlotter () { try { eval(calculationsProcedure.initialization.javascriptCode.code) } catch (err) { - logger.write('[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Error = ' + err.stack) + logger.write('[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Error = ' + err.stack.stack) logger.write('[ERROR] calculationsProcedure -> initialization -> Error executing User Code. Code = ' + calculationsProcedure.initialization.javascriptCode.code) throw ('Error Executing User Code.') } @@ -291,7 +308,7 @@ function newPlotter () { try { eval(calculationsProcedure.loop.javascriptCode.code) } catch (err) { - logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. Error = ' + err.stack) + logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. Error = ' + err.stack.stack) logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. product = ' + JSON.stringify(product)) logger.write('[ERROR] calculationsProcedure -> loop -> Error executing User Code. Code = ' + calculationsProcedure.loop.javascriptCode.code) throw ('Error Executing User Code.') @@ -308,7 +325,7 @@ function newPlotter () { let currentRecord = product currentRecord[property.code.codeName] = newValue } catch (err) { - logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. Error = ' + err.stack) + logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. Error = ' + err.stack.stack) logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. product = ' + JSON.stringify(product)) logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. Code = ' + property.formula.code) throw ('Error Executing User Code.') @@ -376,7 +393,7 @@ function newPlotter () { } } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] recalculateUsingDailyFiles -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] recalculateUsingDailyFiles -> err = ' + err.stack) } } } @@ -394,6 +411,14 @@ function newPlotter () { leftDate = new Date(leftDate.valueOf() - dateDiff * 1.5) rightDate = new Date(rightDate.valueOf() + dateDiff * 1.5) + for (let i = 0; i < records.length; i++) { + let record = records[i] + record.fillStyle = undefined + record.strokeStyle = undefined + record.dataPoints = undefined + record.previous = undefined + records[i] = {} + } records = [] /* Transform the current file content into an array of JSON objects */ @@ -407,14 +432,14 @@ function newPlotter () { records.push(...jsonData)// This adds records to the current array. } } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] recalculateUsingMarketFiles -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] recalculateUsingMarketFiles -> err = ' + err.stack) } } } function recalculateScale () { try { if (timeLineCoordinateSystem.maxValue > 0) { return } // Already calculated. - + /* First we calculate the default scale */ let minValue = { x: MIN_PLOTABLE_DATE.valueOf(), y: 0 @@ -431,8 +456,25 @@ function newPlotter () { thisObject.container.frame.width, thisObject.container.frame.height ) + + /* In case the plotter is configured to a certain slot, we calculate the slot coordinate system too. */ + if (productDefinition.referenceParent.code === undefined) { return } + plotterModuleConfig = JSON.parse(productDefinition.referenceParent.code) + if (plotterModuleConfig.slot === undefined) { return } + + slotCoordinateSystem = newTimeLineCoordinateSystem() + + minValue.y = plotterModuleConfig.slot.minValue + maxValue.y = plotterModuleConfig.slot.maxValue + + slotCoordinateSystem.initialize( + minValue, + maxValue, + thisObject.container.frame.width, + slotHeight + ) } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] recalculateScale -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] recalculateScale -> err = ' + err.stack) } } } @@ -450,6 +492,12 @@ function newPlotter () { for (let i = 0; i < records.length; i++) { let record = records[i] + if (i == 0) { + record.previous = record + } else { + record.previous = records[i - 1] + } + let beginPoint = { x: record.begin, y: 0 @@ -480,18 +528,250 @@ function newPlotter () { thisObject.container.eventHandler.raiseEvent('Current Record Changed', currentRecord) } - eval(productDefinition.referenceParent.javascriptCode.code) + /* If there is code we execute it now. */ + if (productDefinition.referenceParent.javascriptCode !== undefined) { + eval(productDefinition.referenceParent.javascriptCode.code) + } + + if (productDefinition.referenceParent.shapes === undefined) { continue } + if (productDefinition.referenceParent.shapes.chartPoints === undefined) { continue } + + let dataPoints = new Map() + if (record.dataPoints !== undefined && mustRecalculateDataPoints === false) { + /* We use the datapoints already calculated. */ + dataPoints = record.dataPoints + } else { + if (logged === false) { + logged = true + } + /* Only calculate the datapoints for this record, if we have not calculate it before. */ + for (let k = 0; k < productDefinition.referenceParent.shapes.chartPoints.length; k++) { + let chartPoints = productDefinition.referenceParent.shapes.chartPoints[k] + for (let j = 0; j < chartPoints.points.length; j++) { + let point = chartPoints.points[j] + if (point.pointFormula !== undefined) { + let x = 0 + let y = 0 + eval(point.pointFormula.code) + let dataPoint = { + x: x, + y: y + } + + /* + The information we store in files is independent from the charing system and its coordinate systems. + That means that the first thing we allways need to do is to trasform these points to the coordinate system of the timeline. + */ + dataPoint = timeLineCoordinateSystem.transformThisPoint(dataPoint) + + /* + The browser canvas object does not care about our timeline and its coordinate system. In order to draw on a html canvas we + need the points to be converted into the canvas coordinate system. + Next we transform again to the screen coordinate system. + */ + dataPoint = transformThisPoint(dataPoint, thisObject.container) + + /* Store the data point at the local map */ + dataPoints.set(point.id, dataPoint) + + if (plotterModuleConfig !== undefined) { + if (plotterModuleConfig.slot !== undefined) { + /* We reset the y coordinate since it will be transformed with another coordinate system to fit into a slot. */ + dataPoint.y = (-1) * y * slotCoordinateSystem.scale.y + (plotterModuleConfig.slot.number - 1) * slotHeight + viewPort.visibleArea.topLeft.y + } + } + } + } + } + + /* Remember this datapoints, so that we do not need to calculate them again. */ + record.dataPoints = dataPoints + } + + for (let j = 0; j < productDefinition.referenceParent.shapes.polygons.length; j++) { + let polygon = productDefinition.referenceParent.shapes.polygons[j] + let calculatedStyle + + /* Finding out the fill style */ + let fillStyle = { // default values + opacity: 1, + paletteColor: UI_COLOR.BLACK + } + if (polygon.polygonBody !== undefined) { + if (record.fillStyle === undefined) { + record.fillStyle = new Map() + } + calculatedStyle = record.fillStyle.get(polygon.id) + if (calculatedStyle !== undefined) { + /* We use the already calculated style */ + fillStyle = calculatedStyle + } else { + /* Get the default style if exists */ + if (polygon.polygonBody.style !== undefined) { + if (polygon.polygonBody.style.code !== undefined) { + if (polygon.polygonBody.style.code.default !== undefined) { + let bodyStyle = polygon.polygonBody.style.code.default + if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity } + if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) } + } + } + } + /* Apply conditional styles */ + if (polygon.polygonBody.styleConditions !== undefined) { + for (let k = 0; k < polygon.polygonBody.styleConditions.length; k++) { + let condition = polygon.polygonBody.styleConditions[k] + let value = eval(condition.code) + if (value === true) { + if (condition.style !== undefined) { + let bodyStyle = condition.style.code + if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity } + if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) } + } + } + } + } + /* Get the atMousePosition style if exists */ + if (polygon.polygonBody.style !== undefined) { + if (polygon.polygonBody.style.code.atMousePosition !== undefined) { + let atMousePositionStyleDefinition = polygon.polygonBody.style.code.atMousePosition + let atMousePositionStyle = {} + if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity } + if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) } + atMousePositionFillStyles.set(polygon.id, atMousePositionStyle) + } + } + + record.fillStyle.set(polygon.id, fillStyle) + } + } + + /* Finding out the stroke style */ + let strokeStyle = { // default values + opacity: 1, + paletteColor: UI_COLOR.BLACK, + lineWidth: 1, + lineDash: [0, 0] + } + if (polygon.polygonBorder !== undefined) { + if (record.strokeStyle === undefined) { + record.strokeStyle = new Map() + } + calculatedStyle = record.strokeStyle.get(polygon.id) + if (calculatedStyle !== undefined) { + /* We use the already calculated style */ + strokeStyle = calculatedStyle + } else { + /* Get the default style if exists */ + if (polygon.polygonBorder.style !== undefined) { + if (polygon.polygonBorder.style.code !== undefined) { + if (polygon.polygonBorder.style.code.default !== undefined) { + let borderStyle = polygon.polygonBorder.style.code.default + if (borderStyle.opacity !== undefined) { strokeStyle.opacity = borderStyle.opacity } + if (borderStyle.paletteColor !== undefined) { strokeStyle.paletteColor = eval(borderStyle.paletteColor) } + if (borderStyle.lineWidth !== undefined) { strokeStyle.lineWidth = borderStyle.lineWidth } + if (borderStyle.lineDash !== undefined) { strokeStyle.lineDash = borderStyle.lineDash } + } + } + } + /* Apply conditional styles */ + if (polygon.polygonBorder.styleConditions !== undefined) { + for (let k = 0; k < polygon.polygonBorder.styleConditions.length; k++) { + let condition = polygon.polygonBorder.styleConditions[k] + let value = eval(condition.code) + if (value === true) { + if (condition.style !== undefined) { + let borderStyle = condition.style.code + if (borderStyle.opacity !== undefined) { strokeStyle.opacity = borderStyle.opacity } + if (borderStyle.paletteColor !== undefined) { strokeStyle.paletteColor = eval(borderStyle.paletteColor) } + if (borderStyle.lineWidth !== undefined) { strokeStyle.lineWidth = borderStyle.lineWidth } + if (borderStyle.lineDash !== undefined) { strokeStyle.lineDash = borderStyle.lineDash } + } + } + } + } + /* Get the atMousePosition style if exists */ + if (polygon.polygonBorder.style !== undefined) { + if (polygon.polygonBorder.style.code.atMousePosition !== undefined) { + let atMousePositionStyleDefinition = polygon.polygonBorder.style.code.atMousePosition + let atMousePositionStyle = {} + if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity } + if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) } + if (atMousePositionStyleDefinition.lineWidth !== undefined) { atMousePositionStyle.lineWidth = atMousePositionStyleDefinition.lineWidth } + if (atMousePositionStyleDefinition.lineDash !== undefined) { atMousePositionStyle.lineDash = atMousePositionStyleDefinition.lineDash } + atMousePositionStrokeStyles.set(polygon.id, atMousePositionStyle) + } + } + + record.strokeStyle.set(polygon.id, strokeStyle) + } + } + + /* Draw the Polygon */ + browserCanvasContext.beginPath() + for (let k = 0; k < polygon.polygonVertexes.length; k++) { + let polygonVertex = polygon.polygonVertexes[k] + if (polygonVertex.referenceParent !== undefined) { + let dataPointObject = dataPoints.get(polygonVertex.referenceParent.id) + let dataPoint = { + x: dataPointObject.x, + y: dataPointObject.y + } + /* We make sure the points do not fall outside the viewport visible area. This step allways need to be done. */ + dataPoint = viewPort.fitIntoVisibleArea(dataPoint) + if (k === 0) { + browserCanvasContext.moveTo(dataPoint.x, dataPoint.y) + } else { + browserCanvasContext.lineTo(dataPoint.x, dataPoint.y) + } + } + } + browserCanvasContext.closePath() + + /* Apply the fill style to the canvas object */ + if (polygon.polygonBody !== undefined) { + /* Replace the fill style if we are at mouse position */ + if (atMousePosition === true) { + let atMousePositionFillStyle = atMousePositionFillStyles.get(polygon.id) + if (atMousePositionFillStyle !== undefined) { + fillStyle = atMousePositionFillStyle + } + } + + browserCanvasContext.fillStyle = 'rgba(' + fillStyle.paletteColor + ', ' + fillStyle.opacity + ')' + browserCanvasContext.fill() + } + + /* Apply the stroke style to the canvas object */ + if (polygon.polygonBorder !== undefined) { + /* Replace the stroke style if we are at mouse position */ + if (atMousePosition === true) { + let atMousePositionStrokeStyle = atMousePositionStrokeStyles.get(polygon.id) + if (atMousePositionStrokeStyle !== undefined) { + strokeStyle = atMousePositionStrokeStyle + } + } + + browserCanvasContext.lineWidth = strokeStyle.lineWidth + browserCanvasContext.setLineDash(strokeStyle.lineDash) + browserCanvasContext.strokeStyle = 'rgba(' + strokeStyle.paletteColor + ', ' + strokeStyle.opacity + ')' + browserCanvasContext.stroke() + } + } } + + mustRecalculateDataPoints = false + logged = false } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] plotChart -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] plotChart -> err = ' + err.stack) } } } function onZoomChanged (event) { try { + mustRecalculateDataPoints = true recalculate() } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onZoomChanged -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] onZoomChanged -> err = ' + err.stack) } } } @@ -499,12 +779,13 @@ function newPlotter () { try { recalculate() } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onDragFinished -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] onDragFinished -> err = ' + err.stack) } } } function onOffsetChanged (event) { try { + mustRecalculateDataPoints = true if (event !== undefined) { if (event.recalculate === true) { recalculate() @@ -515,7 +796,7 @@ function newPlotter () { recalculate() }; } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] onOffsetChanged -> err = ' + err) } + if (ERROR_LOG === true) { logger.write('[ERROR] onOffsetChanged -> err = ' + err.stack) } } } } diff --git a/ProductStorage.js b/ProductStorage.js index 8cd70d1b7..bdb862032 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -121,6 +121,8 @@ function newProductStorage (pName) { thisObject.fileSequences.push(fileSequences) } break + default: + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> initialize -> dataset with no type defined. Data can not be retrieved. -> codeName = ' + thisSet.codeName) } } function onMarketFileReady (err, pCaller) { diff --git a/README.md b/README.md index 16ceca683..82b465066 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ The Canvas App provides a visual environment for the _Charting System_ and the _ **Installation (for developers):** To install the Canvas App, you need to install AAWeb, following [this guide](https://github.com/Superalgos/AAWeb/blob/develop/README.md). -> The workings of the Canvas App is documented in the [Superalgos Desktop App README](https://github.com/Superalgos/DesktopApp/blob/master/README.md). +> The workings of the Canvas App is documented in the [Superalgos Platform README](https://github.com/Superalgos/DesktopApp/blob/master/README.md). # Maintainer diff --git a/Scales/RateScale.js b/Scales/RateScale.js index e44bbc241..dc675d4db 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -6,7 +6,7 @@ function newRateScale () { rate: undefined, fitFunction: undefined, visible: true, - heightPercentage: 100, + heightPercentage: 150, physics: physics, draw: draw, getContainer: getContainer, @@ -70,7 +70,7 @@ function newRateScale () { if (thisObject.heightPercentage < STEP_SIZE) { thisObject.heightPercentage = STEP_SIZE } } else { thisObject.heightPercentage = thisObject.heightPercentage + STEP_SIZE - if (thisObject.heightPercentage > 100) { thisObject.heightPercentage = 100 } + if (thisObject.heightPercentage > 150) { thisObject.heightPercentage = 200 } } event.heightPercentage = thisObject.heightPercentage thisObject.container.eventHandler.raiseEvent('Height Percentage Changed', event) @@ -106,7 +106,7 @@ function newRateScale () { const DISTANCE_BETWEEN_ARROWS = 10 const MIN_DISTANCE_FROM_CENTER = 30 const CURRENT_VALUE_DISTANCE = MIN_DISTANCE_FROM_CENTER + thisObject.heightPercentage - const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + 115 + DISTANCE_BETWEEN_ARROWS + const MAX_DISTANCE_FROM_CENTER = MIN_DISTANCE_FROM_CENTER + 215 + DISTANCE_BETWEEN_ARROWS let ARROW_DIRECTION = 0 diff --git a/Scales/TimePeriodScale.js b/Scales/TimePeriodScale.js index 93d2cb81b..a93330788 100644 --- a/Scales/TimePeriodScale.js +++ b/Scales/TimePeriodScale.js @@ -83,21 +83,23 @@ function newTimePeriodScale () { } function onZoomChanged (event) { - let currentTimePeriod = thisObject.timePeriod - let timePeriod = recalculatePeriod(event.newLevel) - if (timePeriod !== currentTimePeriod) { - for (let i = 0; i < timePeriodsMasterArray.length; i++) { - let timePeriodArray = timePeriodsMasterArray[i] - for (let j = 0; j < timePeriodArray.length; j++) { - let record = timePeriodArray[j] - if (timePeriod === record[0]) { - filePeriodIndex = i - timePeriodIndex = j + if (event !== undefined) { // it is undefined when the level is just being animated. + let currentTimePeriod = thisObject.timePeriod + let timePeriod = recalculatePeriod(event.newLevel) + if (timePeriod !== currentTimePeriod) { + for (let i = 0; i < timePeriodsMasterArray.length; i++) { + let timePeriodArray = timePeriodsMasterArray[i] + for (let j = 0; j < timePeriodArray.length; j++) { + let record = timePeriodArray[j] + if (timePeriod === record[0]) { + filePeriodIndex = i + timePeriodIndex = j + } } } + saveObjectState() + newTimePeriod() } - saveObjectState() - newTimePeriod() } } @@ -320,4 +322,3 @@ to be visible at the top of the viewPort. */ browserCanvasContext.fillText(label2, labelPoint2.x, labelPoint2.y) } } - diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index 8cde058e0..3dff9ae53 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -35,83 +35,7 @@ function newDesignerSpace () { } function buildIconByUiObjectTypeMap () { - const relationshipArray = [ - ['Definition', 'text'], - ['Network', 'network'], - ['Network Node', 'network-node'], - ['Social Bots', 'social-bot'], - ['Telegram Bot', 'paper-plane'], - ['Announcement', 'promotion'], - ['Layer Manager', 'layer-manager'], - ['Layer', 'attractive'], - ['Task Manager', 'task'], - ['Task', 'timeline'], - ['Sensor Bot Instance', 'bot-sensor'], - ['Indicator Bot Instance', 'bot-indicator'], - ['Trading Bot Instance', 'bot-trading'], - ['Process Instance', 'process'], - ['Backtesting Session', 'session-backtesting'], - ['Live Trading Session', 'session-live-trading'], - ['Fordward Testing Session', 'session-forward-testing'], - ['Paper Trading Session', 'session-paper-trading'], - ['Personal Data', 'security'], - ['Exchange Account', 'approve'], - ['Exchange Account Asset', 'paper-plane'], - ['Exchange Account Key', 'login'], - ['Workspace', 'design-tool'], - ['Trading System', 'analysis'], - ['Parameters', 'settings'], - ['Base Asset', 'loading'], - ['Time Range', 'schedule'], - ['Time Period', 'time-period'], - ['Slippage', 'support'], - ['Fee Structure', 'sitemap'], - ['Strategy', 'quality'], - ['Trigger Stage', 'stage-trigger'], - ['Open Stage', 'stage-open'], - ['Manage Stage', 'video-player'], - ['Close Stage', 'stage-close'], - ['Position Size', 'stage-open-position-size'], - ['Position Rate', 'stage-open-postion-rate'], - ['Trigger On Event', 'stage-trigger-trigger-on'], - ['Trigger Off Event', 'stage-trigger-trigger-off'], - ['Take Position Event', 'stage-trigger-take-position'], - ['Initial Definition', 'task'], - ['Open Execution', 'piggy-bank'], - ['Close Execution', 'piggy-bank'], - ['Stop', 'stop'], - ['Take Profit', 'stage-open-take-profit'], - ['Phase', 'placeholder'], - ['Formula', 'pipette'], - ['Next Phase Event', 'pantone'], - ['Situation', 'pyramid'], - ['Condition', 'testing'], - ['Javascript Code', 'html'], - ['Team', 'team'], - ['Sensor Bot', 'bot-sensor'], - ['Indicator Bot', 'bot-indicator'], - ['Trading Bot', 'bot-trading'], - ['Process Definition', 'process-definition'], - ['Process Output', 'process-output'], - ['Process Dependencies', 'process-dependencies'], - ['Status Report', 'status-report'], - ['Execution Started Event', 'execution-started-event'], - ['Execution Finished Event', 'execution-finished-event'], - ['Calculations Procedure', 'calculations-procedure'], - ['Data Building Procedure', 'data-building-procedure'], - ['Procedure Initialization', 'procedure-initialization'], - ['Procedure Loop', 'procedure-loop'], - ['Output Dataset', 'output-dataset'], - ['Status Dependency', 'status-dependency'], - ['Data Dependency', 'data-dependency'], - ['Product Definition', 'product-definition'], - ['Record Definition', 'record-definition'], - ['Record Property', 'record-property'], - ['Dataset Definition', 'dataset-definition'], - ['Plotter', 'plotter'], - ['Plotter Module', 'plotter-module'], - ['Plotter Panel', 'plotter-panel'] - ] + const relationshipArray = [] for (let i = 0; i < relationshipArray.length; i++) { let record = relationshipArray[i] @@ -236,7 +160,20 @@ function newDesignerSpace () { 'process-dependencies', 'process-output', 'social-bot', - 'execution-started-event' + 'execution-started-event', + 'shapes', + 'chart-point', + 'style', + 'chart-points', + 'shapes-polygon-vertex', + 'shapes-polygon-border', + 'shapes-polygon-body', + 'chart-point-formula', + 'style-condition', + 'shapes-polygon', + 'data-entry', + 'data-formula', + 'clone' ] for (let i = 0; i < iconsNames.length; i++) { @@ -286,5 +223,8 @@ function newDesignerSpace () { if (thisObject.sidePanel !== undefined) { thisObject.sidePanel.draw() } + if (thisObject.workspace !== undefined) { + thisObject.workspace.draw() + } } } diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index b5dbad099..b82fde99e 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -41,6 +41,7 @@ function newFloatingSpace () { let devicePixelRatio = window.devicePixelRatio const SPACE_SIZE = 50000 + const WARM_UP_LIMIT = 10000 thisObject.container.frame.width = SPACE_SIZE thisObject.container.frame.height = SPACE_SIZE @@ -100,7 +101,7 @@ function newFloatingSpace () { After that we will start evaluating which ones are too far from the current user view. */ - if (warmingUpCounter < 10000) { + if (warmingUpCounter < WARM_UP_LIMIT) { warmingUpCounter++ return false } @@ -271,7 +272,7 @@ function newFloatingSpace () { } function physics () { - if (visible === true) { + if (visible === true || warmingUpCounter < WARM_UP_LIMIT) { browserZoomPhysics() thisObject.floatingLayer.physics() } diff --git a/Utilities.js b/Utilities.js index a72310054..4ab4c825a 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,4 +1,14 @@ +function download (filename, text) { + let element = document.createElement('a') + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)) + element.setAttribute('download', filename) + element.style.display = 'none' + document.body.appendChild(element) + element.click() + document.body.removeChild(element) +} + function transformThisPoint (point, container) { /* We make the point relative to the current frame */