From 65a01f0a4f69425bc7ed2a61f6e8be380346ac31 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 10:24:50 +0200 Subject: [PATCH 01/54] not overlapping --- FloatingSpace/ConditionEditor.js | 30 +++++++++++++++++------------- FloatingSpace/Picker.js | 14 +++++++------- FloatingSpace/UiObject.js | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 20 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index f0b2cbef7..b01dca956 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -202,23 +202,27 @@ function newConditionEditor () { function initializePickersSet (logicOperand, comparisonOperand, algebraOperand) { /* Get the ySign */ - let ySign - if (algebraOperand.index === 0) { - ySign = -1 + let yComparisionSign + if (comparisonOperand.index === 0) { + yComparisionSign = -1 } - if (algebraOperand.index === 1) { - ySign = 1 + if (comparisonOperand.index === 1) { + yComparisionSign = 1 } + const LOGIC_SEPARATION = 100 + const COMPARISON_SEPARATION = 50 + const ALGEBRA_SEPARATION = 50 let properties let parent let current + let yOffset = (logicOperand.index - 1) * LOGIC_SEPARATION + yComparisionSign * COMPARISON_SEPARATION + (algebraOperand.index - 1) * ALGEBRA_SEPARATION algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' algebraOperand.whenPicker.container.connectToParent(thisObject.container) algebraOperand.whenPicker.container.frame.position.x = 0 - algebraOperand.whenPicker.container.frame.width / 2 - algebraOperand.whenPicker.container.frame.width * 1.0 - algebraOperand.whenPicker.container.frame.position.y = 0 - algebraOperand.whenPicker.container.frame.height / 2 + algebraOperand.whenPicker.container.frame.height * ySign + algebraOperand.whenPicker.container.frame.position.y = 0 - algebraOperand.whenPicker.container.frame.height / 2 + yOffset current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] algebraOperand.whenPicker.initialize(current, current) algebraOperand.whenPicker.visible = true @@ -227,7 +231,7 @@ function newConditionEditor () { algebraOperand.algebraicPicker.name = 'Algebraic' algebraOperand.algebraicPicker.container.connectToParent(thisObject.container) algebraOperand.algebraicPicker.container.frame.position.x = 0 - algebraOperand.algebraicPicker.container.frame.width / 2 + algebraOperand.algebraicPicker.container.frame.width * 3.0 - algebraOperand.algebraicPicker.container.frame.position.y = 0 - algebraOperand.algebraicPicker.container.frame.height / 2 + algebraOperand.algebraicPicker.container.frame.height * ySign + algebraOperand.algebraicPicker.container.frame.position.y = 0 - algebraOperand.algebraicPicker.container.frame.height / 2 + yOffset current = ['+ - * /', 'Plus', 'Minus', 'Times', 'Divided by'] algebraOperand.algebraicPicker.initialize(current, current) algebraOperand.algebraicPicker.visible = true @@ -236,7 +240,7 @@ function newConditionEditor () { algebraOperand.dataMinePicker.name = 'Data Mine' algebraOperand.dataMinePicker.container.connectToParent(thisObject.container) algebraOperand.dataMinePicker.container.frame.position.x = 0 - algebraOperand.dataMinePicker.container.frame.width / 2 - algebraOperand.dataMinePicker.container.frame.width * 3.0 - algebraOperand.dataMinePicker.container.frame.position.y = 0 - algebraOperand.dataMinePicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + algebraOperand.dataMinePicker.container.frame.position.y = 0 - algebraOperand.dataMinePicker.container.frame.height / 2 + yOffset current = scanResult properties = Object.keys(current) algebraOperand.dataMinePicker.initialize(properties, current) @@ -247,7 +251,7 @@ function newConditionEditor () { algebraOperand.botPicker.name = 'Bot' algebraOperand.botPicker.container.connectToParent(thisObject.container) algebraOperand.botPicker.container.frame.position.x = 0 - algebraOperand.botPicker.container.frame.width / 2 - algebraOperand.botPicker.container.frame.width * 2.0 - algebraOperand.botPicker.container.frame.position.y = 0 - algebraOperand.botPicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + algebraOperand.botPicker.container.frame.position.y = 0 - algebraOperand.botPicker.container.frame.height / 2 + yOffset current = parent[properties[0]] properties = Object.keys(current) algebraOperand.botPicker.initialize(properties, current, parent) @@ -258,7 +262,7 @@ function newConditionEditor () { algebraOperand.productPicker.name = 'Product' algebraOperand.productPicker.container.connectToParent(thisObject.container) algebraOperand.productPicker.container.frame.position.x = 0 - algebraOperand.productPicker.container.frame.width / 2 + algebraOperand.productPicker.container.frame.width * 0.0 - algebraOperand.productPicker.container.frame.position.y = 0 - algebraOperand.productPicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + algebraOperand.productPicker.container.frame.position.y = 0 - algebraOperand.productPicker.container.frame.height / 2 + yOffset current = parent[properties[0]] properties = Object.keys(current) algebraOperand.productPicker.initialize(properties, current, parent) @@ -272,7 +276,7 @@ function newConditionEditor () { algebraOperand.propertyPicker.name = 'Property' algebraOperand.propertyPicker.container.connectToParent(thisObject.container) algebraOperand.propertyPicker.container.frame.position.x = 0 - algebraOperand.propertyPicker.container.frame.width / 2 + algebraOperand.propertyPicker.container.frame.width * 1.0 - algebraOperand.propertyPicker.container.frame.position.y = 0 - algebraOperand.propertyPicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + algebraOperand.propertyPicker.container.frame.position.y = 0 - algebraOperand.propertyPicker.container.frame.height / 2 + yOffset current = productParent[productProperties[0]] current = current.properties properties = Object.keys(current) @@ -284,7 +288,7 @@ function newConditionEditor () { algebraOperand.valuePicker.name = 'Value' algebraOperand.valuePicker.container.connectToParent(thisObject.container) algebraOperand.valuePicker.container.frame.position.x = 0 - algebraOperand.valuePicker.container.frame.width / 2 - algebraOperand.valuePicker.container.frame.position.y = 0 - algebraOperand.valuePicker.container.frame.height / 2 + algebraOperand.valuePicker.container.frame.height * 1 + algebraOperand.valuePicker.container.frame.position.y = 0 - algebraOperand.valuePicker.container.frame.height / 2 + yOffset current = parent[properties[0]] properties = current.possibleValues algebraOperand.valuePicker.initialize(properties, current, parent, 'possibleValues') @@ -295,7 +299,7 @@ function newConditionEditor () { algebraOperand.timeFramePicker.name = 'Time Frame' algebraOperand.timeFramePicker.container.connectToParent(thisObject.container) algebraOperand.timeFramePicker.container.frame.position.x = 0 - algebraOperand.timeFramePicker.container.frame.width / 2 + algebraOperand.timeFramePicker.container.frame.width * 2.0 - algebraOperand.timeFramePicker.container.frame.position.y = 0 - algebraOperand.timeFramePicker.container.frame.height / 2 + algebraOperand.timeFramePicker.container.frame.height * ySign + algebraOperand.timeFramePicker.container.frame.position.y = 0 - algebraOperand.timeFramePicker.container.frame.height / 2 + yOffset current = productParent[productProperties[0]] properties = current.validTimeFrames algebraOperand.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 885b01c11..de438fcf2 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -25,8 +25,8 @@ function newPicker () { thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = 200 - thisObject.container.frame.height = 120 + thisObject.container.frame.width = 100 + thisObject.container.frame.height = 100 let isMouseOver let optionsList @@ -175,7 +175,7 @@ function newPicker () { } function drawForeground () { - const FONT_SIZE = 20 + const FONT_SIZE = 15 const VISIBLE_LABELS = 5 let fontSize let fontColor @@ -190,11 +190,11 @@ function newPicker () { fontColor = UI_COLOR.LIGHT_GREY switch (i) { case 0: - fontSize = FONT_SIZE - 10 + fontSize = FONT_SIZE - 5 opacity = 0.4 break case 1: - fontSize = FONT_SIZE - 5 + fontSize = FONT_SIZE - 3 opacity = 0.5 break case 2: @@ -203,11 +203,11 @@ function newPicker () { opacity = 1 break case 3: - fontSize = FONT_SIZE - 5 + fontSize = FONT_SIZE - 3 opacity = 0.5 break case 4: - fontSize = FONT_SIZE - 10 + fontSize = FONT_SIZE - 5 opacity = 0.4 break } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 8cc05dbf8..2dd1f2db3 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1205,7 +1205,26 @@ function newUiObject () { } } + function isEditorVisible () { + if (thisObject.codeEditor !== undefined) { + if (thisObject.codeEditor.visible === true) { return true } + } + + if (thisObject.configEditor !== undefined) { + if (thisObject.configEditor.visible === true) { return true } + } + + if (thisObject.conditionEditor !== undefined) { + if (thisObject.conditionEditor.visible === true) { return true } + } + + if (thisObject.formulaEditor !== undefined) { + if (thisObject.formulaEditor.visible === true) { return true } + } + } + function drawText () { + if (isEditorVisible() === true) { return } /* Text Follows */ let position = { x: 0, From 00699ed57a81d4783d7980fb4f8bb2bc5e18ad1f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 10:36:47 +0200 Subject: [PATCH 02/54] correct width --- FloatingSpace/ConditionEditor.js | 4 +++- FloatingSpace/Picker.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index b01dca956..261f2b68f 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -230,8 +230,9 @@ function newConditionEditor () { algebraOperand.algebraicPicker = newPicker() algebraOperand.algebraicPicker.name = 'Algebraic' algebraOperand.algebraicPicker.container.connectToParent(thisObject.container) - algebraOperand.algebraicPicker.container.frame.position.x = 0 - algebraOperand.algebraicPicker.container.frame.width / 2 + algebraOperand.algebraicPicker.container.frame.width * 3.0 + algebraOperand.algebraicPicker.container.frame.position.x = 0 - algebraOperand.algebraicPicker.container.frame.width / 2 + algebraOperand.algebraicPicker.container.frame.width * 2.5 algebraOperand.algebraicPicker.container.frame.position.y = 0 - algebraOperand.algebraicPicker.container.frame.height / 2 + yOffset + algebraOperand.algebraicPicker.container.frame.width = algebraOperand.algebraicPicker.container.frame.width / 2 current = ['+ - * /', 'Plus', 'Minus', 'Times', 'Divided by'] algebraOperand.algebraicPicker.initialize(current, current) algebraOperand.algebraicPicker.visible = true @@ -300,6 +301,7 @@ function newConditionEditor () { algebraOperand.timeFramePicker.container.connectToParent(thisObject.container) algebraOperand.timeFramePicker.container.frame.position.x = 0 - algebraOperand.timeFramePicker.container.frame.width / 2 + algebraOperand.timeFramePicker.container.frame.width * 2.0 algebraOperand.timeFramePicker.container.frame.position.y = 0 - algebraOperand.timeFramePicker.container.frame.height / 2 + yOffset + algebraOperand.timeFramePicker.container.frame.width = algebraOperand.timeFramePicker.container.frame.width / 2 current = productParent[productProperties[0]] properties = current.validTimeFrames algebraOperand.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index de438fcf2..b57bd2cd0 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -25,7 +25,7 @@ function newPicker () { thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = 100 + thisObject.container.frame.width = 120 thisObject.container.frame.height = 100 let isMouseOver From 3b13af099f7db52cfafa1a5ebc0ca277feb2797a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 11:32:51 +0200 Subject: [PATCH 03/54] bug fixed --- FloatingSpace/ConditionEditor.js | 46 +++++++++++++++++++------------- FloatingSpace/Picker.js | 4 +-- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 261f2b68f..2438c384c 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -54,7 +54,7 @@ function newConditionEditor () { conditionStructure = { code: thisObject.payload.node.code, - orOperands: [] + logicOperands: [] } scanDataMines() @@ -75,6 +75,9 @@ function newConditionEditor () { } function loadFromCode () { + thisObject.payload.node.code = 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || ' + thisObject.payload.node.code = thisObject.payload.node.code + 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin ' + if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } /* LOGICAL ORs */ @@ -86,7 +89,7 @@ function newConditionEditor () { comparison: {} } checkComparison(logicOperand, j) - conditionStructure.orOperands.push(logicOperand) + conditionStructure.logicOperands.push(logicOperand) } function checkComparison (logicOperand) { @@ -163,7 +166,7 @@ function newConditionEditor () { comparisonOperand.algebra.operatorIndex = 0 if (comparisonOperand.code.indexOf(' + ') > 0) { - let codeArray = logicOperand.code.split(' + ') + let codeArray = comparisonOperand.code.split(' + ') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] comparisonOperand.algebra.operator = ' + ' @@ -171,7 +174,7 @@ function newConditionEditor () { } if (comparisonOperand.code.indexOf(' - ') > 0) { - let codeArray = logicOperand.code.split(' - ') + let codeArray = comparisonOperand.code.split(' - ') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] comparisonOperand.algebra.operator = ' - ' @@ -179,7 +182,7 @@ function newConditionEditor () { } if (comparisonOperand.code.indexOf(' * ') > 0) { - let codeArray = logicOperand.code.split(' * ') + let codeArray = comparisonOperand.code.split(' * ') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] comparisonOperand.algebra.operator = ' * ' @@ -187,7 +190,7 @@ function newConditionEditor () { } if (comparisonOperand.code.indexOf(' / ') > 0) { - let codeArray = logicOperand.code.split(' / ') + let codeArray = comparisonOperand.code.split(' / ') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] comparisonOperand.algebra.operator = ' / ' @@ -195,9 +198,9 @@ function newConditionEditor () { } initializePickersSet(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) - initializePickersSet(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) - updatePickers(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) + initializePickersSet(logicOperand, comparisonOperand, comparisonOperand.algebra.operandB) updatePickers(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) + updatePickers(logicOperand, comparisonOperand, comparisonOperand.algebra.operandB) } function initializePickersSet (logicOperand, comparisonOperand, algebraOperand) { @@ -210,8 +213,8 @@ function newConditionEditor () { yComparisionSign = 1 } - const LOGIC_SEPARATION = 100 - const COMPARISON_SEPARATION = 50 + const LOGIC_SEPARATION = 300 + const COMPARISON_SEPARATION = 150 const ALGEBRA_SEPARATION = 50 let properties let parent @@ -540,8 +543,8 @@ function newConditionEditor () { function finalizePickers () { if (conditionStructure === undefined) { return } - for (let i = 0; i < conditionStructure.orOperands.length; i++) { - let logicOperand = conditionStructure.orOperands[i] + for (let i = 0; i < conditionStructure.logicOperands.length; i++) { + let logicOperand = conditionStructure.logicOperands[i] finalizeOperator(logicOperand.comparison.operandA.algebra.operandA) finalizeOperator(logicOperand.comparison.operandA.algebra.operandB) finalizeOperator(logicOperand.comparison.operandB.algebra.operandA) @@ -627,8 +630,8 @@ function newConditionEditor () { if (thisObject.visible === true) { if (conditionStructure === undefined) { return } - for (let i = 0; i < conditionStructure.orOperands.length; i++) { - let logicOperand = conditionStructure.orOperands[i] + for (let i = 0; i < conditionStructure.logicOperands.length; i++) { + let logicOperand = conditionStructure.logicOperands[i] container = operandGetContainer(point, logicOperand.comparison.operandA.algebra.operandA) if (container !== undefined) { return container } container = operandGetContainer(point, logicOperand.comparison.operandA.algebra.operandB) @@ -637,6 +640,9 @@ function newConditionEditor () { if (container !== undefined) { return container } container = operandGetContainer(point, logicOperand.comparison.operandB.algebra.operandB) if (container !== undefined) { return container } + + container = logicOperand.comparison.picker.getContainer(point) + if (container !== undefined) { return container } } if (thisObject.container.frame.isThisPointHere(point, true) === true) { @@ -718,12 +724,14 @@ function newConditionEditor () { function childrenDrawBackground () { if (conditionStructure === undefined) { return } - for (let i = 0; i < conditionStructure.orOperands.length; i++) { - let logicOperand = conditionStructure.orOperands[i] + for (let i = 0; i < conditionStructure.logicOperands.length; i++) { + let logicOperand = conditionStructure.logicOperands[i] operandDrawBackground(logicOperand.comparison.operandA.algebra.operandA) operandDrawBackground(logicOperand.comparison.operandA.algebra.operandB) operandDrawBackground(logicOperand.comparison.operandB.algebra.operandA) operandDrawBackground(logicOperand.comparison.operandB.algebra.operandB) + + logicOperand.comparison.picker.drawBackground } } @@ -812,12 +820,14 @@ function newConditionEditor () { function childrenDrawForeground () { if (conditionStructure === undefined) { return } - for (let i = 0; i < conditionStructure.orOperands.length; i++) { - let logicOperand = conditionStructure.orOperands[i] + for (let i = 0; i < conditionStructure.logicOperands.length; i++) { + let logicOperand = conditionStructure.logicOperands[i] operandDrawForeground(logicOperand.comparison.operandA.algebra.operandA) operandDrawForeground(logicOperand.comparison.operandA.algebra.operandB) operandDrawForeground(logicOperand.comparison.operandB.algebra.operandA) operandDrawForeground(logicOperand.comparison.operandB.algebra.operandB) + + logicOperand.comparison.picker.drawForeground } } diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index b57bd2cd0..8a7e861e8 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -25,8 +25,8 @@ function newPicker () { thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = 120 - thisObject.container.frame.height = 100 + thisObject.container.frame.width = 150 + thisObject.container.frame.height = 75 let isMouseOver let optionsList From 31ea8009bae3ee49b2d4b1bb5fce57169eb5126e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 11:56:53 +0200 Subject: [PATCH 04/54] Spacing is correct --- FloatingSpace/ConditionEditor.js | 16 ++++------------ FloatingSpace/Picker.js | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 2438c384c..c96b417a3 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -204,22 +204,14 @@ function newConditionEditor () { } function initializePickersSet (logicOperand, comparisonOperand, algebraOperand) { - /* Get the ySign */ - let yComparisionSign - if (comparisonOperand.index === 0) { - yComparisionSign = -1 - } - if (comparisonOperand.index === 1) { - yComparisionSign = 1 - } + const ALGEBRA_SEPARATION = 60 + const COMPARISON_SEPARATION = ALGEBRA_SEPARATION * 2 + const LOGIC_SEPARATION = COMPARISON_SEPARATION * 2 - const LOGIC_SEPARATION = 300 - const COMPARISON_SEPARATION = 150 - const ALGEBRA_SEPARATION = 50 let properties let parent let current - let yOffset = (logicOperand.index - 1) * LOGIC_SEPARATION + yComparisionSign * COMPARISON_SEPARATION + (algebraOperand.index - 1) * ALGEBRA_SEPARATION + let yOffset = (logicOperand.index - 1) * LOGIC_SEPARATION + (comparisonOperand.index - 0.5) * COMPARISON_SEPARATION + (algebraOperand.index - 0.5) * ALGEBRA_SEPARATION algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 8a7e861e8..b306ac85e 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -26,7 +26,7 @@ function newPicker () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 thisObject.container.frame.width = 150 - thisObject.container.frame.height = 75 + thisObject.container.frame.height = 60 let isMouseOver let optionsList From 65ba4c6ec8b6f75dcf1c8d82431026bf492865cc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 12:01:28 +0200 Subject: [PATCH 05/54] timeframe first --- FloatingSpace/ConditionEditor.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index c96b417a3..be316f2d7 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -216,7 +216,7 @@ function newConditionEditor () { algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' algebraOperand.whenPicker.container.connectToParent(thisObject.container) - algebraOperand.whenPicker.container.frame.position.x = 0 - algebraOperand.whenPicker.container.frame.width / 2 - algebraOperand.whenPicker.container.frame.width * 1.0 + algebraOperand.whenPicker.container.frame.position.x = 0 - algebraOperand.whenPicker.container.frame.width / 2 - algebraOperand.whenPicker.container.frame.width * 0.5 algebraOperand.whenPicker.container.frame.position.y = 0 - algebraOperand.whenPicker.container.frame.height / 2 + yOffset current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] algebraOperand.whenPicker.initialize(current, current) @@ -235,7 +235,7 @@ function newConditionEditor () { algebraOperand.dataMinePicker = newPicker() algebraOperand.dataMinePicker.name = 'Data Mine' algebraOperand.dataMinePicker.container.connectToParent(thisObject.container) - algebraOperand.dataMinePicker.container.frame.position.x = 0 - algebraOperand.dataMinePicker.container.frame.width / 2 - algebraOperand.dataMinePicker.container.frame.width * 3.0 + algebraOperand.dataMinePicker.container.frame.position.x = 0 - algebraOperand.dataMinePicker.container.frame.width / 2 - algebraOperand.dataMinePicker.container.frame.width * 2.5 algebraOperand.dataMinePicker.container.frame.position.y = 0 - algebraOperand.dataMinePicker.container.frame.height / 2 + yOffset current = scanResult properties = Object.keys(current) @@ -246,7 +246,7 @@ function newConditionEditor () { algebraOperand.botPicker = newPicker() algebraOperand.botPicker.name = 'Bot' algebraOperand.botPicker.container.connectToParent(thisObject.container) - algebraOperand.botPicker.container.frame.position.x = 0 - algebraOperand.botPicker.container.frame.width / 2 - algebraOperand.botPicker.container.frame.width * 2.0 + algebraOperand.botPicker.container.frame.position.x = 0 - algebraOperand.botPicker.container.frame.width / 2 - algebraOperand.botPicker.container.frame.width * 1.5 algebraOperand.botPicker.container.frame.position.y = 0 - algebraOperand.botPicker.container.frame.height / 2 + yOffset current = parent[properties[0]] properties = Object.keys(current) @@ -257,7 +257,7 @@ function newConditionEditor () { algebraOperand.productPicker = newPicker() algebraOperand.productPicker.name = 'Product' algebraOperand.productPicker.container.connectToParent(thisObject.container) - algebraOperand.productPicker.container.frame.position.x = 0 - algebraOperand.productPicker.container.frame.width / 2 + algebraOperand.productPicker.container.frame.width * 0.0 + algebraOperand.productPicker.container.frame.position.x = 0 - algebraOperand.productPicker.container.frame.width / 2 + algebraOperand.productPicker.container.frame.width * 0.5 algebraOperand.productPicker.container.frame.position.y = 0 - algebraOperand.productPicker.container.frame.height / 2 + yOffset current = parent[properties[0]] properties = Object.keys(current) @@ -271,7 +271,7 @@ function newConditionEditor () { algebraOperand.propertyPicker = newPicker() algebraOperand.propertyPicker.name = 'Property' algebraOperand.propertyPicker.container.connectToParent(thisObject.container) - algebraOperand.propertyPicker.container.frame.position.x = 0 - algebraOperand.propertyPicker.container.frame.width / 2 + algebraOperand.propertyPicker.container.frame.width * 1.0 + algebraOperand.propertyPicker.container.frame.position.x = 0 - algebraOperand.propertyPicker.container.frame.width / 2 + algebraOperand.propertyPicker.container.frame.width * 1.5 algebraOperand.propertyPicker.container.frame.position.y = 0 - algebraOperand.propertyPicker.container.frame.height / 2 + yOffset current = productParent[productProperties[0]] current = current.properties @@ -294,7 +294,7 @@ function newConditionEditor () { algebraOperand.timeFramePicker = newPicker() algebraOperand.timeFramePicker.name = 'Time Frame' algebraOperand.timeFramePicker.container.connectToParent(thisObject.container) - algebraOperand.timeFramePicker.container.frame.position.x = 0 - algebraOperand.timeFramePicker.container.frame.width / 2 + algebraOperand.timeFramePicker.container.frame.width * 2.0 + algebraOperand.timeFramePicker.container.frame.position.x = 0 - algebraOperand.timeFramePicker.container.frame.width / 2 - algebraOperand.timeFramePicker.container.frame.width * 3.0 algebraOperand.timeFramePicker.container.frame.position.y = 0 - algebraOperand.timeFramePicker.container.frame.height / 2 + yOffset algebraOperand.timeFramePicker.container.frame.width = algebraOperand.timeFramePicker.container.frame.width / 2 current = productParent[productProperties[0]] From 3bc2e143a7b29e6c73921c82cfa70a82546a262b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 12:23:31 +0200 Subject: [PATCH 06/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 69 ++++++++++++++------------------ 1 file changed, 31 insertions(+), 38 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index be316f2d7..e59fd5044 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -213,6 +213,18 @@ function newConditionEditor () { let current let yOffset = (logicOperand.index - 1) * LOGIC_SEPARATION + (comparisonOperand.index - 0.5) * COMPARISON_SEPARATION + (algebraOperand.index - 0.5) * ALGEBRA_SEPARATION + if (algebraOperand.index === 0) { + comparisonOperand.algebra.picker = newPicker() + comparisonOperand.algebra.picker.name = 'Algebraic' + comparisonOperand.algebra.picker.container.connectToParent(thisObject.container) + comparisonOperand.algebra.picker.container.frame.position.x = 0 - comparisonOperand.algebra.picker.container.frame.width / 2 + comparisonOperand.algebra.picker.container.frame.width * 2.5 + comparisonOperand.algebra.picker.container.frame.position.y = 0 - comparisonOperand.algebra.picker.container.frame.height / 2 + yOffset + comparisonOperand.algebra.picker.container.frame.width = comparisonOperand.algebra.picker.container.frame.width / 2 + current = ['...', 'Plus', 'Minus', 'Times', 'Divided by'] + comparisonOperand.algebra.picker.initialize(current, current) + comparisonOperand.algebra.picker.visible = true + } + algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' algebraOperand.whenPicker.container.connectToParent(thisObject.container) @@ -222,16 +234,6 @@ function newConditionEditor () { algebraOperand.whenPicker.initialize(current, current) algebraOperand.whenPicker.visible = true - algebraOperand.algebraicPicker = newPicker() - algebraOperand.algebraicPicker.name = 'Algebraic' - algebraOperand.algebraicPicker.container.connectToParent(thisObject.container) - algebraOperand.algebraicPicker.container.frame.position.x = 0 - algebraOperand.algebraicPicker.container.frame.width / 2 + algebraOperand.algebraicPicker.container.frame.width * 2.5 - algebraOperand.algebraicPicker.container.frame.position.y = 0 - algebraOperand.algebraicPicker.container.frame.height / 2 + yOffset - algebraOperand.algebraicPicker.container.frame.width = algebraOperand.algebraicPicker.container.frame.width / 2 - current = ['+ - * /', 'Plus', 'Minus', 'Times', 'Divided by'] - algebraOperand.algebraicPicker.initialize(current, current) - algebraOperand.algebraicPicker.visible = true - algebraOperand.dataMinePicker = newPicker() algebraOperand.dataMinePicker.name = 'Data Mine' algebraOperand.dataMinePicker.container.connectToParent(thisObject.container) @@ -541,6 +543,11 @@ function newConditionEditor () { finalizeOperator(logicOperand.comparison.operandA.algebra.operandB) finalizeOperator(logicOperand.comparison.operandB.algebra.operandA) finalizeOperator(logicOperand.comparison.operandB.algebra.operandB) + + logicOperand.comparison.operandA.algebra.picker.finalize() + logicOperand.comparison.operandB.algebra.picker.finalize() + + logicOperand.comparison.picker.finalize() } } @@ -552,11 +559,6 @@ function newConditionEditor () { operand.whenPicker = undefined } - if (operand.algebraicPicker !== undefined) { - operand.algebraicPicker.finalize() - operand.algebraicPicker = undefined - } - if (operand.dataMinePicker !== undefined) { operand.dataMinePicker.container.eventHandler.stopListening(operand.botPicker.eventSuscriptionId) operand.dataMinePicker.finalize() @@ -599,7 +601,6 @@ function newConditionEditor () { comparisonOperatorA.valuePicker.visible = true comparisonOperatorB.whenPicker.visible = false - comparisonOperatorB.algebraicPicker.visible = false comparisonOperatorB.dataMinePicker.visible = false comparisonOperatorB.botPicker.visible = false comparisonOperatorB.productPicker.visible = false @@ -608,7 +609,6 @@ function newConditionEditor () { } else { comparisonOperatorA.valuePicker.visible = false comparisonOperatorB.whenPicker.visible = true - comparisonOperatorB.algebraicPicker.visible = true comparisonOperatorB.dataMinePicker.visible = true comparisonOperatorB.botPicker.visible = true comparisonOperatorB.productPicker.visible = true @@ -633,6 +633,12 @@ function newConditionEditor () { container = operandGetContainer(point, logicOperand.comparison.operandB.algebra.operandB) if (container !== undefined) { return container } + container = logicOperand.comparison.operandA.algebra.picker.getContainer(point) + if (container !== undefined) { return container } + + container = logicOperand.comparison.operandB.algebra.picker.getContainer(point) + if (container !== undefined) { return container } + container = logicOperand.comparison.picker.getContainer(point) if (container !== undefined) { return container } } @@ -654,13 +660,6 @@ function newConditionEditor () { } } - if (operand.algebraicPicker !== undefined) { - if (operand.algebraicPicker.visible === true) { - container = operand.algebraicPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - if (operand.dataMinePicker !== undefined) { if (operand.dataMinePicker.visible === true) { container = operand.dataMinePicker.getContainer(point) @@ -723,7 +722,10 @@ function newConditionEditor () { operandDrawBackground(logicOperand.comparison.operandB.algebra.operandA) operandDrawBackground(logicOperand.comparison.operandB.algebra.operandB) - logicOperand.comparison.picker.drawBackground + logicOperand.comparison.operandA.algebra.picker.drawBackground() + logicOperand.comparison.operandB.algebra.picker.drawBackground() + + logicOperand.comparison.picker.drawBackground() } } @@ -736,12 +738,6 @@ function newConditionEditor () { } } - if (operand.algebraicPicker !== undefined) { - if (operand.algebraicPicker.visible === true) { - operand.algebraicPicker.drawBackground() - } - } - if (operand.dataMinePicker !== undefined) { if (operand.dataMinePicker.visible === true) { operand.dataMinePicker.drawBackground() @@ -819,7 +815,10 @@ function newConditionEditor () { operandDrawForeground(logicOperand.comparison.operandB.algebra.operandA) operandDrawForeground(logicOperand.comparison.operandB.algebra.operandB) - logicOperand.comparison.picker.drawForeground + logicOperand.comparison.operandA.algebra.picker.drawForeground() + logicOperand.comparison.operandB.algebra.picker.drawForeground() + + logicOperand.comparison.picker.drawForeground() } } @@ -832,12 +831,6 @@ function newConditionEditor () { } } - if (operand.algebraicPicker !== undefined) { - if (operand.algebraicPicker.visible === true) { - operand.algebraicPicker.drawForeground() - } - } - if (operand.dataMinePicker !== undefined) { if (operand.dataMinePicker.visible === true) { operand.dataMinePicker.drawForeground() From 48ee858f712e9ad02c905cf72e0e2d11bf0cecc9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 12:48:02 +0200 Subject: [PATCH 07/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index e59fd5044..908dc57ef 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -137,17 +137,6 @@ function newConditionEditor () { logicOperand.comparison.operatorIndex = 4 } - logicOperand.comparison.picker = newPicker() - let picker = logicOperand.comparison.picker - picker.name = 'Comparison' - picker.container.connectToParent(thisObject.container) - picker.container.frame.position.x = 0 - picker.container.frame.width / 2 - picker.container.frame.position.y = 0 - picker.container.frame.height / 2 - let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] - picker.initialize(optionsList) - - picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged) - /* Each comparison code may have one or more algebraic operators */ checkAlgebra(logicOperand, logicOperand.comparison.operandA) checkAlgebra(logicOperand, logicOperand.comparison.operandB) @@ -219,12 +208,23 @@ function newConditionEditor () { comparisonOperand.algebra.picker.container.connectToParent(thisObject.container) comparisonOperand.algebra.picker.container.frame.position.x = 0 - comparisonOperand.algebra.picker.container.frame.width / 2 + comparisonOperand.algebra.picker.container.frame.width * 2.5 comparisonOperand.algebra.picker.container.frame.position.y = 0 - comparisonOperand.algebra.picker.container.frame.height / 2 + yOffset - comparisonOperand.algebra.picker.container.frame.width = comparisonOperand.algebra.picker.container.frame.width / 2 current = ['...', 'Plus', 'Minus', 'Times', 'Divided by'] comparisonOperand.algebra.picker.initialize(current, current) comparisonOperand.algebra.picker.visible = true } + if (algebraOperand.index === 1) { + logicOperand.comparison.picker = newPicker() + let picker = logicOperand.comparison.picker + picker.name = 'Comparison' + picker.container.connectToParent(thisObject.container) + picker.container.frame.position.x = 0 - picker.container.frame.width / 2 + picker.container.frame.width * 2.5 + picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset + let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] + picker.initialize(optionsList) + picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged) + } + algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' algebraOperand.whenPicker.container.connectToParent(thisObject.container) From 3778466520b4aaf5d79b19f93021c8dc5cec8445 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 13:33:04 +0200 Subject: [PATCH 08/54] events of equal working --- FloatingSpace/ConditionEditor.js | 37 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 908dc57ef..e562eea5b 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -213,7 +213,7 @@ function newConditionEditor () { comparisonOperand.algebra.picker.visible = true } - if (algebraOperand.index === 1) { + if (comparisonOperand.index === 0 && algebraOperand.index === 1) { logicOperand.comparison.picker = newPicker() let picker = logicOperand.comparison.picker picker.name = 'Comparison' @@ -222,7 +222,7 @@ function newConditionEditor () { picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] picker.initialize(optionsList) - picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged) + picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, logicOperand) } algebraOperand.whenPicker = newPicker() @@ -595,25 +595,28 @@ function newConditionEditor () { } } - function onParentChanged (event) { + function onParentChanged (event, logicOperand) { if (event.selected === 4) { // this means Equal To - comparisonOperatorA.valuePicker.visible = true - comparisonOperatorB.whenPicker.visible = false - comparisonOperatorB.dataMinePicker.visible = false - comparisonOperatorB.botPicker.visible = false - comparisonOperatorB.productPicker.visible = false - comparisonOperatorB.propertyPicker.visible = false - comparisonOperatorB.timeFramePicker.visible = false + logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = true + setVisibility(logicOperand.comparison.operandA.algebra.operandB, false) + setVisibility(logicOperand.comparison.operandB.algebra.operandA, false) + setVisibility(logicOperand.comparison.operandB.algebra.operandB, false) } else { - comparisonOperatorA.valuePicker.visible = false - comparisonOperatorB.whenPicker.visible = true - comparisonOperatorB.dataMinePicker.visible = true - comparisonOperatorB.botPicker.visible = true - comparisonOperatorB.productPicker.visible = true - comparisonOperatorB.propertyPicker.visible = true - comparisonOperatorB.timeFramePicker.visible = true + logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = false + setVisibility(logicOperand.comparison.operandA.algebra.operandB, true) + setVisibility(logicOperand.comparison.operandB.algebra.operandA, true) + setVisibility(logicOperand.comparison.operandB.algebra.operandB, true) + } + + function setVisibility (algebraOperand, isVisible) { + algebraOperand.whenPicker.visible = isVisible + algebraOperand.dataMinePicker.visible = isVisible + algebraOperand.botPicker.visible = isVisible + algebraOperand.productPicker.visible = isVisible + algebraOperand.propertyPicker.visible = isVisible + algebraOperand.timeFramePicker.visible = isVisible } } From f258eca72bc6a48937c6216f0fe8d43eeadf1a7b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 14:11:53 +0200 Subject: [PATCH 09/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index e562eea5b..8cafd10fe 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -285,7 +285,7 @@ function newConditionEditor () { algebraOperand.valuePicker = newPicker() algebraOperand.valuePicker.name = 'Value' algebraOperand.valuePicker.container.connectToParent(thisObject.container) - algebraOperand.valuePicker.container.frame.position.x = 0 - algebraOperand.valuePicker.container.frame.width / 2 + algebraOperand.valuePicker.container.frame.position.x = 0 - algebraOperand.valuePicker.container.frame.width / 2 + algebraOperand.valuePicker.container.frame.width * 3.5 algebraOperand.valuePicker.container.frame.position.y = 0 - algebraOperand.valuePicker.container.frame.height / 2 + yOffset current = parent[properties[0]] properties = current.possibleValues From 74fb4fe6105d8e7b2d56dfede199e6ab3fb63cc4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 15:53:34 +0200 Subject: [PATCH 10/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 63 ++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 8cafd10fe..9fca4c6ec 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -222,6 +222,7 @@ function newConditionEditor () { picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] picker.initialize(optionsList) + picker.visible = true picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, logicOperand) } @@ -286,7 +287,7 @@ function newConditionEditor () { algebraOperand.valuePicker.name = 'Value' algebraOperand.valuePicker.container.connectToParent(thisObject.container) algebraOperand.valuePicker.container.frame.position.x = 0 - algebraOperand.valuePicker.container.frame.width / 2 + algebraOperand.valuePicker.container.frame.width * 3.5 - algebraOperand.valuePicker.container.frame.position.y = 0 - algebraOperand.valuePicker.container.frame.height / 2 + yOffset + algebraOperand.valuePicker.container.frame.position.y = 0 - algebraOperand.valuePicker.container.frame.height / 2 + yOffset + ALGEBRA_SEPARATION current = parent[properties[0]] properties = current.possibleValues algebraOperand.valuePicker.initialize(properties, current, parent, 'possibleValues') @@ -600,11 +601,15 @@ function newConditionEditor () { // this means Equal To logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = true + logicOperand.comparison.operandA.algebra.picker.visible = false + logicOperand.comparison.operandB.algebra.picker.visible = false setVisibility(logicOperand.comparison.operandA.algebra.operandB, false) setVisibility(logicOperand.comparison.operandB.algebra.operandA, false) setVisibility(logicOperand.comparison.operandB.algebra.operandB, false) } else { logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = false + logicOperand.comparison.operandA.algebra.picker.visible = true + logicOperand.comparison.operandB.algebra.picker.visible = true setVisibility(logicOperand.comparison.operandA.algebra.operandB, true) setVisibility(logicOperand.comparison.operandB.algebra.operandA, true) setVisibility(logicOperand.comparison.operandB.algebra.operandB, true) @@ -636,14 +641,20 @@ function newConditionEditor () { container = operandGetContainer(point, logicOperand.comparison.operandB.algebra.operandB) if (container !== undefined) { return container } - container = logicOperand.comparison.operandA.algebra.picker.getContainer(point) - if (container !== undefined) { return container } + if (container = logicOperand.comparison.operandA.algebra.picker.visible === true) { + container = logicOperand.comparison.operandA.algebra.picker.getContainer(point) + if (container !== undefined) { return container } + } - container = logicOperand.comparison.operandB.algebra.picker.getContainer(point) - if (container !== undefined) { return container } + if (container = logicOperand.comparison.operandB.algebra.picker.visible === true) { + container = logicOperand.comparison.operandB.algebra.picker.getContainer(point) + if (container !== undefined) { return container } + } - container = logicOperand.comparison.picker.getContainer(point) - if (container !== undefined) { return container } + if (container = logicOperand.comparison.picker.visible === true) { + container = logicOperand.comparison.picker.getContainer(point) + if (container !== undefined) { return container } + } } if (thisObject.container.frame.isThisPointHere(point, true) === true) { @@ -725,10 +736,21 @@ function newConditionEditor () { operandDrawBackground(logicOperand.comparison.operandB.algebra.operandA) operandDrawBackground(logicOperand.comparison.operandB.algebra.operandB) - logicOperand.comparison.operandA.algebra.picker.drawBackground() - logicOperand.comparison.operandB.algebra.picker.drawBackground() - - logicOperand.comparison.picker.drawBackground() + if (logicOperand.comparison.operandA.algebra.picker !== undefined) { + if (logicOperand.comparison.operandA.algebra.picker.visible === true) { + logicOperand.comparison.operandA.algebra.picker.drawBackground() + } + } + if (logicOperand.comparison.operandB.algebra.picker !== undefined) { + if (logicOperand.comparison.operandB.algebra.picker.visible === true) { + logicOperand.comparison.operandB.algebra.picker.drawBackground() + } + } + if (logicOperand.comparison.picker !== undefined) { + if (logicOperand.comparison.picker.visible === true) { + logicOperand.comparison.picker.drawBackground() + } + } } } @@ -818,10 +840,21 @@ function newConditionEditor () { operandDrawForeground(logicOperand.comparison.operandB.algebra.operandA) operandDrawForeground(logicOperand.comparison.operandB.algebra.operandB) - logicOperand.comparison.operandA.algebra.picker.drawForeground() - logicOperand.comparison.operandB.algebra.picker.drawForeground() - - logicOperand.comparison.picker.drawForeground() + if (logicOperand.comparison.operandA.algebra.picker !== undefined) { + if (logicOperand.comparison.operandA.algebra.picker.visible === true) { + logicOperand.comparison.operandA.algebra.picker.drawForeground() + } + } + if (logicOperand.comparison.operandB.algebra.picker !== undefined) { + if (logicOperand.comparison.operandB.algebra.picker.visible === true) { + logicOperand.comparison.operandB.algebra.picker.drawForeground() + } + } + if (logicOperand.comparison.picker !== undefined) { + if (logicOperand.comparison.picker.visible === true) { + logicOperand.comparison.picker.drawForeground() + } + } } } From bbffbb66e75ad677a70212a3776a71377f029e72 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 16:46:21 +0200 Subject: [PATCH 11/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 91 ++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 27 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 9fca4c6ec..22f7c4fb7 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -204,13 +204,20 @@ function newConditionEditor () { if (algebraOperand.index === 0) { comparisonOperand.algebra.picker = newPicker() - comparisonOperand.algebra.picker.name = 'Algebraic' + comparisonOperand.algebra.picker.name = 'Algebra' comparisonOperand.algebra.picker.container.connectToParent(thisObject.container) comparisonOperand.algebra.picker.container.frame.position.x = 0 - comparisonOperand.algebra.picker.container.frame.width / 2 + comparisonOperand.algebra.picker.container.frame.width * 2.5 comparisonOperand.algebra.picker.container.frame.position.y = 0 - comparisonOperand.algebra.picker.container.frame.height / 2 + yOffset current = ['...', 'Plus', 'Minus', 'Times', 'Divided by'] comparisonOperand.algebra.picker.initialize(current, current) comparisonOperand.algebra.picker.visible = true + let structureBranch = { + logicOperand: logicOperand, + comparisonOperand: comparisonOperand, + algebraOperand: algebraOperand, + pickerName: 'Algebra' + } + comparisonOperand.algebra.picker.eventSuscriptionId = comparisonOperand.algebra.picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, structureBranch) } if (comparisonOperand.index === 0 && algebraOperand.index === 1) { @@ -223,9 +230,18 @@ function newConditionEditor () { let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] picker.initialize(optionsList) picker.visible = true - picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, logicOperand) + let structureBranch = { + logicOperand: logicOperand, + comparisonOperand: comparisonOperand, + algebraOperand: algebraOperand, + pickerName: 'Comparison' + } + picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, structureBranch) } + let visible = true + if (algebraOperand.index === 1) { visible = false } + algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' algebraOperand.whenPicker.container.connectToParent(thisObject.container) @@ -233,7 +249,7 @@ function newConditionEditor () { algebraOperand.whenPicker.container.frame.position.y = 0 - algebraOperand.whenPicker.container.frame.height / 2 + yOffset current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] algebraOperand.whenPicker.initialize(current, current) - algebraOperand.whenPicker.visible = true + algebraOperand.whenPicker.visible = visible algebraOperand.dataMinePicker = newPicker() algebraOperand.dataMinePicker.name = 'Data Mine' @@ -244,7 +260,7 @@ function newConditionEditor () { properties = Object.keys(current) algebraOperand.dataMinePicker.initialize(properties, current) parent = current - algebraOperand.dataMinePicker.visible = true + algebraOperand.dataMinePicker.visible = visible algebraOperand.botPicker = newPicker() algebraOperand.botPicker.name = 'Bot' @@ -255,7 +271,7 @@ function newConditionEditor () { properties = Object.keys(current) algebraOperand.botPicker.initialize(properties, current, parent) parent = current - algebraOperand.botPicker.visible = true + algebraOperand.botPicker.visible = visible algebraOperand.productPicker = newPicker() algebraOperand.productPicker.name = 'Product' @@ -266,7 +282,7 @@ function newConditionEditor () { properties = Object.keys(current) algebraOperand.productPicker.initialize(properties, current, parent) parent = current - algebraOperand.productPicker.visible = true + algebraOperand.productPicker.visible = visible let productParent = parent let productProperties = properties @@ -281,7 +297,7 @@ function newConditionEditor () { properties = Object.keys(current) algebraOperand.propertyPicker.initialize(properties, current, productParent, 'properties') parent = current - algebraOperand.propertyPicker.visible = true + algebraOperand.propertyPicker.visible = visible algebraOperand.valuePicker = newPicker() algebraOperand.valuePicker.name = 'Value' @@ -304,7 +320,7 @@ function newConditionEditor () { properties = current.validTimeFrames algebraOperand.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') parent = current - algebraOperand.timeFramePicker.visible = true + algebraOperand.timeFramePicker.visible = visible algebraOperand.botPicker.eventSuscriptionId = algebraOperand.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.botPicker.onParentChanged) algebraOperand.productPicker.eventSuscriptionId = algebraOperand.botPicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.productPicker.onParentChanged) @@ -545,10 +561,20 @@ function newConditionEditor () { finalizeOperator(logicOperand.comparison.operandB.algebra.operandA) finalizeOperator(logicOperand.comparison.operandB.algebra.operandB) - logicOperand.comparison.operandA.algebra.picker.finalize() - logicOperand.comparison.operandB.algebra.picker.finalize() + if (logicOperand.comparison.operandA.algebra.picker !== undefined) { + logicOperand.comparison.operandA.algebra.picker.container.eventHandler.stopListening(logicOperand.comparison.operandA.algebra.picker.eventSuscriptionId) + logicOperand.comparison.operandA.algebra.picker.finalize() + } - logicOperand.comparison.picker.finalize() + if (logicOperand.comparison.operandB.algebra.picker !== undefined) { + logicOperand.comparison.operandB.algebra.picker.container.eventHandler.stopListening(logicOperand.comparison.operandB.algebra.picker.eventSuscriptionId) + logicOperand.comparison.operandB.algebra.picker.finalize() + } + + if (logicOperand.comparison.picker !== undefined) { + logicOperand.comparison.picker.container.eventHandler.stopListening(logicOperand.comparison.picker.eventSuscriptionId) + logicOperand.comparison.picker.finalize() + } } } @@ -596,23 +622,34 @@ function newConditionEditor () { } } - function onParentChanged (event, logicOperand) { - if (event.selected === 4) { - // this means Equal To + function onParentChanged (event, structureBranch) { + let logicOperand = structureBranch.logicOperand + if (structureBranch.pickerName === 'Algebra') { + if (event.selected === 0) { + setVisibility(structureBranch.comparisonOperand.algebra.operandB, false) + } else { + setVisibility(structureBranch.comparisonOperand.algebra.operandB, true) + } + } - logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = true - logicOperand.comparison.operandA.algebra.picker.visible = false - logicOperand.comparison.operandB.algebra.picker.visible = false - setVisibility(logicOperand.comparison.operandA.algebra.operandB, false) - setVisibility(logicOperand.comparison.operandB.algebra.operandA, false) - setVisibility(logicOperand.comparison.operandB.algebra.operandB, false) - } else { - logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = false - logicOperand.comparison.operandA.algebra.picker.visible = true - logicOperand.comparison.operandB.algebra.picker.visible = true - setVisibility(logicOperand.comparison.operandA.algebra.operandB, true) - setVisibility(logicOperand.comparison.operandB.algebra.operandA, true) - setVisibility(logicOperand.comparison.operandB.algebra.operandB, true) + if (structureBranch.pickerName === 'Comparison') { + if (event.selected === 4) { + // this means Equal To + + logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = true + logicOperand.comparison.operandA.algebra.picker.visible = false + logicOperand.comparison.operandB.algebra.picker.visible = false + setVisibility(logicOperand.comparison.operandA.algebra.operandB, false) + setVisibility(logicOperand.comparison.operandB.algebra.operandA, false) + setVisibility(logicOperand.comparison.operandB.algebra.operandB, false) + } else { + logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = false + logicOperand.comparison.operandA.algebra.picker.visible = true + logicOperand.comparison.operandB.algebra.picker.visible = true + setVisibility(logicOperand.comparison.operandA.algebra.operandB, true) + setVisibility(logicOperand.comparison.operandB.algebra.operandA, true) + setVisibility(logicOperand.comparison.operandB.algebra.operandB, true) + } } function setVisibility (algebraOperand, isVisible) { From bc0ff9d595361cffaa1961f4253010cf7dfa81c6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 16:55:55 +0200 Subject: [PATCH 12/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 22f7c4fb7..c9e0b67bc 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -646,9 +646,17 @@ function newConditionEditor () { logicOperand.comparison.operandA.algebra.operandA.valuePicker.visible = false logicOperand.comparison.operandA.algebra.picker.visible = true logicOperand.comparison.operandB.algebra.picker.visible = true - setVisibility(logicOperand.comparison.operandA.algebra.operandB, true) - setVisibility(logicOperand.comparison.operandB.algebra.operandA, true) - setVisibility(logicOperand.comparison.operandB.algebra.operandB, true) + if (logicOperand.comparison.operandA.algebra.picker.getSelected() !== '...') { + setVisibility(logicOperand.comparison.operandA.algebra.operandB, true) + } + + if (logicOperand.comparison.picker.getSelected() !== 'Equal To') { + setVisibility(logicOperand.comparison.operandB.algebra.operandA, true) + } + + if (logicOperand.comparison.operandB.algebra.picker.getSelected() !== '...') { + setVisibility(logicOperand.comparison.operandB.algebra.operandB, true) + } } } From 5080c81a1c3a3730b890f68f5154513562926cb2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 19:15:56 +0200 Subject: [PATCH 13/54] Logical Picker Working --- FloatingSpace/ConditionEditor.js | 106 +++++++++++++++++++++++++++++-- 1 file changed, 101 insertions(+), 5 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index c9e0b67bc..6ee6a3089 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -82,12 +82,21 @@ function newConditionEditor () { /* LOGICAL ORs */ let orArray = conditionStructure.code.split(' || ') - for (let j = 0; j < orArray.length; j++) { + for (let j = 0; j < 3; j++) { let logicOperand = { code: orArray[j], index: j, - comparison: {} + comparison: {}, + visible: false } + + if (logicOperand.code !== undefined) { + logicOperand.visible = true + logicOperand.operator = ' || ' + } else { + logicOperand.code = '' + } + checkComparison(logicOperand, j) conditionStructure.logicOperands.push(logicOperand) } @@ -239,6 +248,28 @@ function newConditionEditor () { picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, structureBranch) } + if (comparisonOperand.index === 1 && algebraOperand.index === 1 && logicOperand.index <= 1) { + logicOperand.picker = newPicker() + let picker = logicOperand.picker + picker.name = 'Logic' + picker.container.connectToParent(thisObject.container) + picker.container.frame.position.x = 0 - picker.container.frame.width / 2 + picker.container.frame.width * 2.5 + picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset + let optionsList = ['...', 'OR'] + picker.initialize(optionsList) + if (logicOperand.operator === ' || ') { + picker.setSelected(undefined, undefined, undefined, 1) + } + picker.visible = true + let structureBranch = { + logicOperand: logicOperand, + comparisonOperand: comparisonOperand, + algebraOperand: algebraOperand, + pickerName: 'Logic' + } + picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, structureBranch) + } + let visible = true if (algebraOperand.index === 1) { visible = false } @@ -332,8 +363,15 @@ function newConditionEditor () { function updatePickers (logicOperand, comparisonOperand, algebraOperand) { let codeArray = algebraOperand.code.split('.') - let codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) - let codeProduct = codeArray[2] + let codeTimeFrame + if (codeArray[1] !== undefined) { + codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) + } + + let codeProduct + if (codeArray[2] !== undefined) { + codeProduct = codeArray[2] + } /* Parse When */ let propertyDisplacement = 0 @@ -360,7 +398,11 @@ function newConditionEditor () { } algebraOperand.whenPicker.setSelected(undefined, undefined, undefined, propertyDisplacement) - let codeProperty = codeArray[3 + propertyDisplacement] + let codeProperty + if (codeArray[3 + propertyDisplacement] !== undefined) { + codeProperty = codeArray[3 + propertyDisplacement] + } + let codeValue = comparisonOperand.algebra.operandB.code.replace('"', '').replace('"', '') let dataMines = Object.keys(scanResult) @@ -575,6 +617,11 @@ function newConditionEditor () { logicOperand.comparison.picker.container.eventHandler.stopListening(logicOperand.comparison.picker.eventSuscriptionId) logicOperand.comparison.picker.finalize() } + + if (logicOperand.picker !== undefined) { + logicOperand.picker.container.eventHandler.stopListening(logicOperand.picker.eventSuscriptionId) + logicOperand.picker.finalize() + } } } @@ -624,6 +671,30 @@ function newConditionEditor () { function onParentChanged (event, structureBranch) { let logicOperand = structureBranch.logicOperand + + if (structureBranch.pickerName === 'Logic') { + if (event.selected === 0) { + if (logicOperand.index === 0) { + conditionStructure.logicOperands[1].visible = false + conditionStructure.logicOperands[2].visible = false + } + if (logicOperand.index === 1) { + conditionStructure.logicOperands[2].visible = false + } + } else { + if (logicOperand.index === 0) { + conditionStructure.logicOperands[1].visible = true + + if (conditionStructure.logicOperands[1].picker.getSelected() !== '...') { + conditionStructure.logicOperands[2].visible = true + } + } + if (logicOperand.index === 1) { + conditionStructure.logicOperands[2].visible = true + } + } + } + if (structureBranch.pickerName === 'Algebra') { if (event.selected === 0) { setVisibility(structureBranch.comparisonOperand.algebra.operandB, false) @@ -660,6 +731,10 @@ function newConditionEditor () { } } + function setLogicOperanVisibility (logicOperand, isVisible) { + + } + function setVisibility (algebraOperand, isVisible) { algebraOperand.whenPicker.visible = isVisible algebraOperand.dataMinePicker.visible = isVisible @@ -677,6 +752,8 @@ function newConditionEditor () { for (let i = 0; i < conditionStructure.logicOperands.length; i++) { let logicOperand = conditionStructure.logicOperands[i] + if (logicOperand.visible !== true) { continue } + container = operandGetContainer(point, logicOperand.comparison.operandA.algebra.operandA) if (container !== undefined) { return container } container = operandGetContainer(point, logicOperand.comparison.operandA.algebra.operandB) @@ -700,6 +777,11 @@ function newConditionEditor () { container = logicOperand.comparison.picker.getContainer(point) if (container !== undefined) { return container } } + + if (container = logicOperand.picker.visible === true) { + container = logicOperand.picker.getContainer(point) + if (container !== undefined) { return container } + } } if (thisObject.container.frame.isThisPointHere(point, true) === true) { @@ -776,6 +858,8 @@ function newConditionEditor () { for (let i = 0; i < conditionStructure.logicOperands.length; i++) { let logicOperand = conditionStructure.logicOperands[i] + if (logicOperand.visible !== true) { continue } + operandDrawBackground(logicOperand.comparison.operandA.algebra.operandA) operandDrawBackground(logicOperand.comparison.operandA.algebra.operandB) operandDrawBackground(logicOperand.comparison.operandB.algebra.operandA) @@ -796,6 +880,11 @@ function newConditionEditor () { logicOperand.comparison.picker.drawBackground() } } + if (logicOperand.picker !== undefined) { + if (logicOperand.picker.visible === true) { + logicOperand.picker.drawBackground() + } + } } } @@ -880,6 +969,8 @@ function newConditionEditor () { for (let i = 0; i < conditionStructure.logicOperands.length; i++) { let logicOperand = conditionStructure.logicOperands[i] + if (logicOperand.visible !== true) { continue } + operandDrawForeground(logicOperand.comparison.operandA.algebra.operandA) operandDrawForeground(logicOperand.comparison.operandA.algebra.operandB) operandDrawForeground(logicOperand.comparison.operandB.algebra.operandA) @@ -900,6 +991,11 @@ function newConditionEditor () { logicOperand.comparison.picker.drawForeground() } } + if (logicOperand.picker !== undefined) { + if (logicOperand.picker.visible === true) { + logicOperand.picker.drawForeground() + } + } } } From 6d1419c671fb6e1592a38c3da5c4cb3078631ddd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 4 May 2020 19:27:43 +0200 Subject: [PATCH 14/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 6ee6a3089..d6c33d2ae 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -103,8 +103,14 @@ function newConditionEditor () { function checkComparison (logicOperand) { /* We are going to decompose the code into 2 comparison operators */ - logicOperand.comparison.operandA = { index: 0} - logicOperand.comparison.operandB = { index: 1} + logicOperand.comparison.operandA = { + index: 0, + code: '' + } + logicOperand.comparison.operandB = { + index: 1, + code: '' + } if (logicOperand.code.indexOf(' > ') > 0) { let codeArray = logicOperand.code.split(' > ') @@ -763,24 +769,32 @@ function newConditionEditor () { container = operandGetContainer(point, logicOperand.comparison.operandB.algebra.operandB) if (container !== undefined) { return container } - if (container = logicOperand.comparison.operandA.algebra.picker.visible === true) { - container = logicOperand.comparison.operandA.algebra.picker.getContainer(point) - if (container !== undefined) { return container } + if (container = logicOperand.comparison.operandA.algebra.picker !== undefined) { + if (container = logicOperand.comparison.operandA.algebra.picker.visible === true) { + container = logicOperand.comparison.operandA.algebra.picker.getContainer(point) + if (container !== undefined) { return container } + } } - if (container = logicOperand.comparison.operandB.algebra.picker.visible === true) { - container = logicOperand.comparison.operandB.algebra.picker.getContainer(point) - if (container !== undefined) { return container } + if (logicOperand.comparison.operandB.algebra.picker !== undefined) { + if (container = logicOperand.comparison.operandB.algebra.picker.visible === true) { + container = logicOperand.comparison.operandB.algebra.picker.getContainer(point) + if (container !== undefined) { return container } + } } - if (container = logicOperand.comparison.picker.visible === true) { - container = logicOperand.comparison.picker.getContainer(point) - if (container !== undefined) { return container } + if (container = logicOperand.comparison.picker !== undefined) { + if (container = logicOperand.comparison.picker.visible === true) { + container = logicOperand.comparison.picker.getContainer(point) + if (container !== undefined) { return container } + } } - if (container = logicOperand.picker.visible === true) { - container = logicOperand.picker.getContainer(point) - if (container !== undefined) { return container } + if (container = logicOperand.picker !== undefined) { + if (container = logicOperand.picker.visible === true) { + container = logicOperand.picker.getContainer(point) + if (container !== undefined) { return container } + } } } From 17b41bac0b6227d4a8f944624e54fa00657402fb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 07:58:04 +0200 Subject: [PATCH 15/54] Parsing Code --- FloatingSpace/ConditionEditor.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index d6c33d2ae..cdd0cd85c 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -75,8 +75,8 @@ function newConditionEditor () { } function loadFromCode () { - thisObject.payload.node.code = 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || ' - thisObject.payload.node.code = thisObject.payload.node.code + 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin ' + // thisObject.payload.node.code = 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || ' + // thisObject.payload.node.code = thisObject.payload.node.code + 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin ' if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } @@ -92,7 +92,9 @@ function newConditionEditor () { if (logicOperand.code !== undefined) { logicOperand.visible = true - logicOperand.operator = ' || ' + if (orArray[j + 1] !== undefined) { + logicOperand.operator = ' || ' + } } else { logicOperand.code = '' } From d09cb5ff41f116966c5bf40d008ef2bca2ebd920 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 08:50:14 +0200 Subject: [PATCH 16/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 160 +++++++++++++++++++------------ 1 file changed, 100 insertions(+), 60 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index cdd0cd85c..4be0fd854 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -75,9 +75,6 @@ function newConditionEditor () { } function loadFromCode () { - // thisObject.payload.node.code = 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin || ' - // thisObject.payload.node.code = thisObject.payload.node.code + 'chart.at24hs.popularSMA.begin + chart.at24hs.popularSMA.begin > chart.at24hs.candlesProbability.begin + chart.at24hs.candlesProbability.begin ' - if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } /* LOGICAL ORs */ @@ -154,7 +151,7 @@ function newConditionEditor () { logicOperand.comparison.operatorIndex = 4 } - /* Each comparison code may have one or more algebraic operators */ + /* Each comparison code may have one or more algebra operators */ checkAlgebra(logicOperand, logicOperand.comparison.operandA) checkAlgebra(logicOperand, logicOperand.comparison.operandB) } @@ -165,7 +162,7 @@ function newConditionEditor () { operandB: { index: 1} } - /* The default situation is that there is no Algebraic operation, meaning we will setup a Algebraic operation only with operandA */ + /* The default situation is that there is no algebra operation, meaning we will setup a algebra operation only with operandA */ comparisonOperand.algebra.operandA.code = comparisonOperand.code comparisonOperand.algebra.operandB.code = '' comparisonOperand.algebra.operator = ' ... ' @@ -527,79 +524,122 @@ function newConditionEditor () { } function convertToCode () { - // if (comparisonOperatorA === undefined || comparisonOperatorB === undefined || comparisonPicker === undefined) { return } + if (conditionStructure === undefined) { return } // chart.at01hs.bollingerSubChannel.previous.previous.slope=== "Extreme" - /* + let code = '' - code = code + 'chart.at' + comparisonOperatorA.timeFramePicker.getSelected().replace('-', '') - code = code + '.' + comparisonOperatorA.productPicker.getSelected() - insertWhen(comparisonOperatorA) - code = code + '.' + comparisonOperatorA.propertyPicker.getSelected() - - switch (comparisonPicker.getSelected()) { - case 'Greater Than': { - code = code + ' > ' + for (let i = 0; i < conditionStructure.logicOperands.length; i++) { + let logicOperand = conditionStructure.logicOperands[i] + logicOperandToCode(logicOperand) + if (logicOperand.picker.getSelected() !== 'OR') { break + } else { + code = code + ' || ' } - case 'Less Than': { - code = code + ' < ' - break - } - case 'Greater or Equal Than': { - code = code + ' >= ' - break - } - case 'Less or Equal Than': { - code = code + ' <= ' - break - } - case 'Equal To': { - code = code + ' === ' - break - } - } - - if (comparisonPicker.getSelected() === 'Equal To') { - code = code + '"' + comparisonOperatorA.valuePicker.getSelected() + '"' - } else { - code = code + 'chart.at' + comparisonOperatorB.timeFramePicker.getSelected().replace('-', '') - code = code + '.' + comparisonOperatorB.productPicker.getSelected() - insertWhen(comparisonOperatorB) - code = code + '.' + comparisonOperatorB.propertyPicker.getSelected() } thisObject.payload.node.code = code - function insertWhen (operator) { - switch (operator.whenPicker.getSelected()) { - case 'Current': { - return + function logicOperandToCode (logicOperand) { + algebraOperandToCode(logicOperand.comparison.operandA.algebra.operandA) + if (logicOperand.comparison.operandA.algebra.picker.getSelected() !== '...') { + insertAlgebraOperator(logicOperand.comparison.operandA.algebra) + algebraOperandToCode(logicOperand.comparison.operandA.algebra.operandB) + } + + switch (logicOperand.comparison.picker.getSelected()) { + case 'Greater Than': { + code = code + ' > ' + break } - case '1 Previous': { - code = code + '.previous' - return + case 'Less Than': { + code = code + ' < ' + break } - case '2 Previous': { - code = code + '.previous.previous' - return + case 'Greater or Equal Than': { + code = code + ' >= ' + break } - case '3 Previous': { - code = code + '.previous.previous.previous' - return + case 'Less or Equal Than': { + code = code + ' <= ' + break } - case '4 Previous': { - code = code + '.previous.previous.previous.previous' - return + case 'Equal To': { + code = code + ' === ' + break } - case '5 Previous': { - code = code + '.previous.previous.previous.previous.previous' - return + } + + if (logicOperand.comparison.picker.getSelected() === 'Equal To') { + code = code + '"' + logicOperand.comparison.operandA.valuePicker.getSelected() + '"' + } else { + algebraOperandToCode(logicOperand.comparison.operandB.algebra.operandA) + if (logicOperand.comparison.operandB.algebra.picker.getSelected() !== '...') { + insertAlgebraOperator(logicOperand.comparison.operandB.algebra) + algebraOperandToCode(logicOperand.comparison.operandB.algebra.operandB) + } + } + + function algebraOperandToCode (algebraOperand) { + code = code + 'chart.at' + algebraOperand.timeFramePicker.getSelected().replace('-', '') + code = code + '.' + algebraOperand.productPicker.getSelected() + insertWhen(algebraOperand) + code = code + '.' + algebraOperand.propertyPicker.getSelected() + } + + function insertAlgebraOperator (algebra) { + switch (algebra.picker.getSelected()) { + case '...': { + return + } + case 'Plus': { + code = code + ' + ' + return + } + case 'Minus': { + code = code + ' - ' + return + } + case 'Times': { + code = code + ' * ' + return + } + case 'Divided by': { + code = code + ' / ' + return + } + } + } + function insertWhen (algebraOperand) { + switch (algebraOperand.whenPicker.getSelected()) { + case 'Current': { + return + } + case '1 Previous': { + code = code + '.previous' + return + } + case '2 Previous': { + code = code + '.previous.previous' + return + } + case '3 Previous': { + code = code + '.previous.previous.previous' + return + } + case '4 Previous': { + code = code + '.previous.previous.previous.previous' + return + } + case '5 Previous': { + code = code + '.previous.previous.previous.previous.previous' + return + } } } } - */ } function finalizePickers () { From 787dcd3fbbe36d349669bbc67c826ce8a454ceaf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 09:46:25 +0200 Subject: [PATCH 17/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 66 +++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 4be0fd854..75ce7b680 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -75,7 +75,7 @@ function newConditionEditor () { } function loadFromCode () { - if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } + if (thisObject.payload.node.code === undefined) { thisObject.payload.node.code = '' } /* LOGICAL ORs */ let orArray = conditionStructure.code.split(' || ') @@ -218,20 +218,39 @@ function newConditionEditor () { if (algebraOperand.index === 0) { comparisonOperand.algebra.picker = newPicker() - comparisonOperand.algebra.picker.name = 'Algebra' - comparisonOperand.algebra.picker.container.connectToParent(thisObject.container) - comparisonOperand.algebra.picker.container.frame.position.x = 0 - comparisonOperand.algebra.picker.container.frame.width / 2 + comparisonOperand.algebra.picker.container.frame.width * 2.5 - comparisonOperand.algebra.picker.container.frame.position.y = 0 - comparisonOperand.algebra.picker.container.frame.height / 2 + yOffset + let picker = comparisonOperand.algebra.picker + picker.name = 'Algebra' + picker.container.connectToParent(thisObject.container) + picker.container.frame.position.x = 0 - picker.container.frame.width / 2 + picker.container.frame.width * 2.5 + picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset current = ['...', 'Plus', 'Minus', 'Times', 'Divided by'] - comparisonOperand.algebra.picker.initialize(current, current) - comparisonOperand.algebra.picker.visible = true + picker.initialize(current, current) + switch (comparisonOperand.algebra.operator) { + case ' + ': { + picker.setSelected(undefined, undefined, undefined, 1) + break + } + case ' - ': { + picker.setSelected(undefined, undefined, undefined, 2) + break + } + case ' * ': { + picker.setSelected(undefined, undefined, undefined, 3) + break + } + case ' / ': { + picker.setSelected(undefined, undefined, undefined, 4) + break + } + } + picker.visible = true let structureBranch = { logicOperand: logicOperand, comparisonOperand: comparisonOperand, algebraOperand: algebraOperand, pickerName: 'Algebra' } - comparisonOperand.algebra.picker.eventSuscriptionId = comparisonOperand.algebra.picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, structureBranch) + picker.eventSuscriptionId = picker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged, structureBranch) } if (comparisonOperand.index === 0 && algebraOperand.index === 1) { @@ -243,6 +262,28 @@ function newConditionEditor () { picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] picker.initialize(optionsList) + switch (logicOperand.comparison.operator) { + case ' > ': { + picker.setSelected(undefined, undefined, undefined, 0) + break + } + case ' < ': { + picker.setSelected(undefined, undefined, undefined, 1) + break + } + case ' >= ': { + picker.setSelected(undefined, undefined, undefined, 2) + break + } + case ' <= ': { + picker.setSelected(undefined, undefined, undefined, 3) + break + } + case ' === ': { + picker.setSelected(undefined, undefined, undefined, 4) + break + } + } picker.visible = true let structureBranch = { logicOperand: logicOperand, @@ -276,7 +317,7 @@ function newConditionEditor () { } let visible = true - if (algebraOperand.index === 1) { visible = false } + if (algebraOperand.index === 1 && comparisonOperand.algebra.picker.getSelected() === '...') { visible = false } algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' @@ -583,7 +624,12 @@ function newConditionEditor () { } function algebraOperandToCode (algebraOperand) { - code = code + 'chart.at' + algebraOperand.timeFramePicker.getSelected().replace('-', '') + if (algebraOperand.timeFramePicker.getSelected() === 'Any Time Frame') { + code = code + 'chart.atAnyTimeFrame' + } else { + code = code + 'chart.at' + algebraOperand.timeFramePicker.getSelected().replace('-', '') + } + code = code + '.' + algebraOperand.productPicker.getSelected() insertWhen(algebraOperand) code = code + '.' + algebraOperand.propertyPicker.getSelected() From 0c11b56ff45b8ede99970e3ece6e5de7be1a60fe Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 12:42:34 +0200 Subject: [PATCH 18/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 96 ++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 42 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 75ce7b680..f5e61d5c6 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -53,7 +53,7 @@ function newConditionEditor () { thisObject.payload.uiObject.setErrorMessage('', 0) conditionStructure = { - code: thisObject.payload.node.code, + code: '', logicOperands: [] } @@ -75,10 +75,14 @@ function newConditionEditor () { } function loadFromCode () { + if (thisObject.payload.node.javascriptCode !== undefined) { + thisObject.payload.node.code = thisObject.payload.node.javascriptCode.code + } if (thisObject.payload.node.code === undefined) { thisObject.payload.node.code = '' } + conditionStructure.code = thisObject.payload.node.code.replace(/ /g, '') /* LOGICAL ORs */ - let orArray = conditionStructure.code.split(' || ') + let orArray = conditionStructure.code.split('||') for (let j = 0; j < 3; j++) { let logicOperand = { code: orArray[j], @@ -90,7 +94,7 @@ function newConditionEditor () { if (logicOperand.code !== undefined) { logicOperand.visible = true if (orArray[j + 1] !== undefined) { - logicOperand.operator = ' || ' + logicOperand.operator = '||' } } else { logicOperand.code = '' @@ -111,43 +115,43 @@ function newConditionEditor () { code: '' } - if (logicOperand.code.indexOf(' > ') > 0) { - let codeArray = logicOperand.code.split(' > ') + if (logicOperand.code.indexOf('>') > 0) { + let codeArray = logicOperand.code.split('>') logicOperand.comparison.operandA.code = codeArray[0] logicOperand.comparison.operandB.code = codeArray[1] - logicOperand.comparison.operator = ' > ' + logicOperand.comparison.operator = '>' logicOperand.comparison.operatorIndex = 0 } - if (logicOperand.code.indexOf(' < ') > 0) { - let codeArray = logicOperand.code.split(' < ') + if (logicOperand.code.indexOf('<') > 0) { + let codeArray = logicOperand.code.split('<') logicOperand.comparison.operandA.code = codeArray[0] logicOperand.comparison.operandB.code = codeArray[1] - logicOperand.comparison.operator = ' < ' + logicOperand.comparison.operator = '<' logicOperand.comparison.operatorIndex = 1 } - if (logicOperand.code.indexOf(' >= ') > 0) { - let codeArray = logicOperand.code.split(' >= ') + if (logicOperand.code.indexOf('>=') > 0) { + let codeArray = logicOperand.code.split('>=') logicOperand.comparison.operandA.code = codeArray[0] logicOperand.comparison.operandB.code = codeArray[1] - logicOperand.comparison.operator = ' >= ' + logicOperand.comparison.operator = '>=' logicOperand.comparison.operatorIndex = 2 } - if (logicOperand.code.indexOf(' <= ') > 0) { - let codeArray = logicOperand.code.split(' <= ') + if (logicOperand.code.indexOf('<=') > 0) { + let codeArray = logicOperand.code.split('<=') logicOperand.comparison.operandA.code = codeArray[0] logicOperand.comparison.operandB.code = codeArray[1] - logicOperand.comparison.operator = ' <= ' + logicOperand.comparison.operator = '<=' logicOperand.comparison.operatorIndex = 3 } - if (logicOperand.code.indexOf(' === ') > 0) { - let codeArray = logicOperand.code.split(' === ') + if (logicOperand.code.indexOf('===') > 0) { + let codeArray = logicOperand.code.split('===') logicOperand.comparison.operandA.code = codeArray[0] logicOperand.comparison.operandB.code = codeArray[1] - logicOperand.comparison.operator = ' === ' + logicOperand.comparison.operator = '===' logicOperand.comparison.operatorIndex = 4 } @@ -165,38 +169,38 @@ function newConditionEditor () { /* The default situation is that there is no algebra operation, meaning we will setup a algebra operation only with operandA */ comparisonOperand.algebra.operandA.code = comparisonOperand.code comparisonOperand.algebra.operandB.code = '' - comparisonOperand.algebra.operator = ' ... ' + comparisonOperand.algebra.operator = '...' comparisonOperand.algebra.operatorIndex = 0 - if (comparisonOperand.code.indexOf(' + ') > 0) { - let codeArray = comparisonOperand.code.split(' + ') + if (comparisonOperand.code.indexOf('+') > 0) { + let codeArray = comparisonOperand.code.split('+') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] - comparisonOperand.algebra.operator = ' + ' + comparisonOperand.algebra.operator = '+' comparisonOperand.algebra.operatorIndex = 1 } - if (comparisonOperand.code.indexOf(' - ') > 0) { - let codeArray = comparisonOperand.code.split(' - ') + if (comparisonOperand.code.indexOf('-') > 0) { + let codeArray = comparisonOperand.code.split('-') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] - comparisonOperand.algebra.operator = ' - ' + comparisonOperand.algebra.operator = '-' comparisonOperand.algebra.operatorIndex = 2 } - if (comparisonOperand.code.indexOf(' * ') > 0) { - let codeArray = comparisonOperand.code.split(' * ') + if (comparisonOperand.code.indexOf('*') > 0) { + let codeArray = comparisonOperand.code.split('*') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] - comparisonOperand.algebra.operator = ' * ' + comparisonOperand.algebra.operator = '*' comparisonOperand.algebra.operatorIndex = 3 } - if (comparisonOperand.code.indexOf(' / ') > 0) { - let codeArray = comparisonOperand.code.split(' / ') + if (comparisonOperand.code.indexOf('/') > 0) { + let codeArray = comparisonOperand.code.split('/') comparisonOperand.algebra.operandA.code = codeArray[0] comparisonOperand.algebra.operandB.code = codeArray[1] - comparisonOperand.algebra.operator = ' / ' + comparisonOperand.algebra.operator = '/' comparisonOperand.algebra.operatorIndex = 4 } @@ -226,19 +230,19 @@ function newConditionEditor () { current = ['...', 'Plus', 'Minus', 'Times', 'Divided by'] picker.initialize(current, current) switch (comparisonOperand.algebra.operator) { - case ' + ': { + case '+': { picker.setSelected(undefined, undefined, undefined, 1) break } - case ' - ': { + case '-': { picker.setSelected(undefined, undefined, undefined, 2) break } - case ' * ': { + case '*': { picker.setSelected(undefined, undefined, undefined, 3) break } - case ' / ': { + case '/': { picker.setSelected(undefined, undefined, undefined, 4) break } @@ -263,23 +267,23 @@ function newConditionEditor () { let optionsList = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] picker.initialize(optionsList) switch (logicOperand.comparison.operator) { - case ' > ': { + case '>': { picker.setSelected(undefined, undefined, undefined, 0) break } - case ' < ': { + case '<': { picker.setSelected(undefined, undefined, undefined, 1) break } - case ' >= ': { + case '>=': { picker.setSelected(undefined, undefined, undefined, 2) break } - case ' <= ': { + case '<=': { picker.setSelected(undefined, undefined, undefined, 3) break } - case ' === ': { + case '===': { picker.setSelected(undefined, undefined, undefined, 4) break } @@ -303,7 +307,7 @@ function newConditionEditor () { picker.container.frame.position.y = 0 - picker.container.frame.height / 2 + yOffset let optionsList = ['...', 'OR'] picker.initialize(optionsList) - if (logicOperand.operator === ' || ') { + if (logicOperand.operator === '||') { picker.setSelected(undefined, undefined, undefined, 1) } picker.visible = true @@ -318,6 +322,7 @@ function newConditionEditor () { let visible = true if (algebraOperand.index === 1 && comparisonOperand.algebra.picker.getSelected() === '...') { visible = false } + if (logicOperand.comparison.picker !== undefined && comparisonOperand.index === 1 && logicOperand.comparison.picker.getSelected() === 'Equal To') { visible = false } algebraOperand.whenPicker = newPicker() algebraOperand.whenPicker.name = 'When' @@ -386,6 +391,9 @@ function newConditionEditor () { algebraOperand.valuePicker.initialize(properties, current, parent, 'possibleValues') parent = current algebraOperand.valuePicker.visible = false + if (logicOperand.comparison.picker !== undefined && logicOperand.comparison.picker.getSelected() === 'Equal To') { + comparisonOperand.algebra.operandA.valuePicker.visible = true + } algebraOperand.timeFramePicker = newPicker() algebraOperand.timeFramePicker.name = 'Time Frame' @@ -583,6 +591,10 @@ function newConditionEditor () { thisObject.payload.node.code = code + if (thisObject.payload.node.javascriptCode !== undefined) { + thisObject.payload.node.javascriptCode.code = thisObject.payload.node.code + } + function logicOperandToCode (logicOperand) { algebraOperandToCode(logicOperand.comparison.operandA.algebra.operandA) if (logicOperand.comparison.operandA.algebra.picker.getSelected() !== '...') { @@ -614,7 +626,7 @@ function newConditionEditor () { } if (logicOperand.comparison.picker.getSelected() === 'Equal To') { - code = code + '"' + logicOperand.comparison.operandA.valuePicker.getSelected() + '"' + code = code + '"' + logicOperand.comparison.operandA.algebra.operandA.valuePicker.getSelected() + '"' } else { algebraOperandToCode(logicOperand.comparison.operandB.algebra.operandA) if (logicOperand.comparison.operandB.algebra.picker.getSelected() !== '...') { From cb7e2a139e4868a6ac8fbe1a8600f51d76c5ad6d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 15:14:51 +0200 Subject: [PATCH 19/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index f5e61d5c6..47ecd27bf 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -457,7 +457,7 @@ function newConditionEditor () { codeProperty = codeArray[3 + propertyDisplacement] } - let codeValue = comparisonOperand.algebra.operandB.code.replace('"', '').replace('"', '') + let codeValue = logicOperand.comparison.operandB.code.replace('"', '').replace('"', '') let dataMines = Object.keys(scanResult) for (let i = 0; i < dataMines.length; i++) { From 283ad23576ce2208aef917ababfe82d8765cadd7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 16:03:19 +0200 Subject: [PATCH 20/54] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 46 +++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 47ecd27bf..cb6c2662f 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -25,12 +25,26 @@ function newConditionEditor () { thisObject.container.isDraggeable = false thisObject.container.detectMouseOver = false thisObject.container.frame.radius = 750 + thisObject.container.frame.width = thisObject.container.frame.radius * 2 + thisObject.container.frame.height = thisObject.container.frame.radius * 2 thisObject.container.frame.containerName = MODULE_NAME let isMouseOver = false let conditionStructure let scanResult + let timeFrameIcon + let dataMineIcon + let botIcon + let whenIcon + let productIcon + let propertyIcon + let operationIcon + let valueIcon + + const PICKER_WIDTH = 150 + const PICKER_HEIGHT = 60 + return thisObject function finalize () { @@ -41,10 +55,26 @@ function newConditionEditor () { conditionStructure = undefined scanResult = undefined + + timeFrameIcon = undefined + dataMineIcon = undefined + whenIcon = undefined + botIcon = undefined + productIcon = undefined + operationIcon = undefined + propertyIcon = undefined + valueIcon = undefined } function initialize () { - + timeFrameIcon = canvas.designSpace.iconCollection.get('time-period') + dataMineIcon = canvas.designSpace.iconCollection.get('data-mine') + botIcon = canvas.designSpace.iconCollection.get('bot-indicator') + whenIcon = canvas.designSpace.iconCollection.get('chronometer') + productIcon = canvas.designSpace.iconCollection.get('product-definition') + propertyIcon = canvas.designSpace.iconCollection.get('record-property') + operationIcon = canvas.designSpace.iconCollection.get('headphones') + valueIcon = canvas.designSpace.iconCollection.get('competition') } function activate (payload) { @@ -211,7 +241,7 @@ function newConditionEditor () { } function initializePickersSet (logicOperand, comparisonOperand, algebraOperand) { - const ALGEBRA_SEPARATION = 60 + const ALGEBRA_SEPARATION = PICKER_HEIGHT const COMPARISON_SEPARATION = ALGEBRA_SEPARATION * 2 const LOGIC_SEPARATION = COMPARISON_SEPARATION * 2 @@ -1160,6 +1190,16 @@ function newConditionEditor () { } function thisObjectDrawForeground () { - + if (thisObject.visible === true) { + const SIZE = 36 + drawIcon(timeFrameIcon, 0, 0, -PICKER_WIDTH * 3.25, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(dataMineIcon, 0, 0, -PICKER_WIDTH * 2.5, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(botIcon, 0, 0, -PICKER_WIDTH * 1.5, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(whenIcon, 0, 0, -PICKER_WIDTH * 0.5, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(productIcon, 0, 0, PICKER_WIDTH * 0.5, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(propertyIcon, 0, 0, PICKER_WIDTH * 1.45, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(operationIcon, 0, 0, PICKER_WIDTH * 2.45, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + drawIcon(valueIcon, 0, 0, PICKER_WIDTH * 3.45, -PICKER_HEIGHT * 7, SIZE, thisObject.container) + } } } From ad9133e13fc193e3c5b58f606e1467738f75f241 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 5 May 2020 16:05:29 +0200 Subject: [PATCH 21/54] Update SplashScreen.js --- SplashScreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SplashScreen.js b/SplashScreen.js index 4370f934b..55508957f 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -122,7 +122,7 @@ function newSplashScreen () { fontSize = 35 - title = 'Beta 4' + title = 'Beta 5' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, From d23e4697fe1b689b24165c38b8c243c0fb796613 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 7 May 2020 12:37:03 +0200 Subject: [PATCH 22/54] Conditional Polygons --- Panels/Layer.js | 2 +- Plotter.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 44e067063..1877a5ecc 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -170,7 +170,7 @@ function newLayer () { 'Plotter Module->Plotter->' + 'Shapes->' + 'Chart Points->Point->Point Formula->' + - 'Polygon->Polygon Body->Style->Style Condition->Style->' + + 'Polygon->Polygon Condition->Polygon Body->Style->Style Condition->Style->' + 'Polygon Border->Style->Style Condition->Style->' + 'Polygon Vertex->Point->' + 'Plotter Panel->Javascript Code->Panel Data->Data Formula->' diff --git a/Plotter.js b/Plotter.js index bba22925f..c17556477 100644 --- a/Plotter.js +++ b/Plotter.js @@ -598,6 +598,12 @@ function newPlotter () { for (let j = 0; j < productDefinition.referenceParent.shapes.polygons.length; j++) { let polygon = productDefinition.referenceParent.shapes.polygons[j] + /* We will check if we need to plot this Polygon or not. */ + if (polygon.polygonCondition !== undefined) { + let mustPlot = eval(polygon.polygonCondition.code) + if (mustPlot !== true) { continue } + } + let calculatedStyle /* Finding out the fill style */ From 1e3cee0b46c71defc7ba3ab6c2d0c28199f68875 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 7 May 2020 13:59:36 +0200 Subject: [PATCH 23/54] Fixed when reports to the coordinate system --- Plotter.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Plotter.js b/Plotter.js index c17556477..ff1bf1368 100644 --- a/Plotter.js +++ b/Plotter.js @@ -570,23 +570,23 @@ function newPlotter () { let x = 0 let y = 0 eval(point.pointFormula.code) - let dataPoint = { + let rawPoint = { x: x, y: y } - /* Contributing to Auto-Scale */ - coordinateSystem.reportYValue(dataPoint.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 = coordinateSystem.transformThisPoint(dataPoint) + let dataPoint + dataPoint = coordinateSystem.transformThisPoint(rawPoint) dataPoint = transformThisPoint(dataPoint, thisObject.container) dataPoint = canvas.chartingSpace.viewport.fitIntoVisibleArea(dataPoint) dataPoint = thisObject.fitFunction(dataPoint) /* Store the data point at the local map */ + dataPoint.rawPoint = rawPoint dataPoints.set(point.id, dataPoint) } } @@ -730,6 +730,12 @@ function newPlotter () { console.log('[WARN] You have a Polygon Vertex not referencing any Point.') continue } + + /* Contributing to Auto-Scale */ + if (dataPointObject.rawPoint.y > 1 && dataPointObject.rawPoint.y !== undefined && isNaN(dataPointObject.rawPoint.y) === false) { + coordinateSystem.reportYValue(dataPointObject.rawPoint.y) + } + let dataPoint = { x: dataPointObject.x, y: dataPointObject.y From 1855b1eb7fb8c7d60b4812203eaa2ad8e8e0e0ce Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 10 May 2020 09:01:29 +0200 Subject: [PATCH 24/54] conditions editor improvement --- DesignSpace/Workspace/Workspace.js | 10 ++++++++++ FloatingSpace/ConditionEditor.js | 7 ------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 3b1a4891e..cb72e1245 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -508,6 +508,16 @@ function newWorkspace () { referenceDetachNode(payload.node) } break + case 'Push Code to Javascript Code': + { + payload.node.javascriptCode.code = payload.node.code + } + break + case 'Fetch Code to Javascript Code': + { + payload.node.code = payload.node.javascriptCode.code + } + break case 'Open Documentation': { let definition = APP_SCHEMA_MAP.get(payload.node.type) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index cb6c2662f..5b22ff07e 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -105,9 +105,6 @@ function newConditionEditor () { } function loadFromCode () { - if (thisObject.payload.node.javascriptCode !== undefined) { - thisObject.payload.node.code = thisObject.payload.node.javascriptCode.code - } if (thisObject.payload.node.code === undefined) { thisObject.payload.node.code = '' } conditionStructure.code = thisObject.payload.node.code.replace(/ /g, '') @@ -621,10 +618,6 @@ function newConditionEditor () { thisObject.payload.node.code = code - if (thisObject.payload.node.javascriptCode !== undefined) { - thisObject.payload.node.javascriptCode.code = thisObject.payload.node.code - } - function logicOperandToCode (logicOperand) { algebraOperandToCode(logicOperand.comparison.operandA.algebra.operandA) if (logicOperand.comparison.operandA.algebra.picker.getSelected() !== '...') { From 99e233cd3f31efcad9d787ce4da2296913b887c2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 11 May 2020 17:16:46 +0200 Subject: [PATCH 25/54] Save workspace at Backend --- DesignSpace/Workspace/Workspace.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index cb72e1245..fc23acf05 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -170,6 +170,19 @@ function newWorkspace () { let textToSave = stringifyWorkspace() window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) window.localStorage.setItem('Session Timestamp', sessionTimestamp) + + let url = 'SaveWorkspace/' + workspace.name + callServer(textToSave, url, onResponse) + + function onResponse (err) { + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + window.localStorage.setItem('Last Used Workspace', workspace.name) + window.localStorage.setItem('Session Timestamp', sessionTimestamp) + canvas.cockpitSpace.setStatus('Workspace Auto-Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) + } else { + canvas.cockpitSpace.setStatus('Could not save the Workspace at the Backend. Please check the Backend Console for more information.', 150, canvas.cockpitSpace.statusTypes.WARNING) + } + } return true } } From 7b540068c03a75f41c4fa5b9d4b50b276e43b8c7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 11 May 2020 20:21:55 +0200 Subject: [PATCH 26/54] Saving and Loading Workspace from Backend --- Canvas.js | 12 ++---- .../FunctionLibraries/UiObjectsFromNodes.js | 2 +- DesignSpace/Workspace/Workspace.js | 41 +++++++++++++------ Spaces/ChartingSpace.js | 6 ++- Spaces/CockpitSpace.js | 22 ++++++---- 5 files changed, 52 insertions(+), 31 deletions(-) diff --git a/Canvas.js b/Canvas.js index b13ac359c..51ad14431 100644 --- a/Canvas.js +++ b/Canvas.js @@ -109,12 +109,12 @@ function newCanvas () { thisObject.topSpace = newTopSpace() thisObject.topSpace.initialize() - thisObject.designSpace = newDesignSpace() - thisObject.designSpace.initialize() - thisObject.cockpitSpace = newCockpitSpace() thisObject.cockpitSpace.initialize() + thisObject.designSpace = newDesignSpace() + thisObject.designSpace.initialize() + thisObject.panelsSpace = newPanelsSpace() thisObject.panelsSpace.initialize() @@ -295,11 +295,7 @@ function newCanvas () { } if (event.shiftKey === true && (event.ctrlKey === true || event.metaKey === true) && (event.key === 'S' || event.key === 's')) { - let saved = canvas.designSpace.workspace.save() - if (saved === true) { - canvas.cockpitSpace.setStatus('Workspace Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) - } - + canvas.designSpace.workspace.save() event.preventDefault() return } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index d6253f558..992a37b8f 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -22,7 +22,7 @@ function newUiObjectsFromNodes () { addIncludedNodes() function addIncludedNodes () { - blobService = newFileStorage() + let blobService = newFileStorage() // if (node.code === undefined) { node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index fc23acf05..f50e50f4d 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -85,19 +85,34 @@ function newWorkspace () { function initialize () { try { - let reset = window.localStorage.getItem('Reset') - let savedWorkspace = window.localStorage.getItem(CANVAS_APP_NAME + '.' + 'Workspace') + let lastUsedWorkspace = window.localStorage.getItem('Last Used Workspace') - if (savedWorkspace === null || reset !== null) { - thisObject.workspaceNode = getWorkspace() + if (lastUsedWorkspace !== 'undefined' && lastUsedWorkspace !== null && lastUsedWorkspace !== undefined) { + let blobService = newFileStorage() + blobService.getFileFromHost('LoadWorkspace' + '/' + lastUsedWorkspace, onFileReceived, true) + function onFileReceived (err, text, response) { + if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + canvas.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, canvas.cockpitSpace.statusTypes.WARNING) + thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. + finishInitialization() + return + } + thisObject.workspaceNode = JSON.parse(text) + finishInitialization() + } } else { - thisObject.workspaceNode = JSON.parse(savedWorkspace) + thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. + finishInitialization() } - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) - setupEventsServerClients() - thisObject.enabled = true - setInterval(saveWorkspace, 60000) + function finishInitialization () { + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) + setupEventsServerClients() + thisObject.enabled = true + canvas.cockpitSpace.initializePosition() + + setInterval(saveWorkspace, 60000) + } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } } @@ -171,14 +186,16 @@ function newWorkspace () { window.localStorage.setItem(CANVAS_APP_NAME + '.' + 'Workspace', textToSave) window.localStorage.setItem('Session Timestamp', sessionTimestamp) - let url = 'SaveWorkspace/' + workspace.name - callServer(textToSave, url, onResponse) + if (workspace.name !== undefined) { + let url = 'SaveWorkspace/' + workspace.name + callServer(textToSave, url, onResponse) + } function onResponse (err) { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { window.localStorage.setItem('Last Used Workspace', workspace.name) window.localStorage.setItem('Session Timestamp', sessionTimestamp) - canvas.cockpitSpace.setStatus('Workspace Auto-Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) + canvas.cockpitSpace.setStatus(workspace.name + ' Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) } else { canvas.cockpitSpace.setStatus('Could not save the Workspace at the Backend. Please check the Backend Console for more information.', 150, canvas.cockpitSpace.statusTypes.WARNING) } diff --git a/Spaces/ChartingSpace.js b/Spaces/ChartingSpace.js index ae4d6fee0..91568cacf 100644 --- a/Spaces/ChartingSpace.js +++ b/Spaces/ChartingSpace.js @@ -96,8 +96,10 @@ function newChartingSpace () { let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes for (let i = 0; i < rootNodes.length; i++) { let rootNode = rootNodes[i] - if (rootNode.type === 'Charting Space') { - thisObject.payload = rootNode.payload + if (rootNode !== null) { + if (rootNode.type === 'Charting Space') { + thisObject.payload = rootNode.payload + } } } diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 248e07c39..ed8cfb932 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -20,7 +20,8 @@ physics: physics, getContainer: getContainer, finalize: finalize, - initialize: initialize + initialize: initialize, + initializePosition: initializePosition } thisObject.container = newContainer() @@ -39,6 +40,7 @@ let statusCounter = 0 let statusText let statusType + let isInitilized = false return thisObject @@ -52,6 +54,15 @@ } function initialize () { + canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) + selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + + thisObject.fullscreen = newFullScreen() + thisObject.fullscreen.container.connectToParent(thisObject.container) + thisObject.fullscreen.initialize() + } + + function initializePosition () { thisObject.container.frame.position.x = 0 let INITIAL_POSITION @@ -68,13 +79,7 @@ INITIAL_POSITION = 100 thisObject.container.frame.position.y = browserCanvas.height * INITIAL_POSITION / 100 - COCKPIT_SPACE_HEIGHT } - - canvasBrowserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) - selfMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) - - thisObject.fullscreen = newFullScreen() - thisObject.fullscreen.container.connectToParent(thisObject.container) - thisObject.fullscreen.initialize() + isInitilized = true } function onMouseClick (event) { @@ -148,6 +153,7 @@ thisObject.fullscreen.physics() } function thisObjectPhysics () { + if (isInitilized === false) { return } /* Check the limits */ thisObject.status = 'MIDDLE' From 38e3d462aaa72fcc83101b5d90b93133d1879458 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 May 2020 12:16:41 +0200 Subject: [PATCH 27/54] Side Space Added --- Canvas.js | 8 ++++++-- .../Workspace/FunctionLibraries/UiObjectsFromNodes.js | 4 ++-- {ControlsToolBox => SideSpace}/SidePanelTab.js | 0 Spaces/ChartingSpace.js | 2 ++ Spaces/CockpitSpace.js | 6 ++++-- ControlsToolBox/SidePanel.js => Spaces/SideSpace.js | 9 +++++++-- 6 files changed, 21 insertions(+), 8 deletions(-) rename {ControlsToolBox => SideSpace}/SidePanelTab.js (100%) rename ControlsToolBox/SidePanel.js => Spaces/SideSpace.js (96%) diff --git a/Canvas.js b/Canvas.js index 51ad14431..014fee0e0 100644 --- a/Canvas.js +++ b/Canvas.js @@ -32,11 +32,11 @@ function newCanvas () { let thisObject = { eventHandler: undefined, topSpace: undefined, + sideSpace: undefined, chartingSpace: undefined, floatingSpace: undefined, panelsSpace: undefined, cockpitSpace: undefined, - bottomSpace: undefined, designSpace: undefined, animation: undefined, mouse: undefined, @@ -63,6 +63,7 @@ function newCanvas () { function finalize () { try { + thisObject.sideSpace.finalize() thisObject.chartingSpace.finalize() thisObject.floatingSpace.finalize() thisObject.shorcutNumbers = undefined @@ -121,7 +122,8 @@ function newCanvas () { thisObject.chartingSpace = newChartingSpace() thisObject.chartingSpace.initialize() - thisObject.bottomSpace = thisObject.cockpitSpace + thisObject.sideSpace = newSideSpace() + thisObject.sideSpace.initialize() splashScreen = newSplashScreen() splashScreen.initialize() @@ -137,6 +139,7 @@ function newCanvas () { animation.addCallBackFunction('Charting Space Physics', thisObject.chartingSpace.physics) animation.addCallBackFunction('Design Space Physics', thisObject.designSpace.physics) animation.addCallBackFunction('Panels Space Physics', thisObject.panelsSpace.physics) + animation.addCallBackFunction('Side Space Physics', thisObject.sideSpace.physics) /* Spcaces Drawing */ animation.addCallBackFunction('Floating Space Draw', thisObject.floatingSpace.draw) @@ -145,6 +148,7 @@ function newCanvas () { animation.addCallBackFunction('CockpitSpace Draw', thisObject.cockpitSpace.draw) animation.addCallBackFunction('Design Space Draw', thisObject.designSpace.draw) animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) + animation.addCallBackFunction('Side Space Draw', thisObject.sideSpace.draw) animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw) animation.start() } catch (err) { diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 992a37b8f..a376f5806 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -238,7 +238,7 @@ function newUiObjectsFromNodes () { switch (property.type) { case 'node': { if (property.name !== previousPropertyName) { - createUiObjectFromNode(node[property.name], node, node, positionOffset) + setTimeout(createUiObjectFromNode, 1, node[property.name], node, node, positionOffset) previousPropertyName = property.name } } @@ -247,7 +247,7 @@ function newUiObjectsFromNodes () { let nodePropertyArray = node[property.name] for (let m = 0; m < nodePropertyArray.length; m++) { let arrayItem = nodePropertyArray[m] - createUiObjectFromNode(arrayItem, node, node, positionOffset) + setTimeout(createUiObjectFromNode, 1, arrayItem, node, node, positionOffset) } } break diff --git a/ControlsToolBox/SidePanelTab.js b/SideSpace/SidePanelTab.js similarity index 100% rename from ControlsToolBox/SidePanelTab.js rename to SideSpace/SidePanelTab.js diff --git a/Spaces/ChartingSpace.js b/Spaces/ChartingSpace.js index 91568cacf..a3959971c 100644 --- a/Spaces/ChartingSpace.js +++ b/Spaces/ChartingSpace.js @@ -92,6 +92,8 @@ function newChartingSpace () { function initialize () { if (isInitialized === true) { return } + if (canvas.designSpace === undefined) { return } + if (canvas.designSpace.workspace === undefined) { return } let rootNodes = canvas.designSpace.workspace.workspaceNode.rootNodes for (let i = 0; i < rootNodes.length; i++) { diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index ed8cfb932..33be244fa 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -272,8 +272,10 @@ printLabel(statusText, position.x, position.y, 1, 15, textColor, true, thisObject.container) } - if (canvas.designSpace.workspace.enabled === true && statusText === undefined) { - arrow() + if (canvas.designSpace !== undefined) { + if (canvas.designSpace.workspace.enabled === true && statusText === undefined) { + arrow() + } } } diff --git a/ControlsToolBox/SidePanel.js b/Spaces/SideSpace.js similarity index 96% rename from ControlsToolBox/SidePanel.js rename to Spaces/SideSpace.js index 8c133e6cc..43297fd04 100644 --- a/ControlsToolBox/SidePanel.js +++ b/Spaces/SideSpace.js @@ -1,9 +1,10 @@ -function newSidePanel () { - const MODULE_NAME = 'Side Panel' +function newSideSpace () { + const MODULE_NAME = 'Side Space' let thisObject = { areas: [], sidePanelTab: undefined, container: undefined, + physics: physics, draw: draw, getContainer: getContainer, initialize: initialize @@ -50,6 +51,10 @@ function newSidePanel () { } } + function physics () { + + } + function draw () { if (isInitialized === false) { return } borders() From f88450ddd7376f6857667a52bf7d86e582fbafea Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 May 2020 12:50:41 +0200 Subject: [PATCH 28/54] Side Panel Opening and Closing --- Canvas.js | 77 +++++++++++++++++++++++++++------------ SideSpace/SidePanelTab.js | 9 ++++- Spaces/SideSpace.js | 8 +--- 3 files changed, 61 insertions(+), 33 deletions(-) diff --git a/Canvas.js b/Canvas.js index 014fee0e0..7fa8989fd 100644 --- a/Canvas.js +++ b/Canvas.js @@ -578,8 +578,21 @@ function newCanvas () { let container - /* We check if the mouse is over an element of the Design Space / */ + /* We check if the mouse is over an element of the Side Space / */ + container = thisObject.sideSpace.getContainer(point) + if (container !== undefined && container.isDraggeable === true) { + containerBeingDragged = container + containerDragStarted = true + containerBeingDragged.eventHandler.raiseEvent('onDragStarted', point) + return + } + + if (container !== undefined && container.isDraggeable === false) { + return + } + + /* We check if the mouse is over an element of the Design Space / */ container = thisObject.designSpace.getContainer(point) if (container !== undefined && container.isDraggeable === true) { @@ -593,8 +606,7 @@ function newCanvas () { return } - /* We check if the mouse is over an element of the Top Space / */ - + /* We check if the mouse is over an element of the Top Space / */ container = thisObject.topSpace.getContainer(point) if (container !== undefined && container.isDraggeable === true) { @@ -604,8 +616,7 @@ function newCanvas () { return } - /* We check if the mouse is over an element of the CockpitSpace / */ - + /* We check if the mouse is over an element of the CockpitSpace / */ container = thisObject.cockpitSpace.getContainer(point) if (container !== undefined && container.isDraggeable === true) { @@ -620,8 +631,7 @@ function newCanvas () { return } - /* We check if the mouse is over a panel/ */ - + /* We check if the mouse is over a panel/ */ container = thisObject.panelsSpace.getContainer(point, GET_CONTAINER_PURPOSE.DRAGGING) if (container !== undefined && event.shiftKey === false) { @@ -640,8 +650,7 @@ function newCanvas () { return } - /* we check if it is over any of the existing containers at the Charting Space. */ - + /* we check if it is over any of the existing containers at the Charting Space. */ container = thisObject.chartingSpace.getContainer(point, GET_CONTAINER_PURPOSE.DRAGGING) if (container !== undefined) { @@ -698,8 +707,15 @@ function newCanvas () { let container - /* We check if the mouse is over an element of the Design Space / */ + /* We check if the mouse is over an element of the Side Space / */ + container = thisObject.sideSpace.getContainer(point) + if (container !== undefined && container.isClickeable === true) { + container.eventHandler.raiseEvent('onMouseClick', point) + return + } + + /* We check if the mouse is over an element of the Design Space / */ container = thisObject.designSpace.getContainer(point) if (container !== undefined && container.isClickeable === true) { @@ -707,8 +723,7 @@ function newCanvas () { return } - /* We check if the mouse is over an element of the Top Space / */ - + /* We check if the mouse is over an element of the Top Space / */ container = thisObject.topSpace.getContainer(point) if (container !== undefined && container.isClickeable === true) { @@ -716,8 +731,7 @@ function newCanvas () { return } - /* We check if the mouse is over an element of the CockpitSpace / */ - + /* We check if the mouse is over an element of the CockpitSpace / */ container = thisObject.cockpitSpace.getContainer(point) if (container !== undefined && container.isClickeable === true) { @@ -725,8 +739,7 @@ function newCanvas () { return } - /* We check if the mouse is over a panel/ */ - + /* We check if the mouse is over a panel/ */ container = thisObject.panelsSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_CLICK) if (container !== undefined && container.isClickeable === true) { @@ -734,8 +747,7 @@ function newCanvas () { return } - /* If it is not, then we check if it is over any of the existing containers at the Charting Space. */ - + /* If it is not, then we check if it is over any of the existing containers at the Charting Space. */ container = thisObject.chartingSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_CLICK) if (container !== undefined && container.isClickeable === true) { @@ -837,6 +849,16 @@ function newCanvas () { let container + /* We check if the mouse is over an element of the Designe Space / */ + if (thisObject.sideSpace !== undefined) { + container = thisObject.sideSpace.getContainer(point) + + if (container !== undefined && container.detectMouseOver === true) { + containerFound() + return + } + } + /* We check if the mouse is over an element of the Designe Space / */ if (thisObject.designSpace !== undefined) { container = thisObject.designSpace.getContainer(point) @@ -934,6 +956,16 @@ function newCanvas () { event.mousePosition = point let container + + /* Side Space */ + container = canvas.sideSpace.getContainer({ x: point.x, y: point.y }) + + if (container !== undefined && container.isWheelable === true) { + container.eventHandler.raiseEvent('onMouseWheel', event) + return false // This instructs the browser not to take the event and scroll the page. + } + + /* Panel Space */ container = canvas.panelsSpace.getContainer({ x: point.x, y: point.y }) if (container !== undefined && container.isWheelable === true) { @@ -941,8 +973,7 @@ function newCanvas () { return false // This instructs the browser not to take the event and scroll the page. } - /* We try the CockpitSpace. */ - + /* We try the CockpitSpace. */ container = canvas.cockpitSpace.getContainer({ x: point.x, y: point.y }) if (container !== undefined && container.isWheelable === true) { @@ -950,8 +981,7 @@ function newCanvas () { return false // This instructs the browser not to take the event and scroll the page. } - /* Charting Space. */ - + /* Charting Space. */ container = canvas.chartingSpace.getContainer({ x: point.x, y: point.y }, GET_CONTAINER_PURPOSE.MOUSE_WHEEL) if (container !== undefined && container.isWheelable === true) { container.eventHandler.raiseEvent('onMouseWheel', event) @@ -963,8 +993,7 @@ function newCanvas () { return false } - /* We try second with floating objects. */ - + /* We try second with floating objects. */ container = canvas.floatingSpace.getContainer({ x: point.x, y: point.y }) if (container !== undefined && container.isWheelable === true) { diff --git a/SideSpace/SidePanelTab.js b/SideSpace/SidePanelTab.js index 8bd0bd253..c415b1046 100644 --- a/SideSpace/SidePanelTab.js +++ b/SideSpace/SidePanelTab.js @@ -3,6 +3,7 @@ function newSidePanelTab () { let thisObject = { pointerDirection: 'left', container: undefined, + physics: physics, draw: draw, getContainer: getContainer, initialize: initialize @@ -28,7 +29,7 @@ function newSidePanelTab () { thisObject.container.frame.width = TAB_WIDTH thisObject.container.frame.height = TAB_HEIGHT thisObject.container.frame.position.x = 0 + thisObject.container.parentContainer.frame.width - thisObject.container.frame.position.y = 20 + thisObject.container.frame.position.y = 69 ORIGINAL_PARENT_POSITON = thisObject.container.parentContainer.frame.position.x @@ -53,9 +54,13 @@ function newSidePanelTab () { } } - function draw () { + function physics () { if (isInitialized === false) { return } animate() + } + + function draw () { + if (isInitialized === false) { return } borders() arrow() } diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 43297fd04..43b01ce6b 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -1,7 +1,6 @@ function newSideSpace () { const MODULE_NAME = 'Side Space' let thisObject = { - areas: [], sidePanelTab: undefined, container: undefined, physics: physics, @@ -52,18 +51,13 @@ function newSideSpace () { } function physics () { - + thisObject.sidePanelTab.physics() } function draw () { if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() - - for (let i = 0; i < thisObject.areas.length; i++) { - let area = thisObject.areas[i] - area.draw() - } } function borders () { From 082f388d2c2e90a2d816b9e316b0cd287382f7dd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 May 2020 13:33:30 +0200 Subject: [PATCH 29/54] Improvement on startup showing boxes more time --- Animation.js | 1 + Canvas.js | 10 ++++------ .../FunctionLibraries/UiObjectsFromNodes.js | 10 +++++++--- DesignSpace/Workspace/Workspace.js | 13 ++++++++----- Globals.js | 2 ++ Spaces/ChartingSpace.js | 1 + Spaces/CockpitSpace.js | 1 + Spaces/DesignSpace.js | 1 + Spaces/FloatingSpace.js | 1 + Spaces/PanelsSpace.js | 1 + Spaces/SideSpace.js | 1 + Spaces/TopSpace.js | 1 + SplashScreen.js | 11 +++++++---- 13 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Animation.js b/Animation.js index 1e06c4849..20f967a48 100644 --- a/Animation.js +++ b/Animation.js @@ -168,6 +168,7 @@ function newAnimation () { } function clearBrowserCanvas () { + if (canWeDraw === false) { return } browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height) } diff --git a/Canvas.js b/Canvas.js index 7fa8989fd..4dd01deb8 100644 --- a/Canvas.js +++ b/Canvas.js @@ -3,7 +3,6 @@ let browserCanvasContext // The context of the canvas object. let stepsInitializationCounter = 0 // This counter the initialization steps required to be able to turn off the splash screen. let marketInitializationCounter = 0 // This counter the initialization of markets required to be able to turn off the splash screen. -let splashScreenNeeded = true function newCanvas () { const MODULE_NAME = 'Canvas' @@ -38,6 +37,7 @@ function newCanvas () { panelsSpace: undefined, cockpitSpace: undefined, designSpace: undefined, + splashScreen: undefined, animation: undefined, mouse: undefined, shorcutNumbers: new Map(), @@ -47,7 +47,6 @@ function newCanvas () { thisObject.eventHandler = newEventHandler() - let splashScreen let lastContainerMouseOver let lastShortcutKeyRejection @@ -87,7 +86,7 @@ function newCanvas () { browserCanvas.removeEventListener('keydown', onKeyDown, false) browserCanvas.removeEventListener('keyup', onKeyUp, false) - splashScreen = undefined + thisObject.splashScreen = undefined lastContainerMouseOver = undefined hisObject.mouse = undefined @@ -125,8 +124,7 @@ function newCanvas () { thisObject.sideSpace = newSideSpace() thisObject.sideSpace.initialize() - splashScreen = newSplashScreen() - splashScreen.initialize() + thisObject.splashScreen = newSplashScreen() let animation = newAnimation() animation.initialize() @@ -149,7 +147,7 @@ function newCanvas () { animation.addCallBackFunction('Design Space Draw', thisObject.designSpace.draw) animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) animation.addCallBackFunction('Side Space Draw', thisObject.sideSpace.draw) - animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw) + animation.addCallBackFunction('Splash Screen Draw', thisObject.splashScreen.draw) animation.start() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index a376f5806..4a56efdc2 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -14,7 +14,7 @@ function newUiObjectsFromNodes () { return thisObject - function recreateWorkspace (node, replacingCurrentWorkspace) { + function recreateWorkspace (node, replacingCurrentWorkspace, callBackFunction) { mapOfNodes = new Map() tasksToRun = [] sessionsToRun = [] @@ -145,6 +145,10 @@ function newUiObjectsFromNodes () { // We give a few seconds for the tasks to start setTimeout(runSessions, 10000) } + + if (callBackFunction !== undefined) { + callBackFunction() // The recreation of the workspace is complete + } } } @@ -238,7 +242,7 @@ function newUiObjectsFromNodes () { switch (property.type) { case 'node': { if (property.name !== previousPropertyName) { - setTimeout(createUiObjectFromNode, 1, node[property.name], node, node, positionOffset) + createUiObjectFromNode(node[property.name], node, node, positionOffset) previousPropertyName = property.name } } @@ -247,7 +251,7 @@ function newUiObjectsFromNodes () { let nodePropertyArray = node[property.name] for (let m = 0; m < nodePropertyArray.length; m++) { let arrayItem = nodePropertyArray[m] - setTimeout(createUiObjectFromNode, 1, arrayItem, node, node, positionOffset) + createUiObjectFromNode(arrayItem, node, node, positionOffset) } } break diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index f50e50f4d..4e0758bd4 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -94,23 +94,26 @@ function newWorkspace () { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { canvas.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, canvas.cockpitSpace.statusTypes.WARNING) thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. - finishInitialization() + recreateWorkspace() return } thisObject.workspaceNode = JSON.parse(text) - finishInitialization() + recreateWorkspace() } } else { thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. - finishInitialization() + recreateWorkspace() + } + + function recreateWorkspace () { + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, false, finishInitialization) } function finishInitialization () { - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) setupEventsServerClients() thisObject.enabled = true canvas.cockpitSpace.initializePosition() - + canvas.splashScreen.initialize() setInterval(saveWorkspace, 60000) } } catch (err) { diff --git a/Globals.js b/Globals.js index cc1ec296a..b0a7414fa 100644 --- a/Globals.js +++ b/Globals.js @@ -224,6 +224,8 @@ const TIME_MACHINE_HEIGHT = 8; let mediaRecorder // to downloadText canvas animation as a mediaRecorder let areWeRecording = false +let canWeDraw = false // This global variable regulates when spaces can or can not draw their contents. + function toRadians(angle) { return angle * (Math.PI / 180); } diff --git a/Spaces/ChartingSpace.js b/Spaces/ChartingSpace.js index a3959971c..afbca8ce9 100644 --- a/Spaces/ChartingSpace.js +++ b/Spaces/ChartingSpace.js @@ -406,6 +406,7 @@ function newChartingSpace () { } function draw () { + if (canWeDraw === false) { return } if (thisObject.visible === false) { return } drawBackground() diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 33be244fa..af67991f7 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -207,6 +207,7 @@ } function draw () { + if (canWeDraw === false) { return } thisObject.container.frame.draw(false, false) drawBackground() diff --git a/Spaces/DesignSpace.js b/Spaces/DesignSpace.js index db26f42ca..305e1d532 100644 --- a/Spaces/DesignSpace.js +++ b/Spaces/DesignSpace.js @@ -334,6 +334,7 @@ function newDesignSpace () { } function draw () { + if (canWeDraw === false) { return } if (thisObject.sidePanel !== undefined) { thisObject.sidePanel.draw() } diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 7664b7fc5..cb94ebc2d 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -415,6 +415,7 @@ function newFloatingSpace () { } function draw () { + if (canWeDraw === false) { return } if (visible === false) { return } drawBackground() thisObject.floatingLayer.draw() diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 28ffa303f..e752631d1 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -336,6 +336,7 @@ function newPanelsSpace () { } function draw () { + if (canWeDraw === false) { return } if (thisObject.visible !== true) { return } thisObject.container.frame.draw(false, false) diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 43b01ce6b..4ef872909 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -55,6 +55,7 @@ function newSideSpace () { } function draw () { + if (canWeDraw === false) { return } if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 905a93894..a7dcf5e62 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -54,6 +54,7 @@ function newTopSpace () { } function draw () { + if (canWeDraw === false) { return } thisObject.container.frame.draw(false, false) drawBackground() diff --git a/SplashScreen.js b/SplashScreen.js index 55508957f..34b7c9589 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -13,7 +13,7 @@ function newSplashScreen () { initialize: initialize } - var container = newContainer() + let container = newContainer() container.initialize() thisObject.container = container @@ -31,21 +31,22 @@ function newSplashScreen () { let logo let canDrawLogo = false + let isInitialized = false + let splashScreenNeeded = true return thisObject function initialize () { logo = new Image() - logo.onload = onImageLoad function onImageLoad () { canDrawLogo = true } - logo.src = window.canvasApp.urlPrefix + 'Images/superalgos-logo.png' - canvas.eventHandler.listenToEvent('Browser Resized', resize) + + isInitialized = true } function resize () { @@ -54,6 +55,7 @@ function newSplashScreen () { } function draw () { + if (isInitialized === false) { return } if (splashScreenNeeded === false) { stepsInitializationCounter = 100 canDrawLogo = false @@ -101,6 +103,7 @@ function newSplashScreen () { if (stepsInitializationCounter > 99) { splashScreenNeeded = false + canWeDraw = true stepsInitializationCounter = 99 } From 72196eb31bf0a20651df002d9e462293ee36b526 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 12 May 2020 16:35:55 +0200 Subject: [PATCH 30/54] Update SideSpace.js --- Spaces/SideSpace.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 4ef872909..2212ae12b 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -16,6 +16,7 @@ function newSideSpace () { thisObject.container.initialize() thisObject.container.isClickeable = true thisObject.container.isDraggeable = false + thisObject.container.detectMouseOver = true thisObject.container.status = 'hidden' resize() From 4727a60509f4e71c54a2dc04222c34b85d45ed26 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 13 May 2020 09:47:13 +0200 Subject: [PATCH 31/54] List View Progress --- SideSpace/ListItem.js | 72 +++++++++++ SideSpace/ListView.js | 285 ++++++++++++++++++++++++++++++++++++++++++ Spaces/SideSpace.js | 15 +++ 3 files changed, 372 insertions(+) create mode 100644 SideSpace/ListItem.js create mode 100644 SideSpace/ListView.js diff --git a/SideSpace/ListItem.js b/SideSpace/ListItem.js new file mode 100644 index 000000000..6e4ec6885 --- /dev/null +++ b/SideSpace/ListItem.js @@ -0,0 +1,72 @@ +function newListItem () { + const MODULE_NAME = 'List Item' + const ERROR_LOG = true + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + container: undefined, + fitFunction: undefined, + physics: physics, + draw: draw, + getContainer: getContainer, + initialize: initialize, + finalize: finalize + } + + thisObject.container = newContainer() + thisObject.container.initialize() + thisObject.container.isDraggeable = false + thisObject.container.isWheelable = false + thisObject.container.detectMouseOver = true + + return thisObject + + function finalize () { + thisObject.container.finalize() + thisObject.container = undefined + thisObject.fitFunction = undefined + } + + function initialize () { + + } + + function getContainer (point) { + if (thisObject.container.frame.isThisPointHere(point, true) === true) { + return thisObject.container + } + } + + function onMouseClick (event) { + + } + + function physics () { + + } + + function draw () { + let label1 = 'TEST NAME' + + let backgroundColor = UI_COLOR.BLACK + + const RED_LINE_HIGHT = 4 + const OPACITY = 0.75 + + let params = { + cornerRadius: 0, + lineWidth: 1, + container: thisObject.container, + borderColor: UI_COLOR.RUSTED_RED, + castShadow: false, + backgroundColor: backgroundColor, + opacity: OPACITY + } + + roundedCornersBackground(params) + + drawLabel(label1, 1 / 2, 6 / 10, -5, 0, label1FontSize, thisObject.container) + drawIcon(thisObject.exchangeIcon, 1 / 8, 2 / 10, 0, 0, 14, thisObject.container) + } +} diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js new file mode 100644 index 000000000..8c8097671 --- /dev/null +++ b/SideSpace/ListView.js @@ -0,0 +1,285 @@ +function newListView () { + const MODULE_NAME = 'List View' + const ERROR_LOG = true + const logger = newWebDebugLog() + logger.fileName = MODULE_NAME + + let thisObject = { + fitFunction: undefined, + container: undefined, + listItems: [], + payload: undefined, + isVisible: false, + physics: physics, + draw: draw, + getContainer: getContainer, + initialize: initialize, + finalize: finalize + } + + thisObject.container = newContainer() + thisObject.container.initialize() + thisObject.container.isDraggeable = false + thisObject.container.isWheelable = true + thisObject.container.detectMouseOver = true + + let isInitialized = false + + let listItemsMap = new Map() + let visibleListItems = [] + let firstVisibleListItem = 1 + + const LAYER_SEPARATION = 0 + + let headerHeight = 40 + let footerHeight = 10 + let listItemHeight = 70 + let desiredVisibleListItems = 5 + let posibleVisibleListItems = 5 + let desiredObjectHeight = (listItemHeight + LAYER_SEPARATION) * desiredVisibleListItems + headerHeight + footerHeight + let posibleObjectHeight = (listItemHeight + LAYER_SEPARATION) * posibleVisibleListItems + headerHeight + footerHeight + + let onMouseWheelEventSuscriptionId + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId + + let isMouseOver + return thisObject + + function finalize () { + thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) + + listItemsMap = undefined + visibleListItems = undefined + + thisObject.container.finalize() + thisObject.container = undefined + + thisObject.payload = undefined + thisObject = undefined + } + + function initialize () { + thisObject.container.name = MODULE_NAME + thisObject.container.frame.containerName = thisObject.container.name + thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.80 + thisObject.container.frame.height = headerHeight + + let position = { // Default position + x: SIDE_PANEL_WIDTH * 0.10, + y: 20 + } + + thisObject.container.frame.position = position + + onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + callServer(undefined, 'ListWorkspaces', onResponse) + + function onResponse (err, text) { + if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> Could not load the list of your workspaces from the backend. ') } + return + } + + let workspacelist = JSON.parse(text) + for (let i = 0; i < workspacelist.length; i++) { + let workspace = workspacelist[i] + let listItem = newListItem() + listItem.initialize() + listItem.container.connectToParent(thisObject.container, false, false) + thisObject.listItems.push(listItem) + } + isInitialized = true + } + } + + function onMouseOver (event) { + isMouseOver = true + } + + function onMouseNotOver () { + isMouseOver = false + } + + function onMouseWheel (event) { + delta = event.wheelDelta + if (delta > 0) { + delta = -1 + } else { + delta = 1 + } + + if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < headerHeight) { // Mouse wheel over the header, not a listItem + desiredVisibleListItems = desiredVisibleListItems + delta + if (desiredVisibleListItems < 0) { desiredVisibleListItems = 0 } + if (desiredVisibleListItems > thisObject.listItems.length) { desiredVisibleListItems = thisObject.listItems.length } + } else { + firstVisibleListItem = firstVisibleListItem + delta + } + desiredObjectHeight = (listItemHeight + LAYER_SEPARATION) * desiredVisibleListItems + headerHeight + footerHeight + calculateVisbleListItems() + } + + function calculateVisbleListItems () { + let availableSlots = posibleVisibleListItems + + if (firstVisibleListItem < 1) { firstVisibleListItem = 1 } + if (firstVisibleListItem > (thisObject.listItems.length - availableSlots + 1)) { firstVisibleListItem = thisObject.listItems.length - availableSlots + 1 } + + visibleListItems = [] + + for (let i = 0; i < thisObject.listItems.length; i++) { + if (i + 1 >= firstVisibleListItem && i + 1 < firstVisibleListItem + availableSlots) { + let listItem = thisObject.listItems[i] + + listItem.container.frame.position.x = 0 + listItem.container.frame.position.y = (listItemHeight + LAYER_SEPARATION) * visibleListItems.length + headerHeight + + /* Add to Visible Product Array */ + visibleListItems.push(listItem) + } + } + } + + function getContainer (point, purpose) { + if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return } + let container + + if (isMouseOver === true && purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) { + container = thisObject.upDownButton.getContainer(point) + if (container !== undefined) { return container } + + container = thisObject.leftRightButton.getContainer(point) + if (container !== undefined) { return container } + } + + /* First we check if thisObject point is inside thisObject space. */ + if (thisObject.container.frame.isThisPointHere(point, true) === true) { + /* Now we see which is the inner most container that has it */ + for (let i = 0; i < visibleListItems.length; i++) { + container = visibleListItems[i].getContainer(point) + + if (container !== undefined) { + let checkPoint = { + x: point.x, + y: point.y + } + + checkPoint = thisObject.fitFunction(checkPoint) + + if (point.x === checkPoint.x && point.y === checkPoint.y) { + if (purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) { + return container + } + } + } + } + + /* The point does not belong to any inner container, so we return the current container. */ + let checkPoint = { + x: point.x, + y: point.y + } + + checkPoint = thisObject.fitFunction(checkPoint) + + if (point.x === checkPoint.x && point.y === checkPoint.y) { + return thisObject.container + } + } + } + + function childrenPhysics () { + for (let i = 0; i < thisObject.listItems.length; i++) { + let listItem = thisObject.listItems[i] + listItem.physics() + } + } + + function physics () { + if (isInitialized === false) { return } + if (thisObject.isVisible === false) { return } + childrenPhysics() + } + + function draw () { + if (isInitialized === false || thisObject.visible === false) { return } + + drawHeader() + drawScrollBar() + } + + function drawHeader () { + let label1 = 'HEADER' + + let icon1 = canvas.designSpace.iconByUiObjectType.get('Workspace') + + let backgroundColor = UI_COLOR.WHITE + + let params = { + cornerRadius: 5, + lineWidth: 1, + container: thisObject.container, + borderColor: UI_COLOR.RUSTED_RED, + castShadow: false, + backgroundColor: backgroundColor, + opacity: 1 + } + + roundedCornersBackground(params) + + drawLabel(label1, 1 / 2, 0, 0, 15, 9, thisObject.container, UI_COLOR.BLACK) + drawIcon(icon1, 1 / 8, 0, 0, 20, 28, thisObject.container) + } + + function drawScrollBar () { + if (thisObject.listItems.length > posibleVisibleListItems && posibleVisibleListItems > 0) { + let xOffset = 4 + let barTopPoint = { + x: thisObject.container.frame.width - xOffset, + y: headerHeight + } + let barBottomPoint = { + x: thisObject.container.frame.width - xOffset, + y: thisObject.container.frame.height - footerHeight + } + let ratio = posibleVisibleListItems / thisObject.listItems.length + let handleHeight = (posibleVisibleListItems * (listItemHeight + LAYER_SEPARATION)) * ratio + let handleTopPoint = { + x: thisObject.container.frame.width - xOffset, + y: headerHeight + (listItemHeight + LAYER_SEPARATION) * ratio * (firstVisibleListItem - 1) + } + let handleBottomPoint = { + x: thisObject.container.frame.width - xOffset, + y: handleTopPoint.y + handleHeight + } + barTopPoint = thisObject.container.frame.frameThisPoint(barTopPoint) + barBottomPoint = thisObject.container.frame.frameThisPoint(barBottomPoint) + handleTopPoint = thisObject.container.frame.frameThisPoint(handleTopPoint) + handleBottomPoint = thisObject.container.frame.frameThisPoint(handleBottomPoint) + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(barTopPoint.x, barTopPoint.y) + browserCanvasContext.lineTo(barBottomPoint.x, barBottomPoint.y) + browserCanvasContext.closePath() + browserCanvasContext.setLineDash([0, 0]) + browserCanvasContext.lineWidth = 1 + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')' + browserCanvasContext.stroke() + + browserCanvasContext.beginPath() + browserCanvasContext.moveTo(handleTopPoint.x, handleTopPoint.y) + browserCanvasContext.lineTo(handleBottomPoint.x, handleBottomPoint.y) + browserCanvasContext.closePath() + browserCanvasContext.setLineDash([0, 0]) + browserCanvasContext.lineWidth = 4 + browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + 1 + ')' + browserCanvasContext.stroke() + } + } +} diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 2212ae12b..66366c11a 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -19,6 +19,8 @@ function newSideSpace () { thisObject.container.detectMouseOver = true thisObject.container.status = 'hidden' + let listView + resize() return thisObject @@ -28,9 +30,17 @@ function newSideSpace () { thisObject.sidePanelTab.initialize() canvas.eventHandler.listenToEvent('Browser Resized', resize) + + initializeListView() isInitialized = true } + function initializeListView () { + listView = newListView() + listView.initialize() + listView.container.connectToParent(thisObject.container, false, false) + } + function resize () { thisObject.container.frame.width = SIDE_PANEL_WIDTH thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT @@ -44,6 +54,9 @@ function newSideSpace () { container = thisObject.sidePanelTab.getContainer(point) if (container !== undefined) { return container } + container = listView.getContainer(point) + if (container !== undefined) { return container } + if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } else { @@ -53,6 +66,7 @@ function newSideSpace () { function physics () { thisObject.sidePanelTab.physics() + listView.physics() } function draw () { @@ -60,6 +74,7 @@ function newSideSpace () { if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() + listView.draw() } function borders () { From 85a90c128e9ea17ec835bff7b6633191d8740bde Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 13 May 2020 21:32:42 +0200 Subject: [PATCH 32/54] Market Panorame Implemented --- Animation.js | 12 ++++++++-- Canvas.js | 17 ++++++++++----- ChartingSpace/EdgeEditor.js | 15 ++++++++++--- DesignSpace/Workspace/Workspace.js | 4 +++- Globals.js | 8 +++++-- Spaces/TopSpace.js | 2 +- Utilities.js | 35 ++++++++++++++++++++++++++++-- 7 files changed, 76 insertions(+), 17 deletions(-) diff --git a/Animation.js b/Animation.js index 20f967a48..cab8a470c 100644 --- a/Animation.js +++ b/Animation.js @@ -144,12 +144,20 @@ function newAnimation () { browserCanvas.height = 1 } - /* Media Recording */ + /* Video Recording */ videoRecorder.physics() - if (areWeRecording === true) { + if (ARE_WE_RECORDING_A_VIDEO === true) { videoRecorder.recordCanvas() } + /* Panorama Recording */ + if (ARE_WE_RECORDING_A_MARKET_PANORAMA === true) { + if (PANORAMA_WAS_PANNED === true) { + addToMarketPanorama() + PANORAMA_WAS_PANNED = false + } + } + /* We request the next frame to be drawn, and stablishing a loop */ /* Use this code for full animation speed. */ diff --git a/Canvas.js b/Canvas.js index 4dd01deb8..8a2cfaa4f 100644 --- a/Canvas.js +++ b/Canvas.js @@ -213,30 +213,35 @@ function newCanvas () { if ((event.ctrlKey === true || event.metaKey === true)) { let constructorParams switch (event.keyCode) { + case 118: { // F7 + downloadPanorama('Superalgos.Market.Panorama') + return + break + } case 119: { // F8 - downloadCanvas('Superalgos.image.capture') + downloadCanvas('Superalgos.Image.Capture', browserCanvas) return break } case 120: { // F9 - constructorParams = { format: 'gif', workersPath: 'externalScripts/', framerate: 8, name: 'Superalgos.video.capture'} + constructorParams = { format: 'gif', workersPath: 'externalScripts/', framerate: 8, name: 'Superalgos.Video.Capture'} break } case 121: { // F10 - constructorParams = { format: 'webm', framerate: 8, name: 'Superalgos.video.capture' } + constructorParams = { format: 'webm', framerate: 8, name: 'Superalgos.Video.Capture' } break } default: return } - if (areWeRecording === false) { + if (ARE_WE_RECORDING_A_VIDEO === false) { console.log('RECORDING', constructorParams.format) mediaRecorder = new CCapture(constructorParams) mediaRecorder.start() - areWeRecording = true + ARE_WE_RECORDING_A_VIDEO = true } else { console.log('SAVING', constructorParams.format) - areWeRecording = false + ARE_WE_RECORDING_A_VIDEO = false mediaRecorder.stop() mediaRecorder.save() } diff --git a/ChartingSpace/EdgeEditor.js b/ChartingSpace/EdgeEditor.js index 6932fa58b..134d0006f 100644 --- a/ChartingSpace/EdgeEditor.js +++ b/ChartingSpace/EdgeEditor.js @@ -195,9 +195,18 @@ function newEdgeEditor () { } if (event.shiftKey === false && event.ctrlKey === false && event.code === 'ArrowRight') { - onDragStarted(event) - thisObject.container.frame.position.x = thisObject.container.frame.position.x - STEP - whatHappened = 'left or right arrow key pressed' + if (ARE_WE_RECORDING_A_MARKET_PANORAMA === true) { + if (PANORAMA_WAS_PANNED === false) { + PANORAMA_WAS_PANNED = true + onDragStarted(event) + thisObject.container.frame.position.x = thisObject.container.frame.position.x - STEP * 2 + whatHappened = 'left or right arrow key pressed' + } + } else { + onDragStarted(event) + thisObject.container.frame.position.x = thisObject.container.frame.position.x - STEP + whatHappened = 'left or right arrow key pressed' + } return } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 4e0758bd4..710f90310 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -198,7 +198,9 @@ function newWorkspace () { if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { window.localStorage.setItem('Last Used Workspace', workspace.name) window.localStorage.setItem('Session Timestamp', sessionTimestamp) - canvas.cockpitSpace.setStatus(workspace.name + ' Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) + if (ARE_WE_RECORDING_A_MARKET_PANORAMA === false) { + canvas.cockpitSpace.setStatus(workspace.name + ' Saved.', 50, canvas.cockpitSpace.statusTypes.ALL_GOOD) + } } else { canvas.cockpitSpace.setStatus('Could not save the Workspace at the Backend. Please check the Backend Console for more information.', 150, canvas.cockpitSpace.statusTypes.WARNING) } diff --git a/Globals.js b/Globals.js index b0a7414fa..92038622b 100644 --- a/Globals.js +++ b/Globals.js @@ -222,9 +222,13 @@ const TIME_MACHINE_WIDTH = 8; const TIME_MACHINE_HEIGHT = 8; let mediaRecorder // to downloadText canvas animation as a mediaRecorder -let areWeRecording = false +let marketPanoramaCanvas +let ARE_WE_RECORDING_A_VIDEO = false +let ARE_WE_RECORDING_A_MARKET_PANORAMA = false +let PANORAMA_WAS_PANNED = false +let CURRENT_PANORAMA_POSITION = 0 -let canWeDraw = false // This global variable regulates when spaces can or can not draw their contents. +let canWeDraw = false // This global variable regulates when spaces can or can not draw their contents. function toRadians(angle) { return angle * (Math.PI / 180); diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index a7dcf5e62..c88dd2960 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -66,7 +66,7 @@ function newTopSpace () { let opacity = 1 browserCanvasContext.beginPath() browserCanvasContext.rect(0, 0, thisObject.container.frame.width, thisObject.container.frame.height) - if (areWeRecording === true) { + if (ARE_WE_RECORDING_A_VIDEO === true) { browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.PATINATED_TURQUOISE + ', ' + opacity + ')' } else { browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.RUSTED_RED + ', ' + opacity + ')' diff --git a/Utilities.js b/Utilities.js index 294c6ec07..5c739b3d7 100644 --- a/Utilities.js +++ b/Utilities.js @@ -108,8 +108,8 @@ function downloadText (filename, text) { document.body.removeChild(element) } -function downloadCanvas (filename) { - let data = browserCanvas.toDataURL('image/png', 1) +function downloadCanvas (filename, canvasToUse) { + let data = canvasToUse.toDataURL('image/png', 1) /* Change MIME type to trick the browser to downlaod the file instead of displaying it */ data = data.replace(/^data:image\/[^;]*/, 'data:application/octet-stream') @@ -125,6 +125,37 @@ function downloadCanvas (filename) { document.body.removeChild(element) }; +function downloadPanorama (filename) { + let INITIAL_WIDTH = 800 + let FINAL_WIDTH = browserCanvas.width - INITIAL_WIDTH + + if (ARE_WE_RECORDING_A_MARKET_PANORAMA === false) { + /* We start recording the panorame. */ + ARE_WE_RECORDING_A_MARKET_PANORAMA = true + marketPanoramaCanvas = document.createElement('canvas') + marketPanoramaCanvas.width = INITIAL_WIDTH * 50 + marketPanoramaCanvas.height = browserCanvas.height + marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, 0, 0, INITIAL_WIDTH, browserCanvas.height, 0, 0, INITIAL_WIDTH, browserCanvas.height) + CURRENT_PANORAMA_POSITION = INITIAL_WIDTH + } else { + /* We stop recording and download the resulting image. */ + ARE_WE_RECORDING_A_MARKET_PANORAMA = false + marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, browserCanvas.width - FINAL_WIDTH, 0, FINAL_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, FINAL_WIDTH, browserCanvas.height) + let finalResultCanvas = document.createElement('canvas') + finalResultCanvas.width = CURRENT_PANORAMA_POSITION + FINAL_WIDTH + finalResultCanvas.height = browserCanvas.height + finalResultCanvas.getContext('2d').drawImage(marketPanoramaCanvas, 0, 0, finalResultCanvas.width, browserCanvas.height, 0, 0, finalResultCanvas.width, browserCanvas.height) + downloadCanvas(filename, finalResultCanvas) + } +} + +function addToMarketPanorama () { + let SECTION_WIDTH = 80 * 2 + let INITIAL_POSITION = 800 - SECTION_WIDTH + marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, INITIAL_POSITION, 0, SECTION_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, SECTION_WIDTH, browserCanvas.height) + CURRENT_PANORAMA_POSITION = CURRENT_PANORAMA_POSITION + SECTION_WIDTH +} + function transformThisPoint (point, container) { /* We make the point relative to the current frame */ From 38fdf962d1a24c18c59d0e0845e13389e2d4d9dc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 13 May 2020 21:46:20 +0200 Subject: [PATCH 33/54] Update Utilities.js --- Utilities.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities.js b/Utilities.js index 5c739b3d7..2af862981 100644 --- a/Utilities.js +++ b/Utilities.js @@ -146,6 +146,7 @@ function downloadPanorama (filename) { finalResultCanvas.height = browserCanvas.height finalResultCanvas.getContext('2d').drawImage(marketPanoramaCanvas, 0, 0, finalResultCanvas.width, browserCanvas.height, 0, 0, finalResultCanvas.width, browserCanvas.height) downloadCanvas(filename, finalResultCanvas) + marketPanoramaCanvas = undefined } } From 4e089cec1d67be7b31797bfddda10e64f1377746 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 10:23:19 +0200 Subject: [PATCH 34/54] Showing workspace list --- Globals.js | 3 +-- SideSpace/ListItem.js | 20 +++++++++++++------- SideSpace/ListView.js | 34 ++++++++++++++++++++-------------- SideSpace/SidePanelTab.js | 4 ++-- 4 files changed, 36 insertions(+), 25 deletions(-) diff --git a/Globals.js b/Globals.js index 92038622b..d9a737c01 100644 --- a/Globals.js +++ b/Globals.js @@ -190,8 +190,7 @@ const MAX_PLOTABLE_DATE = maxDate; const TOP_SPACE_HEIGHT = 40 const COCKPIT_SPACE_HEIGHT = 30; -const BREAKPOINT_HEIGHT = 15; -const SIDE_PANEL_WIDTH = 450 +const SIDE_PANEL_WIDTH = 350 let COCKPIT_SPACE_POSITION = browserCanvas.height - COCKPIT_SPACE_HEIGHT const LAYER_STATUS = { diff --git a/SideSpace/ListItem.js b/SideSpace/ListItem.js index 6e4ec6885..98af0384e 100644 --- a/SideSpace/ListItem.js +++ b/SideSpace/ListItem.js @@ -19,6 +19,11 @@ function newListItem () { thisObject.container.isDraggeable = false thisObject.container.isWheelable = false thisObject.container.detectMouseOver = true + thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75 + thisObject.container.frame.height = SIDE_PANEL_WIDTH * 0.75 + + let name + let type return thisObject @@ -28,8 +33,9 @@ function newListItem () { thisObject.fitFunction = undefined } - function initialize () { - + function initialize (pName, pType) { + name = pName + type = pType } function getContainer (point) { @@ -47,12 +53,11 @@ function newListItem () { } function draw () { - let label1 = 'TEST NAME' - + let icon = canvas.designSpace.iconByUiObjectType.get(type) let backgroundColor = UI_COLOR.BLACK const RED_LINE_HIGHT = 4 - const OPACITY = 0.75 + const OPACITY = 1 let params = { cornerRadius: 0, @@ -66,7 +71,8 @@ function newListItem () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 6 / 10, -5, 0, label1FontSize, thisObject.container) - drawIcon(thisObject.exchangeIcon, 1 / 8, 2 / 10, 0, 0, 14, thisObject.container) + drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container) + drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container) + drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 80, thisObject.container) } } diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index 8c8097671..4be52f866 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -31,7 +31,7 @@ function newListView () { const LAYER_SEPARATION = 0 - let headerHeight = 40 + let headerHeight = 30 let footerHeight = 10 let listItemHeight = 70 let desiredVisibleListItems = 5 @@ -64,15 +64,15 @@ function newListView () { function initialize () { thisObject.container.name = MODULE_NAME thisObject.container.frame.containerName = thisObject.container.name - thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.80 - thisObject.container.frame.height = headerHeight + thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75 let position = { // Default position - x: SIDE_PANEL_WIDTH * 0.10, + x: SIDE_PANEL_WIDTH * 0.25 / 2, y: 20 } thisObject.container.frame.position = position + thisObject.container.frame.height = browserCanvas.height - position.x onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) @@ -88,10 +88,11 @@ function newListView () { let workspacelist = JSON.parse(text) for (let i = 0; i < workspacelist.length; i++) { - let workspace = workspacelist[i] + let workspace = workspacelist[i].replace('.json', '') let listItem = newListItem() - listItem.initialize() + listItem.initialize(workspace, 'Workspace') listItem.container.connectToParent(thisObject.container, false, false) + listItem.container.frame.position.y = headerHeight + i * SIDE_PANEL_WIDTH * 0.75 thisObject.listItems.push(listItem) } isInitialized = true @@ -210,17 +211,22 @@ function newListView () { function draw () { if (isInitialized === false || thisObject.visible === false) { return } - drawHeader() + drawBackground() drawScrollBar() + drawChildren() } - function drawHeader () { - let label1 = 'HEADER' - - let icon1 = canvas.designSpace.iconByUiObjectType.get('Workspace') + function drawChildren () { + for (let i = 0; i < thisObject.listItems.length; i++) { + let listItem = thisObject.listItems[i] + listItem.draw() + } + } + function drawBackground () { + let label = 'Your Workspaces' + let icon = canvas.designSpace.iconByUiObjectType.get('Workspace') let backgroundColor = UI_COLOR.WHITE - let params = { cornerRadius: 5, lineWidth: 1, @@ -233,8 +239,8 @@ function newListView () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 0, 0, 15, 9, thisObject.container, UI_COLOR.BLACK) - drawIcon(icon1, 1 / 8, 0, 0, 20, 28, thisObject.container) + drawLabel(label, 1 / 2, 0, 0, 20, 15, thisObject.container, UI_COLOR.BLACK) + // drawIcon(icon, 1 / 8, 0, 0, 20, 28, thisObject.container) } function drawScrollBar () { diff --git a/SideSpace/SidePanelTab.js b/SideSpace/SidePanelTab.js index c415b1046..ea9108b49 100644 --- a/SideSpace/SidePanelTab.js +++ b/SideSpace/SidePanelTab.js @@ -71,7 +71,7 @@ function newSidePanelTab () { if (animation === 'opening') { xOffset = xOffset + STEP thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset - if (xOffset > thisObject.container.parentContainer.frame.width) { + if (xOffset >= thisObject.container.parentContainer.frame.width) { animation = 'none' xOffset = thisObject.container.parentContainer.frame.width thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset @@ -83,7 +83,7 @@ function newSidePanelTab () { if (animation === 'closing') { xOffset = xOffset - STEP thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset - if (xOffset < 0) { + if (xOffset <= 0) { animation = 'none' xOffset = 0 thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON From 99094491de46f26c273fb226551eab4e79171ef4 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 11:01:26 +0200 Subject: [PATCH 35/54] scroll bar showing up --- SideSpace/ListView.js | 49 ++++++++++++++++++++------------------- SideSpace/SidePanelTab.js | 1 + Spaces/SideSpace.js | 14 +++++++++-- 3 files changed, 38 insertions(+), 26 deletions(-) diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index 4be52f866..0b39a0581 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -10,6 +10,7 @@ function newListView () { listItems: [], payload: undefined, isVisible: false, + reload: reload, physics: physics, draw: draw, getContainer: getContainer, @@ -29,15 +30,13 @@ function newListView () { let visibleListItems = [] let firstVisibleListItem = 1 - const LAYER_SEPARATION = 0 + let headerHeight = 40 + let footerHeight = 30 + let listItemHeight = SIDE_PANEL_WIDTH * 0.75 - let headerHeight = 30 - let footerHeight = 10 - let listItemHeight = 70 - let desiredVisibleListItems = 5 - let posibleVisibleListItems = 5 - let desiredObjectHeight = (listItemHeight + LAYER_SEPARATION) * desiredVisibleListItems + headerHeight + footerHeight - let posibleObjectHeight = (listItemHeight + LAYER_SEPARATION) * posibleVisibleListItems + headerHeight + footerHeight + let posibleVisibleListItems + + let itemSeparation let onMouseWheelEventSuscriptionId let onMouseOverEventSubscriptionId @@ -74,10 +73,17 @@ function newListView () { thisObject.container.frame.position = position thisObject.container.frame.height = browserCanvas.height - position.x + posibleVisibleListItems = (thisObject.container.frame.height - headerHeight - footerHeight) / (listItemHeight) + itemSeparation = ((thisObject.container.frame.height - headerHeight - footerHeight) - listItemHeight * Math.trunc(posibleVisibleListItems)) / (Math.trunc(posibleVisibleListItems) - 1) + onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + reload() + } + + function reload () { callServer(undefined, 'ListWorkspaces', onResponse) function onResponse (err, text) { @@ -87,12 +93,14 @@ function newListView () { } let workspacelist = JSON.parse(text) + thisObject.listItems = [] for (let i = 0; i < workspacelist.length; i++) { let workspace = workspacelist[i].replace('.json', '') let listItem = newListItem() listItem.initialize(workspace, 'Workspace') listItem.container.connectToParent(thisObject.container, false, false) - listItem.container.frame.position.y = headerHeight + i * SIDE_PANEL_WIDTH * 0.75 + listItem.container.frame.position.y = headerHeight + i * SIDE_PANEL_WIDTH * 0.75 + itemSeparation * i + thisObject.listItems.push(listItem) } isInitialized = true @@ -115,14 +123,8 @@ function newListView () { delta = 1 } - if (event.y - thisObject.container.frame.position.y - CURRENT_TOP_MARGIN < headerHeight) { // Mouse wheel over the header, not a listItem - desiredVisibleListItems = desiredVisibleListItems + delta - if (desiredVisibleListItems < 0) { desiredVisibleListItems = 0 } - if (desiredVisibleListItems > thisObject.listItems.length) { desiredVisibleListItems = thisObject.listItems.length } - } else { - firstVisibleListItem = firstVisibleListItem + delta - } - desiredObjectHeight = (listItemHeight + LAYER_SEPARATION) * desiredVisibleListItems + headerHeight + footerHeight + firstVisibleListItem = firstVisibleListItem + delta + calculateVisbleListItems() } @@ -139,7 +141,7 @@ function newListView () { let listItem = thisObject.listItems[i] listItem.container.frame.position.x = 0 - listItem.container.frame.position.y = (listItemHeight + LAYER_SEPARATION) * visibleListItems.length + headerHeight + listItem.container.frame.position.y = (listItemHeight + itemSeparation) * visibleListItems.length + headerHeight /* Add to Visible Product Array */ visibleListItems.push(listItem) @@ -212,8 +214,8 @@ function newListView () { if (isInitialized === false || thisObject.visible === false) { return } drawBackground() - drawScrollBar() drawChildren() + drawScrollBar() } function drawChildren () { @@ -225,7 +227,7 @@ function newListView () { function drawBackground () { let label = 'Your Workspaces' - let icon = canvas.designSpace.iconByUiObjectType.get('Workspace') + let backgroundColor = UI_COLOR.WHITE let params = { cornerRadius: 5, @@ -239,8 +241,7 @@ function newListView () { roundedCornersBackground(params) - drawLabel(label, 1 / 2, 0, 0, 20, 15, thisObject.container, UI_COLOR.BLACK) - // drawIcon(icon, 1 / 8, 0, 0, 20, 28, thisObject.container) + drawLabel(label, 1 / 2, 0, 0, 25, 15, thisObject.container, UI_COLOR.BLACK) } function drawScrollBar () { @@ -255,10 +256,10 @@ function newListView () { y: thisObject.container.frame.height - footerHeight } let ratio = posibleVisibleListItems / thisObject.listItems.length - let handleHeight = (posibleVisibleListItems * (listItemHeight + LAYER_SEPARATION)) * ratio + let handleHeight = (posibleVisibleListItems * (listItemHeight + itemSeparation)) * ratio let handleTopPoint = { x: thisObject.container.frame.width - xOffset, - y: headerHeight + (listItemHeight + LAYER_SEPARATION) * ratio * (firstVisibleListItem - 1) + y: headerHeight + (listItemHeight + itemSeparation) * ratio * (firstVisibleListItem - 1) } let handleBottomPoint = { x: thisObject.container.frame.width - xOffset, diff --git a/SideSpace/SidePanelTab.js b/SideSpace/SidePanelTab.js index ea9108b49..5923353e0 100644 --- a/SideSpace/SidePanelTab.js +++ b/SideSpace/SidePanelTab.js @@ -40,6 +40,7 @@ function newSidePanelTab () { function onMouseClick (event) { if (thisObject.pointerDirection === 'left') { animation = 'opening' + thisObject.container.eventHandler.raiseEvent('opening') } else { animation = 'closing' } diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 66366c11a..e17cb4460 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -6,7 +6,8 @@ function newSideSpace () { physics: physics, draw: draw, getContainer: getContainer, - initialize: initialize + initialize: initialize, + finalize: finalize } let isInitialized = false @@ -22,6 +23,9 @@ function newSideSpace () { let listView resize() + + let openingEventSubscriptionId + let browserResizedEventSubscriptionId return thisObject function initialize () { @@ -29,16 +33,22 @@ function newSideSpace () { thisObject.sidePanelTab.container.connectToParent(thisObject.container, false, false) thisObject.sidePanelTab.initialize() - canvas.eventHandler.listenToEvent('Browser Resized', resize) + browserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize) initializeListView() isInitialized = true } + function finalize () { + canvas.eventHandler.stopListening(browserResizedEventSubscriptionId) + thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId) + } + function initializeListView () { listView = newListView() listView.initialize() listView.container.connectToParent(thisObject.container, false, false) + openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', listView.reload) } function resize () { From b8eecf19fc27f251fcbe2157278b473e48759171 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 12:02:07 +0200 Subject: [PATCH 36/54] Mouse Wheel Working --- SideSpace/ListView.js | 61 ++++++++++++++------------------------- SideSpace/SidePanelTab.js | 4 ++- Spaces/SideSpace.js | 5 +++- 3 files changed, 29 insertions(+), 41 deletions(-) diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index 0b39a0581..9a514526a 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -10,7 +10,8 @@ function newListView () { listItems: [], payload: undefined, isVisible: false, - reload: reload, + turnOn: turnOn, + turnOff: turnOff, physics: physics, draw: draw, getContainer: getContainer, @@ -80,10 +81,10 @@ function newListView () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - reload() + turnOn() } - function reload () { + function turnOn () { callServer(undefined, 'ListWorkspaces', onResponse) function onResponse (err, text) { @@ -103,10 +104,16 @@ function newListView () { thisObject.listItems.push(listItem) } + calculateVisbleListItems() isInitialized = true + thisObject.isVisible = true } } + function turnOff () { + thisObject.isVisible = false + } + function onMouseOver (event) { isMouseOver = true } @@ -129,7 +136,7 @@ function newListView () { } function calculateVisbleListItems () { - let availableSlots = posibleVisibleListItems + let availableSlots = Math.trunc(posibleVisibleListItems) if (firstVisibleListItem < 1) { firstVisibleListItem = 1 } if (firstVisibleListItem > (thisObject.listItems.length - availableSlots + 1)) { firstVisibleListItem = thisObject.listItems.length - availableSlots + 1 } @@ -150,17 +157,9 @@ function newListView () { } function getContainer (point, purpose) { - if (isInitialized === false || thisObject.visible === false || thisObject.isHidden === true) { return } + if (isInitialized === false || thisObject.isVisible === false) { return } let container - if (isMouseOver === true && purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) { - container = thisObject.upDownButton.getContainer(point) - if (container !== undefined) { return container } - - container = thisObject.leftRightButton.getContainer(point) - if (container !== undefined) { return container } - } - /* First we check if thisObject point is inside thisObject space. */ if (thisObject.container.frame.isThisPointHere(point, true) === true) { /* Now we see which is the inner most container that has it */ @@ -168,32 +167,13 @@ function newListView () { container = visibleListItems[i].getContainer(point) if (container !== undefined) { - let checkPoint = { - x: point.x, - y: point.y - } - - checkPoint = thisObject.fitFunction(checkPoint) - - if (point.x === checkPoint.x && point.y === checkPoint.y) { - if (purpose !== GET_CONTAINER_PURPOSE.MOUSE_OVER) { - return container - } + if (container.isForThisPurpose(purpose) === true) { + return container } } } - /* The point does not belong to any inner container, so we return the current container. */ - let checkPoint = { - x: point.x, - y: point.y - } - - checkPoint = thisObject.fitFunction(checkPoint) - - if (point.x === checkPoint.x && point.y === checkPoint.y) { - return thisObject.container - } + return thisObject.container } } @@ -205,13 +185,14 @@ function newListView () { } function physics () { + if (isInitialized === false || thisObject.isVisible === false) { return } if (isInitialized === false) { return } if (thisObject.isVisible === false) { return } childrenPhysics() } function draw () { - if (isInitialized === false || thisObject.visible === false) { return } + if (isInitialized === false || thisObject.isVisible === false) { return } drawBackground() drawChildren() @@ -219,9 +200,11 @@ function newListView () { } function drawChildren () { - for (let i = 0; i < thisObject.listItems.length; i++) { - let listItem = thisObject.listItems[i] - listItem.draw() + for (let i = 0; i < visibleListItems.length; i++) { + let listItem = visibleListItems[i] + if (listItem !== undefined) { + listItem.draw() + } } } diff --git a/SideSpace/SidePanelTab.js b/SideSpace/SidePanelTab.js index 5923353e0..24f38185f 100644 --- a/SideSpace/SidePanelTab.js +++ b/SideSpace/SidePanelTab.js @@ -43,6 +43,7 @@ function newSidePanelTab () { thisObject.container.eventHandler.raiseEvent('opening') } else { animation = 'closing' + thisObject.container.eventHandler.raiseEvent('closing') } } @@ -78,6 +79,7 @@ function newSidePanelTab () { thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset thisObject.container.parentContainer.status = 'visible' thisObject.pointerDirection = 'right' + thisObject.container.eventHandler.raiseEvent('opened') } } @@ -90,6 +92,7 @@ function newSidePanelTab () { thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON thisObject.container.parentContainer.status = 'hidden' thisObject.pointerDirection = 'left' + thisObject.container.eventHandler.raiseEvent('closed') } } } @@ -219,4 +222,3 @@ function newSidePanelTab () { browserCanvasContext.stroke() } } - diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index e17cb4460..b9ea5a918 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -25,6 +25,7 @@ function newSideSpace () { resize() let openingEventSubscriptionId + let closedEventSubscriptionId let browserResizedEventSubscriptionId return thisObject @@ -42,13 +43,15 @@ function newSideSpace () { function finalize () { canvas.eventHandler.stopListening(browserResizedEventSubscriptionId) thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId) + thisObject.sidePanelTab.container.eventHandler.stopListening(closedEventSubscriptionId) } function initializeListView () { listView = newListView() listView.initialize() listView.container.connectToParent(thisObject.container, false, false) - openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', listView.reload) + openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', listView.turnOn) + closedEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('closed', listView.turnOff) } function resize () { From 995fc3b199b0e9a29486544267b6902a48b43457 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 13:21:37 +0200 Subject: [PATCH 37/54] Scroll bar working --- SideSpace/ListView.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index 9a514526a..2bcc92461 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -72,10 +72,15 @@ function newListView () { } thisObject.container.frame.position = position - thisObject.container.frame.height = browserCanvas.height - position.x + thisObject.container.frame.height = browserCanvas.height - position.y * 2 - posibleVisibleListItems = (thisObject.container.frame.height - headerHeight - footerHeight) / (listItemHeight) - itemSeparation = ((thisObject.container.frame.height - headerHeight - footerHeight) - listItemHeight * Math.trunc(posibleVisibleListItems)) / (Math.trunc(posibleVisibleListItems) - 1) + let spaceForListItems = (thisObject.container.frame.height - headerHeight - footerHeight) + posibleVisibleListItems = Math.trunc(spaceForListItems / (listItemHeight)) + if ((posibleVisibleListItems - 1) !== 0) { + itemSeparation = (spaceForListItems - listItemHeight * posibleVisibleListItems) / (posibleVisibleListItems - 1) + } else { + itemSeparation = 0 + } onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) @@ -100,7 +105,6 @@ function newListView () { let listItem = newListItem() listItem.initialize(workspace, 'Workspace') listItem.container.connectToParent(thisObject.container, false, false) - listItem.container.frame.position.y = headerHeight + i * SIDE_PANEL_WIDTH * 0.75 + itemSeparation * i thisObject.listItems.push(listItem) } @@ -238,11 +242,11 @@ function newListView () { x: thisObject.container.frame.width - xOffset, y: thisObject.container.frame.height - footerHeight } - let ratio = posibleVisibleListItems / thisObject.listItems.length - let handleHeight = (posibleVisibleListItems * (listItemHeight + itemSeparation)) * ratio + let ratio = (posibleVisibleListItems * listItemHeight + (posibleVisibleListItems - 1) * itemSeparation) / (thisObject.listItems.length * listItemHeight + (thisObject.listItems.length - 1) * itemSeparation) + let handleHeight = posibleVisibleListItems * (listItemHeight * ratio) + (posibleVisibleListItems - 1) * itemSeparation * ratio let handleTopPoint = { x: thisObject.container.frame.width - xOffset, - y: headerHeight + (listItemHeight + itemSeparation) * ratio * (firstVisibleListItem - 1) + y: headerHeight + (listItemHeight * ratio * (firstVisibleListItem - 1) + itemSeparation * ratio * (firstVisibleListItem - 1)) } let handleBottomPoint = { x: thisObject.container.frame.width - xOffset, From 255c1dfc9ea3f9d62331cf959969fb141e63d863 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 15:38:17 +0200 Subject: [PATCH 38/54] Resize working --- SideSpace/ListView.js | 23 +++++++++++++++-------- SideSpace/SidePanelTab.js | 37 +++++++++++++++++++++++++------------ Spaces/SideSpace.js | 8 ++++++++ 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index 2bcc92461..aed070f7c 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -10,6 +10,7 @@ function newListView () { listItems: [], payload: undefined, isVisible: false, + resize: resize, turnOn: turnOn, turnOff: turnOff, physics: physics, @@ -29,7 +30,7 @@ function newListView () { let listItemsMap = new Map() let visibleListItems = [] - let firstVisibleListItem = 1 + let firstVisibleListItem let headerHeight = 40 let footerHeight = 30 @@ -72,7 +73,17 @@ function newListView () { } thisObject.container.frame.position = position - thisObject.container.frame.height = browserCanvas.height - position.y * 2 + + onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + + resize() + turnOn() + } + + function resize () { + thisObject.container.frame.height = browserCanvas.height - thisObject.container.frame.position.y * 2 let spaceForListItems = (thisObject.container.frame.height - headerHeight - footerHeight) posibleVisibleListItems = Math.trunc(spaceForListItems / (listItemHeight)) @@ -81,15 +92,11 @@ function newListView () { } else { itemSeparation = 0 } - - onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) - - turnOn() } function turnOn () { + firstVisibleListItem = 1 + callServer(undefined, 'ListWorkspaces', onResponse) function onResponse (err, text) { diff --git a/SideSpace/SidePanelTab.js b/SideSpace/SidePanelTab.js index 24f38185f..1934b2337 100644 --- a/SideSpace/SidePanelTab.js +++ b/SideSpace/SidePanelTab.js @@ -3,6 +3,7 @@ function newSidePanelTab () { let thisObject = { pointerDirection: 'left', container: undefined, + resize: resize, physics: physics, draw: draw, getContainer: getContainer, @@ -28,15 +29,20 @@ function newSidePanelTab () { function initialize () { thisObject.container.frame.width = TAB_WIDTH thisObject.container.frame.height = TAB_HEIGHT - thisObject.container.frame.position.x = 0 + thisObject.container.parentContainer.frame.width - thisObject.container.frame.position.y = 69 ORIGINAL_PARENT_POSITON = thisObject.container.parentContainer.frame.position.x thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) + resize() isInitialized = true } + function resize () { + thisObject.container.frame.position.x = 0 + thisObject.container.parentContainer.frame.width + thisObject.container.frame.position.y = 69 + setClosed() + } + function onMouseClick (event) { if (thisObject.pointerDirection === 'left') { animation = 'opening' @@ -74,11 +80,7 @@ function newSidePanelTab () { xOffset = xOffset + STEP thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset if (xOffset >= thisObject.container.parentContainer.frame.width) { - animation = 'none' - xOffset = thisObject.container.parentContainer.frame.width - thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset - thisObject.container.parentContainer.status = 'visible' - thisObject.pointerDirection = 'right' + setOpened() thisObject.container.eventHandler.raiseEvent('opened') } } @@ -87,16 +89,27 @@ function newSidePanelTab () { xOffset = xOffset - STEP thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset if (xOffset <= 0) { - animation = 'none' - xOffset = 0 - thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON - thisObject.container.parentContainer.status = 'hidden' - thisObject.pointerDirection = 'left' + setClosed() thisObject.container.eventHandler.raiseEvent('closed') } } } + function setOpened () { + animation = 'none' + xOffset = thisObject.container.parentContainer.frame.width + thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + xOffset + thisObject.container.parentContainer.status = 'visible' + thisObject.pointerDirection = 'right' + } + function setClosed () { + animation = 'none' + xOffset = 0 + thisObject.container.parentContainer.frame.position.x = ORIGINAL_PARENT_POSITON + thisObject.container.parentContainer.status = 'hidden' + thisObject.pointerDirection = 'left' + } + function arrow () { let point1 let point2 diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index b9ea5a918..99e80feca 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -59,6 +59,14 @@ function newSideSpace () { thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT thisObject.container.frame.position.x = -SIDE_PANEL_WIDTH thisObject.container.frame.position.y = 0 // TOP_SPACE_HEIGHT + + if (listView !== undefined) { + listView.resize() + } + + if (thisObject.sidePanelTab !== undefined) { + thisObject.sidePanelTab.resize() + } } function getContainer (point) { From 599e48062ff71549e92557c706848565836d1ada Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 15:56:30 +0200 Subject: [PATCH 39/54] Mouse over working --- Canvas.js | 2 +- SideSpace/ListItem.js | 29 +++++++++++++++++++++++++++-- SideSpace/ListView.js | 15 --------------- Spaces/SideSpace.js | 6 +++--- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/Canvas.js b/Canvas.js index 8a2cfaa4f..db6104f40 100644 --- a/Canvas.js +++ b/Canvas.js @@ -854,7 +854,7 @@ function newCanvas () { /* We check if the mouse is over an element of the Designe Space / */ if (thisObject.sideSpace !== undefined) { - container = thisObject.sideSpace.getContainer(point) + container = thisObject.sideSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_OVER) if (container !== undefined && container.detectMouseOver === true) { containerFound() diff --git a/SideSpace/ListItem.js b/SideSpace/ListItem.js index 98af0384e..d1aefc3dc 100644 --- a/SideSpace/ListItem.js +++ b/SideSpace/ListItem.js @@ -25,9 +25,16 @@ function newListItem () { let name let type + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId + + let isMouseOver = false return thisObject function finalize () { + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) + thisObject.container.finalize() thisObject.container = undefined thisObject.fitFunction = undefined @@ -36,6 +43,9 @@ function newListItem () { function initialize (pName, pType) { name = pName type = pType + + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) } function getContainer (point) { @@ -44,6 +54,14 @@ function newListItem () { } } + function onMouseOver (event) { + isMouseOver = true + } + + function onMouseNotOver () { + isMouseOver = false + } + function onMouseClick (event) { } @@ -55,6 +73,7 @@ function newListItem () { function draw () { let icon = canvas.designSpace.iconByUiObjectType.get(type) let backgroundColor = UI_COLOR.BLACK + let labelColor const RED_LINE_HIGHT = 4 const OPACITY = 1 @@ -69,10 +88,16 @@ function newListItem () { opacity: OPACITY } + if (isMouseOver === false) { + labelColor = UI_COLOR.WHITE + } else { + labelColor = UI_COLOR.TITANIUM_YELLOW + } + roundedCornersBackground(params) - drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container) - drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container) + drawLabel(name, 1 / 2, 3.0 / 10, -5, 0, 15, thisObject.container, labelColor) + drawLabel(type, 1 / 2, 7.2 / 10, -5, 0, 15, thisObject.container, labelColor) drawIcon(icon, 1 / 2, 1 / 2, 0, 0, 80, thisObject.container) } } diff --git a/SideSpace/ListView.js b/SideSpace/ListView.js index aed070f7c..e066f7b73 100644 --- a/SideSpace/ListView.js +++ b/SideSpace/ListView.js @@ -41,16 +41,11 @@ function newListView () { let itemSeparation let onMouseWheelEventSuscriptionId - let onMouseOverEventSubscriptionId - let onMouseNotOverEventSubscriptionId - let isMouseOver return thisObject function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSuscriptionId) - thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) - thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) listItemsMap = undefined visibleListItems = undefined @@ -75,8 +70,6 @@ function newListView () { thisObject.container.frame.position = position onMouseWheelEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) - onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) - onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) resize() turnOn() @@ -125,14 +118,6 @@ function newListView () { thisObject.isVisible = false } - function onMouseOver (event) { - isMouseOver = true - } - - function onMouseNotOver () { - isMouseOver = false - } - function onMouseWheel (event) { delta = event.wheelDelta if (delta > 0) { diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 99e80feca..a950c9b7c 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -69,13 +69,13 @@ function newSideSpace () { } } - function getContainer (point) { + function getContainer (point, purpose) { let container - container = thisObject.sidePanelTab.getContainer(point) + container = thisObject.sidePanelTab.getContainer(point, purpose) if (container !== undefined) { return container } - container = listView.getContainer(point) + container = listView.getContainer(point, purpose) if (container !== undefined) { return container } if (thisObject.container.frame.isThisPointHere(point, true) === true) { From 6fbb82272ebe42757bb18cc2a7c1e8a8945faee6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 14 May 2020 16:34:08 +0200 Subject: [PATCH 40/54] Loading Workspace Working --- Canvas.js | 2 +- DesignSpace/Workspace/Workspace.js | 34 ++++++++++++++++++++++++++---- SideSpace/ListItem.js | 6 +++++- 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Canvas.js b/Canvas.js index db6104f40..af920101a 100644 --- a/Canvas.js +++ b/Canvas.js @@ -711,7 +711,7 @@ function newCanvas () { let container /* We check if the mouse is over an element of the Side Space / */ - container = thisObject.sideSpace.getContainer(point) + container = thisObject.sideSpace.getContainer(point, GET_CONTAINER_PURPOSE.MOUSE_CLICK) if (container !== undefined && container.isClickeable === true) { container.eventHandler.raiseEvent('onMouseClick', point) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 710f90310..6c7274bf0 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -11,6 +11,7 @@ function newWorkspace () { enabled: false, nodeChildren: undefined, eventsServerClients: new Map(), + replaceWorkspaceByLoadingOne: replaceWorkspaceByLoadingOne, save: saveWorkspace, getHierarchyHeads: getHierarchyHeads, getNodeThatIsOnFocus: getNodeThatIsOnFocus, @@ -68,7 +69,7 @@ function newWorkspace () { let workingAtTask = 0 let circularProgressBar = newBusyProgressBar() circularProgressBar.fitFunction = canvas.floatingSpace.fitIntoVisibleArea - let droppedNode + let loadedWorkspaceNode let sessionTimestamp = (new Date()).valueOf() window.localStorage.setItem('Session Timestamp', sessionTimestamp) @@ -238,8 +239,8 @@ function newWorkspace () { workingAtTask++ break case 3: - thisObject.workspaceNode = droppedNode - droppedNode = undefined + thisObject.workspaceNode = loadedWorkspaceNode + loadedWorkspaceNode = undefined workingAtTask++ break case 4: @@ -339,6 +340,30 @@ function newWorkspace () { return nodes } + function replaceWorkspaceByLoadingOne (name) { + let blobService = newFileStorage() + blobService.getFileFromHost('LoadWorkspace' + '/' + name, onFileReceived, true) + function onFileReceived (err, text, response) { + if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { + canvas.cockpitSpace.setStatus('Could not load the Workspace called "' + name + '". ', 500, canvas.cockpitSpace.statusTypes.WARNING) + return + } + + loadedWorkspaceNode = JSON.parse(text) + + canvas.cockpitSpace.toTop() + + let position = { + x: browserCanvas.width / 2, + y: browserCanvas.height / 2 + } + + circularProgressBar.initialize(position) + circularProgressBar.visible = true + workingAtTask = 1 + } + } + function spawn (nodeText, mousePointer) { try { let point = { @@ -349,9 +374,10 @@ function newWorkspace () { spawnPosition.x = point.x spawnPosition.y = point.y - droppedNode = JSON.parse(nodeText) + let droppedNode = JSON.parse(nodeText) if (droppedNode.type === 'Workspace') { + loadedWorkspaceNode = droppedNode circularProgressBar.initialize(mousePointer) circularProgressBar.visible = true workingAtTask = 1 diff --git a/SideSpace/ListItem.js b/SideSpace/ListItem.js index d1aefc3dc..59e982979 100644 --- a/SideSpace/ListItem.js +++ b/SideSpace/ListItem.js @@ -19,6 +19,7 @@ function newListItem () { thisObject.container.isDraggeable = false thisObject.container.isWheelable = false thisObject.container.detectMouseOver = true + thisObject.container.isClickeable = true thisObject.container.frame.width = SIDE_PANEL_WIDTH * 0.75 thisObject.container.frame.height = SIDE_PANEL_WIDTH * 0.75 @@ -27,6 +28,7 @@ function newListItem () { let onMouseOverEventSubscriptionId let onMouseNotOverEventSubscriptionId + let onMouseClickEventSubscriptionId let isMouseOver = false return thisObject @@ -34,6 +36,7 @@ function newListItem () { function finalize () { thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseClickEventSubscriptionId) thisObject.container.finalize() thisObject.container = undefined @@ -46,6 +49,7 @@ function newListItem () { onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + onMouseClickEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) } function getContainer (point) { @@ -63,7 +67,7 @@ function newListItem () { } function onMouseClick (event) { - + canvas.designSpace.workspace.replaceWorkspaceByLoadingOne(name) } function physics () { From ca1675e8f5a1bda2fcd890cb091770978ed215dc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 16 May 2020 08:05:42 +0200 Subject: [PATCH 41/54] Update Workspace.js --- DesignSpace/Workspace/Workspace.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 6c7274bf0..5bcd91742 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -350,7 +350,7 @@ function newWorkspace () { } loadedWorkspaceNode = JSON.parse(text) - + saveWorkspace() canvas.cockpitSpace.toTop() let position = { From 3a7e60332ffa4d56048fcb61a57e02c92dca08af Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 18 May 2020 17:01:54 +0200 Subject: [PATCH 42/54] Update PlotterPanel.js --- Panels/PlotterPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index d180560fe..e50ebebde 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -154,7 +154,7 @@ function newPlotterPanel () { if (panelData.code.valueDecimals !== undefined) { if (value !== undefined) { if (isNaN(value) === false) { - value = value.toFixed(panelData.code.valueDecimals) + value = dynamicDecimals(value, panelData.code.valueDecimals) } } } From 1f56b6b37c05be84a571eb4f3bff686b948852ab Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 18 May 2020 17:40:39 +0200 Subject: [PATCH 43/54] Bug fixed while reconnecting to backend --- .../FunctionLibraries/UiObjectsFromNodes.js | 15 +++------------ DesignSpace/Workspace/Workspace.js | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 4a56efdc2..b29c96755 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -1,5 +1,7 @@ function newUiObjectsFromNodes () { thisObject = { + runTasks: runTasks, + runSessions: runSessions, recreateWorkspace: recreateWorkspace, tryToConnectChildrenWithReferenceParents: tryToConnectChildrenWithReferenceParents, createUiObjectFromNode: createUiObjectFromNode, @@ -14,7 +16,7 @@ function newUiObjectsFromNodes () { return thisObject - function recreateWorkspace (node, replacingCurrentWorkspace, callBackFunction) { + function recreateWorkspace (node, callBackFunction) { mapOfNodes = new Map() tasksToRun = [] sessionsToRun = [] @@ -135,17 +137,6 @@ function newUiObjectsFromNodes () { tryToConnectChildrenWithReferenceParents() - if (replacingCurrentWorkspace === true) { - // We need to wait all tasks that were potentially running to stop - setTimeout(runTasks, 70000) - // We give a few seconds for the tasks to start - setTimeout(runSessions, 80000) - } else { - runTasks() - // We give a few seconds for the tasks to start - setTimeout(runSessions, 10000) - } - if (callBackFunction !== undefined) { callBackFunction() // The recreation of the workspace is complete } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 5bcd91742..2680c323c 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -107,11 +107,12 @@ function newWorkspace () { } function recreateWorkspace () { - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, false, finishInitialization) + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, finishInitialization) } function finishInitialization () { setupEventsServerClients() + runTasksAndSessions(false) thisObject.enabled = true canvas.cockpitSpace.initializePosition() canvas.splashScreen.initialize() @@ -122,6 +123,19 @@ function newWorkspace () { } } + function runTasksAndSessions (replacingCurrentWorkspace) { + if (replacingCurrentWorkspace === true) { + // We need to wait all tasks that were potentially running to stop + setTimeout(functionLibraryUiObjectsFromNodes.runTasks, 70000) + // We give a few seconds for the tasks to start + setTimeout(functionLibraryUiObjectsFromNodes.runSessions, 80000) + } else { + functionLibraryUiObjectsFromNodes.runTasks() + // We give a few seconds for the tasks to start + setTimeout(functionLibraryUiObjectsFromNodes.runSessions, 10000) + } + } + function setupEventsServerClients () { for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] @@ -244,8 +258,9 @@ function newWorkspace () { workingAtTask++ break case 4: - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, true) + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) setupEventsServerClients() + runTasksAndSessions(true) workingAtTask++ break case 5: From f979583175ba0a7438469556bc4186cc54551ae0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 18 May 2020 18:24:01 +0200 Subject: [PATCH 44/54] Update UiObject.js --- FloatingSpace/UiObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 2dd1f2db3..1739df110 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1351,7 +1351,7 @@ function newUiObject () { label = currentValue if (!isNaN(label)) { if (currentValue.toFixed !== undefined) { - label = currentValue.toFixed(2) + label = dynamicDecimals(currentValue, 2) } } From d21c05013743b6bf99688687108471baba978df6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 18 May 2020 18:33:36 +0200 Subject: [PATCH 45/54] Update Speedometer.js --- CockpitSpace/Speedometer.js | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/CockpitSpace/Speedometer.js b/CockpitSpace/Speedometer.js index 12f8cc14e..b2e26df1f 100644 --- a/CockpitSpace/Speedometer.js +++ b/CockpitSpace/Speedometer.js @@ -181,18 +181,6 @@ function newSpeedometer () { /* We put the thisObject.params.VALUE in the middle */ - fontSize = 22 - if (thisObject.params.VALUE > 999) { - fontSize = 18 - } - if (thisObject.params.VALUE > 9999) { - fontSize = 14 - } - if (thisObject.params.VALUE > 99999) { - fontSize = 10 - } - browserCanvasContext.font = 'bold ' + fontSize + 'px ' + UI_FONT.PRIMARY - label = thisObject.params.VALUE if (isNaN(label) === false) { @@ -202,6 +190,22 @@ function newSpeedometer () { if (label === 0) { label = label.toFixed(2) } } + fontSize = 22 + if (label.length > 8) { + fontSize = 18 + } + if (label.length > 10) { + fontSize = 14 + } + if (label.length > 12) { + fontSize = 10 + } + if (label.length > 14) { + fontSize = 8 + } + + browserCanvasContext.font = 'bold ' + fontSize + 'px ' + UI_FONT.PRIMARY + // label = label.substring(0, 6) xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO + 7 From 4a03b7e0c428f8706e60bf745e248debd7e3ba94 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 22 May 2020 14:08:37 +0200 Subject: [PATCH 46/54] Resume working --- .../Workspace/FunctionLibraries/SessionFunctions.js | 5 +++-- DesignSpace/Workspace/Workspace.js | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index e1f7883e2..e29fb8254 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -6,7 +6,7 @@ function newSessionFunctions () { return thisObject - function runSession (node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction) { + function runSession (node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, resume, callBackFunction) { if (validations(node) !== true) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return @@ -54,7 +54,8 @@ function newSessionFunctions () { let event = { session: JSON.stringify(session), tradingSystem: JSON.stringify(tradingSystem), - dependencyFilter: JSON.stringify(dependencyFilter) + dependencyFilter: JSON.stringify(dependencyFilter), + resume: resume } eventsServerClient.raiseEvent(key, 'Run Session', event) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 2680c323c..49b6f4edf 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -561,7 +561,12 @@ function newWorkspace () { break case 'Run Session': { - functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction) + functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, false, callBackFunction) + } + break + case 'Resume Session': + { + functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, true, callBackFunction) } break case 'Stop Session': From 2f1536b3a4ad7ae9fa3123a1315643da64eecd9b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 May 2020 10:45:03 +0200 Subject: [PATCH 47/54] Utilities Functions Reorganized --- Utilities.js | 242 ------------------ Utilities/CoordinateTransformations.js | 18 ++ Utilities/DateRateTransformations.js | 53 ++++ Utilities/Download.js | 58 +++++ ...undedCornersBackground.js => DrawPrint.js} | 69 +++++ Utilities/LoadSaveFrame.js | 24 ++ Utilities/NodeConfig.js | 18 ++ 7 files changed, 240 insertions(+), 242 deletions(-) create mode 100644 Utilities/CoordinateTransformations.js create mode 100644 Utilities/DateRateTransformations.js create mode 100644 Utilities/Download.js rename Utilities/{RoundedCornersBackground.js => DrawPrint.js} (77%) create mode 100644 Utilities/LoadSaveFrame.js create mode 100644 Utilities/NodeConfig.js diff --git a/Utilities.js b/Utilities.js index 2af862981..594a85199 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,26 +1,3 @@ -function drawContainerBackground (container, color, opacity, fitFunction) { - let fromPoint = { - x: 0, - y: 0 - } - - let toPoint = { - x: container.frame.width, - y: container.frame.height - } - - fromPoint = transformThisPoint(fromPoint, container) - toPoint = transformThisPoint(toPoint, container) - - fromPoint = fitFunction(fromPoint) - toPoint = fitFunction(toPoint) - - browserCanvasContext.beginPath() - browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y) - browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')' - browserCanvasContext.closePath() - browserCanvasContext.fill() -} function dynamicDecimals (value, minDecimals) { if (minDecimals === undefined) { @@ -38,50 +15,6 @@ function dynamicDecimals (value, minDecimals) { return returnValue } -function savePropertyAtNodeConfig (payload, propertyName, value) { - try { - let code = JSON.parse(payload.node.code) - code[propertyName] = value - payload.node.code = JSON.stringify(code, null, 4) - } catch (err) { - // we ignore errors here since most likely they will be parsing errors. - } -} - -function loadPropertyFromNodeConfig (payload, propertyName) { - try { - let code = JSON.parse(payload.node.code) - return code[propertyName] - } catch (err) { - // we ignore errors here since most likely they will be parsing errors. - } -} - -function saveFrame (payload, frame) { - payload.frame = { - position: { - x: frame.position.x, - y: frame.position.y - }, - width: frame.width, - height: frame.height, - radius: frame.radius - } -} - -function loadFrame (payload, frame) { - if (payload.node.savedPayload !== undefined) { - if (payload.node.savedPayload.frame !== undefined) { - frame.position.x = payload.node.savedPayload.frame.position.x - frame.position.y = payload.node.savedPayload.frame.position.y - frame.width = payload.node.savedPayload.frame.width - frame.height = payload.node.savedPayload.frame.height - frame.radius = payload.node.savedPayload.frame.radius - payload.node.savedPayload.frame = undefined - } - } -} - function convertTimeFrameToName (pTimeFrame) { for (let i = 0; i < dailyFilePeriods.length; i++) { let period = dailyFilePeriods[i] @@ -98,84 +31,6 @@ function convertTimeFrameToName (pTimeFrame) { } } -function downloadText (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 downloadCanvas (filename, canvasToUse) { - let data = canvasToUse.toDataURL('image/png', 1) - /* Change MIME type to trick the browser to downlaod the file instead of displaying it */ - data = data.replace(/^data:image\/[^;]*/, 'data:application/octet-stream') - - /* In addition to 's "download" attribute, you can define HTTP-style headers */ - data = data.replace(/^data:application\/octet-stream/, 'data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=' + filename + '.png') - - let element = document.createElement('a') - element.setAttribute('href', data) - element.setAttribute('download', filename + '.PNG') - element.style.display = 'none' - document.body.appendChild(element) - element.click() - document.body.removeChild(element) -}; - -function downloadPanorama (filename) { - let INITIAL_WIDTH = 800 - let FINAL_WIDTH = browserCanvas.width - INITIAL_WIDTH - - if (ARE_WE_RECORDING_A_MARKET_PANORAMA === false) { - /* We start recording the panorame. */ - ARE_WE_RECORDING_A_MARKET_PANORAMA = true - marketPanoramaCanvas = document.createElement('canvas') - marketPanoramaCanvas.width = INITIAL_WIDTH * 50 - marketPanoramaCanvas.height = browserCanvas.height - marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, 0, 0, INITIAL_WIDTH, browserCanvas.height, 0, 0, INITIAL_WIDTH, browserCanvas.height) - CURRENT_PANORAMA_POSITION = INITIAL_WIDTH - } else { - /* We stop recording and download the resulting image. */ - ARE_WE_RECORDING_A_MARKET_PANORAMA = false - marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, browserCanvas.width - FINAL_WIDTH, 0, FINAL_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, FINAL_WIDTH, browserCanvas.height) - let finalResultCanvas = document.createElement('canvas') - finalResultCanvas.width = CURRENT_PANORAMA_POSITION + FINAL_WIDTH - finalResultCanvas.height = browserCanvas.height - finalResultCanvas.getContext('2d').drawImage(marketPanoramaCanvas, 0, 0, finalResultCanvas.width, browserCanvas.height, 0, 0, finalResultCanvas.width, browserCanvas.height) - downloadCanvas(filename, finalResultCanvas) - marketPanoramaCanvas = undefined - } -} - -function addToMarketPanorama () { - let SECTION_WIDTH = 80 * 2 - let INITIAL_POSITION = 800 - SECTION_WIDTH - marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, INITIAL_POSITION, 0, SECTION_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, SECTION_WIDTH, browserCanvas.height) - CURRENT_PANORAMA_POSITION = CURRENT_PANORAMA_POSITION + SECTION_WIDTH -} - -function transformThisPoint (point, container) { - /* We make the point relative to the current frame */ - - point = container.frame.frameThisPoint(point) - - /* We pass this point through the canvas.chartingSpace.viewport lends, meaning we apply the canvas.chartingSpace.viewport zoom and displacement. */ - - point = canvas.chartingSpace.viewport.transformThisPoint(point) - - return point -} - -function unTransformThisPoint (point, container) { - point = canvas.chartingSpace.viewport.unTransformThisPoint(point) - point = container.frame.unframeThisPoint(point) - - return point -} - function nextPorwerOf10 (number) { for (let i = -10; i <= 10; i++) { if (number < Math.pow(10, i)) { @@ -189,59 +44,6 @@ function pad (str, max) { return str.length < max ? pad('0' + str, max) : str } -function getDateFromPointAtBrowserCanvas (point, container, coordinateSystem) { - point = unTransformThisPoint(point, container) - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - let date = new Date(point.x) - - return date -} - -function getDateFromPointAtChartsSpace (point, container, coordinateSystem) { - point = container.frame.unframeThisPoint(point) - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - let date = new Date(point.x) - - return date -} - -function getDateFromPointAtContainer (point, container, coordinateSystem) { - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - let date = new Date(point.x) - - return date -} - -function getRateFromPointAtBrowserCanvas (point, container, coordinateSystem) { - point = unTransformThisPoint(point, container) - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - return point.y -} - -function getRateFromPointAtChartingSpace (point, container, coordinateSystem) { - point = container.frame.unframeThisPoint(point) - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - return point.y -} - -function getRateFromPointAtContainer (point, container, coordinateSystem) { - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - return point.y -} - -function getMilisecondsFromPoint (point, container, coordinateSystem) { - point = unTransformThisPoint(point, container) - point = coordinateSystem.unInverseTransform(point, container.frame.height) - - return point.x -} - function moveToUserPosition (container, currentDate, currentRate, coordinateSystem, ignoreX, ignoreY, mousePosition, fitFunction) { let targetPoint = { x: currentDate.valueOf(), @@ -276,50 +78,6 @@ function removeTime (datetime) { return dateOnly } -function printLabel (labelToPrint, x, y, opacity, fontSize, color, center, container, fitFunction, noDecimals, fixedDecimals) { - if (labelToPrint === undefined) { return } - let labelPoint - if (color === undefined) { color = UI_COLOR.DARK } - if (fontSize === undefined) { fontSize = 10 }; - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - let label = labelToPrint - if (isNaN(label) === false && label !== '') { - if (fixedDecimals !== true) { - label = dynamicDecimals(labelToPrint) - } - label = label.toLocaleString() - if (noDecimals === true) { - label = Math.trunc(label) - } - } - - let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO - - if (center === true) { - labelPoint = { - x: x - xOffset, - y: y - } - } else { - labelPoint = { - x: x, - y: y - } - } - - if (container !== undefined) { - labelPoint = container.frame.frameThisPoint(labelPoint) - } - - if (fitFunction !== undefined) { - labelPoint = fitFunction(labelPoint) - } - - browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) -} - function newUniqueId () { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8) diff --git a/Utilities/CoordinateTransformations.js b/Utilities/CoordinateTransformations.js new file mode 100644 index 000000000..9f3f9444d --- /dev/null +++ b/Utilities/CoordinateTransformations.js @@ -0,0 +1,18 @@ +function transformThisPoint (point, container) { + /* We make the point relative to the current frame */ + + point = container.frame.frameThisPoint(point) + + /* We pass this point through the canvas.chartingSpace.viewport lends, meaning we apply the canvas.chartingSpace.viewport zoom and displacement. */ + + point = canvas.chartingSpace.viewport.transformThisPoint(point) + + return point +} + +function unTransformThisPoint (point, container) { + point = canvas.chartingSpace.viewport.unTransformThisPoint(point) + point = container.frame.unframeThisPoint(point) + + return point +} diff --git a/Utilities/DateRateTransformations.js b/Utilities/DateRateTransformations.js new file mode 100644 index 000000000..196c99ecc --- /dev/null +++ b/Utilities/DateRateTransformations.js @@ -0,0 +1,53 @@ +function getDateFromPointAtBrowserCanvas (point, container, coordinateSystem) { + point = unTransformThisPoint(point, container) + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + let date = new Date(point.x) + + return date +} + +function getDateFromPointAtChartsSpace (point, container, coordinateSystem) { + point = container.frame.unframeThisPoint(point) + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + let date = new Date(point.x) + + return date +} + +function getDateFromPointAtContainer (point, container, coordinateSystem) { + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + let date = new Date(point.x) + + return date +} + +function getRateFromPointAtBrowserCanvas (point, container, coordinateSystem) { + point = unTransformThisPoint(point, container) + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + return point.y +} + +function getRateFromPointAtChartingSpace (point, container, coordinateSystem) { + point = container.frame.unframeThisPoint(point) + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + return point.y +} + +function getRateFromPointAtContainer (point, container, coordinateSystem) { + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + return point.y +} + +function getMilisecondsFromPoint (point, container, coordinateSystem) { + point = unTransformThisPoint(point, container) + point = coordinateSystem.unInverseTransform(point, container.frame.height) + + return point.x +} + diff --git a/Utilities/Download.js b/Utilities/Download.js new file mode 100644 index 000000000..39e8e3884 --- /dev/null +++ b/Utilities/Download.js @@ -0,0 +1,58 @@ +function downloadText (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 downloadCanvas (filename, canvasToUse) { + let data = canvasToUse.toDataURL('image/png', 1) + /* Change MIME type to trick the browser to downlaod the file instead of displaying it */ + data = data.replace(/^data:image\/[^;]*/, 'data:application/octet-stream') + + /* In addition to 's "download" attribute, you can define HTTP-style headers */ + data = data.replace(/^data:application\/octet-stream/, 'data:application/octet-stream;headers=Content-Disposition%3A%20attachment%3B%20filename=' + filename + '.png') + + let element = document.createElement('a') + element.setAttribute('href', data) + element.setAttribute('download', filename + '.PNG') + element.style.display = 'none' + document.body.appendChild(element) + element.click() + document.body.removeChild(element) +}; + +function downloadPanorama (filename) { + let INITIAL_WIDTH = 800 + let FINAL_WIDTH = browserCanvas.width - INITIAL_WIDTH + + if (ARE_WE_RECORDING_A_MARKET_PANORAMA === false) { + /* We start recording the panorame. */ + ARE_WE_RECORDING_A_MARKET_PANORAMA = true + marketPanoramaCanvas = document.createElement('canvas') + marketPanoramaCanvas.width = INITIAL_WIDTH * 50 + marketPanoramaCanvas.height = browserCanvas.height + marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, 0, 0, INITIAL_WIDTH, browserCanvas.height, 0, 0, INITIAL_WIDTH, browserCanvas.height) + CURRENT_PANORAMA_POSITION = INITIAL_WIDTH + } else { + /* We stop recording and download the resulting image. */ + ARE_WE_RECORDING_A_MARKET_PANORAMA = false + marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, browserCanvas.width - FINAL_WIDTH, 0, FINAL_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, FINAL_WIDTH, browserCanvas.height) + let finalResultCanvas = document.createElement('canvas') + finalResultCanvas.width = CURRENT_PANORAMA_POSITION + FINAL_WIDTH + finalResultCanvas.height = browserCanvas.height + finalResultCanvas.getContext('2d').drawImage(marketPanoramaCanvas, 0, 0, finalResultCanvas.width, browserCanvas.height, 0, 0, finalResultCanvas.width, browserCanvas.height) + downloadCanvas(filename, finalResultCanvas) + marketPanoramaCanvas = undefined + } +} + +function addToMarketPanorama () { + let SECTION_WIDTH = 80 * 2 + let INITIAL_POSITION = 800 - SECTION_WIDTH + marketPanoramaCanvas.getContext('2d').drawImage(browserCanvas, INITIAL_POSITION, 0, SECTION_WIDTH, browserCanvas.height, CURRENT_PANORAMA_POSITION, 0, SECTION_WIDTH, browserCanvas.height) + CURRENT_PANORAMA_POSITION = CURRENT_PANORAMA_POSITION + SECTION_WIDTH +} diff --git a/Utilities/RoundedCornersBackground.js b/Utilities/DrawPrint.js similarity index 77% rename from Utilities/RoundedCornersBackground.js rename to Utilities/DrawPrint.js index 825400009..4e38f2a0c 100644 --- a/Utilities/RoundedCornersBackground.js +++ b/Utilities/DrawPrint.js @@ -150,3 +150,72 @@ function drawIcon (icon, xFactor, yFactor, xOffset, yOffset, imageSize, containe } } } + +function drawContainerBackground (container, color, opacity, fitFunction) { + let fromPoint = { + x: 0, + y: 0 + } + + let toPoint = { + x: container.frame.width, + y: container.frame.height + } + + fromPoint = transformThisPoint(fromPoint, container) + toPoint = transformThisPoint(toPoint, container) + + fromPoint = fitFunction(fromPoint) + toPoint = fitFunction(toPoint) + + browserCanvasContext.beginPath() + browserCanvasContext.rect(fromPoint.x, fromPoint.y, toPoint.x - fromPoint.x, toPoint.y - fromPoint.y) + browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')' + browserCanvasContext.closePath() + browserCanvasContext.fill() +} + +function printLabel (labelToPrint, x, y, opacity, fontSize, color, center, container, fitFunction, noDecimals, fixedDecimals) { + if (labelToPrint === undefined) { return } + let labelPoint + if (color === undefined) { color = UI_COLOR.DARK } + if (fontSize === undefined) { fontSize = 10 }; + + browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY + let label = labelToPrint + if (isNaN(label) === false && label !== '') { + if (fixedDecimals !== true) { + label = dynamicDecimals(labelToPrint) + } + label = label.toLocaleString() + if (noDecimals === true) { + label = Math.trunc(label) + } + } + + let xOffset = label.length / 2 * fontSize * FONT_ASPECT_RATIO + + if (center === true) { + labelPoint = { + x: x - xOffset, + y: y + } + } else { + labelPoint = { + x: x, + y: y + } + } + + if (container !== undefined) { + labelPoint = container.frame.frameThisPoint(labelPoint) + } + + if (fitFunction !== undefined) { + labelPoint = fitFunction(labelPoint) + } + + browserCanvasContext.fillStyle = 'rgba(' + color + ', ' + opacity + ')' + browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) +} + diff --git a/Utilities/LoadSaveFrame.js b/Utilities/LoadSaveFrame.js new file mode 100644 index 000000000..5bda8c98b --- /dev/null +++ b/Utilities/LoadSaveFrame.js @@ -0,0 +1,24 @@ +function saveFrame (payload, frame) { + payload.frame = { + position: { + x: frame.position.x, + y: frame.position.y + }, + width: frame.width, + height: frame.height, + radius: frame.radius + } +} + +function loadFrame (payload, frame) { + if (payload.node.savedPayload !== undefined) { + if (payload.node.savedPayload.frame !== undefined) { + frame.position.x = payload.node.savedPayload.frame.position.x + frame.position.y = payload.node.savedPayload.frame.position.y + frame.width = payload.node.savedPayload.frame.width + frame.height = payload.node.savedPayload.frame.height + frame.radius = payload.node.savedPayload.frame.radius + payload.node.savedPayload.frame = undefined + } + } +} diff --git a/Utilities/NodeConfig.js b/Utilities/NodeConfig.js new file mode 100644 index 000000000..50473c906 --- /dev/null +++ b/Utilities/NodeConfig.js @@ -0,0 +1,18 @@ +function savePropertyAtNodeConfig (payload, propertyName, value) { + try { + let code = JSON.parse(payload.node.code) + code[propertyName] = value + payload.node.code = JSON.stringify(code, null, 4) + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } +} + +function loadPropertyFromNodeConfig (payload, propertyName) { + try { + let code = JSON.parse(payload.node.code) + return code[propertyName] + } catch (err) { + // we ignore errors here since most likely they will be parsing errors. + } +} From ffea28131382e19cfaf6d885bb589712b17c4162 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 May 2020 11:11:37 +0200 Subject: [PATCH 48/54] node nameSpaces implemented --- .../FunctionLibraries/ChainAttachDetach.js | 8 ++++---- .../FunctionLibraries/DependenciesFilter.js | 2 +- .../FunctionLibraries/NodeChildren.js | 4 ++-- .../FunctionLibraries/NodeCloning.js | 4 ++-- .../FunctionLibraries/NodeDeleter.js | 4 ++-- .../Workspace/FunctionLibraries/OnFocus.js | 2 +- .../FunctionLibraries/ProtocolNode.js | 2 +- .../FunctionLibraries/ShortcutKeys.js | 2 +- .../FunctionLibraries/SuperScripts.js | 2 +- .../FunctionLibraries/UiObjectsFromNodes.js | 10 +++++----- DesignSpace/Workspace/Workspace.js | 4 ++-- FloatingSpace/UiObject.js | 20 +++++++++---------- FloatingSpace/UiObjectConstructor.js | 6 +++--- FloatingSpace/UiObjectTitle.js | 8 ++++---- Panels/Layer.js | 2 +- PostLoader.js | 8 +++++++- Utilities.js | 9 +++++++++ 17 files changed, 56 insertions(+), 41 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index 44dd1e1db..5a75546ab 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -31,11 +31,11 @@ function newChainAttachDetach () { return } default: { - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { /* Detach from parent */ if (node.payload.parentNode !== undefined) { - let parentNodeDefinition = APP_SCHEMA_MAP.get(node.payload.parentNode.type) + let parentNodeDefinition = getNodeDefinition (node.payload.parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let i = 0; i < parentNodeDefinition.properties.length; i++) { @@ -166,13 +166,13 @@ function newChainAttachDetach () { } break default: { - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) 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) + let parentNodeDefinition = getNodeDefinition (node.payload.parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let i = 0; i < parentNodeDefinition.properties.length; i++) { diff --git a/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js b/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js index 2f88bf30d..1e4fb26ac 100644 --- a/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js +++ b/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js @@ -14,7 +14,7 @@ function newDependenciesFilter () { function recursiveFilter (node) { filter(node.code) - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { if (nodeDefinition.properties !== undefined) { let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. diff --git a/DesignSpace/Workspace/FunctionLibraries/NodeChildren.js b/DesignSpace/Workspace/FunctionLibraries/NodeChildren.js index 894dd0623..0165b1ecd 100644 --- a/DesignSpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/DesignSpace/Workspace/FunctionLibraries/NodeChildren.js @@ -14,7 +14,7 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } - let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + let parentNodeDefinition = getNodeDefinition (parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children. @@ -34,7 +34,7 @@ function newNodeChildren () { } break case 'array': { - let nodeDefinition = APP_SCHEMA_MAP.get(childNode.type) + let nodeDefinition = getNodeDefinition (childNode) if (nodeDefinition !== undefined) { let nodePropertyArray = parentNode[property.name] for (let j = 0; j < nodePropertyArray.length; j++) { diff --git a/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js index fce49b44f..6b7d1559f 100644 --- a/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -19,7 +19,7 @@ function newNodeCloning () { function cloneNode (node) { if (node === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { let object = { type: node.type, @@ -71,7 +71,7 @@ function newNodeCloning () { function redirectReferenceParents (node) { if (node === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { let object = { type: node.type, diff --git a/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js index c880ade46..7b17905dc 100644 --- a/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -29,7 +29,7 @@ function newNodeDeleter () { node.payload.referenceParent.payload.uiObject.isShowing = false } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { /* Remove all of its own children nodes. */ if (nodeDefinition.properties !== undefined) { @@ -63,7 +63,7 @@ function newNodeDeleter () { /* Remove node from parent */ if (node.payload !== undefined) { if (node.payload.parentNode !== undefined) { - let parentNodeDefinition = APP_SCHEMA_MAP.get(node.payload.parentNode.type) + let parentNodeDefinition = getNodeDefinition (node.payload.parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let i = 0; i < parentNodeDefinition.properties.length; i++) { diff --git a/DesignSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignSpace/Workspace/FunctionLibraries/OnFocus.js index a45c9f76c..21596fb7c 100644 --- a/DesignSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignSpace/Workspace/FunctionLibraries/OnFocus.js @@ -7,7 +7,7 @@ function newOnFocus () { function getNodeThatIsOnFocus (node) { if (node === undefined) { return } if (node.payload === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { /* First we ask the question to ourself */ if (node.payload.uiObject.isOnFocus === true) { diff --git a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js index 73d626530..c351819bf 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -13,7 +13,7 @@ function newProtocolNode () { if (node === undefined) { return } if (node.payload === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return } let object = { diff --git a/DesignSpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignSpace/Workspace/FunctionLibraries/ShortcutKeys.js index 28e6afc2a..2cd449769 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -6,7 +6,7 @@ function newShortcutKeys () { function getNodeByShortcutKey (node, searchingKey) { if (node === undefined) { return } - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { /* Check Self first */ if (node.payload.uiObject.shortcutKey === searchingKey) { diff --git a/DesignSpace/Workspace/FunctionLibraries/SuperScripts.js b/DesignSpace/Workspace/FunctionLibraries/SuperScripts.js index 3965fe328..e8e6b8a90 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SuperScripts.js +++ b/DesignSpace/Workspace/FunctionLibraries/SuperScripts.js @@ -18,7 +18,7 @@ function newSuperScriptsFunctions () { if (exchange === undefined) { functionLibraryUiObjectsFromNodes.createUiObjectFromNode(templateClone, target, target) } else { - let definition = APP_SCHEMA_MAP.get(target.type) + let definition = getNodeDefinition (target) for (let i = 0; i < definition.properties.length; i++) { let property = definition.properties[i] if (property.childType === exchangeNodeType) { diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index b29c96755..db40e3f0f 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -181,7 +181,7 @@ function newUiObjectsFromNodes () { function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { /* Get node definition */ - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) if (nodeDefinition !== undefined) { /* Resolve Initial Values */ if (nodeDefinition.initialValues !== undefined) { @@ -195,7 +195,7 @@ function newUiObjectsFromNodes () { /* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */ if (nodeDefinition.chainedToSameType === true) { if (parentNode !== undefined) { - let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + let parentNodeDefinition = getNodeDefinition (parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let i = 0; i < parentNodeDefinition.properties.length; i++) { @@ -263,12 +263,12 @@ function newUiObjectsFromNodes () { type: type } - let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type) + let parentNodeDefinition = getNodeDefinition (parentNode) if (parentNodeDefinition === undefined) { console.log('Cannot addUIOBject from parent of ' + type + ' because that type it is not defined at the APP_SCHEMA.') } /* Resolve Initial Values */ - let nodeDefinition = APP_SCHEMA_MAP.get(object.type) + let nodeDefinition = getNodeDefinition (object) if (nodeDefinition === undefined) { console.log('Cannot addUIOBject of ' + type + ' because that type it is not defined at the APP_SCHEMA.') @@ -393,7 +393,7 @@ function newUiObjectsFromNodes () { } function addMissingChildren (node) { - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) /* Connect to Parent */ if (nodeDefinition.properties !== undefined) { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 49b6f4edf..c386ffea1 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -345,7 +345,7 @@ function newWorkspace () { let nodes = [] for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - let nodeDefinition = APP_SCHEMA_MAP.get(rootNode.type) + let nodeDefinition = getNodeDefinition (rootNode) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead === true) { nodes.push(rootNode) @@ -601,7 +601,7 @@ function newWorkspace () { break case 'Open Documentation': { - let definition = APP_SCHEMA_MAP.get(payload.node.type) + let definition = getNodeDefinition (payload.node) if (definition !== undefined) { if (definition.docURL !== undefined) { let newTab = window.open(definition.docURL, '_blank') diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 1739df110..976550a98 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -363,7 +363,7 @@ function newUiObject () { } function childrenRunningPhysics () { - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition.properties === undefined) { return } let monitorChildrenRunning = false for (let i = 0; i < nodeDefinition.properties.length; i++) { @@ -407,7 +407,7 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.chainAttachesTo !== undefined) { compatibleTypes = nodeDefinition.chainAttachesTo.compatibleTypes @@ -429,10 +429,10 @@ function newUiObject () { let nearbyNode = floatingObject.payload.node if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Discard App Schema defined objects with busy coonection ports */ - nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { let mustContinue = false - let parentNodeDefinition = APP_SCHEMA_MAP.get(nearbyNode.type) + let parentNodeDefinition = getNodeDefinition (nearbyNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let j = 0; j < parentNodeDefinition.properties.length; j++) { @@ -560,7 +560,7 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.referenceAttachesTo !== undefined) { compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes @@ -842,7 +842,7 @@ function newUiObject () { function iconPhysics () { icon = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.type) - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition.alternativeIcons !== undefined) { let nodeToUse = thisObject.payload.node if (nodeDefinition.alternativeIcons === 'Use Reference Parent') { @@ -859,7 +859,7 @@ function newUiObject () { } } } - nodeDefinition = APP_SCHEMA_MAP.get(nodeToUse.type) + nodeDefinition = getNodeDefinition (nodeToUse) let code = nodeToUse.code try { code = JSON.parse(code) @@ -1261,7 +1261,7 @@ function newUiObject () { if (canvas.floatingSpace.inMapMode === true) { labelPoint.y = labelPoint.y - 20 - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { return @@ -1578,7 +1578,7 @@ function newUiObject () { browserCanvasContext.fill() - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead === true) { VISIBLE_RADIUS = thisObject.payload.floatingObject.currentHierarchyRing * 2.8 @@ -1760,7 +1760,7 @@ function newUiObject () { let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize if (canvas.floatingSpace.inMapMode === true) { totalImageSize = canvas.floatingSpace.transformImagesizeToMap(totalImageSize) - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { totalImageSize = totalImageSize / 4 diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 0be9a5a24..b2445657a 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -74,7 +74,7 @@ function newUiObjectConstructor () { */ if (userAddingNew === true) { - let definition = APP_SCHEMA_MAP.get(payload.parentNode.type) + let definition = getNodeDefinition (payload.parentNode) if (definition.properties !== undefined) { for (let i = 0; i < definition.properties.length; i++) { let property = definition.properties[i] @@ -406,7 +406,7 @@ function newUiObjectConstructor () { function getMenuItemsInitialValues (uiObject, floatingObject, payload) { let menuItemsInitialValues = [] - let nodeDefinition = APP_SCHEMA_MAP.get(payload.node.type) + let nodeDefinition = getNodeDefinition (payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.editors !== undefined) { if (nodeDefinition.editors.config === true) { @@ -495,7 +495,7 @@ function newUiObjectConstructor () { } default: { - let nodeDefinition = APP_SCHEMA_MAP.get(payload.node.type) + let nodeDefinition = getNodeDefinition (payload.node) if (nodeDefinition !== undefined) { switch (nodeDefinition.level) { case 0: { diff --git a/FloatingSpace/UiObjectTitle.js b/FloatingSpace/UiObjectTitle.js index e96b23eac..89e39c5c0 100644 --- a/FloatingSpace/UiObjectTitle.js +++ b/FloatingSpace/UiObjectTitle.js @@ -51,7 +51,7 @@ function newUiObjectTitle () { thisObject.payload = payload thisObject.allwaysVisible = false // Default value - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isTitleAllwaysVisible === true) { thisObject.allwaysVisible = true @@ -100,7 +100,7 @@ function newUiObjectTitle () { if (thisObject.payload.title === undefined) { return } /* It is possible to override the default title by setting the APP SCHEMA property 'title' */ - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition.title !== undefined) { thisObject.payload.title = '' thisObject.payload.node.name = '' @@ -221,7 +221,7 @@ function newUiObjectTitle () { } function onMouseClick (event) { - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition.title !== undefined) { return } let checkPoint = { @@ -329,7 +329,7 @@ function newUiObjectTitle () { labelPoint.x = labelPoint.x - label.length / 2 * fontSize * FONT_ASPECT_RATIO labelPoint.y = labelPoint.y - 35 - let nodeDefinition = APP_SCHEMA_MAP.get(thisObject.payload.node.type) + let nodeDefinition = getNodeDefinition (thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { return diff --git a/Panels/Layer.js b/Panels/Layer.js index 1877a5ecc..cd2e8c063 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -240,7 +240,7 @@ function newLayer () { } function getIcon (node) { - let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + let nodeDefinition = getNodeDefinition (node) let iconName if (nodeDefinition.alternativeIcons !== undefined) { for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { diff --git a/PostLoader.js b/PostLoader.js index d47eb8add..efb258cd7 100644 --- a/PostLoader.js +++ b/PostLoader.js @@ -28,7 +28,13 @@ function newDashboard () { APP_SCHEMA_ARRAY = getAppSchema() for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { let nodeDefinition = APP_SCHEMA_ARRAY[i] - let key = nodeDefinition.type + + let key + if (nodeDefinition.nameSpace !== undefined) { + key = nodeDefinition.type + '@' + nodeDefinition.nameSpace + } else { + key = nodeDefinition.type + } APP_SCHEMA_MAP.set(key, nodeDefinition) } diff --git a/Utilities.js b/Utilities.js index 594a85199..183ef2af2 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,3 +1,12 @@ +function getNodeDefinition (node) { + let key + if (node.nameSpace !== undefined) { + key = node.type + '@' + node.nameSpace + } else { + key = node.type + } + return APP_SCHEMA_MAP.get(key) +} function dynamicDecimals (value, minDecimals) { if (minDecimals === undefined) { From 51606f11fc871af3efb8c54d8d0644ff56921af1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 May 2020 12:42:57 +0200 Subject: [PATCH 49/54] Splitting Code From Config --- ChartingSpace/PlottersManager.js | 20 +++--- ChartingSpace/Viewport.js | 22 +++---- .../FunctionLibraries/CCXTFunctions.js | 6 +- .../FunctionLibraries/NodeCloning.js | 10 +-- .../FunctionLibraries/ProtocolNode.js | 25 +++---- .../FunctionLibraries/UiObjectsFromNodes.js | 66 +++++++++++++------ DesignSpace/Workspace/Workspace.js | 10 +-- FloatingSpace/ConfigEditor.js | 8 +-- FloatingSpace/UiObject.js | 26 ++++---- Panels/Layer.js | 10 +-- Panels/PlotterPanel.js | 16 ++--- Plotter.js | 34 +++++----- ProductStorage.js | 4 +- Scales/RateScale.js | 38 +++++------ Scales/TimeFrameScale.js | 12 ++-- Scales/TimeScale.js | 32 ++++----- Spaces/PanelsSpace.js | 4 +- Utilities/NodeConfig.js | 10 +-- 18 files changed, 191 insertions(+), 162 deletions(-) diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index a0002b6fa..e660e48de 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -99,7 +99,7 @@ function newPlottersManager () { for (let i = 0; i < layer.definition.referenceParent.referenceParent.datasets.length; i++) { let dataset = layer.definition.referenceParent.referenceParent.datasets[i] - switch (dataset.code.type) { + switch (dataset.config.type) { case 'Market Files': { storage.onMarketFileLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('Market File Loaded', layer.onMarketFileLoaded) } @@ -125,8 +125,8 @@ function newPlottersManager () { } } - let baseAsset = layer.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.code.codeName - let quotedAsset = layer.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.code.codeName + let baseAsset = layer.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + let quotedAsset = layer.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let market = { baseAsset: baseAsset, quotedAsset: quotedAsset @@ -146,8 +146,8 @@ function newPlottersManager () { } } - let host = layer.networkNode.code.host - let webPort = layer.networkNode.code.webPort + let host = layer.networkNode.config.host + let webPort = layer.networkNode.config.webPort if (host === undefined) { host = 'localhost' } if (webPort === undefined) { webPort = window.location.port } @@ -174,10 +174,10 @@ function newPlottersManager () { /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ let plotter - if (plotterModule.code.isLegacy !== true) { + if (plotterModule.config.isLegacy !== true) { plotter = newPlotter() } else { - plotter = getNewPlotter(dataMine.code.codeName, plotterModule.parentNode.code.codeName, plotterModule.code.codeName) + plotter = getNewPlotter(dataMine.config.codeName, plotterModule.parentNode.config.codeName, plotterModule.config.codeName) } plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) @@ -203,9 +203,9 @@ function newPlottersManager () { let panel = plotterModule.panels[i] let parameters = { - dataMine: dataMine.code.codeName, - plotterCodeName: plotterModule.parentNode.code.codeName, - moduleCodeName: plotterModule.code.codeName, + dataMine: dataMine.config.codeName, + plotterCodeName: plotterModule.parentNode.config.codeName, + moduleCodeName: plotterModule.config.codeName, panelNode: panel } diff --git a/ChartingSpace/Viewport.js b/ChartingSpace/Viewport.js index 4f60172be..5bd837de8 100644 --- a/ChartingSpace/Viewport.js +++ b/ChartingSpace/Viewport.js @@ -369,10 +369,10 @@ function newViewport () { /* Save the zoom at the node config, so that the user can change it if he wishes to. */ try { - let code = JSON.parse(thisObject.payload.node.code) - code.zoom = (thisObject.zoomTargetLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 - code.zoom = code.zoom.toFixed(2) - thisObject.payload.node.code = JSON.stringify(code) + let config = JSON.parse(thisObject.payload.node.config) + config.zoom = (thisObject.zoomTargetLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 + config.zoom = config.zoom.toFixed(2) + thisObject.payload.node.config = JSON.stringify(config) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -383,18 +383,18 @@ function newViewport () { /* Read the zoom level from the node config */ try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) - if (isNaN(code.zoom) || code.zoom === null || code.zoom === undefined) { + if (isNaN(config.zoom) || config.zoom === null || config.zoom === undefined) { saveObjectState() return } - code.zoom = code.zoom / 100 * (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) + MIN_ZOOM_LEVEL - if (code.zoom < MIN_ZOOM_LEVEL) { code.zoom = MIN_ZOOM_LEVEL } - if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL } + config.zoom = config.zoom / 100 * (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) + MIN_ZOOM_LEVEL + if (config.zoom < MIN_ZOOM_LEVEL) { config.zoom = MIN_ZOOM_LEVEL } + if (config.zoom > MAX_ZOOM_LEVEL) { config.zoom = MAX_ZOOM_LEVEL } - if (code.zoom.toFixed(2) !== thisObject.zoomTargetLevel.toFixed(2)) { - newZoomLevel(code.zoom) + if (config.zoom.toFixed(2) !== thisObject.zoomTargetLevel.toFixed(2)) { + newZoomLevel(config.zoom) } else { saveObjectState() } diff --git a/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js b/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js index e89b15e3b..047c4dcf3 100644 --- a/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js @@ -44,7 +44,7 @@ function newCCXTFunctions () { if (existingExchange === undefined) { let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange') newExchange.name = exchange.name - newExchange.code = '{ \n\"codeName\": \"' + exchange.id + '\"\n}' + newExchange.config = '{ \n\"codeName\": \"' + exchange.id + '\"\n}' newExchange.payload.floatingObject.collapseToggle() newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 @@ -114,7 +114,7 @@ function newCCXTFunctions () { function addAsset (name) { let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset') newAsseet.name = name - newAsseet.code = '{ \n\"codeName\": \"' + name + '\"\n}' + newAsseet.config = '{ \n\"codeName\": \"' + name + '\"\n}' } } } @@ -182,7 +182,7 @@ function newCCXTFunctions () { function addMarket (name, baseAsset, quotedAsset) { let newMarket = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Market') newMarket.name = name - newMarket.code = '{ \n\"codeName\": \"' + name + '\"\n}' + newMarket.config = '{ \n\"codeName\": \"' + name + '\"\n}' newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE diff --git a/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js index 6b7d1559f..6de8afad8 100644 --- a/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -19,12 +19,13 @@ function newNodeCloning () { function cloneNode (node) { if (node === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { let object = { type: node.type, name: node.name, - code: node.code + code: node.code, + config: node.config } /* Children Nodes */ @@ -71,12 +72,13 @@ function newNodeCloning () { function redirectReferenceParents (node) { if (node === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { let object = { type: node.type, name: node.name, - code: node.code + code: node.code, + config: node.config } /* Children Nodes */ diff --git a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js index c351819bf..a6a533549 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -9,17 +9,18 @@ function newProtocolNode () { } return thisObject - function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) { + function getProtocolNode (node, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) { if (node === undefined) { return } if (node.payload === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return } let object = { type: node.type, name: node.name, - code: node.code + code: node.code, + config: node.config } /* Children Nodes */ @@ -31,11 +32,11 @@ function newProtocolNode () { case 'node': { if (node[property.name] !== undefined) { if (lightingPath === undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload) } else { let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType) if (newLightingPath !== undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } } @@ -47,7 +48,7 @@ function newProtocolNode () { let nodePropertyArray = node[property.name] object[property.name] = [] for (let m = 0; m < nodePropertyArray.length; m++) { - let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload) if (protocolNode !== undefined) { object[property.name].push(protocolNode) } @@ -58,7 +59,7 @@ function newProtocolNode () { let nodePropertyArray = node[property.name] object[property.name] = [] for (let m = 0; m < nodePropertyArray.length; m++) { - let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) if (protocolNode !== undefined) { object[property.name].push(protocolNode) } @@ -76,25 +77,25 @@ function newProtocolNode () { if (node.payload.parentNode !== undefined) { let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.parentNode.type) if (newLightingPath !== undefined) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } if (node.payload.referenceParent !== undefined) { let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.referenceParent.type) if (newLightingPath !== undefined) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } - if (parseCode && object.code !== undefined && nodeDefinition.editors !== undefined) { + if (parseConfig && object.config !== undefined && nodeDefinition.editors !== undefined) { if (nodeDefinition.editors.config === true) { try { - object.code = JSON.parse(node.code) + object.config = JSON.parse(node.config) } 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.config = ' + node.config) } if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) } } } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index db40e3f0f..81490f399 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -26,14 +26,14 @@ function newUiObjectsFromNodes () { function addIncludedNodes () { let blobService = newFileStorage() - // if (node.code === undefined) { - node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' + // if (node.config === undefined) { + node.config = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' // } - let code = JSON.parse(node.code) - let includeDataMines = code.includeDataMines - let includeTradingSystems = code.includeTradingSystems - let includeSuperScripts = code.includeSuperScripts + let config = JSON.parse(node.config) + let includeDataMines = config.includeDataMines + let includeTradingSystems = config.includeTradingSystems + let includeSuperScripts = config.includeSuperScripts let totalIncluded = 0 @@ -49,9 +49,9 @@ function newUiObjectsFromNodes () { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] if (rootNode.type === 'Data Mine') { - if (rootNode.code !== undefined) { - let code = JSON.parse(rootNode.code) - if (code.name === name) { + if (rootNode.config !== undefined) { + let config = JSON.parse(rootNode.config) + if (config.name === name) { rootNodes.splice(i, 1) } } @@ -78,9 +78,9 @@ function newUiObjectsFromNodes () { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] if (rootNode.type === 'Trading System') { - if (rootNode.code !== undefined) { - let code = JSON.parse(rootNode.code) - if (code.name === name) { + if (rootNode.config !== undefined) { + let config = JSON.parse(rootNode.config) + if (config.name === name) { rootNodes.splice(i, 1) } } @@ -107,9 +107,9 @@ function newUiObjectsFromNodes () { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] if (rootNode.type === 'Super Scripts') { - if (rootNode.code !== undefined) { - let code = JSON.parse(rootNode.code) - if (code.name === name) { + if (rootNode.config !== undefined) { + let config = JSON.parse(rootNode.config) + if (config.name === name) { rootNodes.splice(i, 1) } } @@ -179,10 +179,23 @@ function newUiObjectsFromNodes () { } } + function migrateCodeToConfig (node, nodeDefinition) { + if (nodeDefinition.editors !== undefined) { + if (nodeDefinition.editors.config === true) { + if (node.code !== undefined) { + node.config = node.code + node.code = undefined + } + } + } + } + function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { /* Get node definition */ - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { + migrateCodeToConfig(node, nodeDefinition) + /* Resolve Initial Values */ if (nodeDefinition.initialValues !== undefined) { if (nodeDefinition.initialValues.code !== undefined) { @@ -190,12 +203,17 @@ function newUiObjectsFromNodes () { node.code = nodeDefinition.initialValues.code } } + if (nodeDefinition.initialValues.config !== undefined) { + if (node.config === undefined) { + node.config = nodeDefinition.initialValues.config + } + } } /* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */ if (nodeDefinition.chainedToSameType === true) { if (parentNode !== undefined) { - let parentNodeDefinition = getNodeDefinition (parentNode) + let parentNodeDefinition = getNodeDefinition(parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let i = 0; i < parentNodeDefinition.properties.length; i++) { @@ -263,12 +281,12 @@ function newUiObjectsFromNodes () { type: type } - let parentNodeDefinition = getNodeDefinition (parentNode) + let parentNodeDefinition = getNodeDefinition(parentNode) if (parentNodeDefinition === undefined) { console.log('Cannot addUIOBject from parent of ' + type + ' because that type it is not defined at the APP_SCHEMA.') } /* Resolve Initial Values */ - let nodeDefinition = getNodeDefinition (object) + let nodeDefinition = getNodeDefinition(object) if (nodeDefinition === undefined) { console.log('Cannot addUIOBject of ' + type + ' because that type it is not defined at the APP_SCHEMA.') @@ -279,6 +297,11 @@ function newUiObjectsFromNodes () { object.code = nodeDefinition.initialValues.code } } + if (nodeDefinition.initialValues !== undefined) { + if (nodeDefinition.initialValues.config !== undefined) { + object.config = nodeDefinition.initialValues.config + } + } if (nodeDefinition.isHierarchyHead === true) { parentNode.rootNodes.push(object) @@ -321,6 +344,9 @@ function newUiObjectsFromNodes () { if (nodeDefinition.initialValues.code !== undefined) { object.code = nodeDefinition.initialValues.code } + if (nodeDefinition.initialValues.config !== undefined) { + object.config = nodeDefinition.initialValues.config + } } } @@ -393,7 +419,7 @@ function newUiObjectsFromNodes () { } function addMissingChildren (node) { - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) /* Connect to Parent */ if (nodeDefinition.properties !== undefined) { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index c386ffea1..4882502b8 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -148,9 +148,9 @@ function newWorkspace () { let webSocketsPort /* At this point the node does not have the payload property yet, that is why we have to do this manually */ try { - let code = JSON.parse(networkNode.code) - host = code.host - webSocketsPort = code.webSocketsPort + let config = JSON.parse(networkNode.config) + host = config.host + webSocketsPort = config.webSocketsPort } catch (err) { console.log('[ERROR] networkNode ' + networkNode.name + ' has an invalid configuration. Cannot know the host name and webSocketsPort.') return @@ -345,7 +345,7 @@ function newWorkspace () { let nodes = [] for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - let nodeDefinition = getNodeDefinition (rootNode) + let nodeDefinition = getNodeDefinition(rootNode) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead === true) { nodes.push(rootNode) @@ -601,7 +601,7 @@ function newWorkspace () { break case 'Open Documentation': { - let definition = getNodeDefinition (payload.node) + let definition = getNodeDefinition(payload.node) if (definition !== undefined) { if (definition.docURL !== undefined) { let newTab = window.open(definition.docURL, '_blank') diff --git a/FloatingSpace/ConfigEditor.js b/FloatingSpace/ConfigEditor.js index b25331644..8cb2ffb83 100644 --- a/FloatingSpace/ConfigEditor.js +++ b/FloatingSpace/ConfigEditor.js @@ -52,10 +52,10 @@ function newConfigEditor () { thisObject.visible = false let textArea = document.getElementById('textArea') textArea.style.display = 'none' - thisObject.payload.node.code = textArea.value + thisObject.payload.node.config = textArea.value try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) } catch (err) { thisObject.payload.uiObject.setErrorMessage(err.message, 10) } @@ -72,7 +72,7 @@ function newConfigEditor () { thisObject.payload.uiObject.setErrorMessage('', 0) let textArea = document.getElementById('textArea') - textArea.value = payload.node.code + textArea.value = payload.node.config textArea.style = 'resize: none;' + ' border: none;' + ' outline: none;' + @@ -94,7 +94,7 @@ function newConfigEditor () { if (thisObject.visible === true) { if (point.x === VERY_LARGE_NUMBER) { /* The the mouse leaves the canvas, and event of mouse over with a ridiculous coordinate is triggered so that - anyone can react. In our case, the code editor has a text area that is not part of the canvas, so the event is + anyone can react. In our case, the config editor has a text area that is not part of the canvas, so the event is triggered. We compensate recognizing this coordinate and returning our container. */ return thisObject.container } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 976550a98..00740dcd9 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -363,7 +363,7 @@ function newUiObject () { } function childrenRunningPhysics () { - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition.properties === undefined) { return } let monitorChildrenRunning = false for (let i = 0; i < nodeDefinition.properties.length; i++) { @@ -407,7 +407,7 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.chainAttachesTo !== undefined) { compatibleTypes = nodeDefinition.chainAttachesTo.compatibleTypes @@ -429,10 +429,10 @@ function newUiObject () { let nearbyNode = floatingObject.payload.node if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Discard App Schema defined objects with busy coonection ports */ - nodeDefinition = getNodeDefinition (thisObject.payload.node) + nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { let mustContinue = false - let parentNodeDefinition = getNodeDefinition (nearbyNode) + let parentNodeDefinition = getNodeDefinition(nearbyNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let j = 0; j < parentNodeDefinition.properties.length; j++) { @@ -560,7 +560,7 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.referenceAttachesTo !== undefined) { compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes @@ -842,7 +842,7 @@ function newUiObject () { function iconPhysics () { icon = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.type) - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition.alternativeIcons !== undefined) { let nodeToUse = thisObject.payload.node if (nodeDefinition.alternativeIcons === 'Use Reference Parent') { @@ -859,15 +859,15 @@ function newUiObject () { } } } - nodeDefinition = getNodeDefinition (nodeToUse) - let code = nodeToUse.code + nodeDefinition = getNodeDefinition(nodeToUse) + let config = nodeToUse.config try { - code = JSON.parse(code) + config = JSON.parse(config) let alternativeIcon let iconName for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { alternativeIcon = nodeDefinition.alternativeIcons[i] - if (alternativeIcon.codeName === code.codeName) { + if (alternativeIcon.codeName === config.codeName) { iconName = alternativeIcon.iconName } } @@ -1261,7 +1261,7 @@ function newUiObject () { if (canvas.floatingSpace.inMapMode === true) { labelPoint.y = labelPoint.y - 20 - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { return @@ -1578,7 +1578,7 @@ function newUiObject () { browserCanvasContext.fill() - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead === true) { VISIBLE_RADIUS = thisObject.payload.floatingObject.currentHierarchyRing * 2.8 @@ -1760,7 +1760,7 @@ function newUiObject () { let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize if (canvas.floatingSpace.inMapMode === true) { totalImageSize = canvas.floatingSpace.transformImagesizeToMap(totalImageSize) - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { totalImageSize = totalImageSize / 4 diff --git a/Panels/Layer.js b/Panels/Layer.js index cd2e8c063..c1ac56823 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -200,7 +200,7 @@ function newLayer () { /* Get ready to draw this layer */ thisObject.baseAsset = thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent thisObject.quotedAsset = thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent - thisObject.market = thisObject.baseAsset.code.codeName + '/' + thisObject.quotedAsset.code.codeName + thisObject.market = thisObject.baseAsset.config.codeName + '/' + thisObject.quotedAsset.config.codeName thisObject.exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode /* Some basic validations. */ @@ -226,8 +226,8 @@ function newLayer () { thisObject.exchangeIcon = getIcon(thisObject.exchange) - if (thisObject.plotterModule.code.icon !== undefined) { - thisObject.plotterTypeIcon = canvas.designSpace.iconCollection.get(thisObject.plotterModule.code.icon) + if (thisObject.plotterModule.config.icon !== undefined) { + thisObject.plotterTypeIcon = canvas.designSpace.iconCollection.get(thisObject.plotterModule.config.icon) } thisObject.baseAssetIcon = getIcon(thisObject.baseAsset) @@ -240,12 +240,12 @@ function newLayer () { } function getIcon (node) { - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) let iconName if (nodeDefinition.alternativeIcons !== undefined) { for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { alternativeIcon = nodeDefinition.alternativeIcons[i] - if (alternativeIcon.codeName === node.code.codeName) { + if (alternativeIcon.codeName === node.config.codeName) { iconName = alternativeIcon.iconName } } diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index e50ebebde..14f1fe5ba 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -151,24 +151,24 @@ function newPlotterPanel () { } } - if (panelData.code.valueDecimals !== undefined) { + if (panelData.config.valueDecimals !== undefined) { if (value !== undefined) { if (isNaN(value) === false) { - value = dynamicDecimals(value, panelData.code.valueDecimals) + value = dynamicDecimals(value, panelData.config.valueDecimals) } } } - if (panelData.code.labelText !== undefined) { - labelText = panelData.code.labelText + if (panelData.config.labelText !== undefined) { + labelText = panelData.config.labelText } - if (panelData.code.labelPosition !== undefined) { - labelPosition = panelData.code.labelPosition + if (panelData.config.labelPosition !== undefined) { + labelPosition = panelData.config.labelPosition } - if (panelData.code.valuePosition !== undefined) { - valuePosition = panelData.code.valuePosition + if (panelData.config.valuePosition !== undefined) { + valuePosition = panelData.config.valuePosition } printLabel(labelText, X_AXIS, UI_PANEL.HEIGHT.NORMAL * labelPosition / 100 / heightFactor, '0.60', undefined, undefined, true, thisObject.container, thisObject.fitFunction) diff --git a/Plotter.js b/Plotter.js index ff1bf1368..ca72ed893 100644 --- a/Plotter.js +++ b/Plotter.js @@ -277,8 +277,8 @@ function newPlotter () { let record = {} for (let j = 0; j < recordDefinition.properties.length; j++) { let property = recordDefinition.properties[j] - if (property.code.isCalculated !== true) { - record[property.code.codeName] = dataFile[i][j] + if (property.config.isCalculated !== true) { + record[property.config.codeName] = dataFile[i][j] } } @@ -310,7 +310,7 @@ function newPlotter () { timeFrame: timeFrame, ONE_DAY_IN_MILISECONDS: ONE_DAY_IN_MILISECONDS } - let variable = {} // This is the structure where the user will define its own variables that will be shared across different code blocks and formulas. + let variable = {} // This is the structure where the user will define its own variables that will be shared across different config blocks and formulas. let results = [] /* This is Initialization Code */ @@ -345,13 +345,13 @@ function newPlotter () { /* For each calculated property we apply its formula */ for (let j = 0; j < recordDefinition.properties.length; j++) { let property = recordDefinition.properties[j] - if (property.code.isCalculated === true) { + if (property.config.isCalculated === true) { if (property.formula !== undefined) { if (property.formula.code !== undefined) { try { let newValue = eval(property.formula.code) let currentRecord = product - currentRecord[property.code.codeName] = newValue + currentRecord[property.config.codeName] = newValue } catch (err) { 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)) @@ -622,9 +622,9 @@ function newPlotter () { } 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 (polygon.polygonBody.style.config !== undefined) { + if (polygon.polygonBody.style.config.default !== undefined) { + let bodyStyle = polygon.polygonBody.style.config.default if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity } if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) } } @@ -637,7 +637,7 @@ function newPlotter () { let value = eval(condition.code) if (value === true) { if (condition.style !== undefined) { - let bodyStyle = condition.style.code + let bodyStyle = condition.style.config if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity } if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) } } @@ -646,8 +646,8 @@ function newPlotter () { } /* 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 + if (polygon.polygonBody.style.config.atMousePosition !== undefined) { + let atMousePositionStyleDefinition = polygon.polygonBody.style.config.atMousePosition let atMousePositionStyle = {} if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity } if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) } @@ -677,9 +677,9 @@ function newPlotter () { } 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 (polygon.polygonBorder.style.config !== undefined) { + if (polygon.polygonBorder.style.config.default !== undefined) { + let borderStyle = polygon.polygonBorder.style.config.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 } @@ -694,7 +694,7 @@ function newPlotter () { let value = eval(condition.code) if (value === true) { if (condition.style !== undefined) { - let borderStyle = condition.style.code + let borderStyle = condition.style.config 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 } @@ -705,8 +705,8 @@ function newPlotter () { } /* 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 + if (polygon.polygonBorder.style.config.atMousePosition !== undefined) { + let atMousePositionStyleDefinition = polygon.polygonBorder.style.config.atMousePosition let atMousePositionStyle = {} if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity } if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) } diff --git a/ProductStorage.js b/ProductStorage.js index 68c76ef1b..57c8e6b8a 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -85,7 +85,7 @@ function newProductStorage (name) { for (let i = 0; i < product.datasets.length; i++) { let dataset = product.datasets[i] - switch (dataset.code.type) { + switch (dataset.config.type) { case 'Market Files': { dataSetsToLoad++ @@ -122,7 +122,7 @@ function newProductStorage (name) { } break default: - if (ERROR_LOG === true) { logger.write('[WARN] initialize -> dataset with no type defined or type not supported -> dataset.code.type = ' + dataset.code.type) } + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> dataset with no type defined or type not supported -> dataset.config.type = ' + dataset.config.type) } } function onMarketFileReady (err, pCaller) { diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 6964143fd..93ca0cf9d 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -255,12 +255,12 @@ function newRateScale () { function saveObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - code.minValue = coordinateSystem.min.y - code.maxValue = coordinateSystem.max.y - code.autoMinScale = coordinateSystem.autoMinYScale - code.autoMaxScale = coordinateSystem.autoMaxYScale - thisObject.payload.node.code = JSON.stringify(code, null, 4) + let config = JSON.parse(thisObject.payload.node.config) + config.minValue = coordinateSystem.min.y + config.maxValue = coordinateSystem.max.y + config.autoMinScale = coordinateSystem.autoMinYScale + config.autoMaxScale = coordinateSystem.autoMaxYScale + thisObject.payload.node.config = JSON.stringify(config, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -268,29 +268,29 @@ function newRateScale () { function readObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) if ( - (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) || - (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) + (isNaN(config.minValue) || config.minValue === null || config.minValue === undefined) || + (isNaN(config.maxValue) || config.maxValue === null || config.maxValue === undefined) ) { // not using this value } else { if ( - thisObject.minValue !== code.minValue || - thisObject.maxValue !== code.maxValue || - coordinateSystem.autoMinYScale !== code.autoMinScale || - coordinateSystem.autoMaxYScale !== code.autoMaxScale + thisObject.minValue !== config.minValue || + thisObject.maxValue !== config.maxValue || + coordinateSystem.autoMinYScale !== config.autoMinScale || + coordinateSystem.autoMaxYScale !== config.autoMaxScale ) { - thisObject.minValue = code.minValue - thisObject.maxValue = code.maxValue + thisObject.minValue = config.minValue + thisObject.maxValue = config.maxValue coordinateSystem.min.y = thisObject.minValue coordinateSystem.max.y = thisObject.maxValue - if (code.autoMinScale !== undefined && (code.autoMinScale === true || code.autoMinScale === false) && code.autoMaxScale !== undefined && (code.autoMaxScale === true || code.autoMaxScale === false)) { - coordinateSystem.autoMinYScale = code.autoMinScale - coordinateSystem.autoMaxYScale = code.autoMaxScale - autoScaleButton.setStatus(code.autoMinScale, code.autoMaxScale) + if (config.autoMinScale !== undefined && (config.autoMinScale === true || config.autoMinScale === false) && config.autoMaxScale !== undefined && (config.autoMaxScale === true || config.autoMaxScale === false)) { + coordinateSystem.autoMinYScale = config.autoMinScale + coordinateSystem.autoMaxYScale = config.autoMaxScale + autoScaleButton.setStatus(config.autoMinScale, config.autoMaxScale) } coordinateSystem.recalculateScale() diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 89fdebc8e..3d0d41cd0 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -313,9 +313,9 @@ function newTimeFrameScale () { function saveObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - code.value = timeFrameLabel - thisObject.payload.node.code = JSON.stringify(code) + let config = JSON.parse(thisObject.payload.node.config) + config.value = timeFrameLabel + thisObject.payload.node.config = JSON.stringify(config) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -323,14 +323,14 @@ function newTimeFrameScale () { function readObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - if (code.value !== timeFrameLabel) { + let config = JSON.parse(thisObject.payload.node.config) + if (config.value !== timeFrameLabel) { let found = false for (let i = 0; i < timeFramesMasterArray.length; i++) { let timeFrameArray = timeFramesMasterArray[i] for (let j = 0; j < timeFrameArray.length; j++) { let record = timeFrameArray[j] - if (code.value === record[1]) { + if (config.value === record[1]) { filePeriodIndex = i timeFrameIndex = j found = true diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 00d52c530..90ee96fb0 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -172,12 +172,12 @@ function newTimeScale () { function saveObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - code.fromDate = (new Date(coordinateSystem.min.x)).toISOString() - code.toDate = (new Date(coordinateSystem.max.x)).toISOString() - code.autoMinScale = coordinateSystem.autoMinXScale - code.autoMaxScale = coordinateSystem.autoMaxXScale - thisObject.payload.node.code = JSON.stringify(code, null, 4) + let config = JSON.parse(thisObject.payload.node.config) + config.fromDate = (new Date(coordinateSystem.min.x)).toISOString() + config.toDate = (new Date(coordinateSystem.max.x)).toISOString() + config.autoMinScale = coordinateSystem.autoMinXScale + config.autoMaxScale = coordinateSystem.autoMaxXScale + thisObject.payload.node.config = JSON.stringify(config, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -185,24 +185,24 @@ function newTimeScale () { function readObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) if ( - (isNaN(Date.parse(code.fromDate)) || code.fromDate === null || code.fromDate === undefined) || - (isNaN(Date.parse(code.toDate)) || code.toDate === null || code.toDate === undefined) + (isNaN(Date.parse(config.fromDate)) || config.fromDate === null || config.fromDate === undefined) || + (isNaN(Date.parse(config.toDate)) || config.toDate === null || config.toDate === undefined) ) { // not using this value } else { - if (thisObject.fromDate !== Date.parse(code.fromDate) || thisObject.toDate !== Date.parse(code.toDate)) { - thisObject.fromDate = Date.parse(code.fromDate) - thisObject.toDate = Date.parse(code.toDate) + if (thisObject.fromDate !== Date.parse(config.fromDate) || thisObject.toDate !== Date.parse(config.toDate)) { + thisObject.fromDate = Date.parse(config.fromDate) + thisObject.toDate = Date.parse(config.toDate) coordinateSystem.min.x = thisObject.fromDate coordinateSystem.max.x = thisObject.toDate - if (code.autoMinScale !== undefined && (code.autoMinScale === true || code.autoMinScale === false) && code.autoMaxScale !== undefined && (code.autoMaxScale === true || code.autoMaxScale === false)) { - coordinateSystem.autoMinXScale = code.autoMinScale - coordinateSystem.autoMaxXScale = code.autoMaxScale - autoScaleButton.setStatus(code.autoMinScale, code.autoMaxScale) + if (config.autoMinScale !== undefined && (config.autoMinScale === true || config.autoMinScale === false) && config.autoMaxScale !== undefined && (config.autoMaxScale === true || config.autoMaxScale === false)) { + coordinateSystem.autoMinXScale = config.autoMinScale + coordinateSystem.autoMaxXScale = config.autoMaxScale + autoScaleButton.setStatus(config.autoMinScale, config.autoMaxScale) } coordinateSystem.recalculateScale() } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index e752631d1..a634fa26e 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -50,14 +50,14 @@ function newPanelsSpace () { } case 'Plotter Panel': { - if (pParameters.panelNode.code.isLegacy !== true) { + if (pParameters.panelNode.config.isLegacy !== true) { panel = newPlotterPanel() panel.fitFunction = canvas.chartingSpace.fitFunction panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible panel.session = pSession panel.initialize(pParameters.panelNode) } else { - panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.code.codeName) + panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName) panel.fitFunction = canvas.chartingSpace.fitFunction panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible panel.session = pSession diff --git a/Utilities/NodeConfig.js b/Utilities/NodeConfig.js index 50473c906..482e1ae3e 100644 --- a/Utilities/NodeConfig.js +++ b/Utilities/NodeConfig.js @@ -1,8 +1,8 @@ function savePropertyAtNodeConfig (payload, propertyName, value) { try { - let code = JSON.parse(payload.node.code) - code[propertyName] = value - payload.node.code = JSON.stringify(code, null, 4) + let config = JSON.parse(payload.node.config) + config[propertyName] = value + payload.node.config = JSON.stringify(config, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -10,8 +10,8 @@ function savePropertyAtNodeConfig (payload, propertyName, value) { function loadPropertyFromNodeConfig (payload, propertyName) { try { - let code = JSON.parse(payload.node.code) - return code[propertyName] + let config = JSON.parse(payload.node.config) + return config[propertyName] } catch (err) { // we ignore errors here since most likely they will be parsing errors. } From db0c12d8cb4eaefcb350cd59a1bc1374ba66ab62 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 May 2020 16:38:27 +0200 Subject: [PATCH 50/54] desambiguation --- .../Workspace/FunctionLibraries/UiObjectsFromNodes.js | 10 ++++++++++ Utilities.js | 7 +------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 81490f399..53a01c7cf 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -180,6 +180,7 @@ function newUiObjectsFromNodes () { } function migrateCodeToConfig (node, nodeDefinition) { + /* Code needed to Migrante from Beta 5 to Beta a Workspace */ if (nodeDefinition.editors !== undefined) { if (nodeDefinition.editors.config === true) { if (node.code !== undefined) { @@ -191,6 +192,15 @@ function newUiObjectsFromNodes () { } function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { + /* Code needed to Migrante from Beta 5 to Beta 6 a Trading System + if (node.type === 'Take Profit') { + node.type = 'Managed Take Profit' + } + if (node.type === 'Stop') { + node.type = 'Managed Stop Loss' + } + */ + /* Get node definition */ let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { diff --git a/Utilities.js b/Utilities.js index 183ef2af2..4a434bba8 100644 --- a/Utilities.js +++ b/Utilities.js @@ -1,10 +1,5 @@ function getNodeDefinition (node) { - let key - if (node.nameSpace !== undefined) { - key = node.type + '@' + node.nameSpace - } else { - key = node.type - } + let key = node.type return APP_SCHEMA_MAP.get(key) } From ed11228c994fbc6127e5c1ec800446b927cb488d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 23 May 2020 16:48:44 +0200 Subject: [PATCH 51/54] Update DesignSpace.js --- Spaces/DesignSpace.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignSpace.js b/Spaces/DesignSpace.js index 305e1d532..4940727b6 100644 --- a/Spaces/DesignSpace.js +++ b/Spaces/DesignSpace.js @@ -285,7 +285,13 @@ function newDesignSpace () { 'arrangement-vertical-right', 'arrangement-vertical-left', 'arrangement-concave', - 'move-to-phase-event' + 'move-to-phase-event', + 'open-execution', + 'move-order', + 'market-order', + 'limit-order', + 'execution-algorithm', + 'cancel-order' ] for (let i = 0; i < iconsNames.length; i++) { From 591ebd376b3220455322b801d13ad0858c143419 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Jun 2020 09:50:24 +0200 Subject: [PATCH 52/54] Update UiObjectsFromNodes.js --- DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 53a01c7cf..c852cb93f 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -27,7 +27,7 @@ function newUiObjectsFromNodes () { let blobService = newFileStorage() // if (node.config === undefined) { - node.config = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' + node.config = '{ \n"includeDataMines": ["Masters", "Sparta", "Masters-Trading"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' // } let config = JSON.parse(node.config) From 7292f6ed2807d7bda26be74873e0549391e65f41 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Jun 2020 10:32:54 +0200 Subject: [PATCH 53/54] Update SessionFunctions.js --- .../FunctionLibraries/SessionFunctions.js | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index e29fb8254..31c87c63e 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -37,7 +37,28 @@ function newSessionFunctions () { 'Close Stage->Close Execution->' + 'Announcement->Formula->' - let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath) + let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath) + + lightingPath = '' + + 'Trading Engine->' + + 'Episode->Current->Last->Previous->' + + 'Episode Counters->Episode Statistics->' + + 'Periods->Positions->Hits->Fails->' + + 'Profit Loss->Hit Ratio->Days->ROI->Anualized Rate Of Return->User Defined Statistic->' + + 'Formula->' + + 'Balance->Base Asset->Quoted Asset->' + + 'Distance To Event->' + + 'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->' + + 'Strategy->' + + 'Begin->End->Strategy Name->Index->Stage Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Strategy Counters->Periods->' + + 'Position->' + + 'Begin->End->Rate->Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' + + 'Position Counters->Periods->' + + 'Position Statistics->Days->ROI->User Defined Statistic->' + + 'Formula' + + let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath) lightingPath = '' + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + @@ -48,12 +69,13 @@ function newSessionFunctions () { let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) - let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.payload.referenceParent) + let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.tradingSystemReference.payload.referenceParent) /* Raise event to run the session */ let event = { session: JSON.stringify(session), tradingSystem: JSON.stringify(tradingSystem), + tradingEngine: JSON.stringify(tradingEngine), dependencyFilter: JSON.stringify(dependencyFilter), resume: resume } @@ -122,8 +144,23 @@ function newSessionFunctions () { return } - if (node.payload.referenceParent === undefined) { - node.payload.uiObject.setErrorMessage('Session needs to reference a Trading System.') + if (node.tradingSystemReference === undefined) { + node.payload.uiObject.setErrorMessage('Session needs a child Trading System Reference.') + return + } + + if (node.tradingEngineReference === undefined) { + node.payload.uiObject.setErrorMessage('Session needs a child Trading Engine Reference.') + return + } + + if (node.tradingSystemReference.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Trading System Reference needs to reference a Trading System.') + return + } + + if (node.tradingEngineReference.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Trading Engine Reference needs to reference a Trading Engine.') return } return true From 04791fac8fc9269783d486152bcfce9733ea866a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 1 Jun 2020 12:09:36 +0200 Subject: [PATCH 54/54] Sending Schema on Session Run --- .../Workspace/FunctionLibraries/SessionFunctions.js | 1 + PostLoader.js | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 31c87c63e..41b4da779 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -73,6 +73,7 @@ function newSessionFunctions () { /* Raise event to run the session */ let event = { + appSchema: JSON.stringify(APP_SCHEMA_ARRAY), session: JSON.stringify(session), tradingSystem: JSON.stringify(tradingSystem), tradingEngine: JSON.stringify(tradingEngine), diff --git a/PostLoader.js b/PostLoader.js index efb258cd7..82c268bec 100644 --- a/PostLoader.js +++ b/PostLoader.js @@ -28,17 +28,9 @@ function newDashboard () { APP_SCHEMA_ARRAY = getAppSchema() for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { let nodeDefinition = APP_SCHEMA_ARRAY[i] - - let key - if (nodeDefinition.nameSpace !== undefined) { - key = nodeDefinition.type + '@' + nodeDefinition.nameSpace - } else { - key = nodeDefinition.type - } - + let key = nodeDefinition.type APP_SCHEMA_MAP.set(key, nodeDefinition) } - startCanvas() }