Merge pull request #105 from AAMasters/develop

Release #5 - Plotters without coding
This commit is contained in:
Luis Fernando Molina authored and GitHub committed 2019-12-20 18:21:20 +01:00
commit 74911260fa
35 files changed
+1755 -5849

No files matched your search

+29 -1
View File
@@ -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
+10 -4
View File
@@ -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()
+2
View File
@@ -290,6 +290,8 @@ function newViewPort () {
x: 0,
y: 0
}
thisObject.eventHandler.raiseEvent('Zoom Changed')
}
function zoomFontSize (baseSize, level) {
+1 -1
View File
@@ -45,7 +45,7 @@ function newDashboard () {
}
APP_SCHEMA_MAP.set(key, nodeDefinition)
}
console.log(APP_SCHEMA_MAP)
startCanvas()
}
@@ -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)
}
}
}
}
@@ -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
}
}
@@ -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
}
}
@@ -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)
@@ -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
}
}
}
}
}
}
}
@@ -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
@@ -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
}
}
@@ -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
}
}
}
}
}
}
}
}
}
@@ -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)
}
}
+93 -88
View File
@@ -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)
}
}
+72
View File
@@ -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()
}
}
+35
View File
@@ -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)
}
+11 -4
View File
@@ -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. */
+2
View File
@@ -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
+7 -1
View File
@@ -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()
}
+1 -1
View File
@@ -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()
+227 -183
View File
@@ -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])
File diff suppressed because it is too large. Load diff
+7 -5
View File
@@ -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
}
}
}
}
+57 -7
View File
@@ -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()
}
}
+14 -3
View File
@@ -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
+2 -3
View File
@@ -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
+6 -4
View File
@@ -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)
}
+304 -23
View File
@@ -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) }
}
}
}
+2
View File
@@ -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) {
+1 -1
View File
@@ -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
+3 -3
View File
@@ -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
+14 -13
View File
@@ -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)
}
}
+18 -78
View File
@@ -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()
}
}
}
+3 -2
View File
@@ -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()
}
+10
View File
@@ -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 */