From ee0c6cbe6d3b6b94a87a25ca3a204d82c3d088db Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 9 Apr 2020 10:14:53 +0200 Subject: [PATCH 01/55] Update ReferenceAttachDetach.js --- .../Workspace/FunctionLibraries/ReferenceAttachDetach.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js index 643dd37ed..98dadd313 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js +++ b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js @@ -19,7 +19,7 @@ function newReferenceAttachDetach () { } function completeDetachment (node) { - if (node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) { + if (node.payload !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) { node.payload.referenceParent.payload.uiObject.isShowing = false } From 6e82e86fe51c0395fd3b942ec373f7391a3d667d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Apr 2020 10:20:52 +0200 Subject: [PATCH 02/55] Update PostLoader.js --- PostLoader.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PostLoader.js b/PostLoader.js index c0f41ee78..b4b6737a4 100644 --- a/PostLoader.js +++ b/PostLoader.js @@ -75,7 +75,7 @@ function newDashboard () { function setBrowserEvents () { window.onbeforeunload = onBrowserClosed function onBrowserClosed () { - // canvas.designSpace.workspace.stopAllRunningTasks() + canvas.designSpace.workspace.save() } } } From 7db8445d713b9fbc74320ec5f26857e54f958494 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Apr 2020 11:15:06 +0200 Subject: [PATCH 03/55] Update SessionFunctions.js --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index a35c3ec60..13e33b381 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -21,7 +21,7 @@ function newSessionFunctions () { } if (node.payload.referenceParent === undefined) { - node.payload.uiObject.setErrorMessage('Parent Process Instance need to reference a Process Definition.') + node.payload.uiObject.setErrorMessage('Session needs to reference a Trading System.') callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return } From 1a346c1560a1249db8d1e73c5fde8eb1f177ba07 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 10 Apr 2020 12:01:09 +0200 Subject: [PATCH 04/55] Update ReferenceAttachDetach.js --- .../Workspace/FunctionLibraries/ReferenceAttachDetach.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js index 98dadd313..576eb3214 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js +++ b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js @@ -19,8 +19,12 @@ function newReferenceAttachDetach () { } function completeDetachment (node) { - if (node.payload !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) { - node.payload.referenceParent.payload.uiObject.isShowing = false + if (node.payload !== undefined !== undefined) { + if (node.payload.referenceParent.payload !== undefined) { + if (node.payload.referenceParent.payload.uiObject !== undefined) { + node.payload.referenceParent.payload.uiObject.isShowing = false + } + } } node.payload.referenceParent = undefined From 1201e4876a4e865869713f2342e0c748096f7da3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Apr 2020 10:04:42 +0200 Subject: [PATCH 05/55] Update ReferenceAttachDetach.js --- .../Workspace/FunctionLibraries/ReferenceAttachDetach.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js index 576eb3214..f9b6b3cd5 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js +++ b/DesignSpace/Workspace/FunctionLibraries/ReferenceAttachDetach.js @@ -20,9 +20,11 @@ function newReferenceAttachDetach () { function completeDetachment (node) { if (node.payload !== undefined !== undefined) { - if (node.payload.referenceParent.payload !== undefined) { - if (node.payload.referenceParent.payload.uiObject !== undefined) { - node.payload.referenceParent.payload.uiObject.isShowing = false + if (node.payload.referenceParent !== undefined) { + if (node.payload.referenceParent.payload !== undefined) { + if (node.payload.referenceParent.payload.uiObject !== undefined) { + node.payload.referenceParent.payload.uiObject.isShowing = false + } } } } From d13c12674aa84d01c9e98b5bfecbc52eeeb9584b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Apr 2020 10:27:35 +0200 Subject: [PATCH 06/55] Update PostLoader.js --- PostLoader.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/PostLoader.js b/PostLoader.js index b4b6737a4..0af816538 100644 --- a/PostLoader.js +++ b/PostLoader.js @@ -73,8 +73,21 @@ function newDashboard () { } function setBrowserEvents () { - window.onbeforeunload = onBrowserClosed - function onBrowserClosed () { + window.onbeforeunload = saveWorkspace + + /* handles backspace and refresh(F5) from keyboard */ + window.manageBackRefresh = function (event) { + var tag = event.target.tagName.toLowerCase() + if (event.keyCode == 8 && tag != 'input' && tag != 'textarea') { // Backbutton pressed + saveWorkspace() + } else if (event.keyCode == 116) { // F5 pressed + saveWorkspace() + } + } + + window.addEventListener('keydown', window.manageBackRefresh) + + function saveWorkspace () { canvas.designSpace.workspace.save() } } From 0bad0775147ee31b9076cb2114943e9afa43caf5 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 11 Apr 2020 18:25:50 +0200 Subject: [PATCH 07/55] Update Plotter.js --- Plotter.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Plotter.js b/Plotter.js index fdd1cce45..dbe40a887 100644 --- a/Plotter.js +++ b/Plotter.js @@ -202,6 +202,8 @@ function newPlotter () { if (newMarketFile !== undefined) { marketFile = newMarketFile recalculate() + } else { + logger.write('[WARN] setTimeFrame -> Could not change to market file for timeFrame = ' + pTimeFrame } } else { let newFileCursor = dailyFiles.getFileCursor(pTimeFrame) @@ -209,6 +211,8 @@ function newPlotter () { if (newFileCursor !== undefined) { fileCursor = newFileCursor recalculate() + } else { + logger.write('[WARN] setTimeFrame -> Could not change to market file for timeFrame = ' + pTimeFrame } } } From ad347fc27f5923b3325d0fd79a33bf74b142762d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 12 Apr 2020 15:35:12 +0200 Subject: [PATCH 08/55] Update Plotter.js --- Plotter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plotter.js b/Plotter.js index dbe40a887..3034b81b9 100644 --- a/Plotter.js +++ b/Plotter.js @@ -203,7 +203,7 @@ function newPlotter () { marketFile = newMarketFile recalculate() } else { - logger.write('[WARN] setTimeFrame -> Could not change to market file for timeFrame = ' + pTimeFrame + logger.write('[WARN] setTimeFrame -> Could not change to market file for timeFrame = ' + pTimeFrame) } } else { let newFileCursor = dailyFiles.getFileCursor(pTimeFrame) @@ -212,7 +212,7 @@ function newPlotter () { fileCursor = newFileCursor recalculate() } else { - logger.write('[WARN] setTimeFrame -> Could not change to market file for timeFrame = ' + pTimeFrame + logger.write('[WARN] setTimeFrame -> Could not change to market file for timeFrame = ' + pTimeFrame) } } } From 885b8fc27a13027418e0e1254a56e0421a419e67 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 13 Apr 2020 17:44:07 +0200 Subject: [PATCH 09/55] Update UiObject.js --- FloatingSpace/UiObject.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 9958af61e..e29e2ecbf 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -876,7 +876,11 @@ function newUiObject () { thisObject.isOnFocus = true if (thisObject.payload !== undefined && thisObject.isOnFocus === true && thisObject.payload.referenceParent !== undefined) { - thisObject.payload.referenceParent.payload.uiObject.isShowing = true + if (thisObject.payload.referenceParent.payload !== undefined) { + if (thisObject.payload.referenceParent.payload.uiObject !== undefined) { + thisObject.payload.referenceParent.payload.uiObject.isShowing = true + } + } } } From 0ffcd537fa07d6c9c12cf6180cc95a4cac5fc893 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Apr 2020 14:49:54 +0200 Subject: [PATCH 10/55] Update Layer.js --- Panels/Layer.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index 5958076f0..989cb3a01 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -525,7 +525,7 @@ function newLayer () { let label3 = thisObject.status.toUpperCase() if (label1 !== undefined) { - label1 = label1.substring(0, 22) + label1 = label1.substring(0, 30) } let backgroundColor = UI_COLOR.BLACK @@ -545,7 +545,15 @@ function newLayer () { roundedCornersBackground(params) - drawLabel(label1, 1 / 2, 6 / 10, -5, 0, 17, thisObject.container) + let label1FontSize + + if (label1.length > 20) { + label1FontSize = 12 + } else { + label1FontSize = 15 + } + + drawLabel(label1, 1 / 2, 6 / 10, -5, 0, label1FontSize, thisObject.container) drawLabel(label2, 1 / 2, 8.2 / 10, -5, 0, 9, thisObject.container) drawLabel(label3, 1 / 2, 9.5 / 10, -5, 0, 9, thisObject.container) @@ -560,3 +568,4 @@ function newLayer () { drawIcon(thisObject.quotedAssetIcon, 4.6 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } + From 25c005d70e1d738e468e9673f3a997151c278e78 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 14 Apr 2020 18:38:28 +0200 Subject: [PATCH 11/55] Decimals --- Panels/PlotterPanel.js | 2 +- Plotter.js | 4 ++++ Utilities.js | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index 820f4702a..d180560fe 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -172,7 +172,7 @@ function newPlotterPanel () { } printLabel(labelText, X_AXIS, UI_PANEL.HEIGHT.NORMAL * labelPosition / 100 / heightFactor, '0.60', undefined, undefined, true, thisObject.container, thisObject.fitFunction) - printLabel(value, X_AXIS, UI_PANEL.HEIGHT.NORMAL * valuePosition / 100 / heightFactor, '1.00', 14, undefined, true, thisObject.container, thisObject.fitFunction) + printLabel(value, X_AXIS, UI_PANEL.HEIGHT.NORMAL * valuePosition / 100 / heightFactor, '1.00', 14, undefined, true, thisObject.container, thisObject.fitFunction, false, true) } } } diff --git a/Plotter.js b/Plotter.js index 3034b81b9..bba22925f 100644 --- a/Plotter.js +++ b/Plotter.js @@ -720,6 +720,10 @@ function newPlotter () { let polygonVertex = polygon.polygonVertexes[k] if (polygonVertex.referenceParent !== undefined) { let dataPointObject = dataPoints.get(polygonVertex.referenceParent.id) + if (dataPointObject === undefined) { + console.log('[WARN] You have a Polygon Vertex not referencing any Point.') + continue + } let dataPoint = { x: dataPointObject.x, y: dataPointObject.y diff --git a/Utilities.js b/Utilities.js index e9c85a67b..294c6ec07 100644 --- a/Utilities.js +++ b/Utilities.js @@ -244,7 +244,7 @@ function removeTime (datetime) { return dateOnly } -function printLabel (labelToPrint, x, y, opacity, fontSize, color, center, container, fitFunction, noDecimals) { +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 } @@ -253,7 +253,9 @@ function printLabel (labelToPrint, x, y, opacity, fontSize, color, center, conta browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY let label = labelToPrint if (isNaN(label) === false && label !== '') { - label = dynamicDecimals(labelToPrint) + if (fixedDecimals !== true) { + label = dynamicDecimals(labelToPrint) + } label = label.toLocaleString() if (noDecimals === true) { label = Math.trunc(label) From befa4aa868716f4e3d577b76bdbd01822e834f93 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Apr 2020 08:16:46 +0200 Subject: [PATCH 12/55] Update FloatingObject.js --- FloatingSpace/FloatingObject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FloatingSpace/FloatingObject.js b/FloatingSpace/FloatingObject.js index 88cb75b4d..12cb186f6 100644 --- a/FloatingSpace/FloatingObject.js +++ b/FloatingSpace/FloatingObject.js @@ -285,7 +285,7 @@ function newFloatingObject () { } function positionContraintsPhysics () { - const MAX_DISTANCE_TO_PARENT = 3000 + const MAX_DISTANCE_TO_PARENT = 5000 const MIN_DISTANCE_TO_PARENT = 100 if (thisObject.angleToParent !== ANGLE_TO_PARENT.NOT_FIXED && thisObject.isOnFocus !== true) { From 3328cb73ed7fff24e08b10b7edac0b06f1c41148 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Apr 2020 08:34:00 +0200 Subject: [PATCH 13/55] Update RateScale.js --- Scales/RateScale.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 129a34dd2..6964143fd 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -347,17 +347,14 @@ function newRateScale () { function onUpstreamScaleChanged (event) { if (event === undefined) { return } + if (event.dragVector.y === 0) { return } if (event.type === 'center dragged') { let point = { x: event.dragVector.x, y: -event.dragVector.y } - let newMinDate = getDateFromPointAtContainer(point, rateCalculationsContainer, coordinateSystem) let newMaxRate = getRateFromPointAtContainer(point, rateCalculationsContainer, coordinateSystem) - let xDifferenceMaxMin = coordinateSystem.max.x - coordinateSystem.min.x let yDifferenceMaxMin = coordinateSystem.max.y - coordinateSystem.min.y - coordinateSystem.min.x = newMinDate.valueOf() - coordinateSystem.max.x = newMinDate.valueOf() + xDifferenceMaxMin coordinateSystem.min.y = newMaxRate - yDifferenceMaxMin coordinateSystem.max.y = newMaxRate From ad8a73a8c162958f9ceba13b5b247a1723fe241b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 15 Apr 2020 09:21:35 +0200 Subject: [PATCH 14/55] Update Layer.js --- Panels/Layer.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Panels/Layer.js b/Panels/Layer.js index 989cb3a01..a6a188d23 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -195,6 +195,26 @@ function newLayer () { thisObject.quotedAsset = thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent thisObject.market = thisObject.baseAsset.code.codeName + '/' + thisObject.quotedAsset.code.codeName thisObject.exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode + + /* Some basic validations. */ + if (thisObject.definition.referenceParent === undefined) { + console.log('[WARN] Could not start plotter because ' + thisObject.definition.type + ' ' + thisObject.definition.name + ' does not have a Reference Parent.') + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + + if (thisObject.definition.referenceParent.referenceParent === undefined) { + console.log('[WARN] Could not start plotter because ' + thisObject.definition.referenceParent.type + ' ' + thisObject.definition.referenceParent.name + ' does not have a Reference Parent.') + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + + if (thisObject.definition.referenceParent.referenceParent.referenceParent === undefined) { + console.log('[WARN] Could not start plotter because ' + thisObject.definition.referenceParent.referenceParent.type + ' ' + thisObject.definition.referenceParent.referenceParent.name + ' does not have a Reference Parent.') + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + thisObject.plotterModule = thisObject.definition.referenceParent.referenceParent.referenceParent thisObject.exchangeIcon = getIcon(thisObject.exchange) From abb05c7e771eefc6836c72aada8d06f09e25ce82 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Apr 2020 10:00:13 +0200 Subject: [PATCH 15/55] Update UiObjectsFromNodes.js --- .../Workspace/FunctionLibraries/UiObjectsFromNodes.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 751a3d846..82ce129ad 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -547,7 +547,9 @@ function newUiObjectsFromNodes () { if (userAddingNew === false && uiObjectType === 'Task' && node.savedPayload !== undefined) { if (node.savedPayload.uiObject.isRunning === true) { if (node.payload.parentNode !== undefined) { - tasksToRun.push(node) + if (tasksToRun !== undefined) { // it might be undefined when you are spawning a task that was running while backed up + tasksToRun.push(node) + } } } } @@ -557,7 +559,9 @@ function newUiObjectsFromNodes () { if (uiObjectType === 'Live Trading Session' || uiObjectType === 'Fordward Testing Session' || uiObjectType === 'Backtesting Session' || uiObjectType === 'Paper Trading Session') { if (node.savedPayload.uiObject.isRunning === true) { if (node.payload.parentNode !== undefined) { - sessionsToRun.push(node) + if (sessionsToRun !== undefined) { // it might be undefined when you are spawning a session that was running while backed up + sessionsToRun.push(node) + } } } } From b5d3971ee0bb2320d345fc277f46edcfec976a5d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Apr 2020 18:19:58 +0200 Subject: [PATCH 16/55] webhooks --- .../FunctionLibraries/WebhookFunctions.js | 18 ++++++++++++++++++ DesignSpace/Workspace/Workspace.js | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js diff --git a/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js b/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js new file mode 100644 index 000000000..e30be6b06 --- /dev/null +++ b/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js @@ -0,0 +1,18 @@ +function newWebhookFunctions () { + thisObject = { + sendTestMessage: sendTestMessage + } + + return thisObject + + function sendTestMessage (node) { + let testMessage = loadPropertyFromNodeConfig(node.payload, 'testMessage') + let letURL = loadPropertyFromNodeConfig(node.payload, 'webhookURL') + + callServer(testMessage, letURL, onResponse) + + function onResponse (err) { + console.log(err) + } + } +} diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 928a8679d..590922175 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -59,6 +59,7 @@ function newWorkspace () { let functionLibraryOnFocus = newOnFocus() let functionLibrarySuperScripts = newSuperScriptsFunctions() let functionLibraryCCXTFunctions = newCCXTFunctions() + let functionLibraryWebhookFunctions = newWebhookFunctions() thisObject.nodeChildren = newNodeChildren() @@ -411,7 +412,11 @@ function newWorkspace () { functionLibraryCCXTFunctions.addMissingMarkets(payload.node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning) } break - + case 'Send Webhook Test Message': + { + functionLibraryWebhookFunctions.sendTestMessage(payload.node) + } + break case 'Run Session': { functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, callBackFunction) From a4cc64e9cd680b3f328ec3062927943524d91144 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Apr 2020 20:19:11 +0200 Subject: [PATCH 17/55] Update Workspace.js --- DesignSpace/Workspace/Workspace.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 590922175..7b36964dc 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -83,9 +83,10 @@ function newWorkspace () { function initialize () { try { + let reset = window.localStorage.getItem('Reset') let savedWorkspace = window.localStorage.getItem(CANVAS_APP_NAME + '.' + 'Workspace') - if (savedWorkspace === null) { + if (savedWorkspace === null || reset !== null) { thisObject.workspaceNode = getWorkspace() } else { thisObject.workspaceNode = JSON.parse(savedWorkspace) From 401ad83c44ffb0fd00fa3517d44b59e9313b7e16 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 16 Apr 2020 21:45:00 +0200 Subject: [PATCH 18/55] Webhooks improved --- .../Workspace/FunctionLibraries/WebhookFunctions.js | 8 ++++++-- DesignSpace/Workspace/Workspace.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js b/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js index e30be6b06..ca7e6b2f1 100644 --- a/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/WebhookFunctions.js @@ -5,14 +5,18 @@ function newWebhookFunctions () { return thisObject - function sendTestMessage (node) { + function sendTestMessage (node, callBackFunction) { let testMessage = loadPropertyFromNodeConfig(node.payload, 'testMessage') let letURL = loadPropertyFromNodeConfig(node.payload, 'webhookURL') callServer(testMessage, letURL, onResponse) function onResponse (err) { - console.log(err) + if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) + } else { + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + } } } } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 7b36964dc..5bb9a0a88 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -415,7 +415,7 @@ function newWorkspace () { break case 'Send Webhook Test Message': { - functionLibraryWebhookFunctions.sendTestMessage(payload.node) + functionLibraryWebhookFunctions.sendTestMessage(payload.node, callBackFunction) } break case 'Run Session': From 3482139b776a27a2d35c3eab66840e8c5033f465 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 17 Apr 2020 10:50:11 +0200 Subject: [PATCH 19/55] Update UiObject.js --- FloatingSpace/UiObject.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index e29e2ecbf..43f389648 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -899,7 +899,11 @@ function newUiObject () { thisObject.formulaEditor.deactivate() } - if (thisObject.payload !== undefined && thisObject.isOnFocus === false && thisObject.payload.referenceParent !== undefined) { + if (thisObject.payload !== undefined && + thisObject.isOnFocus === false && + thisObject.payload.referenceParent !== undefined && + thisObject.payload.referenceParent.payload !== undefined && + thisObject.payload.referenceParent.payload.uiObject !== undefined) { thisObject.payload.referenceParent.payload.uiObject.isShowing = false } } From 0239c2250c71b518da08fd27795ab9a59ea1b417 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 18 Apr 2020 12:15:44 +0200 Subject: [PATCH 20/55] Dependency Filters --- .../FunctionLibraries/DependenciesFilter.js | 74 +++++++++++++++++++ .../FunctionLibraries/SessionFunctions.js | 7 +- DesignSpace/Workspace/Workspace.js | 3 +- 3 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js diff --git a/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js b/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js new file mode 100644 index 000000000..2f88bf30d --- /dev/null +++ b/DesignSpace/Workspace/FunctionLibraries/DependenciesFilter.js @@ -0,0 +1,74 @@ +function newDependenciesFilter () { + thisObject = { + createFilter: createFilter + } + + return thisObject + + function createFilter (node) { + let filters = new Map() + recursiveFilter(node) + + return Array.from(filters.keys()) + + function recursiveFilter (node) { + filter(node.code) + + let nodeDefinition = APP_SCHEMA_MAP.get(node.type) + 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. + for (let i = 0; i < nodeDefinition.properties.length; i++) { + let property = nodeDefinition.properties[i] + + switch (property.type) { + case 'node': { + if (property.name !== previousPropertyName) { + if (node[property.name] !== undefined) { + recursiveFilter(node[property.name]) + } + previousPropertyName = property.name + } + } + break + case 'array': { + let nodePropertyArray = node[property.name] + if (nodePropertyArray !== undefined) { + for (let j = 0; j < nodePropertyArray.length; j++) { + let nodeProperty = nodePropertyArray[j] + recursiveFilter(nodeProperty) + } + } + } + break + } + } + } + } + } + + function filter (code) { + if (code === undefined) { return } + + let instructionsArray = code.split(' ') + for (let i = 0; i < instructionsArray.length; i++) { + let instruction = instructionsArray[i] + if (instruction.indexOf('chart') >= 0) { + let parts = instruction.split('.') + let timeFrame = parts[1] + let product = parts[2] + let productParts = product.split(',') + product = productParts[0] + productParts = product.split(')') + product = productParts[0] + + // Example: chart.at01hs.popularSMA.sma200 - chart.at01hs.popularSMA.sma100 < 10 + if (timeFrame !== 'atAnyTimeFrame') { + timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7) + } + filters.set(timeFrame + '-' + product, true) + } + } + } + } +} diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 13e33b381..c29f97884 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, callBackFunction) { + function runSession (node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction) { /* We can not run a sessionif its parent process is not running. Less if it does not have a parent. */ if (node.payload.parentNode === undefined) { node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.') @@ -59,10 +59,13 @@ function newSessionFunctions () { let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) + let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.payload.referenceParent) + /* Raise event to run the session */ let event = { session: JSON.stringify(session), - tradingSystem: JSON.stringify(tradingSystem) + tradingSystem: JSON.stringify(tradingSystem), + dependencyFilter: JSON.stringify(dependencyFilter) } eventsServerClient.raiseEvent(key, 'Run Session', event) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index 5bb9a0a88..dedea1c5b 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -60,6 +60,7 @@ function newWorkspace () { let functionLibrarySuperScripts = newSuperScriptsFunctions() let functionLibraryCCXTFunctions = newCCXTFunctions() let functionLibraryWebhookFunctions = newWebhookFunctions() + let functionLibraryDependenciesFilter = newDependenciesFilter() thisObject.nodeChildren = newNodeChildren() @@ -420,7 +421,7 @@ function newWorkspace () { break case 'Run Session': { - functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, callBackFunction) + functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction) } break case 'Stop Session': From 301b79b08b8a9a8845e37c49e653c4f1585c37cf Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 19 Apr 2020 21:42:45 +0200 Subject: [PATCH 21/55] 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 82ce129ad..41c809567 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -25,7 +25,7 @@ function newUiObjectsFromNodes () { blobService = newFileStorage() // if (node.code === undefined) { - node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Masters-WHB-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' + node.code = '{ \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) From 3691d7a0fbd25296311a87538729acb451219137 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Apr 2020 11:48:26 +0200 Subject: [PATCH 22/55] Update Layer.js --- Panels/Layer.js | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Panels/Layer.js b/Panels/Layer.js index a6a188d23..bc1ffadb5 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -565,17 +565,43 @@ function newLayer () { roundedCornersBackground(params) - let label1FontSize + let parentLabel1FontSize = loadPropertyFromNodeConfig(thisObject.payload.parentNode.payload, 'label1FontSize') + let parentLabel2FontSize = loadPropertyFromNodeConfig(thisObject.payload.parentNode.payload, 'label2FontSize') + let parentLabel3FontSize = loadPropertyFromNodeConfig(thisObject.payload.parentNode.payload, 'label3FontSize') - if (label1.length > 20) { - label1FontSize = 12 - } else { - label1FontSize = 15 + let label1FontSize = loadPropertyFromNodeConfig(thisObject.payload, 'label1FontSize') + let label2FontSize = loadPropertyFromNodeConfig(thisObject.payload, 'label2FontSize') + let label3FontSize = loadPropertyFromNodeConfig(thisObject.payload, 'label3FontSize') + + if (parentLabel1FontSize !== undefined) { + label1FontSize = parentLabel1FontSize + } + if (parentLabel2FontSize !== undefined) { + label2FontSize = parentLabel2FontSize + } + if (parentLabel3FontSize !== undefined) { + label3FontSize = parentLabel3FontSize + } + + if (label1FontSize === undefined) { + if (label1.length > 20) { + label1FontSize = 12 + } else { + label1FontSize = 15 + } + } + + if (label2FontSize === undefined) { + label2FontSize = 10 + } + + if (label3FontSize === undefined) { + label3FontSize = 9 } drawLabel(label1, 1 / 2, 6 / 10, -5, 0, label1FontSize, thisObject.container) - drawLabel(label2, 1 / 2, 8.2 / 10, -5, 0, 9, thisObject.container) - drawLabel(label3, 1 / 2, 9.5 / 10, -5, 0, 9, thisObject.container) + drawLabel(label2, 1 / 2, 8.2 / 10, -5, 0, label2FontSize, thisObject.container) + drawLabel(label3, 1 / 2, 9.5 / 10, -5, 0, label3FontSize, thisObject.container) drawProgressBar(marketFileProgressBar, 1, -45) drawProgressBar(dailyFileProgressBar, 1, -46) @@ -588,4 +614,3 @@ function newLayer () { drawIcon(thisObject.quotedAssetIcon, 4.6 / 8, 2 / 10, 0, 0, 14, thisObject.container) } } - From a3c6b7396a0ad8d375e9f946c0a3c5e7d977dc0f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Apr 2020 14:56:25 +0200 Subject: [PATCH 23/55] Move to Phase --- DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js | 2 +- DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index c29f97884..6d0b3d230 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -43,7 +43,7 @@ function newSessionFunctions () { 'Initial Stop->Initial Take Profit->' + 'Manage Stage->' + 'Stop->Take Profit->' + - 'Phase->Formula->Next Phase Event->' + + 'Phase->Formula->Next Phase Event->Move to Phase Event->Phase->' + 'Situation->Condition->Javascript Code->' + 'Close Stage->Close Execution->' + 'Announcement->Formula->' diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 41c809567..eadf4355e 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -252,6 +252,10 @@ function newUiObjectsFromNodes () { } break } + } else { + if (property.type === 'array') { + node[property.name] = [] + } } } } From 8e0c44797414f8b918020c6ebff7e358c86c1fff Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 20 Apr 2020 16:58:28 +0200 Subject: [PATCH 24/55] Update DesignSpace.js --- Spaces/DesignSpace.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Spaces/DesignSpace.js b/Spaces/DesignSpace.js index cbf9fedb2..db26f42ca 100644 --- a/Spaces/DesignSpace.js +++ b/Spaces/DesignSpace.js @@ -284,7 +284,8 @@ function newDesignSpace () { 'arrangement-horizontal-bottom', 'arrangement-vertical-right', 'arrangement-vertical-left', - 'arrangement-concave' + 'arrangement-concave', + 'move-to-phase-event' ] for (let i = 0; i < iconsNames.length; i++) { From fe7f1777362600931448055c0d846b456cd7826d Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Apr 2020 11:19:52 +0200 Subject: [PATCH 25/55] Update Canvas.js --- Canvas.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Canvas.js b/Canvas.js index 60522dd68..1d0e440d0 100644 --- a/Canvas.js +++ b/Canvas.js @@ -401,36 +401,44 @@ function newCanvas () { if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowLeft') { let displaceVector = canvas.floatingSpace.oneScreenLeft() - dragVector.downX = dragVector.downX + displaceVector.x - dragVector.downY = dragVector.downY + displaceVector.y - checkDrag() + if (displaceVector !== undefined) { + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() + } event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowRight') { let displaceVector = canvas.floatingSpace.oneScreenRight() - dragVector.downX = dragVector.downX + displaceVector.x - dragVector.downY = dragVector.downY + displaceVector.y - checkDrag() + if (displaceVector !== undefined) { + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() + } event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowUp') { let displaceVector = canvas.floatingSpace.oneScreenUp() - dragVector.downX = dragVector.downX + displaceVector.x - dragVector.downY = dragVector.downY + displaceVector.y - checkDrag() + if (displaceVector !== undefined) { + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() + } event.preventDefault() return } if ((event.ctrlKey === true || event.metaKey === true) && event.shiftKey === false && event.code === 'ArrowDown') { let displaceVector = canvas.floatingSpace.oneScreenDown() - dragVector.downX = dragVector.downX + displaceVector.x - dragVector.downY = dragVector.downY + displaceVector.y - checkDrag() + if (displaceVector !== undefined) { + dragVector.downX = dragVector.downX + displaceVector.x + dragVector.downY = dragVector.downY + displaceVector.y + checkDrag() + } event.preventDefault() return } From eac4c47e2e9e22479d0f9d76fc0f4ef8c1241b92 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Apr 2020 14:34:36 +0200 Subject: [PATCH 26/55] host and pot implementation --- ChartingSpace/PlottersManager.js | 7 +++++++ .../FunctionLibraries/UiObjectsFromNodes.js | 6 +++--- Panels/Layer.js | 15 ++++++++++++++- ProductStorage.js | 10 +++++----- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 2b36cf693..5610ec1b1 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -146,6 +146,11 @@ function newPlottersManager () { } } + let host = layer.networkNode.code.host + let webPort = layer.networkNode.code.webPort + if (host === undefined) { host = 'localhost' } + if (webPort === undefined) { webPort = window.location.port } + storage.initialize( dataMine, bot, @@ -155,6 +160,8 @@ function newPlottersManager () { market, datetime, timeFrame, + host, + webPort, onProductStorageInitialized ) diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index eadf4355e..d6253f558 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -37,7 +37,7 @@ function newUiObjectsFromNodes () { for (let i = 0; i < includeDataMines.length; i++) { let name = includeDataMines[i] - blobService.getBlobToText('DataMines' + '/' + name, undefined, onFileReceived, true) + blobService.getFileFromHost('DataMines' + '/' + name, onFileReceived, true) function onFileReceived (err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.') @@ -66,7 +66,7 @@ function newUiObjectsFromNodes () { for (let i = 0; i < includeTradingSystems.length; i++) { let name = includeTradingSystems[i] - blobService.getBlobToText('TradingSystems' + '/' + name, undefined, onFileReceived, true) + blobService.getFileFromHost('TradingSystems' + '/' + name, onFileReceived, true) function onFileReceived (err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.') @@ -95,7 +95,7 @@ function newUiObjectsFromNodes () { for (let i = 0; i < includeSuperScripts.length; i++) { let name = includeSuperScripts[i] - blobService.getBlobToText('SuperScripts' + '/' + name, undefined, onFileReceived, true) + blobService.getFileFromHost('SuperScripts' + '/' + name, onFileReceived, true) function onFileReceived (err, text, response) { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.') diff --git a/Panels/Layer.js b/Panels/Layer.js index bc1ffadb5..217d3d805 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -20,6 +20,7 @@ function newLayer () { plotterTypeIcon: undefined, baseAssetIcon: undefined, quotedAssetIcon: undefined, + networkNode: undefined, checkStatusAtShutDown: checkStatusAtShutDown, physics: physics, draw: draw, @@ -128,6 +129,7 @@ function newLayer () { thisObject.plotterTypeIcon = undefined thisObject.baseAssetIcon = undefined thisObject.quotedAssetIcon = undefined + thisObject.networkNode = undefined } function initialize (callBackFunction) { @@ -151,8 +153,9 @@ function newLayer () { let functionLibraryProtocolNode = newProtocolNode() let lightingPath = '->Layer->' + - 'Data Product->Single Market Data->' + + 'Data Product->Single Market Data->Exchange Data Products->' + 'Session Independent Data->Session Based Data->' + + 'Data Storage->Network Node->' + 'Session Reference->Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + @@ -186,6 +189,10 @@ function newLayer () { if (thisObject.definition.referenceParent.referenceParent === undefined) { return } if (thisObject.definition.referenceParent.referenceParent.parentNode === undefined) { return } if (thisObject.definition.referenceParent.referenceParent.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode === undefined) { return } + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.parentNode === undefined) { return } /* Lets listen to our own events to react when we have a Mouse Click */ onMouseClickEventSuscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseClick', onMouseClick) @@ -226,6 +233,12 @@ function newLayer () { thisObject.baseAssetIcon = getIcon(thisObject.baseAsset) thisObject.quotedAssetIcon = getIcon(thisObject.quotedAsset) + if (thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.type === 'Data Storage') { + thisObject.networkNode = thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.parentNode + } else { + thisObject.networkNode = thisObject.definition.referenceParent.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode + } + function getIcon (node) { let nodeDefinition = APP_SCHEMA_MAP.get(node.type) let iconName diff --git a/ProductStorage.js b/ProductStorage.js index 4e0c4142a..181486dcf 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -74,7 +74,7 @@ function newProductStorage (name) { } } - function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, callBackFunction) { + function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, callBackFunction) { try { datetime = pDatetime timeFrame = pTimeFrame @@ -90,7 +90,7 @@ function newProductStorage (name) { dataSetsToLoad++ let marketFiles = newMarketFiles() - marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, onMarketFileReady) + marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onMarketFileReady) thisObject.marketFiles.push(marketFiles) } break @@ -99,7 +99,7 @@ function newProductStorage (name) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, onDailyFileReady) + dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -108,7 +108,7 @@ function newProductStorage (name) { dataSetsToLoad++ let singleFile = newSingleFile() - singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, onSingleFileReady) + singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onSingleFileReady) thisObject.singleFile.push(singleFile) } break @@ -117,7 +117,7 @@ function newProductStorage (name) { dataSetsToLoad++ let fileSequences = newFileSequence() - fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, onFileSequenceReady) + fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onFileSequenceReady) thisObject.fileSequences.push(fileSequences) } break From 5f0664fa816dd8c682e31160e7248563ade273ae Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 22 Apr 2020 13:57:41 +0200 Subject: [PATCH 27/55] Remote Backends Implemented --- Canvas.js | 2 - ChartingSpace/PlottersManager.js | 3 + .../FunctionLibraries/SessionFunctions.js | 75 +++++++++++++++---- .../FunctionLibraries/TaskFunctions.js | 54 +++++++++++-- DesignSpace/Workspace/Workspace.js | 48 ++++++++++++ EventsServerClient.js | 20 ++--- FloatingSpace/CircularProgressBar.js | 22 ++++-- FloatingSpace/UiObject.js | 31 +++++--- Panels/Layer.js | 4 +- PostLoader.js | 5 +- ProductStorage.js | 10 +-- 11 files changed, 211 insertions(+), 63 deletions(-) diff --git a/Canvas.js b/Canvas.js index 1d0e440d0..b13ac359c 100644 --- a/Canvas.js +++ b/Canvas.js @@ -130,8 +130,6 @@ function newCanvas () { animation.initialize() thisObject.animation = animation - /* Low Level Infraestructure First */ - animation.addCallBackFunction('System Event Handler Physics', eventsServerClient.physics) /* Spcaces Physics */ animation.addCallBackFunction('CockpitSpace Physics', thisObject.cockpitSpace.physics) diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index 5610ec1b1..a0002b6fa 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -151,6 +151,8 @@ function newPlottersManager () { if (host === undefined) { host = 'localhost' } if (webPort === undefined) { webPort = window.location.port } + let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(layer.networkNode.id) + storage.initialize( dataMine, bot, @@ -162,6 +164,7 @@ function newPlottersManager () { timeFrame, host, webPort, + eventsServerClient, onProductStorageInitialized ) diff --git a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js index 6d0b3d230..e1f7883e2 100644 --- a/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/SessionFunctions.js @@ -7,26 +7,15 @@ function newSessionFunctions () { return thisObject function runSession (node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction) { - /* We can not run a sessionif its parent process is not running. Less if it does not have a parent. */ - if (node.payload.parentNode === undefined) { - node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.') + if (validations(node) !== true) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return } - if (node.payload.parentNode.payload.uiObject.isRunning !== true) { - node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be running to be able to run.') - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } + let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode + let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id) - if (node.payload.referenceParent === undefined) { - node.payload.uiObject.setErrorMessage('Session needs to reference a Trading System.') - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - - node.payload.uiObject.run(callBackFunction) + node.payload.uiObject.run(eventsServerClient, callBackFunction) let key = node.name + '-' + node.type + '-' + node.id @@ -77,9 +66,65 @@ function newSessionFunctions () { } function stopSession (node, functionLibraryProtocolNode, callBackFunction) { + if (validations(node) !== true) { + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + + let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode + let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id) + let key = node.name + '-' + node.type + '-' + node.id eventsServerClient.raiseEvent(key, 'Stop Session') node.payload.uiObject.stop(callBackFunction) } + + function validations (node) { + if (node.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.') + return + } + + if (node.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to be inside a Trading Process Instance.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to be inside a Task.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to be inside a Task Manager.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to be inside Exchange Tasks.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to be inside a Testing or Production Environment.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to be inside a Network Node.') + return + } + + if (node.payload.parentNode.payload.uiObject.isRunning !== true) { + node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be running.') + return + } + + if (node.payload.referenceParent === undefined) { + node.payload.uiObject.setErrorMessage('Session needs to reference a Trading System.') + return + } + return true + } } diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index 6c89285ed..f9a617a8a 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -13,19 +13,17 @@ function newTaskFunctions () { return thisObject function runTask (node, functionLibraryProtocolNode, callBackFunction) { - /* Check if it is possible to Run or not */ - if (node.bot === undefined) { - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) - return - } - if (node.bot.processes.length === 0) { + if (validations(node) !== true) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return } + let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode + let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id) + for (let i = 0; i < node.bot.processes.length; i++) { let process = node.bot.processes[i] - process.payload.uiObject.run() + process.payload.uiObject.run(eventsServerClient) } let lightingPath = '->Task->' + @@ -72,11 +70,19 @@ function newTaskFunctions () { return } - node.payload.uiObject.run(callBackFunction) + node.payload.uiObject.run(eventsServerClient, callBackFunction) eventsServerClient.raiseEvent('Task Manager', 'Run Task', event) } function stopTask (node, functionLibraryProtocolNode, callBackFunction) { + if (validations(node) !== true) { + callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + return + } + + let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode + let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id) + let event = { taskId: node.id, taskName: node.name @@ -94,6 +100,38 @@ function newTaskFunctions () { } } + function validations (node) { + if (node.bot === undefined) { + node.payload.uiObject.setErrorMessage('Task needs to have a Bot Instance.') + return + } + if (node.bot.processes.length === 0) { + node.payload.uiObject.setErrorMessage('Task Bot Instance needs to have al least once Process Instance.') + return + } + + if (node.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Task needs to be inside a Task Manager.') + return + } + + if (node.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Task needs to be inside Exchange Tasks.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Task needs to be inside a Testing or Production Environment or a Data Mining node.') + return + } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Task needs to be inside a Network Node.') + return + } + return true + } + function runAllTasks (taskManager, functionLibraryProtocolNode) { for (let i = 0; i < taskManager.tasks.length; i++) { let node = taskManager.tasks[i] diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index dedea1c5b..d076dcb8f 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -10,6 +10,7 @@ function newWorkspace () { container: undefined, enabled: false, nodeChildren: undefined, + eventsServerClients: new Map(), save: saveWorkspace, getHierarchyHeads: getHierarchyHeads, getNodeThatIsOnFocus: getNodeThatIsOnFocus, @@ -93,6 +94,7 @@ function newWorkspace () { thisObject.workspaceNode = JSON.parse(savedWorkspace) } functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) + setupEventsServerClients() thisObject.enabled = true setInterval(saveWorkspace, 60000) @@ -101,6 +103,38 @@ function newWorkspace () { } } + function setupEventsServerClients () { + for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { + let rootNode = thisObject.workspaceNode.rootNodes[i] + + if (rootNode.type === 'Network') { + for (let j = 0; j < rootNode.networkNodes.length; j++) { + let networkNode = rootNode.networkNodes[j] + + let host + 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 + } catch (err) { + console.log('[ERROR] networkNode ' + networkNode.name + ' has an invalid configuration. Cannot know the host name and webSocketsPort.') + return + } + + if (host === undefined) { host = 'localhost' } + if (webSocketsPort === undefined) { webSocketsPort = '8080' } + + let eventsServerClient = newEventsServerClient(host, webSocketsPort) + eventsServerClient.initialize() + + thisObject.eventsServerClients.set(networkNode.id, eventsServerClient) + } + } + } + } + function chainDetachNode (node) { functionLibraryChainAttachDetach.chainDetachNode(node, thisObject.workspaceNode.rootNodes) } @@ -130,6 +164,19 @@ function newWorkspace () { } function physics () { + eventsServerClientsPhysics() + replacingWorkspacePhysics() + } + + function eventsServerClientsPhysics () { + thisObject.eventsServerClients.forEach(applyPhysics) + + function applyPhysics (eventServerClient) { + eventServerClient.physics() + } + } + + function replacingWorkspacePhysics () { if (thisObject.enabled !== true) { return } if (workingAtTask > 0) { @@ -151,6 +198,7 @@ function newWorkspace () { break case 4: functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, true) + setupEventsServerClients() workingAtTask++ break case 5: diff --git a/EventsServerClient.js b/EventsServerClient.js index f5d05ea8f..a94c1495a 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -1,5 +1,5 @@ -function newEventsServerClient () { +function newEventsServerClient (host, port) { /* Web Sockets Connection */ const MODULE_NAME = 'System Event Handler' @@ -8,7 +8,7 @@ function newEventsServerClient () { const logger = newWebDebugLog() logger.fileName = MODULE_NAME - const WEB_SOCKETS_URL = 'ws://localhost:8080' + const WEB_SOCKETS_URL = 'ws://' + host + ':' + port + '' let WEB_SOCKETS_CONNECTION let thisObject = { @@ -56,12 +56,7 @@ function newEventsServerClient () { responseWaiters.set(command.callerId, responseCallBack) } - if (WEB_SOCKETS_CONNECTION.readyState === 1) { - // 1 means connected and ready. - sendToWebSocketServer(command) - } else { - console.log('WebSocket message could not be sent because the connection was not ready. Message = ' + JSON.stringify(command)) - } + sendToWebSocketServer(command) } function sendToWebSocketServer (command) { @@ -72,7 +67,12 @@ function newEventsServerClient () { commandsSentByTimestamp.set(stringNonce, timestamp) let messageToWebSocketServer = 'Web Browser' + '|*|' + stringNonce + '|*|' + JSON.stringify(command) - WEB_SOCKETS_CONNECTION.send(messageToWebSocketServer) + + if (WEB_SOCKETS_CONNECTION.readyState === 1) { + WEB_SOCKETS_CONNECTION.send(messageToWebSocketServer) + } else { + console.log('WebSocket message could not be sent because the connection was not ready. Will retry soon. Message = ' + JSON.stringify(command)) + } } function createEventHandler (eventHandlerName, callerId, responseCallBack) { @@ -153,7 +153,7 @@ function newEventsServerClient () { } if (thisObject.isConnected() !== true) { - canvas.cockpitSpace.setStatus('Connection with the local backend lost. Please check that all localhost servers are running.', 100, canvas.cockpitSpace.statusTypes.WARNING) + canvas.cockpitSpace.setStatus('Connecting with ' + host + '. Please hold on until the connection can be stablished.', 100, canvas.cockpitSpace.statusTypes.WARNING) } else { retryCommandsPhysics() } diff --git a/FloatingSpace/CircularProgressBar.js b/FloatingSpace/CircularProgressBar.js index 8e6a55336..d662589c8 100644 --- a/FloatingSpace/CircularProgressBar.js +++ b/FloatingSpace/CircularProgressBar.js @@ -22,27 +22,35 @@ function newCircularProgressBar () { thisObject.container.frame.position.y = 0 let opacityCounters = [] - let eventSubscriptionIdHeartbeat - let needToDrawRing = true + let eventsServerClient return thisObject function finalize () { - let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - if (eventSubscriptionIdHeartbeat !== undefined) { - eventsServerClient.stopListening(key, eventSubscriptionIdHeartbeat) - } + finalizeEventsServerClient() thisObject.container = undefined thisObject.payload = undefined thisObject.fitFunction = undefined } - function initialize (payload) { + function finalizeEventsServerClient () { + if (eventsServerClient !== undefined) { + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + if (eventSubscriptionIdHeartbeat !== undefined) { + eventsServerClient.stopListening(key, eventSubscriptionIdHeartbeat) + } + } + } + + function initialize (payload, pEventsServerClient) { thisObject.payload = payload + finalizeEventsServerClient() + eventsServerClient = pEventsServerClient + for (let i = 0; i < 60; i++) { opacityCounters.push(0) } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 43f389648..136c3c9a0 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -117,17 +117,12 @@ function newUiObject () { let referenceLineCounter = 0 let chainLineCounter = 0 + let eventsServerClient + return thisObject function finalize () { - let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id - - if (eventSubscriptionIdOnRunning !== undefined) { - eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject') - } - if (eventSubscriptionIdOnStopped !== undefined) { - eventsServerClient.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject') - } + finalizeEventsServerClient() thisObject.container.eventHandler.stopListening(selfFocusEventSubscriptionId) thisObject.container.eventHandler.stopListening(selfNotFocusEventSubscriptionId) @@ -173,6 +168,19 @@ function newUiObject () { onRunningCallBackFunction = undefined } + function finalizeEventsServerClient () { + if (eventsServerClient !== undefined) { + let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id + + if (eventSubscriptionIdOnRunning !== undefined) { + eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject') + } + if (eventSubscriptionIdOnStopped !== undefined) { + eventsServerClient.stopListening(key, eventSubscriptionIdOnStopped, 'UiObject') + } + } + } + function initialize (payload, menuItemsInitialValues) { thisObject.payload = payload @@ -750,14 +758,17 @@ function newUiObject () { } } - function run (callBackFunction) { + function run (pEventsServerClient, callBackFunction) { + finalizeEventsServerClient() + eventsServerClient = pEventsServerClient + /* We setup the circular progress bar. */ if (thisObject.circularProgressBar !== undefined) { thisObject.circularProgressBar.finalize() } thisObject.circularProgressBar = newCircularProgressBar() - thisObject.circularProgressBar.initialize(thisObject.payload) + thisObject.circularProgressBar.initialize(thisObject.payload, eventsServerClient) thisObject.circularProgressBar.fitFunction = thisObject.fitFunction thisObject.circularProgressBar.container = thisObject.container diff --git a/Panels/Layer.js b/Panels/Layer.js index 217d3d805..44e067063 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -154,9 +154,9 @@ function newLayer () { let lightingPath = '->Layer->' + 'Data Product->Single Market Data->Exchange Data Products->' + - 'Session Independent Data->Session Based Data->' + + 'Session Reference->Session Independent Data->Session Based Data->Exchange Sessions->Session Based Data->Data Storage->Network Node->' + 'Data Storage->Network Node->' + - 'Session Reference->Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + + 'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' + 'Market->Market Base Asset->Asset->' + 'Market Quoted Asset->Asset->' + 'Exchange Markets->Crypto Exchange->' + diff --git a/PostLoader.js b/PostLoader.js index 0af816538..d47eb8add 100644 --- a/PostLoader.js +++ b/PostLoader.js @@ -1,6 +1,5 @@ let canvas let markets -let eventsServerClient let APP_SCHEMA_MAP = new Map() let APP_SCHEMA_ARRAY = [] @@ -23,9 +22,7 @@ function newDashboard () { function start () { try { setBrowserEvents() - - eventsServerClient = newEventsServerClient() - eventsServerClient.initialize(setUpAppSchema) + setUpAppSchema() function setUpAppSchema () { APP_SCHEMA_ARRAY = getAppSchema() diff --git a/ProductStorage.js b/ProductStorage.js index 181486dcf..68c76ef1b 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -74,7 +74,7 @@ function newProductStorage (name) { } } - function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, callBackFunction) { + function initialize (dataMine, bot, session, product, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, callBackFunction) { try { datetime = pDatetime timeFrame = pTimeFrame @@ -90,7 +90,7 @@ function newProductStorage (name) { dataSetsToLoad++ let marketFiles = newMarketFiles() - marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onMarketFileReady) + marketFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onMarketFileReady) thisObject.marketFiles.push(marketFiles) } break @@ -99,7 +99,7 @@ function newProductStorage (name) { dataSetsToLoad++ let dailyFiles = newDailyFiles() - dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, onDailyFileReady) + dailyFiles.initialize(dataMine, bot, session, product, dataset, exchange, market, pDatetime, pTimeFrame, host, port, eventsServerClient, onDailyFileReady) thisObject.dailyFiles.push(dailyFiles) } break @@ -108,7 +108,7 @@ function newProductStorage (name) { dataSetsToLoad++ let singleFile = newSingleFile() - singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onSingleFileReady) + singleFile.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onSingleFileReady) thisObject.singleFile.push(singleFile) } break @@ -117,7 +117,7 @@ function newProductStorage (name) { dataSetsToLoad++ let fileSequences = newFileSequence() - fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, onFileSequenceReady) + fileSequences.initialize(dataMine, bot, session, product, dataset, exchange, market, host, port, eventsServerClient, onFileSequenceReady) thisObject.fileSequences.push(fileSequences) } break From ac58ba3cbe61ee6fa6762024d1a7131a75df0bc6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 22 Apr 2020 14:40:06 +0200 Subject: [PATCH 28/55] Debug menu --- DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js | 6 +++--- DesignSpace/Workspace/Workspace.js | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index f9a617a8a..4a83f27db 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -12,7 +12,7 @@ function newTaskFunctions () { return thisObject - function runTask (node, functionLibraryProtocolNode, callBackFunction) { + function runTask (node, functionLibraryProtocolNode, isDebugging, callBackFunction) { if (validations(node) !== true) { callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) return @@ -64,8 +64,8 @@ function newTaskFunctions () { definition: JSON.stringify(definition) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager. } - if (node.payload.parentNode === undefined) { - callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE) + if (isDebugging === true) { + callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE) eventsServerClient.raiseEvent('Task Server', 'Debug Task Started', event) return } diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index d076dcb8f..a58fb46a1 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -406,10 +406,15 @@ function newWorkspace () { downloadText(fileName, text) } + break + case 'Debug Task': + { + functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, true, callBackFunction) + } break case 'Run Task': { - functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, callBackFunction) + functionLibraryTaskFunctions.runTask(payload.node, functionLibraryProtocolNode, false, callBackFunction) } break case 'Stop Task': From 5e2196bc2829a55f23129494d76f434eb5ee9733 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 23 Apr 2020 11:10:18 +0200 Subject: [PATCH 29/55] Update EventsServerClient.js --- EventsServerClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventsServerClient.js b/EventsServerClient.js index a94c1495a..f54bfb477 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -153,7 +153,7 @@ function newEventsServerClient (host, port) { } if (thisObject.isConnected() !== true) { - canvas.cockpitSpace.setStatus('Connecting with ' + host + '. Please hold on until the connection can be stablished.', 100, canvas.cockpitSpace.statusTypes.WARNING) + canvas.cockpitSpace.setStatus('Connecting to ' + host + '. Please hold on until the connection can be stablished.', 100, canvas.cockpitSpace.statusTypes.WARNING) } else { retryCommandsPhysics() } From 14eee0353497920465344d114c37fc48c8caea56 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 23 Apr 2020 13:40:37 +0200 Subject: [PATCH 30/55] data from network node --- .../FunctionLibraries/TaskFunctions.js | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index 4a83f27db..a63fef7db 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -26,7 +26,7 @@ function newTaskFunctions () { process.payload.uiObject.run(eventsServerClient) } - let lightingPath = '->Task->' + + let taskLightingPath = '->Task->' + 'Sensor Bot Instance->' + 'Indicator Bot Instance->' + 'Trading Bot Instance->' + @@ -56,12 +56,22 @@ function newTaskFunctions () { 'Trading Bot->' + 'Data Mine->' - let definition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath) + let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath) + + let networkLightingPath = '->Task->Task Manager->' + + 'Exchange Tasks->' + + 'Data Mining->Testing Environment->Production Environment->' + + 'Network Node->Network->Network Node->' + + 'Data Storage->Session Independent Data->Exchange Data Products->' + + 'Single Market Data->Data Product->Product Definition->' + + let networkDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, networkLightingPath) let event = { taskId: node.id, taskName: node.name, - definition: JSON.stringify(definition) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager. + taskDefinition: JSON.stringify(taskDefinition), + networkDefinition: JSON.stringify(networkDefinition) } if (isDebugging === true) { @@ -129,6 +139,28 @@ function newTaskFunctions () { node.payload.uiObject.setErrorMessage('Task needs to be inside a Network Node.') return } + + if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { + node.payload.uiObject.setErrorMessage('Task needs to be inside a Network.') + return + } + + let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode + if (loadPropertyFromNodeConfig(networkNode.payload, 'host') === undefined) { + node.payload.uiObject.setErrorMessage('Network Node needs to have a valid Host property at its config.') + return + } + + if (loadPropertyFromNodeConfig(networkNode.payload, 'webPort') === undefined) { + node.payload.uiObject.setErrorMessage('Network Node needs to have a valid webPort property at its config.') + return + } + + if (loadPropertyFromNodeConfig(networkNode.payload, 'webSocketsPort') === undefined) { + node.payload.uiObject.setErrorMessage('Network Node needs to have a valid webSocketsPort property at its config.') + return + } + return true } From 6b6ef06b44fae8080f3b75d80a2c6b2ea21082b8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Apr 2020 12:03:37 +0200 Subject: [PATCH 31/55] Remote Data Implemented --- .../Workspace/FunctionLibraries/ProtocolNode.js | 16 ++++++---------- .../Workspace/FunctionLibraries/TaskFunctions.js | 16 ++++++++++------ DesignSpace/Workspace/Workspace.js | 2 +- EventsServerClient.js | 4 ++-- FloatingSpace/UiObject.js | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js index 3fff812a4..73d626530 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -24,23 +24,19 @@ function newProtocolNode () { /* Children Nodes */ 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. for (let i = 0; i < nodeDefinition.properties.length; i++) { let property = nodeDefinition.properties[i] switch (property.type) { case 'node': { if (node[property.name] !== undefined) { - if (property.name !== previousPropertyName) { - if (lightingPath === undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, 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) - } + if (lightingPath === undefined) { + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, 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) } - previousPropertyName = property.name } } break diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index a63fef7db..54af3c9c7 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -58,14 +58,18 @@ function newTaskFunctions () { let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath) - let networkLightingPath = '->Task->Task Manager->' + - 'Exchange Tasks->' + - 'Data Mining->Testing Environment->Production Environment->' + - 'Network Node->Network->Network Node->' + + let networkLightingPath = '->Network->Network Node->' + 'Data Storage->Session Independent Data->Exchange Data Products->' + - 'Single Market Data->Data Product->Product Definition->' + 'Single Market Data->Data Product->Product Definition->' + + 'Data Mining->Testing Environment->Production Environment->' + + 'Exchange Tasks->Crypto Exchange->' + + 'Task Manager->Task->' + + 'Indicator Bot Instance->Sensor Bot Instance->' + + 'Indicator Process Instance->Sensor Process Instance->' + + 'Market Reference->Market->' + + 'Process Definition->' - let networkDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, networkLightingPath) + let networkDefinition = functionLibraryProtocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath) let event = { taskId: node.id, diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index a58fb46a1..b8e4062f4 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -126,7 +126,7 @@ function newWorkspace () { if (host === undefined) { host = 'localhost' } if (webSocketsPort === undefined) { webSocketsPort = '8080' } - let eventsServerClient = newEventsServerClient(host, webSocketsPort) + let eventsServerClient = newEventsServerClient(host, webSocketsPort, networkNode.name) eventsServerClient.initialize() thisObject.eventsServerClients.set(networkNode.id, eventsServerClient) diff --git a/EventsServerClient.js b/EventsServerClient.js index f54bfb477..1c5301e37 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -1,5 +1,5 @@ -function newEventsServerClient (host, port) { +function newEventsServerClient (host, port, hostName) { /* Web Sockets Connection */ const MODULE_NAME = 'System Event Handler' @@ -153,7 +153,7 @@ function newEventsServerClient (host, port) { } if (thisObject.isConnected() !== true) { - canvas.cockpitSpace.setStatus('Connecting to ' + host + '. Please hold on until the connection can be stablished.', 100, canvas.cockpitSpace.statusTypes.WARNING) + canvas.cockpitSpace.setStatus('Connecting to ' + hostName + ' Network Node. Please hold on until the connection can be stablished.', 100, canvas.cockpitSpace.statusTypes.WARNING) } else { retryCommandsPhysics() } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 136c3c9a0..574fd4a4c 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -1424,7 +1424,7 @@ function newUiObject () { let label if (radius > 6) { - const MAX_LABEL_LENGTH = 65 + const MAX_LABEL_LENGTH = 100 label = currentStatus From 47e4c5677a513ae97d583f79f4801df77c7420df Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 24 Apr 2020 13:27:27 +0200 Subject: [PATCH 32/55] bugs fixed --- FloatingSpace/UiObjectConstructor.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 03f80b2ac..6c02e1d2c 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -157,6 +157,17 @@ function newUiObjectConstructor () { } } + /* Default Values in case there was no way to set a value previous to this. */ + if (floatingObject.angleToParent === undefined) { + floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_360 + } + if (floatingObject.distanceToParent === undefined) { + floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X + } + if (floatingObject.arrangementStyle === undefined) { + floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE + } + let uiObject = newUiObject() payload.uiObject = uiObject uiObject.fitFunction = canvas.floatingSpace.fitIntoVisibleArea @@ -243,7 +254,7 @@ function newUiObjectConstructor () { ) menuItemsInitialValues.push( { - action: 'change Distance to Paarent', + action: 'Change Distance to Paarent', actionFunction: floatingObject.distanceToParentToggle, actionStatus: floatingObject.getDistanceToParent, currentStatus: true, @@ -258,7 +269,7 @@ function newUiObjectConstructor () { ) menuItemsInitialValues.push( { - action: 'change Arrangement Style', + action: 'Change Arrangement Style', actionFunction: floatingObject.arrangementStyleToggle, actionStatus: floatingObject.getArrangementStyle, currentStatus: true, From 40968b01758e8d3d28ed105a53171cf94326d1bd Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 25 Apr 2020 09:08:59 +0200 Subject: [PATCH 33/55] Bugs Fixed --- DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js | 5 +++-- EventsServerClient.js | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js index 54af3c9c7..e364f9303 100644 --- a/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -64,8 +64,9 @@ function newTaskFunctions () { 'Data Mining->Testing Environment->Production Environment->' + 'Exchange Tasks->Crypto Exchange->' + 'Task Manager->Task->' + - 'Indicator Bot Instance->Sensor Bot Instance->' + - 'Indicator Process Instance->Sensor Process Instance->' + + 'Indicator Bot Instance->Sensor Bot Instance->Trading Bot Instance->' + + 'Indicator Process Instance->Sensor Process Instance->Trading Process Instance->' + + 'Paper Trading Session->Forward Testing Session->Backtesting Session->Live Trading Session->' + 'Market Reference->Market->' + 'Process Definition->' diff --git a/EventsServerClient.js b/EventsServerClient.js index 1c5301e37..bdbe7f37b 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -8,6 +8,9 @@ function newEventsServerClient (host, port, hostName) { const logger = newWebDebugLog() logger.fileName = MODULE_NAME + if (host === '' || host === undefined) { host = 'localhost' } + if (port === '' || port === undefined) { port = '8080' } + const WEB_SOCKETS_URL = 'ws://' + host + ':' + port + '' let WEB_SOCKETS_CONNECTION From b8453d03a9358a2c821f2edfe9209e566dbbf59c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 26 Apr 2020 10:52:01 +0200 Subject: [PATCH 34/55] scan Data Mines --- DesignSpace/Workspace/Workspace.js | 11 ++++++ FloatingSpace/ConditionEditor.js | 61 +++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index b8e4062f4..3b1a4891e 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -152,6 +152,17 @@ function newWorkspace () { } function saveWorkspace () { + /* When there is an exception while loading the app, the rootNodes of the workspace get into null value. To avoid saving a corrupt staate we are going to verufy we are not in that situation before saving. */ + let workspace = canvas.designSpace.workspace.workspaceNode + + for (let i = 0; i < workspace.rootNodes.length; i++) { + let rootNode = workspace.rootNodes[i] + if (rootNode === null) { + canvas.cockpitSpace.setStatus('Could not save the Workspace. The state of the workspace in memory is corrupt, please reload the App.', 150, canvas.cockpitSpace.statusTypes.WARNING) + return + } + } + let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp') if (Number(savedSessionTimestamp) !== sessionTimestamp) { canvas.cockpitSpace.setStatus('Could not save the Workspace. You have more that one instance of the Superlagos User Interface open at the same time. Plese close this instance as it is older than the others.', 150, canvas.cockpitSpace.statusTypes.WARNING) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index d7a16f968..c42b3dc5a 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -34,6 +34,8 @@ function newConditionEditor () { thisObject.container.frame.position.y = 0 let isMouseOver = false + let operator1 + let operator2 return thisObject @@ -92,15 +94,70 @@ function newConditionEditor () { 'overflow:hidden;' + 'font-family: ' + UI_FONT.PRIMARY + ';' + 'font-size: 14px;' + - 'background-color: rgb(' + UI_COLOR.GREEN + ');' + + 'background-color: rgb(' + UI_COLOR.GREY + ');' + 'color:rgb(255, 255, 255);' + 'width: ' + thisObject.container.frame.width + 'px;' + 'height: ' + thisObject.container.frame.height + 'px' textArea.style.display = 'block' textArea.focus() + + scanDataMines() EDITOR_ON_FOCUS = true } + function scanDataMines () { + let selector = {} + + let workspace = canvas.designSpace.workspace.workspaceNode + + for (let i = 0; i < workspace.rootNodes.length; i++) { + let rootNode = workspace.rootNodes[i] + if (rootNode.type !== 'Data Mine') { continue } + let dataMine = rootNode + let dataMineName = loadPropertyFromNodeConfig(dataMine.payload, 'codeName') + selector[dataMineName] = {} + let bots = dataMine.sensorBots.concat(dataMine.indicatorBots) + for (let j = 0; j < bots.length; j++) { + let bot = bots[j] + let botName = loadPropertyFromNodeConfig(bot.payload, 'codeName') + let selectorDataMine = selector[dataMineName] + selectorDataMine[botName] = {} + for (let k = 0; k < bot.products.length; k++) { + let product = bot.products[k] + let productName = loadPropertyFromNodeConfig(product.payload, 'singularVariableName') + if (productName === undefined) { continue } + let selectorProduct = selectorDataMine[botName] + selectorProduct[productName] = {} + if (product.record === undefined) { continue } + for (let m = 0; m < product.record.properties.length; m++) { + let property = product.record.properties[m] + let propertyName = loadPropertyFromNodeConfig(property.payload, 'codeName') + let selectorProperty = selectorProduct[productName] + selectorProperty[propertyName] = {} + let possibleValues = loadPropertyFromNodeConfig(property.payload, 'possibleValues') + if (possibleValues === undefined) { possibleValues = [] } + let selectorPossibleValue = selectorProperty[propertyName] + selectorPossibleValue.possibleValues = possibleValues + } + let productKeys = Object.keys(selectorProduct[productName]) + if (productKeys.length === 0) { + selectorProduct[productName] = undefined + } + } + let botKeys = Object.keys(selectorDataMine[botName]) + if (botKeys.length === 0) { + selectorDataMine[botName] = undefined + } + } + let dataMineKeys = Object.keys(selector[dataMineName]) + if (dataMineKeys.length === 0) { + selector[dataMineName] = undefined + } + } + operator1 = JSON.parse(JSON.stringify(selector)) + operator2 = JSON.parse(JSON.stringify(selector)) + } + function getContainer (point) { let container if (thisObject.visible === true) { @@ -176,7 +233,7 @@ function newConditionEditor () { browserCanvasContext.beginPath() browserCanvasContext.arc(position.x, position.y, radius * 1.3, 0, Math.PI * 2, true) browserCanvasContext.closePath() - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREEN + ', ' + 1 + ')' + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')' browserCanvasContext.fill() } } From 73f68b155aadde30e99dc9e869cb45b28e44cd29 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 26 Apr 2020 11:48:15 +0200 Subject: [PATCH 35/55] Cleaning unused code --- FloatingSpace/CodeEditor.js | 19 ---------- FloatingSpace/ConditionEditor.js | 58 ------------------------------ FloatingSpace/ConfigEditor.js | 19 ---------- FloatingSpace/FormulaEditor.js | 19 ---------- FloatingSpace/Picker.js | 61 ++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 115 deletions(-) create mode 100644 FloatingSpace/Picker.js diff --git a/FloatingSpace/CodeEditor.js b/FloatingSpace/CodeEditor.js index 89bce2189..4dea3fb0c 100644 --- a/FloatingSpace/CodeEditor.js +++ b/FloatingSpace/CodeEditor.js @@ -4,8 +4,6 @@ function newCodeEditor () { let thisObject = { isVisibleFunction: undefined, - iconOK: undefined, - iconNOT_OK: undefined, visible: false, imagePathOK: undefined, imagePathNOT_OK: undefined, @@ -41,29 +39,12 @@ function newCodeEditor () { function finalize () { thisObject.container.finalize() thisObject.container = undefined - thisObject.iconOK = undefined - thisObject.iconNOT_OK = undefined thisObject.payload = undefined thisObject.isVisibleFunction = undefined } function initialize () { - /* Load Images */ - thisObject.iconOK = new Image() - thisObject.iconOK.onload = onImageLoad - - function onImageLoad () { - thisObject.iconNOT_OK = new Image() - thisObject.iconNOT_OK.onload = onImageLoad - - function onImageLoad () { - thisObject.canDrawIcon = true - } - thisObject.iconNOT_OK.src = window.canvasApp.urlPrefix + thisObject.imagePathNOT_OK - } - // thisObject.iconOK.src = window.canvasApp.urlPrefix + thisObject.imagePathOK - // thisObject.icon = thisObject.iconOK // The default value is ON. } function deactivate () { diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index c42b3dc5a..36735a41e 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -4,8 +4,6 @@ function newConditionEditor () { let thisObject = { isVisibleFunction: undefined, - iconOK: undefined, - iconNOT_OK: undefined, visible: false, imagePathOK: undefined, imagePathNOT_OK: undefined, @@ -42,37 +40,17 @@ function newConditionEditor () { function finalize () { thisObject.container.finalize() thisObject.container = undefined - thisObject.iconOK = undefined - thisObject.iconNOT_OK = undefined thisObject.payload = undefined thisObject.isVisibleFunction = undefined } function initialize () { - /* Load Images */ - thisObject.iconOK = new Image() - thisObject.iconOK.onload = onImageLoad - - function onImageLoad () { - thisObject.iconNOT_OK = new Image() - thisObject.iconNOT_OK.onload = onImageLoad - - function onImageLoad () { - thisObject.canDrawIcon = true - } - thisObject.iconNOT_OK.src = window.canvasApp.urlPrefix + thisObject.imagePathNOT_OK - } - // thisObject.iconOK.src = window.canvasApp.urlPrefix + thisObject.imagePathOK - // thisObject.icon = thisObject.iconOK // The default value is ON. } function deactivate () { if (thisObject.visible === true) { thisObject.visible = false - let textArea = document.getElementById('textArea') - textArea.style.display = 'none' - thisObject.payload.node.code = textArea.value } EDITOR_ON_FOCUS = false } @@ -85,22 +63,6 @@ function newConditionEditor () { thisObject.currentRadius = 0 thisObject.payload.uiObject.setErrorMessage('', 0) - let textArea = document.getElementById('textArea') - textArea.value = payload.node.code - textArea.style = 'resize: none;' + - ' border: none;' + - ' outline: none;' + - 'box-shadow: none;' + - 'overflow:hidden;' + - 'font-family: ' + UI_FONT.PRIMARY + ';' + - 'font-size: 14px;' + - 'background-color: rgb(' + UI_COLOR.GREY + ');' + - 'color:rgb(255, 255, 255);' + - 'width: ' + thisObject.container.frame.width + 'px;' + - 'height: ' + thisObject.container.frame.height + 'px' - textArea.style.display = 'block' - textArea.focus() - scanDataMines() EDITOR_ON_FOCUS = true } @@ -190,26 +152,6 @@ function newConditionEditor () { thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * 2 thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 - - let textAreaPosition = { - x: 0 - thisObject.container.frame.width / 2, - y: 0 - thisObject.container.frame.height * 3 / 7 + CURRENT_TOP_MARGIN - } - - textAreaPosition = thisObject.container.frame.frameThisPoint(textAreaPosition) - if (thisObject.visible === true) { - let checkPosition = { - x: textAreaPosition.x, - y: textAreaPosition.y - CURRENT_TOP_MARGIN - } - if (thisObject.isVisibleFunction(checkPosition) === false) { - deactivate() - } - } - if (thisObject.visible === true) { - let textAreaDiv = document.getElementById('textAreaDiv') - textAreaDiv.style = 'position:fixed; top:' + textAreaPosition.y + 'px; left:' + textAreaPosition.x + 'px; z-index:1; ' - } } function drawBackground () { diff --git a/FloatingSpace/ConfigEditor.js b/FloatingSpace/ConfigEditor.js index 5ddb74eac..b25331644 100644 --- a/FloatingSpace/ConfigEditor.js +++ b/FloatingSpace/ConfigEditor.js @@ -4,8 +4,6 @@ function newConfigEditor () { let thisObject = { isVisibleFunction: undefined, - iconOK: undefined, - iconNOT_OK: undefined, visible: false, imagePathOK: undefined, imagePathNOT_OK: undefined, @@ -41,29 +39,12 @@ function newConfigEditor () { function finalize () { thisObject.container.finalize() thisObject.container = undefined - thisObject.iconOK = undefined - thisObject.iconNOT_OK = undefined thisObject.payload = undefined thisObject.isVisibleFunction = undefined } function initialize () { - /* Load Images */ - thisObject.iconOK = new Image() - thisObject.iconOK.onload = onImageLoad - - function onImageLoad () { - thisObject.iconNOT_OK = new Image() - thisObject.iconNOT_OK.onload = onImageLoad - - function onImageLoad () { - thisObject.canDrawIcon = true - } - thisObject.iconNOT_OK.src = window.canvasApp.urlPrefix + thisObject.imagePathNOT_OK - } - // thisObject.iconOK.src = window.canvasApp.urlPrefix + thisObject.imagePathOK - // thisObject.icon = thisObject.iconOK // The default value is ON. } function deactivate () { diff --git a/FloatingSpace/FormulaEditor.js b/FloatingSpace/FormulaEditor.js index 0872f1b5f..596f1ba27 100644 --- a/FloatingSpace/FormulaEditor.js +++ b/FloatingSpace/FormulaEditor.js @@ -4,8 +4,6 @@ function newFormulaEditor () { let thisObject = { isVisibleFunction: undefined, - iconOK: undefined, - iconNOT_OK: undefined, visible: false, imagePathOK: undefined, imagePathNOT_OK: undefined, @@ -41,29 +39,12 @@ function newFormulaEditor () { function finalize () { thisObject.container.finalize() thisObject.container = undefined - thisObject.iconOK = undefined - thisObject.iconNOT_OK = undefined thisObject.payload = undefined thisObject.isVisibleFunction = undefined } function initialize () { - /* Load Images */ - thisObject.iconOK = new Image() - thisObject.iconOK.onload = onImageLoad - - function onImageLoad () { - thisObject.iconNOT_OK = new Image() - thisObject.iconNOT_OK.onload = onImageLoad - - function onImageLoad () { - thisObject.canDrawIcon = true - } - thisObject.iconNOT_OK.src = window.canvasApp.urlPrefix + thisObject.imagePathNOT_OK - } - // thisObject.iconOK.src = window.canvasApp.urlPrefix + thisObject.imagePathOK - // thisObject.icon = thisObject.iconOK // The default value is ON. } function deactivate () { diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js new file mode 100644 index 000000000..8f00f9c81 --- /dev/null +++ b/FloatingSpace/Picker.js @@ -0,0 +1,61 @@ + +function newPicker () { + const MODULE_NAME = 'Picker' + + let thisObject = { + container: undefined, + physics: physics, + drawBackground: drawBackground, + drawForeground: drawForeground, + getContainer: getContainer, + finalize: finalize, + initialize: initialize + } + + thisObject.container = newContainer() + thisObject.container.initialize(MODULE_NAME) + thisObject.container.isClickeable = false + thisObject.container.isDraggeable = false + thisObject.container.frame.radius = 0 + thisObject.container.frame.position.x = 0 + thisObject.container.frame.position.y = 0 + thisObject.container.frame.width = 50 + thisObject.container.frame.height = 100 + + let optionsList + return thisObject + + function finalize () { + thisObject.container.finalize() + thisObject.container = undefined + optionsList = undefined + } + + function initialize (pOptionsList, payload) { + optionsList = pOptionsList + } + + function getContainer (point) { + let container + + if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { + return thisObject.container + } + } + + function physics () { + + } + + function drawBackground (pFloatingObject) { + + } + + function drawForeground (pFloatingObject) { + const FONT_SIZE = 15 + + for (let i = 0; i < optionsList.length; i++) { + drawLabel(optionsList[i], 1 / 2, i / optionsList.length, 0, 0, FONT_SIZE, thisObject.container, UI_COLOR.BLACK, undefined, undefined) + } + } +} From 76ae07e3ab505b0900f4350148645bce6982065a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 26 Apr 2020 12:26:03 +0200 Subject: [PATCH 36/55] showing up --- FloatingSpace/ConditionEditor.js | 57 ++++++++++++++++++++++++++++---- FloatingSpace/Picker.js | 9 ++--- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 36735a41e..bfd9147f9 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -32,8 +32,8 @@ function newConditionEditor () { thisObject.container.frame.position.y = 0 let isMouseOver = false - let operator1 - let operator2 + let operatorA = {} + let operatorB = {} return thisObject @@ -64,6 +64,7 @@ function newConditionEditor () { thisObject.payload.uiObject.setErrorMessage('', 0) scanDataMines() + setUpPickers() EDITOR_ON_FOCUS = true } @@ -116,8 +117,16 @@ function newConditionEditor () { selector[dataMineName] = undefined } } - operator1 = JSON.parse(JSON.stringify(selector)) - operator2 = JSON.parse(JSON.stringify(selector)) + operatorA.selector = JSON.parse(JSON.stringify(selector)) + operatorB.selector = JSON.parse(JSON.stringify(selector)) + } + + function setUpPickers () { + operatorA.dataMinePicker = newPicker() + operatorA.dataMinePicker.container.connectToParent(thisObject.container) + operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 + operatorA.dataMinePicker.container.frame.position.y = 0 - operatorA.dataMinePicker.container.frame.height / 2 + operatorA.dataMinePicker.initialize(Object.keys(operatorA.selector)) } function getContainer (point) { @@ -139,6 +148,17 @@ function newConditionEditor () { } function physics () { + thisObjectphysics() + operatorsPhysics() + } + + function operatorsPhysics () { + if (operatorA.dataMinePicker !== undefined) { + operatorA.dataMinePicker.physics() + } + } + + function thisObjectphysics () { if (Math.abs(thisObject.currentRadius - thisObject.targetRadius) >= 0.5) { if (thisObject.currentRadius < thisObject.targetRadius) { thisObject.currentRadius = thisObject.currentRadius + 0.5 @@ -150,11 +170,22 @@ function newConditionEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1.8 * 2 + thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 } function drawBackground () { + thisObjectDrawBackground() + childrenDrawBackground() + } + + function childrenDrawBackground () { + if (operatorA.dataMinePicker !== undefined) { + operatorA.dataMinePicker.drawBackground() + } + } + + function thisObjectDrawBackground () { if (thisObject.visible === true) { let position = { x: 0, @@ -163,7 +194,7 @@ function newConditionEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius * 2 + let radius = thisObject.container.frame.radius * 1 if (radius > 0.5) { browserCanvasContext.beginPath() @@ -180,10 +211,22 @@ function newConditionEditor () { } } } + function drawForeground () { + thisObjectDrawForeground() + childrenDrawForeground() + } + + function childrenDrawForeground () { + if (operatorA.dataMinePicker !== undefined) { + operatorA.dataMinePicker.drawForeground() + } + } + + function thisObjectDrawForeground () { let iconPosition = { x: 0, - y: thisObject.currentRadius * 1.5 + y: thisObject.currentRadius * 1 } iconPosition = thisObject.container.frame.frameThisPoint(iconPosition) diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 8f00f9c81..957c275d2 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -4,6 +4,7 @@ function newPicker () { let thisObject = { container: undefined, + selectedItem: 0, physics: physics, drawBackground: drawBackground, drawForeground: drawForeground, @@ -31,7 +32,7 @@ function newPicker () { optionsList = undefined } - function initialize (pOptionsList, payload) { + function initialize (pOptionsList) { optionsList = pOptionsList } @@ -47,15 +48,15 @@ function newPicker () { } - function drawBackground (pFloatingObject) { + function drawBackground () { } - function drawForeground (pFloatingObject) { + function drawForeground () { const FONT_SIZE = 15 for (let i = 0; i < optionsList.length; i++) { - drawLabel(optionsList[i], 1 / 2, i / optionsList.length, 0, 0, FONT_SIZE, thisObject.container, UI_COLOR.BLACK, undefined, undefined) + drawLabel(optionsList[i], 1 / 2, i / optionsList.length, 0, 0, FONT_SIZE, thisObject.container, UI_COLOR.WHITE, undefined, undefined) } } } From 5e51a494688d329c041202044781071dbd55cbef Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 27 Apr 2020 15:13:48 +0200 Subject: [PATCH 37/55] picker implemented --- FloatingSpace/ConditionEditor.js | 21 ++++++++----- FloatingSpace/Picker.js | 52 +++++++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index bfd9147f9..f3c8c1948 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -49,6 +49,8 @@ function newConditionEditor () { } function deactivate () { + finalizePickers() + if (thisObject.visible === true) { thisObject.visible = false } @@ -64,7 +66,7 @@ function newConditionEditor () { thisObject.payload.uiObject.setErrorMessage('', 0) scanDataMines() - setUpPickers() + initializePickers() EDITOR_ON_FOCUS = true } @@ -121,7 +123,7 @@ function newConditionEditor () { operatorB.selector = JSON.parse(JSON.stringify(selector)) } - function setUpPickers () { + function initializePickers () { operatorA.dataMinePicker = newPicker() operatorA.dataMinePicker.container.connectToParent(thisObject.container) operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 @@ -129,14 +131,19 @@ function newConditionEditor () { operatorA.dataMinePicker.initialize(Object.keys(operatorA.selector)) } + function finalizePickers () { + if (operatorA.dataMinePicker !== undefined) { + operatorA.dataMinePicker.finalize() + operatorA.dataMinePicker = undefined + } + } + function getContainer (point) { let container 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 - triggered. We compensate recognizing this coordinate and returning our container. */ - return thisObject.container + if (operatorA.dataMinePicker !== undefined) { + container = operatorA.dataMinePicker.getContainer(point) + if (container !== undefined) { return container } } if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 957c275d2..410b6c968 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -17,16 +17,21 @@ function newPicker () { thisObject.container.initialize(MODULE_NAME) thisObject.container.isClickeable = false thisObject.container.isDraggeable = false + thisObject.container.isWheelable = true thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 thisObject.container.frame.width = 50 - thisObject.container.frame.height = 100 + thisObject.container.frame.height = 200 let optionsList + let selected = 0 + let onMouseWheelEventSubscriptionId + return thisObject function finalize () { + thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) thisObject.container.finalize() thisObject.container = undefined optionsList = undefined @@ -34,6 +39,7 @@ function newPicker () { function initialize (pOptionsList) { optionsList = pOptionsList + onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } function getContainer (point) { @@ -44,6 +50,21 @@ function newPicker () { } } + function onMouseWheel () { + delta = event.wheelDelta + if (delta > 0) { + delta = -1 + } else { + delta = 1 + } + + selected = selected + delta + if (selected < 0) { selected = 0 } + if (selected > optionsList.length - 1) { + selected = optionsList.length - 1 + } + } + function physics () { } @@ -53,10 +74,33 @@ function newPicker () { } function drawForeground () { - const FONT_SIZE = 15 + const FONT_SIZE = 25 + const VISIBLE_LABELS = 5 + let fontSize + let fontColor - for (let i = 0; i < optionsList.length; i++) { - drawLabel(optionsList[i], 1 / 2, i / optionsList.length, 0, 0, FONT_SIZE, thisObject.container, UI_COLOR.WHITE, undefined, undefined) + for (let i = 0; i < VISIBLE_LABELS; i++) { + let index = i - 2 + selected + let label = '' + if (index >= 0 && index < VISIBLE_LABELS) { + label = optionsList[index] + } + fontColor = UI_COLOR.WHITE + switch (i) { + case 0: fontSize = FONT_SIZE - 15 + break + case 1: fontSize = FONT_SIZE - 8 + break + case 2: fontSize = FONT_SIZE - 0 + fontColor = UI_COLOR.BLACK + break + case 3: fontSize = FONT_SIZE - 8 + break + case 4: fontSize = FONT_SIZE - 15 + break + } + drawLabel(label, 1 / 2, i / VISIBLE_LABELS, 0, 0, fontSize, thisObject.container, fontColor, undefined, undefined) } } } + From 91c39b30ae38bb3e099ecb3cbda6cdcdf327e4a6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 27 Apr 2020 22:27:57 +0200 Subject: [PATCH 38/55] pikers interconnected --- FloatingSpace/ConditionEditor.js | 123 +++++++++++++++++++++++++++++-- FloatingSpace/Picker.js | 41 ++++++++++- SplashScreen.js | 2 +- 3 files changed, 155 insertions(+), 11 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index f3c8c1948..920b4b100 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -124,18 +124,74 @@ function newConditionEditor () { } function initializePickers () { + let properties + let parent + let current + operatorA.dataMinePicker = newPicker() operatorA.dataMinePicker.container.connectToParent(thisObject.container) - operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 - operatorA.dataMinePicker.container.frame.position.y = 0 - operatorA.dataMinePicker.container.frame.height / 2 - operatorA.dataMinePicker.initialize(Object.keys(operatorA.selector)) + operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 - operatorA.dataMinePicker.container.frame.width * 1.5 + operatorA.dataMinePicker.container.frame.position.y = 0 - operatorA.dataMinePicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = operatorA.selector + properties = Object.keys(current) + operatorA.dataMinePicker.initialize(properties) + parent = current + + operatorA.botPicker = newPicker() + operatorA.botPicker.container.connectToParent(thisObject.container) + operatorA.botPicker.container.frame.position.x = 0 - operatorA.botPicker.container.frame.width / 2 - operatorA.botPicker.container.frame.width * 0.5 + operatorA.botPicker.container.frame.position.y = 0 - operatorA.botPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = parent[properties[0]] + properties = Object.keys(current) + operatorA.botPicker.initialize(properties, parent) + parent = current + + operatorA.productPicker = newPicker() + operatorA.productPicker.container.connectToParent(thisObject.container) + operatorA.productPicker.container.frame.position.x = 0 - operatorA.productPicker.container.frame.width / 2 + operatorA.productPicker.container.frame.width * 0.5 + operatorA.productPicker.container.frame.position.y = 0 - operatorA.productPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = parent[properties[0]] + properties = Object.keys(current) + operatorA.productPicker.initialize(properties, parent) + parent = current + + operatorA.propertyPicker = newPicker() + operatorA.propertyPicker.container.connectToParent(thisObject.container) + operatorA.propertyPicker.container.frame.position.x = 0 - operatorA.propertyPicker.container.frame.width / 2 + operatorA.propertyPicker.container.frame.width * 1.5 + operatorA.propertyPicker.container.frame.position.y = 0 - operatorA.propertyPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + current = parent[properties[0]] + properties = Object.keys(current) + operatorA.propertyPicker.initialize(properties, parent) + parent = current + + operatorA.dataMinePicker.eventSuscriptionId = operatorA.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.botPicker.onParentChanged) + operatorA.botPicker.eventSuscriptionId = operatorA.botPicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.productPicker.onParentChanged) + operatorA.productPicker.eventSuscriptionId = operatorA.productPicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.propertyPicker.onParentChanged) } function finalizePickers () { if (operatorA.dataMinePicker !== undefined) { + operatorA.dataMinePicker.container.eventHandler.stopListening(operatorA.dataMinePicker.eventSuscriptionId) operatorA.dataMinePicker.finalize() operatorA.dataMinePicker = undefined } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.container.eventHandler.stopListening(operatorA.botPicker.eventSuscriptionId) + operatorA.botPicker.finalize() + operatorA.botPicker = undefined + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.container.eventHandler.stopListening(operatorA.productPicker.eventSuscriptionId) + operatorA.productPicker.finalize() + operatorA.productPicker = undefined + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.finalize() + operatorA.propertyPicker = undefined + } } function getContainer (point) { @@ -146,6 +202,21 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorA.botPicker !== undefined) { + container = operatorA.botPicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorA.productPicker !== undefined) { + container = operatorA.productPicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorA.propertyPicker !== undefined) { + container = operatorA.propertyPicker.getContainer(point) + if (container !== undefined) { return container } + } + if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { return thisObject.container } else { @@ -159,10 +230,26 @@ function newConditionEditor () { operatorsPhysics() } + function selectionPhysics () { + + } + function operatorsPhysics () { if (operatorA.dataMinePicker !== undefined) { operatorA.dataMinePicker.physics() } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.physics() + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.physics() + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.physics() + } } function thisObjectphysics () { @@ -177,8 +264,8 @@ function newConditionEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 + thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 * 2 + thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 * 2 } function drawBackground () { @@ -190,6 +277,18 @@ function newConditionEditor () { if (operatorA.dataMinePicker !== undefined) { operatorA.dataMinePicker.drawBackground() } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.drawBackground() + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.drawBackground() + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.drawBackground() + } } function thisObjectDrawBackground () { @@ -201,7 +300,7 @@ function newConditionEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius * 1 + let radius = thisObject.container.frame.radius * 2 if (radius > 0.5) { browserCanvasContext.beginPath() @@ -228,6 +327,18 @@ function newConditionEditor () { if (operatorA.dataMinePicker !== undefined) { operatorA.dataMinePicker.drawForeground() } + + if (operatorA.botPicker !== undefined) { + operatorA.botPicker.drawForeground() + } + + if (operatorA.productPicker !== undefined) { + operatorA.productPicker.drawForeground() + } + + if (operatorA.propertyPicker !== undefined) { + operatorA.propertyPicker.drawForeground() + } } function thisObjectDrawForeground () { diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 410b6c968..97beda5a5 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -5,6 +5,8 @@ function newPicker () { let thisObject = { container: undefined, selectedItem: 0, + onParentChanged: onParentChanged, + getSelected: getSelected, physics: physics, drawBackground: drawBackground, drawForeground: drawForeground, @@ -21,11 +23,13 @@ function newPicker () { thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = 50 + thisObject.container.frame.width = 250 thisObject.container.frame.height = 200 let optionsList + let parent let selected = 0 + let lastSelected = 0 let onMouseWheelEventSubscriptionId return thisObject @@ -35,13 +39,31 @@ function newPicker () { thisObject.container.finalize() thisObject.container = undefined optionsList = undefined + parent = undefined } - function initialize (pOptionsList) { + function initialize (pOptionsList, pParent) { optionsList = pOptionsList + parent = pParent onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } + function onParentChanged (event) { + if (event.parent !== undefined) { + parent = event.parent + } + + selected = 0 + let parentKeys = Object.keys(parent) + optionsList = Object.keys(parent[parentKeys[event.selected]]) + + event = { + selected: selected, + parent: parent[parentKeys[event.selected]] + } + thisObject.container.eventHandler.raiseEvent('onParentChanged', event) + } + function getContainer (point) { let container @@ -50,6 +72,10 @@ function newPicker () { } } + function getSelected () { + return optionsList[selected] + } + function onMouseWheel () { delta = event.wheelDelta if (delta > 0) { @@ -63,6 +89,14 @@ function newPicker () { if (selected > optionsList.length - 1) { selected = optionsList.length - 1 } + + if (selected !== lastSelected) { + let event = { + selected: selected + } + thisObject.container.eventHandler.raiseEvent('onParentChanged', event) + lastSelected = selected + } } function physics () { @@ -82,7 +116,7 @@ function newPicker () { for (let i = 0; i < VISIBLE_LABELS; i++) { let index = i - 2 + selected let label = '' - if (index >= 0 && index < VISIBLE_LABELS) { + if (index >= 0 && index < optionsList.length) { label = optionsList[index] } fontColor = UI_COLOR.WHITE @@ -103,4 +137,3 @@ function newPicker () { } } } - diff --git a/SplashScreen.js b/SplashScreen.js index 5fe6da376..4370f934b 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -122,7 +122,7 @@ function newSplashScreen () { fontSize = 35 - title = 'Beta' + title = 'Beta 4' titlePoint = { x: thisObject.container.frame.width / 2 - title.length / 2 * fontSize * FONT_ASPECT_RATIO - 20, From d0ffb72fcc63584fb2597b23bef2873ecf12b81e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Apr 2020 09:03:45 +0200 Subject: [PATCH 39/55] 2 operators --- FloatingSpace/ConditionEditor.js | 192 ++++++++++++++++++++----------- FloatingSpace/Picker.js | 14 ++- 2 files changed, 135 insertions(+), 71 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 920b4b100..96f3c55f6 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -92,18 +92,32 @@ function newConditionEditor () { let productName = loadPropertyFromNodeConfig(product.payload, 'singularVariableName') if (productName === undefined) { continue } let selectorProduct = selectorDataMine[botName] - selectorProduct[productName] = {} + selectorProduct[productName] = { + properties: {} + } if (product.record === undefined) { continue } for (let m = 0; m < product.record.properties.length; m++) { let property = product.record.properties[m] let propertyName = loadPropertyFromNodeConfig(property.payload, 'codeName') let selectorProperty = selectorProduct[productName] + selectorProperty = selectorProperty.properties selectorProperty[propertyName] = {} let possibleValues = loadPropertyFromNodeConfig(property.payload, 'possibleValues') if (possibleValues === undefined) { possibleValues = [] } let selectorPossibleValue = selectorProperty[propertyName] selectorPossibleValue.possibleValues = possibleValues } + let allPossibleTimeFrames = [] + for (let m = 0; m < product.datasets.length; m++) { + let dataset = product.datasets[m] + let validTimeFrames = loadPropertyFromNodeConfig(dataset.payload, 'validTimeFrames') + if (validTimeFrames !== undefined) { + allPossibleTimeFrames = allPossibleTimeFrames.concat(validTimeFrames) + } + } + let selectorValidTimeFrames = selectorProduct[productName] + selectorValidTimeFrames.validTimeFrames = allPossibleTimeFrames + let productKeys = Object.keys(selectorProduct[productName]) if (productKeys.length === 0) { selectorProduct[productName] = undefined @@ -124,73 +138,84 @@ function newConditionEditor () { } function initializePickers () { + initializeOperator(operatorA, -0.5) + initializeOperator(operatorB, 0.5) + } + + function initializeOperator (operator, ySign) { let properties let parent let current - operatorA.dataMinePicker = newPicker() - operatorA.dataMinePicker.container.connectToParent(thisObject.container) - operatorA.dataMinePicker.container.frame.position.x = 0 - operatorA.dataMinePicker.container.frame.width / 2 - operatorA.dataMinePicker.container.frame.width * 1.5 - operatorA.dataMinePicker.container.frame.position.y = 0 - operatorA.dataMinePicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height - current = operatorA.selector + operator.dataMinePicker = newPicker() + operator.dataMinePicker.container.connectToParent(thisObject.container) + operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 1.5 + operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign + current = operator.selector properties = Object.keys(current) - operatorA.dataMinePicker.initialize(properties) + operator.dataMinePicker.initialize(properties) parent = current - operatorA.botPicker = newPicker() - operatorA.botPicker.container.connectToParent(thisObject.container) - operatorA.botPicker.container.frame.position.x = 0 - operatorA.botPicker.container.frame.width / 2 - operatorA.botPicker.container.frame.width * 0.5 - operatorA.botPicker.container.frame.position.y = 0 - operatorA.botPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + operator.botPicker = newPicker() + operator.botPicker.container.connectToParent(thisObject.container) + operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 0.5 + operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) - operatorA.botPicker.initialize(properties, parent) + operator.botPicker.initialize(properties, parent) parent = current - operatorA.productPicker = newPicker() - operatorA.productPicker.container.connectToParent(thisObject.container) - operatorA.productPicker.container.frame.position.x = 0 - operatorA.productPicker.container.frame.width / 2 + operatorA.productPicker.container.frame.width * 0.5 - operatorA.productPicker.container.frame.position.y = 0 - operatorA.productPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + operator.productPicker = newPicker() + operator.productPicker.container.connectToParent(thisObject.container) + operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.5 + operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) - operatorA.productPicker.initialize(properties, parent) + operator.productPicker.initialize(properties, parent) parent = current - operatorA.propertyPicker = newPicker() - operatorA.propertyPicker.container.connectToParent(thisObject.container) - operatorA.propertyPicker.container.frame.position.x = 0 - operatorA.propertyPicker.container.frame.width / 2 + operatorA.propertyPicker.container.frame.width * 1.5 - operatorA.propertyPicker.container.frame.position.y = 0 - operatorA.propertyPicker.container.frame.height / 2 - operatorA.dataMinePicker.container.frame.height + operator.propertyPicker = newPicker() + operator.propertyPicker.container.connectToParent(thisObject.container) + operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.5 + operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] + current = current.properties properties = Object.keys(current) - operatorA.propertyPicker.initialize(properties, parent) + operator.propertyPicker.initialize(properties, parent, 'properties') parent = current - operatorA.dataMinePicker.eventSuscriptionId = operatorA.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.botPicker.onParentChanged) - operatorA.botPicker.eventSuscriptionId = operatorA.botPicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.productPicker.onParentChanged) - operatorA.productPicker.eventSuscriptionId = operatorA.productPicker.container.eventHandler.listenToEvent('onParentChanged', operatorA.propertyPicker.onParentChanged) + operator.dataMinePicker.eventSuscriptionId = operator.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operator.botPicker.onParentChanged) + operator.botPicker.eventSuscriptionId = operator.botPicker.container.eventHandler.listenToEvent('onParentChanged', operator.productPicker.onParentChanged) + operator.productPicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.propertyPicker.onParentChanged) } function finalizePickers () { - if (operatorA.dataMinePicker !== undefined) { - operatorA.dataMinePicker.container.eventHandler.stopListening(operatorA.dataMinePicker.eventSuscriptionId) - operatorA.dataMinePicker.finalize() - operatorA.dataMinePicker = undefined + finalizeOperator(operatorA) + finalizeOperator(operatorB) + } + + function finalizeOperator (operator) { + if (operator.dataMinePicker !== undefined) { + operator.dataMinePicker.container.eventHandler.stopListening(operator.dataMinePicker.eventSuscriptionId) + operator.dataMinePicker.finalize() + operator.dataMinePicker = undefined } - if (operatorA.botPicker !== undefined) { - operatorA.botPicker.container.eventHandler.stopListening(operatorA.botPicker.eventSuscriptionId) - operatorA.botPicker.finalize() - operatorA.botPicker = undefined + if (operator.botPicker !== undefined) { + operator.botPicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) + operator.botPicker.finalize() + operator.botPicker = undefined } - if (operatorA.productPicker !== undefined) { - operatorA.productPicker.container.eventHandler.stopListening(operatorA.productPicker.eventSuscriptionId) - operatorA.productPicker.finalize() - operatorA.productPicker = undefined + if (operator.productPicker !== undefined) { + operator.productPicker.container.eventHandler.stopListening(operator.productPicker.eventSuscriptionId) + operator.productPicker.finalize() + operator.productPicker = undefined } - if (operatorA.propertyPicker !== undefined) { - operatorA.propertyPicker.finalize() - operatorA.propertyPicker = undefined + if (operator.propertyPicker !== undefined) { + operator.propertyPicker.finalize() + operator.propertyPicker = undefined } } @@ -217,6 +242,26 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorB.dataMinePicker !== undefined) { + container = operatorB.dataMinePicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorB.botPicker !== undefined) { + container = operatorB.botPicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorB.productPicker !== undefined) { + container = operatorB.productPicker.getContainer(point) + if (container !== undefined) { return container } + } + + if (operatorB.propertyPicker !== undefined) { + container = operatorB.propertyPicker.getContainer(point) + if (container !== undefined) { return container } + } + if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { return thisObject.container } else { @@ -227,28 +272,29 @@ function newConditionEditor () { function physics () { thisObjectphysics() - operatorsPhysics() + operatorsPhysics(operatorA) + operatorsPhysics(operatorB) } function selectionPhysics () { } - function operatorsPhysics () { - if (operatorA.dataMinePicker !== undefined) { - operatorA.dataMinePicker.physics() + function operatorsPhysics (operator) { + if (operator.dataMinePicker !== undefined) { + operator.dataMinePicker.physics() } - if (operatorA.botPicker !== undefined) { - operatorA.botPicker.physics() + if (operator.botPicker !== undefined) { + operator.botPicker.physics() } - if (operatorA.productPicker !== undefined) { - operatorA.productPicker.physics() + if (operator.productPicker !== undefined) { + operator.productPicker.physics() } - if (operatorA.propertyPicker !== undefined) { - operatorA.propertyPicker.physics() + if (operator.propertyPicker !== undefined) { + operator.propertyPicker.physics() } } @@ -264,8 +310,8 @@ function newConditionEditor () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 - thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 * 2 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 * 2 + thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 * 4 + thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 * 4 } function drawBackground () { @@ -274,20 +320,25 @@ function newConditionEditor () { } function childrenDrawBackground () { - if (operatorA.dataMinePicker !== undefined) { - operatorA.dataMinePicker.drawBackground() + operatorDrawBackground(operatorA) + operatorDrawBackground(operatorB) + } + + function operatorDrawBackground (operator) { + if (operator.dataMinePicker !== undefined) { + operator.dataMinePicker.drawBackground() } - if (operatorA.botPicker !== undefined) { - operatorA.botPicker.drawBackground() + if (operator.botPicker !== undefined) { + operator.botPicker.drawBackground() } - if (operatorA.productPicker !== undefined) { - operatorA.productPicker.drawBackground() + if (operator.productPicker !== undefined) { + operator.productPicker.drawBackground() } - if (operatorA.propertyPicker !== undefined) { - operatorA.propertyPicker.drawBackground() + if (operator.propertyPicker !== undefined) { + operator.propertyPicker.drawBackground() } } @@ -324,20 +375,25 @@ function newConditionEditor () { } function childrenDrawForeground () { - if (operatorA.dataMinePicker !== undefined) { - operatorA.dataMinePicker.drawForeground() + operatorDrawForeground(operatorA) + operatorDrawForeground(operatorB) + } + + function operatorDrawForeground (operator) { + if (operator.dataMinePicker !== undefined) { + operator.dataMinePicker.drawForeground() } - if (operatorA.botPicker !== undefined) { - operatorA.botPicker.drawForeground() + if (operator.botPicker !== undefined) { + operator.botPicker.drawForeground() } - if (operatorA.productPicker !== undefined) { - operatorA.productPicker.drawForeground() + if (operator.productPicker !== undefined) { + operator.productPicker.drawForeground() } - if (operatorA.propertyPicker !== undefined) { - operatorA.propertyPicker.drawForeground() + if (operator.propertyPicker !== undefined) { + operator.propertyPicker.drawForeground() } } diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 97beda5a5..07668f6fc 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -28,6 +28,7 @@ function newPicker () { let optionsList let parent + let propertyName let selected = 0 let lastSelected = 0 let onMouseWheelEventSubscriptionId @@ -42,9 +43,10 @@ function newPicker () { parent = undefined } - function initialize (pOptionsList, pParent) { + function initialize (pOptionsList, pParent, pPropertyName) { optionsList = pOptionsList parent = pParent + propertyName = pPropertyName onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } @@ -55,7 +57,13 @@ function newPicker () { selected = 0 let parentKeys = Object.keys(parent) - optionsList = Object.keys(parent[parentKeys[event.selected]]) + + if (propertyName !== undefined) { + optionsList = parent[parentKeys[event.selected]] + optionsList = Object.keys(optionsList[propertyName]) + } else { + optionsList = Object.keys(parent[parentKeys[event.selected]]) + } event = { selected: selected, @@ -119,7 +127,7 @@ function newPicker () { if (index >= 0 && index < optionsList.length) { label = optionsList[index] } - fontColor = UI_COLOR.WHITE + fontColor = UI_COLOR.LIGHT_GREY switch (i) { case 0: fontSize = FONT_SIZE - 15 break From 431e063326ef5d69fbb93a5ab254350085bf77cb Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Apr 2020 18:04:34 +0200 Subject: [PATCH 40/55] Fucking working finally --- FloatingSpace/ConditionEditor.js | 63 +++++++++++++++++++++++++++----- FloatingSpace/Picker.js | 52 ++++++++++++++++++-------- 2 files changed, 90 insertions(+), 25 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 96f3c55f6..1eec4f729 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -148,45 +148,60 @@ function newConditionEditor () { let current operator.dataMinePicker = newPicker() + operator.dataMinePicker.name = 'Data Mine' operator.dataMinePicker.container.connectToParent(thisObject.container) operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 1.5 operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = operator.selector properties = Object.keys(current) - operator.dataMinePicker.initialize(properties) + operator.dataMinePicker.initialize(properties, current) parent = current operator.botPicker = newPicker() + operator.botPicker.name = 'Bot' operator.botPicker.container.connectToParent(thisObject.container) operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 0.5 operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) - operator.botPicker.initialize(properties, parent) + operator.botPicker.initialize(properties, current, parent) parent = current operator.productPicker = newPicker() + operator.productPicker.name = 'Product' operator.productPicker.container.connectToParent(thisObject.container) operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.5 operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) - operator.productPicker.initialize(properties, parent) + operator.productPicker.initialize(properties, current, parent) parent = current operator.propertyPicker = newPicker() + operator.propertyPicker.name = 'Property' operator.propertyPicker.container.connectToParent(thisObject.container) operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.5 operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] current = current.properties properties = Object.keys(current) - operator.propertyPicker.initialize(properties, parent, 'properties') + operator.propertyPicker.initialize(properties, current, parent, 'properties') parent = current - operator.dataMinePicker.eventSuscriptionId = operator.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operator.botPicker.onParentChanged) - operator.botPicker.eventSuscriptionId = operator.botPicker.container.eventHandler.listenToEvent('onParentChanged', operator.productPicker.onParentChanged) - operator.productPicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.propertyPicker.onParentChanged) + operator.valuePicker = newPicker() + operator.valuePicker.name = 'Value' + operator.valuePicker.container.connectToParent(thisObject.container) + operator.valuePicker.container.frame.position.x = 0 - operator.valuePicker.container.frame.width / 2 + operator.valuePicker.container.frame.width * 2.5 + operator.valuePicker.container.frame.position.y = 0 - operator.valuePicker.container.frame.height / 2 + operator.valuePicker.container.frame.height * ySign + current = parent[properties[0]] + properties = current.possibleValues + operator.valuePicker.initialize(properties, current, parent, 'possibleValues') + parent = current + + operator.botPicker.eventSuscriptionId = operator.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operator.botPicker.onParentChanged) + operator.productPicker.eventSuscriptionId = operator.botPicker.container.eventHandler.listenToEvent('onParentChanged', operator.productPicker.onParentChanged) + operator.propertyPicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.propertyPicker.onParentChanged) + operator.valuePicker.eventSuscriptionId = operator.propertyPicker.container.eventHandler.listenToEvent('onParentChanged', operator.valuePicker.onParentChanged) } function finalizePickers () { @@ -196,19 +211,20 @@ function newConditionEditor () { function finalizeOperator (operator) { if (operator.dataMinePicker !== undefined) { - operator.dataMinePicker.container.eventHandler.stopListening(operator.dataMinePicker.eventSuscriptionId) + operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) operator.dataMinePicker.finalize() operator.dataMinePicker = undefined } if (operator.botPicker !== undefined) { - operator.botPicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) + operator.botPicker.container.eventHandler.stopListening(operator.productPicker.eventSuscriptionId) operator.botPicker.finalize() operator.botPicker = undefined } if (operator.productPicker !== undefined) { - operator.productPicker.container.eventHandler.stopListening(operator.productPicker.eventSuscriptionId) + operator.productPicker.container.eventHandler.stopListening(operator.propertyPicker.eventSuscriptionId) + operator.productPicker.container.eventHandler.stopListening(operator.valuePicker.eventSuscriptionId) operator.productPicker.finalize() operator.productPicker = undefined } @@ -217,6 +233,11 @@ function newConditionEditor () { operator.propertyPicker.finalize() operator.propertyPicker = undefined } + + if (operator.valuePicker !== undefined) { + operator.valuePicker.finalize() + operator.valuePicker = undefined + } } function getContainer (point) { @@ -242,6 +263,11 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorA.valuePicker !== undefined) { + container = operatorA.valuePicker.getContainer(point) + if (container !== undefined) { return container } + } + if (operatorB.dataMinePicker !== undefined) { container = operatorB.dataMinePicker.getContainer(point) if (container !== undefined) { return container } @@ -262,6 +288,11 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorB.valuePicker !== undefined) { + container = operatorB.valuePicker.getContainer(point) + if (container !== undefined) { return container } + } + if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { return thisObject.container } else { @@ -296,6 +327,10 @@ function newConditionEditor () { if (operator.propertyPicker !== undefined) { operator.propertyPicker.physics() } + + if (operator.valuePicker !== undefined) { + operator.valuePicker.physics() + } } function thisObjectphysics () { @@ -340,6 +375,10 @@ function newConditionEditor () { if (operator.propertyPicker !== undefined) { operator.propertyPicker.drawBackground() } + + if (operator.valuePicker !== undefined) { + operator.valuePicker.drawBackground() + } } function thisObjectDrawBackground () { @@ -395,6 +434,10 @@ function newConditionEditor () { if (operator.propertyPicker !== undefined) { operator.propertyPicker.drawForeground() } + + if (operator.valuePicker !== undefined) { + operator.valuePicker.drawForeground() + } } function thisObjectDrawForeground () { diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 07668f6fc..b623719d1 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -28,6 +28,8 @@ function newPicker () { let optionsList let parent + let current + let parentSelected = 0 let propertyName let selected = 0 let lastSelected = 0 @@ -41,10 +43,12 @@ function newPicker () { thisObject.container = undefined optionsList = undefined parent = undefined + current = undefined } - function initialize (pOptionsList, pParent, pPropertyName) { + function initialize (pOptionsList, pCurrent, pParent, pPropertyName) { optionsList = pOptionsList + current = pCurrent parent = pParent propertyName = pPropertyName onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) @@ -54,22 +58,34 @@ function newPicker () { if (event.parent !== undefined) { parent = event.parent } + parentSelected = event.selected selected = 0 - let parentKeys = Object.keys(parent) + let parentKeys - if (propertyName !== undefined) { - optionsList = parent[parentKeys[event.selected]] - optionsList = Object.keys(optionsList[propertyName]) - } else { - optionsList = Object.keys(parent[parentKeys[event.selected]]) + parentKeys = Object.keys(parent) + checkPropertyName() + + function checkPropertyName () { + if (propertyName === undefined) { + current = parent[parentKeys[parentSelected]] + checkArray() + } else { + current = parent[parentKeys[parentSelected]] + current = current[propertyName] + checkArray() + } } - event = { - selected: selected, - parent: parent[parentKeys[event.selected]] + function checkArray () { + if (Array.isArray(current) === false) { + optionsList = Object.keys(current) + } else { + optionsList = current + } } - thisObject.container.eventHandler.raiseEvent('onParentChanged', event) + + raiseEventParentChanged() } function getContainer (point) { @@ -99,14 +115,20 @@ function newPicker () { } if (selected !== lastSelected) { - let event = { - selected: selected - } - thisObject.container.eventHandler.raiseEvent('onParentChanged', event) lastSelected = selected + raiseEventParentChanged() } } + function raiseEventParentChanged () { + let event = { + selected: selected, + parent: current, + propertyName: propertyName + } + thisObject.container.eventHandler.raiseEvent('onParentChanged', event) + } + function physics () { } From e7c5016a97e5da9d59a2474ac6a9440305d029e0 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Apr 2020 18:51:34 +0200 Subject: [PATCH 41/55] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 58 +++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 1eec4f729..d0efcf7cd 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -150,7 +150,7 @@ function newConditionEditor () { operator.dataMinePicker = newPicker() operator.dataMinePicker.name = 'Data Mine' operator.dataMinePicker.container.connectToParent(thisObject.container) - operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 1.5 + operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 2.5 operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = operator.selector properties = Object.keys(current) @@ -160,7 +160,7 @@ function newConditionEditor () { operator.botPicker = newPicker() operator.botPicker.name = 'Bot' operator.botPicker.container.connectToParent(thisObject.container) - operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 0.5 + operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 1.5 operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -170,38 +170,52 @@ function newConditionEditor () { operator.productPicker = newPicker() operator.productPicker.name = 'Product' operator.productPicker.container.connectToParent(thisObject.container) - operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.5 + operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 - operator.productPicker.container.frame.width * 0.5 operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) operator.productPicker.initialize(properties, current, parent) parent = current + let productParent = parent + let productProperties = properties + operator.propertyPicker = newPicker() operator.propertyPicker.name = 'Property' operator.propertyPicker.container.connectToParent(thisObject.container) - operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.5 + operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 0.5 operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign - current = parent[properties[0]] + current = productParent[productProperties[0]] current = current.properties properties = Object.keys(current) - operator.propertyPicker.initialize(properties, current, parent, 'properties') + operator.propertyPicker.initialize(properties, current, productParent, 'properties') parent = current operator.valuePicker = newPicker() operator.valuePicker.name = 'Value' operator.valuePicker.container.connectToParent(thisObject.container) - operator.valuePicker.container.frame.position.x = 0 - operator.valuePicker.container.frame.width / 2 + operator.valuePicker.container.frame.width * 2.5 + operator.valuePicker.container.frame.position.x = 0 - operator.valuePicker.container.frame.width / 2 + operator.valuePicker.container.frame.width * 1.5 operator.valuePicker.container.frame.position.y = 0 - operator.valuePicker.container.frame.height / 2 + operator.valuePicker.container.frame.height * ySign current = parent[properties[0]] properties = current.possibleValues operator.valuePicker.initialize(properties, current, parent, 'possibleValues') parent = current + operator.timeFramePicker = newPicker() + operator.timeFramePicker.name = 'Time Frame' + operator.timeFramePicker.container.connectToParent(thisObject.container) + operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2.5 + operator.timeFramePicker.container.frame.position.y = 0 - operator.timeFramePicker.container.frame.height / 2 + operator.timeFramePicker.container.frame.height * ySign + current = productParent[productProperties[0]] + properties = current.validTimeFrames + operator.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') + parent = current + operator.botPicker.eventSuscriptionId = operator.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operator.botPicker.onParentChanged) operator.productPicker.eventSuscriptionId = operator.botPicker.container.eventHandler.listenToEvent('onParentChanged', operator.productPicker.onParentChanged) operator.propertyPicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.propertyPicker.onParentChanged) operator.valuePicker.eventSuscriptionId = operator.propertyPicker.container.eventHandler.listenToEvent('onParentChanged', operator.valuePicker.onParentChanged) + operator.timeFramePicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.timeFramePicker.onParentChanged) } function finalizePickers () { @@ -224,12 +238,13 @@ function newConditionEditor () { if (operator.productPicker !== undefined) { operator.productPicker.container.eventHandler.stopListening(operator.propertyPicker.eventSuscriptionId) - operator.productPicker.container.eventHandler.stopListening(operator.valuePicker.eventSuscriptionId) + operator.productPicker.container.eventHandler.stopListening(operator.timeFramePicker.eventSuscriptionId) operator.productPicker.finalize() operator.productPicker = undefined } if (operator.propertyPicker !== undefined) { + operator.propertyPicker.container.eventHandler.stopListening(operator.valuePicker.eventSuscriptionId) operator.propertyPicker.finalize() operator.propertyPicker = undefined } @@ -238,6 +253,11 @@ function newConditionEditor () { operator.valuePicker.finalize() operator.valuePicker = undefined } + + if (operator.timeFramePicker !== undefined) { + operator.timeFramePicker.finalize() + operator.timeFramePicker = undefined + } } function getContainer (point) { @@ -268,6 +288,11 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorA.timeFramePicker !== undefined) { + container = operatorA.timeFramePicker.getContainer(point) + if (container !== undefined) { return container } + } + if (operatorB.dataMinePicker !== undefined) { container = operatorB.dataMinePicker.getContainer(point) if (container !== undefined) { return container } @@ -293,6 +318,11 @@ function newConditionEditor () { if (container !== undefined) { return container } } + if (operatorB.timeFramePicker !== undefined) { + container = operatorB.timeFramePicker.getContainer(point) + if (container !== undefined) { return container } + } + if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { return thisObject.container } else { @@ -331,6 +361,10 @@ function newConditionEditor () { if (operator.valuePicker !== undefined) { operator.valuePicker.physics() } + + if (operator.timeFramePicker !== undefined) { + operator.timeFramePicker.physics() + } } function thisObjectphysics () { @@ -379,6 +413,10 @@ function newConditionEditor () { if (operator.valuePicker !== undefined) { operator.valuePicker.drawBackground() } + + if (operator.timeFramePicker !== undefined) { + operator.timeFramePicker.drawBackground() + } } function thisObjectDrawBackground () { @@ -438,6 +476,10 @@ function newConditionEditor () { if (operator.valuePicker !== undefined) { operator.valuePicker.drawForeground() } + + if (operator.timeFramePicker !== undefined) { + operator.timeFramePicker.drawForeground() + } } function thisObjectDrawForeground () { From 5e6517040b3dde149fb854e29799d64d76293647 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 28 Apr 2020 19:14:57 +0200 Subject: [PATCH 42/55] operation picker --- FloatingSpace/ConditionEditor.js | 53 ++++++++++++++++++++++++++------ FloatingSpace/Picker.js | 2 +- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index d0efcf7cd..576352ccb 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -32,6 +32,7 @@ function newConditionEditor () { thisObject.container.frame.position.y = 0 let isMouseOver = false + let operationPicker let operatorA = {} let operatorB = {} @@ -42,6 +43,10 @@ function newConditionEditor () { thisObject.container = undefined thisObject.payload = undefined thisObject.isVisibleFunction = undefined + + operationPicker = undefined + operatorA = undefined + operatorB = undefined } function initialize () { @@ -138,8 +143,16 @@ function newConditionEditor () { } function initializePickers () { - initializeOperator(operatorA, -0.5) - initializeOperator(operatorB, 0.5) + initializeOperator(operatorA, -1) + initializeOperator(operatorB, 1) + + operationPicker = newPicker() + operationPicker.name = 'Data Mine' + operationPicker.container.connectToParent(thisObject.container) + operationPicker.container.frame.position.x = 0 - operationPicker.container.frame.width / 2 + operationPicker.container.frame.position.y = 0 - operationPicker.container.frame.height / 2 + current = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal Than'] + operationPicker.initialize(current, current) } function initializeOperator (operator, ySign) { @@ -150,7 +163,7 @@ function newConditionEditor () { operator.dataMinePicker = newPicker() operator.dataMinePicker.name = 'Data Mine' operator.dataMinePicker.container.connectToParent(thisObject.container) - operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 2.5 + operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 2 operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = operator.selector properties = Object.keys(current) @@ -160,7 +173,7 @@ function newConditionEditor () { operator.botPicker = newPicker() operator.botPicker.name = 'Bot' operator.botPicker.container.connectToParent(thisObject.container) - operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 1.5 + operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 1 operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -170,7 +183,7 @@ function newConditionEditor () { operator.productPicker = newPicker() operator.productPicker.name = 'Product' operator.productPicker.container.connectToParent(thisObject.container) - operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 - operator.productPicker.container.frame.width * 0.5 + operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 - operator.productPicker.container.frame.width * 0 operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -183,7 +196,7 @@ function newConditionEditor () { operator.propertyPicker = newPicker() operator.propertyPicker.name = 'Property' operator.propertyPicker.container.connectToParent(thisObject.container) - operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 0.5 + operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1 operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = productParent[productProperties[0]] current = current.properties @@ -194,8 +207,8 @@ function newConditionEditor () { operator.valuePicker = newPicker() operator.valuePicker.name = 'Value' operator.valuePicker.container.connectToParent(thisObject.container) - operator.valuePicker.container.frame.position.x = 0 - operator.valuePicker.container.frame.width / 2 + operator.valuePicker.container.frame.width * 1.5 - operator.valuePicker.container.frame.position.y = 0 - operator.valuePicker.container.frame.height / 2 + operator.valuePicker.container.frame.height * ySign + operator.valuePicker.container.frame.position.x = 0 - operator.valuePicker.container.frame.width / 2 + operator.valuePicker.container.frame.position.y = 0 - operator.valuePicker.container.frame.height / 2 + operator.valuePicker.container.frame.height * 1 current = parent[properties[0]] properties = current.possibleValues operator.valuePicker.initialize(properties, current, parent, 'possibleValues') @@ -204,7 +217,7 @@ function newConditionEditor () { operator.timeFramePicker = newPicker() operator.timeFramePicker.name = 'Time Frame' operator.timeFramePicker.container.connectToParent(thisObject.container) - operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2.5 + operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2 operator.timeFramePicker.container.frame.position.y = 0 - operator.timeFramePicker.container.frame.height / 2 + operator.timeFramePicker.container.frame.height * ySign current = productParent[productProperties[0]] properties = current.validTimeFrames @@ -224,6 +237,11 @@ function newConditionEditor () { } function finalizeOperator (operator) { + if (operationPicker !== undefined) { + operationPicker.finalize() + operationPicker = undefined + } + if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) operator.dataMinePicker.finalize() @@ -263,6 +281,11 @@ function newConditionEditor () { function getContainer (point) { let container if (thisObject.visible === true) { + if (operationPicker !== undefined) { + container = operationPicker.getContainer(point) + if (container !== undefined) { return container } + } + if (operatorA.dataMinePicker !== undefined) { container = operatorA.dataMinePicker.getContainer(point) if (container !== undefined) { return container } @@ -335,6 +358,10 @@ function newConditionEditor () { thisObjectphysics() operatorsPhysics(operatorA) operatorsPhysics(operatorB) + + if (operationPicker !== undefined) { + operationPicker.physics() + } } function selectionPhysics () { @@ -391,6 +418,10 @@ function newConditionEditor () { function childrenDrawBackground () { operatorDrawBackground(operatorA) operatorDrawBackground(operatorB) + + if (operationPicker !== undefined) { + operationPicker.drawBackground() + } } function operatorDrawBackground (operator) { @@ -454,6 +485,10 @@ function newConditionEditor () { function childrenDrawForeground () { operatorDrawForeground(operatorA) operatorDrawForeground(operatorB) + + if (operationPicker !== undefined) { + operationPicker.drawForeground() + } } function operatorDrawForeground (operator) { diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index b623719d1..0fab62c85 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -24,7 +24,7 @@ function newPicker () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 thisObject.container.frame.width = 250 - thisObject.container.frame.height = 200 + thisObject.container.frame.height = 150 let optionsList let parent From 33076a3f322c4365a18b596c7965e13709bb4817 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Apr 2020 08:07:58 +0200 Subject: [PATCH 43/55] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 215 ++++++++++++++++++++++--------- 1 file changed, 151 insertions(+), 64 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 576352ccb..cca40d35b 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -33,8 +33,8 @@ function newConditionEditor () { let isMouseOver = false let operationPicker - let operatorA = {} - let operatorB = {} + let operatorA + let operatorB return thisObject @@ -70,6 +70,8 @@ function newConditionEditor () { thisObject.currentRadius = 0 thisObject.payload.uiObject.setErrorMessage('', 0) + operatorA = {} + operatorB = {} scanDataMines() initializePickers() EDITOR_ON_FOCUS = true @@ -151,8 +153,10 @@ function newConditionEditor () { operationPicker.container.connectToParent(thisObject.container) operationPicker.container.frame.position.x = 0 - operationPicker.container.frame.width / 2 operationPicker.container.frame.position.y = 0 - operationPicker.container.frame.height / 2 - current = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal Than'] + current = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] operationPicker.initialize(current, current) + + operationPicker.eventSuscriptionId = operationPicker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged) } function initializeOperator (operator, ySign) { @@ -169,6 +173,7 @@ function newConditionEditor () { properties = Object.keys(current) operator.dataMinePicker.initialize(properties, current) parent = current + operator.dataMinePicker.visible = true operator.botPicker = newPicker() operator.botPicker.name = 'Bot' @@ -179,6 +184,7 @@ function newConditionEditor () { properties = Object.keys(current) operator.botPicker.initialize(properties, current, parent) parent = current + operator.botPicker.visible = true operator.productPicker = newPicker() operator.productPicker.name = 'Product' @@ -189,6 +195,7 @@ function newConditionEditor () { properties = Object.keys(current) operator.productPicker.initialize(properties, current, parent) parent = current + operator.productPicker.visible = true let productParent = parent let productProperties = properties @@ -203,6 +210,7 @@ function newConditionEditor () { properties = Object.keys(current) operator.propertyPicker.initialize(properties, current, productParent, 'properties') parent = current + operator.propertyPicker.visible = true operator.valuePicker = newPicker() operator.valuePicker.name = 'Value' @@ -213,6 +221,7 @@ function newConditionEditor () { properties = current.possibleValues operator.valuePicker.initialize(properties, current, parent, 'possibleValues') parent = current + operator.valuePicker.visible = false operator.timeFramePicker = newPicker() operator.timeFramePicker.name = 'Time Frame' @@ -223,6 +232,7 @@ function newConditionEditor () { properties = current.validTimeFrames operator.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') parent = current + operator.timeFramePicker.visible = true operator.botPicker.eventSuscriptionId = operator.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operator.botPicker.onParentChanged) operator.productPicker.eventSuscriptionId = operator.botPicker.container.eventHandler.listenToEvent('onParentChanged', operator.productPicker.onParentChanged) @@ -234,14 +244,16 @@ function newConditionEditor () { function finalizePickers () { finalizeOperator(operatorA) finalizeOperator(operatorB) - } - function finalizeOperator (operator) { + operationPicker.container.eventHandler.stopListening(operationPicker.eventSuscriptionId) + if (operationPicker !== undefined) { operationPicker.finalize() operationPicker = undefined } + } + function finalizeOperator (operator) { if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) operator.dataMinePicker.finalize() @@ -278,6 +290,24 @@ function newConditionEditor () { } } + function onParentChanged (event) { + if (event.selected === 4) { // this means Equal To + operatorA.valuePicker.visible = true + operatorB.dataMinePicker.visible = false + operatorB.botPicker.visible = false + operatorB.productPicker.visible = false + operatorB.propertyPicker.visible = false + operatorB.timeFramePicker.visible = false + } else { + operatorA.valuePicker.visible = false + operatorB.dataMinePicker.visible = true + operatorB.botPicker.visible = true + operatorB.productPicker.visible = true + operatorB.propertyPicker.visible = true + operatorB.timeFramePicker.visible = true + } + } + function getContainer (point) { let container if (thisObject.visible === true) { @@ -286,64 +316,91 @@ function newConditionEditor () { if (container !== undefined) { return container } } - if (operatorA.dataMinePicker !== undefined) { - container = operatorA.dataMinePicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorA !== undefined) { + if (operatorA.dataMinePicker !== undefined) { + if (operatorA.dataMinePicker.visible === true) { + container = operatorA.dataMinePicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorA.botPicker !== undefined) { - container = operatorA.botPicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorA.botPicker !== undefined) { + if (operatorA.botPicker.visible === true) { + container = operatorA.botPicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorA.productPicker !== undefined) { - container = operatorA.productPicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorA.productPicker !== undefined) { + if (operatorA.productPicker.visible === true) { + container = operatorA.productPicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorA.propertyPicker !== undefined) { - container = operatorA.propertyPicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorA.propertyPicker !== undefined) { + if (operatorA.propertyPicker.visible === true) { + container = operatorA.propertyPicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorA.valuePicker !== undefined) { - container = operatorA.valuePicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorA.valuePicker !== undefined) { + if (operatorA.valuePicker.visible === true) { + container = operatorA.valuePicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorA.timeFramePicker !== undefined) { - container = operatorA.timeFramePicker.getContainer(point) - if (container !== undefined) { return container } + if (operatorA.timeFramePicker !== undefined) { + if (operatorA.timeFramePicker.visible === true) { + container = operatorA.timeFramePicker.getContainer(point) + if (container !== undefined) { return container } + } + } } + if (operatorB !== undefined) { + if (operatorB.dataMinePicker !== undefined) { + if (operatorB.dataMinePicker.visible === true) { + container = operatorB.dataMinePicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorB.dataMinePicker !== undefined) { - container = operatorB.dataMinePicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorB.botPicker !== undefined) { + if (operatorB.botPicker.visible === true) { + container = operatorB.botPicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorB.botPicker !== undefined) { - container = operatorB.botPicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorB.productPicker !== undefined) { + if (operatorB.productPicker.visible === true) { + container = operatorB.productPicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorB.productPicker !== undefined) { - container = operatorB.productPicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorB.propertyPicker !== undefined) { + if (operatorB.propertyPicker.visible === true) { + container = operatorB.propertyPicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorB.propertyPicker !== undefined) { - container = operatorB.propertyPicker.getContainer(point) - if (container !== undefined) { return container } - } + if (operatorB.valuePicker !== undefined) { + if (operatorB.valuePicker.visible === true) { + container = operatorB.valuePicker.getContainer(point) + if (container !== undefined) { return container } + } + } - if (operatorB.valuePicker !== undefined) { - container = operatorB.valuePicker.getContainer(point) - if (container !== undefined) { return container } - } - - if (operatorB.timeFramePicker !== undefined) { - container = operatorB.timeFramePicker.getContainer(point) - if (container !== undefined) { return container } + if (operatorB.timeFramePicker !== undefined) { + if (operatorB.timeFramePicker.visible === true) { + container = operatorB.timeFramePicker.getContainer(point) + if (container !== undefined) { return container } + } + } } if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { @@ -369,6 +426,8 @@ function newConditionEditor () { } function operatorsPhysics (operator) { + if (operator === undefined) { return } + if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.physics() } @@ -425,28 +484,42 @@ function newConditionEditor () { } function operatorDrawBackground (operator) { + if (operator === undefined) { return } + if (operator.dataMinePicker !== undefined) { - operator.dataMinePicker.drawBackground() + if (operator.dataMinePicker.visible === true) { + operator.dataMinePicker.drawBackground() + } } if (operator.botPicker !== undefined) { - operator.botPicker.drawBackground() + if (operator.botPicker.visible === true) { + operator.botPicker.drawBackground() + } } if (operator.productPicker !== undefined) { - operator.productPicker.drawBackground() + if (operator.productPicker.visible === true) { + operator.productPicker.drawBackground() + } } if (operator.propertyPicker !== undefined) { - operator.propertyPicker.drawBackground() + if (operator.propertyPicker.visible === true) { + operator.propertyPicker.drawBackground() + } } if (operator.valuePicker !== undefined) { - operator.valuePicker.drawBackground() + if (operator.valuePicker.visible === true) { + operator.valuePicker.drawBackground() + } } if (operator.timeFramePicker !== undefined) { - operator.timeFramePicker.drawBackground() + if (operator.timeFramePicker.visible === true) { + operator.timeFramePicker.drawBackground() + } } } @@ -492,28 +565,42 @@ function newConditionEditor () { } function operatorDrawForeground (operator) { + if (operator === undefined) { return } + if (operator.dataMinePicker !== undefined) { - operator.dataMinePicker.drawForeground() + if (operator.dataMinePicker.visible === true) { + operator.dataMinePicker.drawForeground() + } } if (operator.botPicker !== undefined) { - operator.botPicker.drawForeground() + if (operator.botPicker.visible === true) { + operator.botPicker.drawForeground() + } } if (operator.productPicker !== undefined) { - operator.productPicker.drawForeground() + if (operator.productPicker.visible === true) { + operator.productPicker.drawForeground() + } } if (operator.propertyPicker !== undefined) { - operator.propertyPicker.drawForeground() + if (operator.propertyPicker.visible === true) { + operator.propertyPicker.drawForeground() + } } if (operator.valuePicker !== undefined) { - operator.valuePicker.drawForeground() + if (operator.valuePicker.visible === true) { + operator.valuePicker.drawForeground() + } } if (operator.timeFramePicker !== undefined) { - operator.timeFramePicker.drawForeground() + if (operator.timeFramePicker.visible === true) { + operator.timeFramePicker.drawForeground() + } } } From 2eb284c8c74f7ac69b074a67437cedfb258862bc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Apr 2020 09:53:45 +0200 Subject: [PATCH 44/55] toCode implemented --- FloatingSpace/ConditionEditor.js | 50 +++++++++++++++++++++++++++++++- FloatingSpace/Picker.js | 5 ++++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index cca40d35b..19c8f2fa0 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -54,6 +54,7 @@ function newConditionEditor () { } function deactivate () { + convertToCode() finalizePickers() if (thisObject.visible === true) { @@ -62,6 +63,50 @@ function newConditionEditor () { EDITOR_ON_FOCUS = false } + function convertToCode () { + if (operatorA === undefined || operatorB === undefined || operationPicker === undefined) { return } + + // chart.at01hs.bollingerSubChannel.previous.previous.slope=== "Extreme" + let code = '' + + code = code + 'chart.at' + operatorA.timeFramePicker.getValue().replace('-', '') + code = code + '.' + operatorA.productPicker.getValue() + code = code + '.' + operatorA.propertyPicker.getValue() + + switch (operationPicker.getValue()) { + case 'Greater Than': { + code = code + ' > ' + break + } + 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 (operationPicker.getValue() === 'Equal To') { + code = code + '"' + operatorA.valuePicker.getValue() + '"' + } else { + code = code + 'chart.at' + operatorB.timeFramePicker.getValue().replace('-', '') + code = code + '.' + operatorB.productPicker.getValue() + code = code + '.' + operatorB.propertyPicker.getValue() + } + + thisObject.payload.node.code = code + } + function activate (payload) { thisObject.visible = true thisObject.payload = payload @@ -245,15 +290,18 @@ function newConditionEditor () { finalizeOperator(operatorA) finalizeOperator(operatorB) - operationPicker.container.eventHandler.stopListening(operationPicker.eventSuscriptionId) + operatorA = undefined + operatorB = undefined if (operationPicker !== undefined) { + operationPicker.container.eventHandler.stopListening(operationPicker.eventSuscriptionId) operationPicker.finalize() operationPicker = undefined } } function finalizeOperator (operator) { + if (operator === undefined) { return } if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) operator.dataMinePicker.finalize() diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 0fab62c85..45e4143d2 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -5,6 +5,7 @@ function newPicker () { let thisObject = { container: undefined, selectedItem: 0, + getValue: getValue, onParentChanged: onParentChanged, getSelected: getSelected, physics: physics, @@ -54,6 +55,10 @@ function newPicker () { onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } + function getValue () { + return optionsList[selected] + } + function onParentChanged (event) { if (event.parent !== undefined) { parent = event.parent From 90d8b4861395c0e8449aa115d9537a27cd60da8a Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Apr 2020 12:09:03 +0200 Subject: [PATCH 45/55] deactivation fixed --- FloatingSpace/ConditionEditor.js | 81 ++++++---------------------- FloatingSpace/UiObject.js | 2 +- FloatingSpace/UiObjectConstructor.js | 8 +-- Frame.js | 2 +- 4 files changed, 21 insertions(+), 72 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 19c8f2fa0..18c570352 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -7,9 +7,6 @@ function newConditionEditor () { visible: false, imagePathOK: undefined, imagePathNOT_OK: undefined, - rawRadius: undefined, - targetRadius: undefined, - currentRadius: undefined, container: undefined, payload: undefined, deactivate: deactivate, @@ -23,13 +20,12 @@ function newConditionEditor () { } thisObject.container = newContainer() - thisObject.container.initialize(MODULE_NAME) + thisObject.container.initialize(MODULE_NAME, 'Circle') thisObject.container.isClickeable = false thisObject.container.isDraggeable = false thisObject.container.detectMouseOver = false - thisObject.container.frame.radius = 0 - thisObject.container.frame.position.x = 0 - thisObject.container.frame.position.y = 0 + thisObject.container.frame.radius = 750 + thisObject.container.frame.containerName = MODULE_NAME let isMouseOver = false let operationPicker @@ -110,9 +106,6 @@ function newConditionEditor () { function activate (payload) { thisObject.visible = true thisObject.payload = payload - thisObject.rawRadius = 8 - thisObject.targetRadius = thisObject.container.frame.radius - thisObject.currentRadius = 0 thisObject.payload.uiObject.setErrorMessage('', 0) operatorA = {} @@ -451,7 +444,7 @@ function newConditionEditor () { } } - if (thisObject.container.frame.isThisPointHere(point, true, false) === true) { + if (thisObject.container.frame.isThisPointHere(point, true) === true) { return thisObject.container } else { return undefined @@ -502,19 +495,7 @@ function newConditionEditor () { } function thisObjectphysics () { - if (Math.abs(thisObject.currentRadius - thisObject.targetRadius) >= 0.5) { - if (thisObject.currentRadius < thisObject.targetRadius) { - thisObject.currentRadius = thisObject.currentRadius + 0.5 - } else { - thisObject.currentRadius = thisObject.currentRadius - 0.5 - } - } - thisObject.container.frame.position.x = 0 - thisObject.container.frame.position.y = 0 - - thisObject.container.frame.width = thisObject.container.frame.radius * 1 * 2 * 4 - thisObject.container.frame.height = thisObject.container.frame.radius * 1 * 2 * 4 } function drawBackground () { @@ -580,21 +561,19 @@ function newConditionEditor () { position = thisObject.container.frame.frameThisPoint(position) - let radius = thisObject.container.frame.radius * 2 + let radius = thisObject.container.frame.radius - if (radius > 0.5) { - browserCanvasContext.beginPath() - browserCanvasContext.arc(position.x, position.y, radius * 1.3 + 3, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + 1 + ')' - browserCanvasContext.fill() + browserCanvasContext.beginPath() + browserCanvasContext.arc(position.x, position.y, radius + 3, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', ' + 1 + ')' + browserCanvasContext.fill() - browserCanvasContext.beginPath() - browserCanvasContext.arc(position.x, position.y, radius * 1.3, 0, Math.PI * 2, true) - browserCanvasContext.closePath() - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')' - browserCanvasContext.fill() - } + browserCanvasContext.beginPath() + browserCanvasContext.arc(position.x, position.y, radius, 0, Math.PI * 2, true) + browserCanvasContext.closePath() + browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')' + browserCanvasContext.fill() } } @@ -653,36 +632,6 @@ function newConditionEditor () { } function thisObjectDrawForeground () { - let iconPosition = { - x: 0, - y: thisObject.currentRadius * 1 - } - iconPosition = thisObject.container.frame.frameThisPoint(iconPosition) - - /* Menu Item */ - - if (thisObject.canDrawIcon === true && thisObject.currentRadius > 1) { - browserCanvasContext.drawImage(thisObject.icon, iconPosition.x - thisObject.currentRadius, iconPosition.y - thisObject.currentRadius, thisObject.currentRadius * 2, thisObject.currentRadius * 2) - - /* Menu Label */ - - let label = 'Code looks good!' - let labelPoint - let fontSize = 10 - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - - if (label !== undefined && thisObject.currentRadius >= thisObject.targetRadius) { - labelPoint = { - x: iconPosition.x + thisObject.currentRadius + 10, - y: iconPosition.y + fontSize * FONT_ASPECT_RATIO - } - - browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' - browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) - } - } } } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 574fd4a4c..8cc05dbf8 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -265,7 +265,7 @@ function newUiObject () { if (container !== undefined) { return container } } - if (thisObject.container.frame.isThisPointHere(point, true) === true) { + if (thisObject.container.frame.isThisPointHere(point, true, true) === true) { return thisObject.container } else { return undefined diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 6c02e1d2c..0be9a5a24 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -412,26 +412,26 @@ function newUiObjectConstructor () { if (nodeDefinition.editors.config === true) { uiObject.configEditor = newConfigEditor() uiObject.configEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.configEditor.initialize() uiObject.configEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + uiObject.configEditor.initialize() } if (nodeDefinition.editors.code === true) { uiObject.codeEditor = newCodeEditor() uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.codeEditor.initialize() uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + uiObject.codeEditor.initialize() } if (nodeDefinition.editors.formula === true) { uiObject.formulaEditor = newFormulaEditor() uiObject.formulaEditor.isVisibleFunction = uiObject.isVisibleFunction - uiObject.formulaEditor.initialize() uiObject.formulaEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) + uiObject.formulaEditor.initialize() } if (nodeDefinition.editors.condition === true) { uiObject.conditionEditor = newConditionEditor() uiObject.conditionEditor.isVisibleFunction = uiObject.isVisibleFunction + uiObject.conditionEditor.container.connectToParent(uiObject.container, false, false, false, true, false, false, false, false) uiObject.conditionEditor.initialize() - uiObject.conditionEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false) } } if (nodeDefinition.addLeftIcons === true) { diff --git a/Frame.js b/Frame.js index ea2b7ab12..7e27a2242 100644 --- a/Frame.js +++ b/Frame.js @@ -211,7 +211,7 @@ function newFrame () { /* Now we check if the resulting point is whin the current Frame. */ if (isNaN(checkPoint.x) || isNaN(checkPoint.y)) { return false } if (thisObject.type === 'Circle') { - let distance = Math.sqrt(Math.pow(thisObject.position.x - point.x, 2) + Math.pow(thisObject.position.y - point.y, 2)) + let distance = Math.sqrt(Math.pow(thisObject.position.x - checkPoint.x, 2) + Math.pow(thisObject.position.y - checkPoint.y, 2)) if (distance < thisObject.radius) { return true From 75155da9c7fb202c08f5ee6757d799d8b31a65c7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Apr 2020 19:56:17 +0200 Subject: [PATCH 46/55] loadFrom Code v1 working --- FloatingSpace/ConditionEditor.js | 111 ++++++++++++++++++++++++++++--- FloatingSpace/Picker.js | 11 ++- 2 files changed, 111 insertions(+), 11 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 18c570352..677d1f20e 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -65,11 +65,11 @@ function newConditionEditor () { // chart.at01hs.bollingerSubChannel.previous.previous.slope=== "Extreme" let code = '' - code = code + 'chart.at' + operatorA.timeFramePicker.getValue().replace('-', '') - code = code + '.' + operatorA.productPicker.getValue() - code = code + '.' + operatorA.propertyPicker.getValue() + code = code + 'chart.at' + operatorA.timeFramePicker.getSelected().replace('-', '') + code = code + '.' + operatorA.productPicker.getSelected() + code = code + '.' + operatorA.propertyPicker.getSelected() - switch (operationPicker.getValue()) { + switch (operationPicker.getSelected()) { case 'Greater Than': { code = code + ' > ' break @@ -92,12 +92,12 @@ function newConditionEditor () { } } - if (operationPicker.getValue() === 'Equal To') { - code = code + '"' + operatorA.valuePicker.getValue() + '"' + if (operationPicker.getSelected() === 'Equal To') { + code = code + '"' + operatorA.valuePicker.getSelected() + '"' } else { - code = code + 'chart.at' + operatorB.timeFramePicker.getValue().replace('-', '') - code = code + '.' + operatorB.productPicker.getValue() - code = code + '.' + operatorB.propertyPicker.getValue() + code = code + 'chart.at' + operatorB.timeFramePicker.getSelected().replace('-', '') + code = code + '.' + operatorB.productPicker.getSelected() + code = code + '.' + operatorB.propertyPicker.getSelected() } thisObject.payload.node.code = code @@ -112,9 +112,102 @@ function newConditionEditor () { operatorB = {} scanDataMines() initializePickers() + + loadFromCode() EDITOR_ON_FOCUS = true } + function loadFromCode () { + if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } + + let code = thisObject.payload.node.code + let codeA + let codeB + + if (code.indexOf(' > ') > 0) { + let codeArray = code.split(' > ') + codeA = codeArray[0] + codeB = codeArray[1] + } + + if (code.indexOf(' < ') > 0) { + let codeArray = code.split(' < ') + codeA = codeArray[0] + codeB = codeArray[1] + } + + if (code.indexOf(' >= ') > 0) { + let codeArray = code.split(' >= ') + codeA = codeArray[0] + codeB = codeArray[1] + } + + if (code.indexOf(' <= ') > 0) { + let codeArray = code.split(' <= ') + codeA = codeArray[0] + codeB = codeArray[1] + } + + if (code.indexOf(' === ') > 0) { + let codeArray = code.split(' === ') + codeA = codeArray[0] + codeB = codeArray[1] + } + + let codeAArray = codeA.split('.') + let codeBArray = codeB.split('.') + + if (code.indexOf(' === ') > 0) { + } else { + updatePickers(operatorA, codeAArray) + updatePickers(operatorB, codeBArray) + + function updatePickers (operator, codeArray) { + let codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) + let codeProduct = codeArray[2] + let codeProperty = codeArray[3] + let codeValue = '' + + let dataMines = Object.keys(operator.selector) + for (let i = 0; i < dataMines.length; i++) { + let dataMine = dataMines[i] + let dataMineObject = operator.selector[dataMine] + let bots = Object.keys(dataMineObject) + for (let j = 0; j < bots.length; j++) { + let bot = bots[j] + let botObject = dataMineObject[bot] + let products = Object.keys(botObject) + for (let k = 0; k < products.length; k++) { + let product = products[k] + let productObject = botObject[product] + if (codeProduct === product) { + operator.dataMinePicker.setSelected(dataMines, operator.selector, undefined, i) + operator.botPicker.setSelected(bots, dataMineObject, operator.selector, j) + operator.productPicker.setSelected(products, botObject, dataMineObject, k) + let properties = Object.keys(productObject.properties) + for (let m = 0; m < properties.length; m++) { + let property = properties[m] + let propertyObject = productObject.properties[property] + if (codeProperty === property) { + operator.propertyPicker.setSelected(properties, productObject.properties, botObject, m) + let values = propertyObject.possibleValues + for (let n = 0; n < values.length; n++) { + let value = values[n] + let valueObject = propertyObject[value] + if (codeValue === value) { + operator.valuePicker.setSelected(propevaluesrties, propertyObject, productObject, n) + } + } + } + } + } + } + } + } + } + } + } + function scanDataMines () { let selector = {} diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 45e4143d2..1d3d0d15d 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -5,9 +5,9 @@ function newPicker () { let thisObject = { container: undefined, selectedItem: 0, - getValue: getValue, onParentChanged: onParentChanged, getSelected: getSelected, + setSelected: setSelected, physics: physics, drawBackground: drawBackground, drawForeground: drawForeground, @@ -55,10 +55,17 @@ function newPicker () { onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) } - function getValue () { + function getSelected () { return optionsList[selected] } + function setSelected (pOptionsList, pCurrent, pParent, pSelected) { + optionsList = pOptionsList + current = pCurrent + parent = pParent + selected = pSelected + } + function onParentChanged (event) { if (event.parent !== undefined) { parent = event.parent From 5e82b6867722957abb5977204de2f1763353aea2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 29 Apr 2020 20:09:50 +0200 Subject: [PATCH 47/55] Look and Feel --- FloatingSpace/Picker.js | 27 +++++++++++++++++++-------- Utilities/RoundedCornersBackground.js | 5 +++-- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 1d3d0d15d..47e3246b9 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -25,7 +25,7 @@ function newPicker () { thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 thisObject.container.frame.width = 250 - thisObject.container.frame.height = 150 + thisObject.container.frame.height = 120 let optionsList let parent @@ -150,10 +150,11 @@ function newPicker () { } function drawForeground () { - const FONT_SIZE = 25 + const FONT_SIZE = 22 const VISIBLE_LABELS = 5 let fontSize let fontColor + let opacity for (let i = 0; i < VISIBLE_LABELS; i++) { let index = i - 2 + selected @@ -163,19 +164,29 @@ function newPicker () { } fontColor = UI_COLOR.LIGHT_GREY switch (i) { - case 0: fontSize = FONT_SIZE - 15 + case 0: + fontSize = FONT_SIZE - 12 + opacity = 0.4 break - case 1: fontSize = FONT_SIZE - 8 + case 1: + fontSize = FONT_SIZE - 8 + opacity = 0.5 break - case 2: fontSize = FONT_SIZE - 0 + case 2: + fontSize = FONT_SIZE - 0 fontColor = UI_COLOR.BLACK + opacity = 1 break - case 3: fontSize = FONT_SIZE - 8 + case 3: + fontSize = FONT_SIZE - 8 + opacity = 0.5 break - case 4: fontSize = FONT_SIZE - 15 + case 4: + fontSize = FONT_SIZE - 12 + opacity = 0.4 break } - drawLabel(label, 1 / 2, i / VISIBLE_LABELS, 0, 0, fontSize, thisObject.container, fontColor, undefined, undefined) + drawLabel(label, 1 / 2, i / VISIBLE_LABELS, 0, 0, fontSize, thisObject.container, fontColor, undefined, undefined, opacity) } } } diff --git a/Utilities/RoundedCornersBackground.js b/Utilities/RoundedCornersBackground.js index e21100bf3..825400009 100644 --- a/Utilities/RoundedCornersBackground.js +++ b/Utilities/RoundedCornersBackground.js @@ -105,10 +105,11 @@ function roundedCornersBackground (params) { browserCanvasContext.stroke() } -function drawLabel (label, xFactor, yFactor, xOffset, yOffset, fontSize, container, fontColor, noFrameX, noFrameY) { +function drawLabel (label, xFactor, yFactor, xOffset, yOffset, fontSize, container, fontColor, noFrameX, noFrameY, opacity) { if (label === undefined) { return } if (fontColor === undefined) { fontColor = UI_COLOR.WHITE } let fontOffset = label.length * fontSize * FONT_ASPECT_RATIO + 10 + if (opacity === undefined) { opacity = 1 } let labelPoint = { x: container.frame.width * xFactor + xOffset - fontOffset / 2, @@ -126,7 +127,7 @@ function drawLabel (label, xFactor, yFactor, xOffset, yOffset, fontSize, contain } browserCanvasContext.font = fontSize + 'px ' + UI_FONT.PRIMARY - browserCanvasContext.fillStyle = 'rgba(' + fontColor + ', 1)' + browserCanvasContext.fillStyle = 'rgba(' + fontColor + ', ' + opacity + ')' browserCanvasContext.fillText(label, labelPoint.x, labelPoint.y) } From 81b217ffa4fdd89f069fe954d3900686c2d8a5b1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Apr 2020 09:54:56 +0200 Subject: [PATCH 48/55] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 677d1f20e..1d6498455 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -49,6 +49,20 @@ function newConditionEditor () { } + function activate (payload) { + thisObject.visible = true + thisObject.payload = payload + thisObject.payload.uiObject.setErrorMessage('', 0) + + operatorA = {} + operatorB = {} + scanDataMines() + initializePickers() + + loadFromCode() + EDITOR_ON_FOCUS = true + } + function deactivate () { convertToCode() finalizePickers() @@ -103,20 +117,6 @@ function newConditionEditor () { thisObject.payload.node.code = code } - function activate (payload) { - thisObject.visible = true - thisObject.payload = payload - thisObject.payload.uiObject.setErrorMessage('', 0) - - operatorA = {} - operatorB = {} - scanDataMines() - initializePickers() - - loadFromCode() - EDITOR_ON_FOCUS = true - } - function loadFromCode () { if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } @@ -200,6 +200,14 @@ function newConditionEditor () { } } } + let timeFrames = productObject.validTimeFrames + for (let m = 0; m < timeFrames.length; m++) { + let timeFrame = timeFrames[m] + let timeFrameObject = productObject.validTimeFrames[timeFrame] + if (codeTimeFrame === timeFrame) { + operator.timeFramePicker.setSelected(timeFrames, productObject, botObject, m) + } + } } } } From aaa0e57f8775ca7982721813e2eab34c2e159357 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Apr 2020 10:42:15 +0200 Subject: [PATCH 49/55] values working --- FloatingSpace/ConditionEditor.js | 92 ++++++++++++++++---------------- FloatingSpace/Picker.js | 17 ++++-- 2 files changed, 60 insertions(+), 49 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 1d6498455..e4222013e 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -128,85 +128,87 @@ function newConditionEditor () { let codeArray = code.split(' > ') codeA = codeArray[0] codeB = codeArray[1] + operationPicker.setSelected(undefined, undefined, undefined, 0) } if (code.indexOf(' < ') > 0) { let codeArray = code.split(' < ') codeA = codeArray[0] codeB = codeArray[1] + operationPicker.setSelected(undefined, undefined, undefined, 1) } if (code.indexOf(' >= ') > 0) { let codeArray = code.split(' >= ') codeA = codeArray[0] codeB = codeArray[1] + operationPicker.setSelected(undefined, undefined, undefined, 2) } if (code.indexOf(' <= ') > 0) { let codeArray = code.split(' <= ') codeA = codeArray[0] codeB = codeArray[1] + operationPicker.setSelected(undefined, undefined, undefined, 3) } if (code.indexOf(' === ') > 0) { let codeArray = code.split(' === ') codeA = codeArray[0] codeB = codeArray[1] + operationPicker.setSelected(undefined, undefined, undefined, 4) } let codeAArray = codeA.split('.') let codeBArray = codeB.split('.') - if (code.indexOf(' === ') > 0) { - } else { - updatePickers(operatorA, codeAArray) - updatePickers(operatorB, codeBArray) + updatePickers(operatorA, codeAArray) + updatePickers(operatorB, codeBArray) - function updatePickers (operator, codeArray) { - let codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) - let codeProduct = codeArray[2] - let codeProperty = codeArray[3] - let codeValue = '' + function updatePickers (operator, codeArray) { + let codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) + let codeProduct = codeArray[2] + let codeProperty = codeArray[3] + let codeValue = codeBArray[0].replace('"', '').replace('"', '') - let dataMines = Object.keys(operator.selector) - for (let i = 0; i < dataMines.length; i++) { - let dataMine = dataMines[i] - let dataMineObject = operator.selector[dataMine] - let bots = Object.keys(dataMineObject) - for (let j = 0; j < bots.length; j++) { - let bot = bots[j] - let botObject = dataMineObject[bot] - let products = Object.keys(botObject) - for (let k = 0; k < products.length; k++) { - let product = products[k] - let productObject = botObject[product] - if (codeProduct === product) { - operator.dataMinePicker.setSelected(dataMines, operator.selector, undefined, i) - operator.botPicker.setSelected(bots, dataMineObject, operator.selector, j) - operator.productPicker.setSelected(products, botObject, dataMineObject, k) - let properties = Object.keys(productObject.properties) - for (let m = 0; m < properties.length; m++) { - let property = properties[m] - let propertyObject = productObject.properties[property] - if (codeProperty === property) { - operator.propertyPicker.setSelected(properties, productObject.properties, botObject, m) - let values = propertyObject.possibleValues - for (let n = 0; n < values.length; n++) { - let value = values[n] - let valueObject = propertyObject[value] - if (codeValue === value) { - operator.valuePicker.setSelected(propevaluesrties, propertyObject, productObject, n) - } + let dataMines = Object.keys(operator.selector) + for (let i = 0; i < dataMines.length; i++) { + let dataMine = dataMines[i] + let dataMineObject = operator.selector[dataMine] + let bots = Object.keys(dataMineObject) + for (let j = 0; j < bots.length; j++) { + let bot = bots[j] + let botObject = dataMineObject[bot] + let products = Object.keys(botObject) + for (let k = 0; k < products.length; k++) { + let product = products[k] + let productObject = botObject[product] + if (codeProduct === product) { + operator.dataMinePicker.setSelected(dataMines, operator.selector, undefined, i) + operator.botPicker.setSelected(bots, dataMineObject, operator.selector, j) + operator.productPicker.setSelected(products, botObject, dataMineObject, k) + let properties = Object.keys(productObject.properties) + for (let m = 0; m < properties.length; m++) { + let property = properties[m] + let propertyObject = productObject.properties[property] + if (codeProperty === property) { + operator.propertyPicker.setSelected(properties, productObject.properties, botObject, m) + let values = propertyObject.possibleValues + for (let n = 0; n < values.length; n++) { + let value = values[n] + let valueObject = propertyObject[value] + if (codeValue === value) { + operator.valuePicker.setSelected(values, propertyObject, productObject, n) } } } - let timeFrames = productObject.validTimeFrames - for (let m = 0; m < timeFrames.length; m++) { - let timeFrame = timeFrames[m] - let timeFrameObject = productObject.validTimeFrames[timeFrame] - if (codeTimeFrame === timeFrame) { - operator.timeFramePicker.setSelected(timeFrames, productObject, botObject, m) - } + } + let timeFrames = productObject.validTimeFrames + for (let m = 0; m < timeFrames.length; m++) { + let timeFrame = timeFrames[m] + let timeFrameObject = productObject.validTimeFrames[timeFrame] + if (codeTimeFrame === timeFrame) { + operator.timeFramePicker.setSelected(timeFrames, productObject, botObject, m) } } } diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 47e3246b9..9cfc32b67 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -60,10 +60,19 @@ function newPicker () { } function setSelected (pOptionsList, pCurrent, pParent, pSelected) { - optionsList = pOptionsList - current = pCurrent - parent = pParent - selected = pSelected + if (pOptionsList !== undefined) { + optionsList = pOptionsList + } + if (pCurrent !== undefined) { + current = pCurrent + } + if (pParent !== undefined) { + parent = pParent + } + if (pSelected !== undefined) { + selected = pSelected + } + raiseEventParentChanged() } function onParentChanged (event) { From e3c7ffc35c1386f37b9fe37bf74b08cc899c27bc Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Apr 2020 12:39:37 +0200 Subject: [PATCH 50/55] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 91 +++++++++++++++++++++++++++++--- 1 file changed, 85 insertions(+), 6 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index e4222013e..fa1876491 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -81,6 +81,7 @@ function newConditionEditor () { code = code + 'chart.at' + operatorA.timeFramePicker.getSelected().replace('-', '') code = code + '.' + operatorA.productPicker.getSelected() + insertWhen(operatorA) code = code + '.' + operatorA.propertyPicker.getSelected() switch (operationPicker.getSelected()) { @@ -111,10 +112,39 @@ function newConditionEditor () { } else { code = code + 'chart.at' + operatorB.timeFramePicker.getSelected().replace('-', '') code = code + '.' + operatorB.productPicker.getSelected() + insertWhen(operatorB) code = code + '.' + operatorB.propertyPicker.getSelected() } thisObject.payload.node.code = code + + function insertWhen (operator) { + switch (operator.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 loadFromCode () { @@ -305,10 +335,19 @@ function newConditionEditor () { let parent let current + operator.whenPicker = newPicker() + operator.whenPicker.name = 'When' + operator.whenPicker.container.connectToParent(thisObject.container) + operator.whenPicker.container.frame.position.x = 0 - operator.whenPicker.container.frame.width / 2 - operator.whenPicker.container.frame.width * 0.5 + operator.whenPicker.container.frame.position.y = 0 - operator.whenPicker.container.frame.height / 2 + operator.whenPicker.container.frame.height * ySign + current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] + operator.whenPicker.initialize(current, current) + operator.whenPicker.visible = true + operator.dataMinePicker = newPicker() operator.dataMinePicker.name = 'Data Mine' operator.dataMinePicker.container.connectToParent(thisObject.container) - operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 2 + operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 2.5 operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = operator.selector properties = Object.keys(current) @@ -319,7 +358,7 @@ function newConditionEditor () { operator.botPicker = newPicker() operator.botPicker.name = 'Bot' operator.botPicker.container.connectToParent(thisObject.container) - operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 1 + operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 1.5 operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -330,7 +369,7 @@ function newConditionEditor () { operator.productPicker = newPicker() operator.productPicker.name = 'Product' operator.productPicker.container.connectToParent(thisObject.container) - operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 - operator.productPicker.container.frame.width * 0 + operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.5 operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -344,7 +383,7 @@ function newConditionEditor () { operator.propertyPicker = newPicker() operator.propertyPicker.name = 'Property' operator.propertyPicker.container.connectToParent(thisObject.container) - operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1 + operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.5 operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = productParent[productProperties[0]] current = current.properties @@ -367,7 +406,7 @@ function newConditionEditor () { operator.timeFramePicker = newPicker() operator.timeFramePicker.name = 'Time Frame' operator.timeFramePicker.container.connectToParent(thisObject.container) - operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2 + operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2.5 operator.timeFramePicker.container.frame.position.y = 0 - operator.timeFramePicker.container.frame.height / 2 + operator.timeFramePicker.container.frame.height * ySign current = productParent[productProperties[0]] properties = current.validTimeFrames @@ -398,6 +437,12 @@ function newConditionEditor () { function finalizeOperator (operator) { if (operator === undefined) { return } + + if (operator.whenPicker !== undefined) { + operator.whenPicker.finalize() + operator.whenPicker = undefined + } + if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) operator.dataMinePicker.finalize() @@ -435,8 +480,11 @@ function newConditionEditor () { } function onParentChanged (event) { - if (event.selected === 4) { // this means Equal To + if (event.selected === 4) { + // this means Equal To + operatorA.valuePicker.visible = true + operatorB.whenPicker.visible = false operatorB.dataMinePicker.visible = false operatorB.botPicker.visible = false operatorB.productPicker.visible = false @@ -444,6 +492,7 @@ function newConditionEditor () { operatorB.timeFramePicker.visible = false } else { operatorA.valuePicker.visible = false + operatorB.whenPicker.visible = true operatorB.dataMinePicker.visible = true operatorB.botPicker.visible = true operatorB.productPicker.visible = true @@ -461,6 +510,13 @@ function newConditionEditor () { } if (operatorA !== undefined) { + if (operatorA.whenPicker !== undefined) { + if (operatorA.whenPicker.visible === true) { + container = operatorA.whenPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + if (operatorA.dataMinePicker !== undefined) { if (operatorA.dataMinePicker.visible === true) { container = operatorA.dataMinePicker.getContainer(point) @@ -504,6 +560,13 @@ function newConditionEditor () { } } if (operatorB !== undefined) { + if (operatorB.whenPicker !== undefined) { + if (operatorB.whenPicker.visible === true) { + container = operatorB.whenPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + if (operatorB.dataMinePicker !== undefined) { if (operatorB.dataMinePicker.visible === true) { container = operatorB.dataMinePicker.getContainer(point) @@ -572,6 +635,10 @@ function newConditionEditor () { function operatorsPhysics (operator) { if (operator === undefined) { return } + if (operator.whenPicker !== undefined) { + operator.whenPicker.physics() + } + if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.physics() } @@ -618,6 +685,12 @@ function newConditionEditor () { function operatorDrawBackground (operator) { if (operator === undefined) { return } + if (operator.whenPicker !== undefined) { + if (operator.whenPicker.visible === true) { + operator.whenPicker.drawBackground() + } + } + if (operator.dataMinePicker !== undefined) { if (operator.dataMinePicker.visible === true) { operator.dataMinePicker.drawBackground() @@ -697,6 +770,12 @@ function newConditionEditor () { function operatorDrawForeground (operator) { if (operator === undefined) { return } + if (operator.whenPicker !== undefined) { + if (operator.whenPicker.visible === true) { + operator.whenPicker.drawForeground() + } + } + if (operator.dataMinePicker !== undefined) { if (operator.dataMinePicker.visible === true) { operator.dataMinePicker.drawForeground() From 35006152748ab369614390ad3ac073aa5d7dc018 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Apr 2020 12:59:23 +0200 Subject: [PATCH 51/55] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index fa1876491..66d9f1289 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -198,7 +198,33 @@ function newConditionEditor () { function updatePickers (operator, codeArray) { let codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) let codeProduct = codeArray[2] - let codeProperty = codeArray[3] + + /* Parse When */ + let propertyDisplacement = 0 + let codeWhen = 'Current' + if (codeArray[3] === 'previous') { + propertyDisplacement++ + codeWhen = '1 Previous' + } + if (codeArray[4] === 'previous') { + propertyDisplacement++ + codeWhen = '2 Previous' + } + if (codeArray[5] === 'previous') { + propertyDisplacement++ + codeWhen = '3 Previous' + } + if (codeArray[6] === 'previous') { + propertyDisplacement++ + codeWhen = '4 Previous' + } + if (codeArray[7] === 'previous') { + propertyDisplacement++ + codeWhen = '5 Previous' + } + operator.whenPicker.setSelected(undefined, undefined, undefined, propertyDisplacement) + + let codeProperty = codeArray[3 + propertyDisplacement] let codeValue = codeBArray[0].replace('"', '').replace('"', '') let dataMines = Object.keys(operator.selector) From b024d110d75de02c5978d1062b20bd11b4ae5e5f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Apr 2020 19:23:24 +0200 Subject: [PATCH 52/55] Update Picker.js --- FloatingSpace/Picker.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 9cfc32b67..703e193c1 100644 --- a/FloatingSpace/Picker.js +++ b/FloatingSpace/Picker.js @@ -21,12 +21,14 @@ function newPicker () { thisObject.container.isClickeable = false thisObject.container.isDraggeable = false thisObject.container.isWheelable = true + thisObject.container.detectMouseOver = true thisObject.container.frame.radius = 0 thisObject.container.frame.position.x = 0 thisObject.container.frame.position.y = 0 thisObject.container.frame.width = 250 thisObject.container.frame.height = 120 + let isMouseOver let optionsList let parent let current @@ -35,11 +37,15 @@ function newPicker () { let selected = 0 let lastSelected = 0 let onMouseWheelEventSubscriptionId + let onMouseOverEventSubscriptionId + let onMouseNotOverEventSubscriptionId return thisObject function finalize () { thisObject.container.eventHandler.stopListening(onMouseWheelEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseOverEventSubscriptionId) + thisObject.container.eventHandler.stopListening(onMouseNotOverEventSubscriptionId) thisObject.container.finalize() thisObject.container = undefined optionsList = undefined @@ -53,6 +59,16 @@ function newPicker () { parent = pParent propertyName = pPropertyName onMouseWheelEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel) + onMouseOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseOver', onMouseOver) + onMouseNotOverEventSubscriptionId = thisObject.container.eventHandler.listenToEvent('onMouseNotOver', onMouseNotOver) + } + + function onMouseOver (event) { + isMouseOver = true + } + + function onMouseNotOver () { + isMouseOver = false } function getSelected () { @@ -195,7 +211,10 @@ function newPicker () { opacity = 0.4 break } - drawLabel(label, 1 / 2, i / VISIBLE_LABELS, 0, 0, fontSize, thisObject.container, fontColor, undefined, undefined, opacity) + + if (i === 2 || isMouseOver === true) { + drawLabel(label, 1 / 2, i / VISIBLE_LABELS, 0, 0, fontSize, thisObject.container, fontColor, undefined, undefined, opacity) + } } } } From 7f33925786b43fc5157e86f368e22420ca7b7669 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 30 Apr 2020 19:59:46 +0200 Subject: [PATCH 53/55] Algebraic --- FloatingSpace/ConditionEditor.js | 58 ++++++++++++++++++++++++++++---- FloatingSpace/Picker.js | 12 +++---- 2 files changed, 58 insertions(+), 12 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 66d9f1289..6029b184f 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -364,16 +364,25 @@ function newConditionEditor () { operator.whenPicker = newPicker() operator.whenPicker.name = 'When' operator.whenPicker.container.connectToParent(thisObject.container) - operator.whenPicker.container.frame.position.x = 0 - operator.whenPicker.container.frame.width / 2 - operator.whenPicker.container.frame.width * 0.5 + operator.whenPicker.container.frame.position.x = 0 - operator.whenPicker.container.frame.width / 2 - operator.whenPicker.container.frame.width * 1.0 operator.whenPicker.container.frame.position.y = 0 - operator.whenPicker.container.frame.height / 2 + operator.whenPicker.container.frame.height * ySign current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] operator.whenPicker.initialize(current, current) operator.whenPicker.visible = true + operator.algebraicPicker = newPicker() + operator.algebraicPicker.name = 'Algebraic' + operator.algebraicPicker.container.connectToParent(thisObject.container) + operator.algebraicPicker.container.frame.position.x = 0 - operator.algebraicPicker.container.frame.width / 2 + operator.algebraicPicker.container.frame.width * 3.0 + operator.algebraicPicker.container.frame.position.y = 0 - operator.algebraicPicker.container.frame.height / 2 + operator.algebraicPicker.container.frame.height * ySign + current = ['+ - * /', 'Plus', 'Minus', 'Times', 'Divided by'] + operator.algebraicPicker.initialize(current, current) + operator.algebraicPicker.visible = true + operator.dataMinePicker = newPicker() operator.dataMinePicker.name = 'Data Mine' operator.dataMinePicker.container.connectToParent(thisObject.container) - operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 2.5 + operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 3.0 operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = operator.selector properties = Object.keys(current) @@ -384,7 +393,7 @@ function newConditionEditor () { operator.botPicker = newPicker() operator.botPicker.name = 'Bot' operator.botPicker.container.connectToParent(thisObject.container) - operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 1.5 + operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 2.0 operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -395,7 +404,7 @@ function newConditionEditor () { operator.productPicker = newPicker() operator.productPicker.name = 'Product' operator.productPicker.container.connectToParent(thisObject.container) - operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.5 + operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.0 operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = parent[properties[0]] properties = Object.keys(current) @@ -409,7 +418,7 @@ function newConditionEditor () { operator.propertyPicker = newPicker() operator.propertyPicker.name = 'Property' operator.propertyPicker.container.connectToParent(thisObject.container) - operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.5 + operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.0 operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign current = productParent[productProperties[0]] current = current.properties @@ -432,7 +441,7 @@ function newConditionEditor () { operator.timeFramePicker = newPicker() operator.timeFramePicker.name = 'Time Frame' operator.timeFramePicker.container.connectToParent(thisObject.container) - operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2.5 + operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2.0 operator.timeFramePicker.container.frame.position.y = 0 - operator.timeFramePicker.container.frame.height / 2 + operator.timeFramePicker.container.frame.height * ySign current = productParent[productProperties[0]] properties = current.validTimeFrames @@ -469,6 +478,11 @@ function newConditionEditor () { operator.whenPicker = undefined } + if (operator.algebraicPicker !== undefined) { + operator.algebraicPicker.finalize() + operator.algebraicPicker = undefined + } + if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) operator.dataMinePicker.finalize() @@ -511,6 +525,7 @@ function newConditionEditor () { operatorA.valuePicker.visible = true operatorB.whenPicker.visible = false + operatorB.algebraicPicker.visible = false operatorB.dataMinePicker.visible = false operatorB.botPicker.visible = false operatorB.productPicker.visible = false @@ -519,6 +534,7 @@ function newConditionEditor () { } else { operatorA.valuePicker.visible = false operatorB.whenPicker.visible = true + operatorB.algebraicPicker.visible = true operatorB.dataMinePicker.visible = true operatorB.botPicker.visible = true operatorB.productPicker.visible = true @@ -543,6 +559,13 @@ function newConditionEditor () { } } + if (operatorA.algebraicPicker !== undefined) { + if (operatorA.algebraicPicker.visible === true) { + container = operatorA.algebraicPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + if (operatorA.dataMinePicker !== undefined) { if (operatorA.dataMinePicker.visible === true) { container = operatorA.dataMinePicker.getContainer(point) @@ -593,6 +616,13 @@ function newConditionEditor () { } } + if (operatorB.algebraicPicker !== undefined) { + if (operatorB.algebraicPicker.visible === true) { + container = operatorB.algebraicPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + if (operatorB.dataMinePicker !== undefined) { if (operatorB.dataMinePicker.visible === true) { container = operatorB.dataMinePicker.getContainer(point) @@ -665,6 +695,10 @@ function newConditionEditor () { operator.whenPicker.physics() } + if (operator.algebraicPicker !== undefined) { + operator.algebraicPicker.physics() + } + if (operator.dataMinePicker !== undefined) { operator.dataMinePicker.physics() } @@ -717,6 +751,12 @@ function newConditionEditor () { } } + if (operator.algebraicPicker !== undefined) { + if (operator.algebraicPicker.visible === true) { + operator.algebraicPicker.drawBackground() + } + } + if (operator.dataMinePicker !== undefined) { if (operator.dataMinePicker.visible === true) { operator.dataMinePicker.drawBackground() @@ -802,6 +842,12 @@ function newConditionEditor () { } } + if (operator.algebraicPicker !== undefined) { + if (operator.algebraicPicker.visible === true) { + operator.algebraicPicker.drawForeground() + } + } + if (operator.dataMinePicker !== undefined) { if (operator.dataMinePicker.visible === true) { operator.dataMinePicker.drawForeground() diff --git a/FloatingSpace/Picker.js b/FloatingSpace/Picker.js index 703e193c1..885b01c11 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 = 250 + thisObject.container.frame.width = 200 thisObject.container.frame.height = 120 let isMouseOver @@ -175,7 +175,7 @@ function newPicker () { } function drawForeground () { - const FONT_SIZE = 22 + const FONT_SIZE = 20 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 - 12 + fontSize = FONT_SIZE - 10 opacity = 0.4 break case 1: - fontSize = FONT_SIZE - 8 + fontSize = FONT_SIZE - 5 opacity = 0.5 break case 2: @@ -203,11 +203,11 @@ function newPicker () { opacity = 1 break case 3: - fontSize = FONT_SIZE - 8 + fontSize = FONT_SIZE - 5 opacity = 0.5 break case 4: - fontSize = FONT_SIZE - 12 + fontSize = FONT_SIZE - 10 opacity = 0.4 break } From 5b31251e82641b22c93b40b64c80820560e0eaa2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 2 May 2020 08:18:12 +0200 Subject: [PATCH 54/55] Update ConditionEditor.js --- FloatingSpace/ConditionEditor.js | 1030 +++++++++++++++--------------- 1 file changed, 506 insertions(+), 524 deletions(-) diff --git a/FloatingSpace/ConditionEditor.js b/FloatingSpace/ConditionEditor.js index 6029b184f..f0b2cbef7 100644 --- a/FloatingSpace/ConditionEditor.js +++ b/FloatingSpace/ConditionEditor.js @@ -28,9 +28,8 @@ function newConditionEditor () { thisObject.container.frame.containerName = MODULE_NAME let isMouseOver = false - let operationPicker - let operatorA - let operatorB + let conditionStructure + let scanResult return thisObject @@ -40,9 +39,8 @@ function newConditionEditor () { thisObject.payload = undefined thisObject.isVisibleFunction = undefined - operationPicker = undefined - operatorA = undefined - operatorB = undefined + conditionStructure = undefined + scanResult = undefined } function initialize () { @@ -54,11 +52,12 @@ function newConditionEditor () { thisObject.payload = payload thisObject.payload.uiObject.setErrorMessage('', 0) - operatorA = {} - operatorB = {} - scanDataMines() - initializePickers() + conditionStructure = { + code: thisObject.payload.node.code, + orOperands: [] + } + scanDataMines() loadFromCode() EDITOR_ON_FOCUS = true } @@ -67,135 +66,252 @@ function newConditionEditor () { convertToCode() finalizePickers() + conditionStructure = undefined + if (thisObject.visible === true) { thisObject.visible = false } EDITOR_ON_FOCUS = false } - function convertToCode () { - if (operatorA === undefined || operatorB === undefined || operationPicker === undefined) { return } - - // chart.at01hs.bollingerSubChannel.previous.previous.slope=== "Extreme" - let code = '' - - code = code + 'chart.at' + operatorA.timeFramePicker.getSelected().replace('-', '') - code = code + '.' + operatorA.productPicker.getSelected() - insertWhen(operatorA) - code = code + '.' + operatorA.propertyPicker.getSelected() - - switch (operationPicker.getSelected()) { - case 'Greater Than': { - code = code + ' > ' - break - } - 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 (operationPicker.getSelected() === 'Equal To') { - code = code + '"' + operatorA.valuePicker.getSelected() + '"' - } else { - code = code + 'chart.at' + operatorB.timeFramePicker.getSelected().replace('-', '') - code = code + '.' + operatorB.productPicker.getSelected() - insertWhen(operatorB) - code = code + '.' + operatorB.propertyPicker.getSelected() - } - - thisObject.payload.node.code = code - - function insertWhen (operator) { - switch (operator.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 loadFromCode () { if (thisObject.payload.node.code === undefined || thisObject.payload.node.code === '') { return } - let code = thisObject.payload.node.code - let codeA - let codeB - - if (code.indexOf(' > ') > 0) { - let codeArray = code.split(' > ') - codeA = codeArray[0] - codeB = codeArray[1] - operationPicker.setSelected(undefined, undefined, undefined, 0) + /* LOGICAL ORs */ + let orArray = conditionStructure.code.split(' || ') + for (let j = 0; j < orArray.length; j++) { + let logicOperand = { + code: orArray[j], + index: j, + comparison: {} + } + checkComparison(logicOperand, j) + conditionStructure.orOperands.push(logicOperand) } - if (code.indexOf(' < ') > 0) { - let codeArray = code.split(' < ') - codeA = codeArray[0] - codeB = codeArray[1] - operationPicker.setSelected(undefined, undefined, undefined, 1) + function checkComparison (logicOperand) { + /* We are going to decompose the code into 2 comparison operators */ + logicOperand.comparison.operandA = { index: 0} + logicOperand.comparison.operandB = { index: 1} + + 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.operatorIndex = 0 + } + + 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.operatorIndex = 1 + } + + 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.operatorIndex = 2 + } + + 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.operatorIndex = 3 + } + + 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.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) } - if (code.indexOf(' >= ') > 0) { - let codeArray = code.split(' >= ') - codeA = codeArray[0] - codeB = codeArray[1] - operationPicker.setSelected(undefined, undefined, undefined, 2) + function checkAlgebra (logicOperand, comparisonOperand) { + comparisonOperand.algebra = { + operandA: { index: 0}, + operandB: { index: 1} + } + + /* The default situation is that there is no Algebraic operation, meaning we will setup a Algebraic operation only with operandA */ + comparisonOperand.algebra.operandA.code = comparisonOperand.code + comparisonOperand.algebra.operandB.code = '' + comparisonOperand.algebra.operator = ' ... ' + comparisonOperand.algebra.operatorIndex = 0 + + if (comparisonOperand.code.indexOf(' + ') > 0) { + let codeArray = logicOperand.code.split(' + ') + comparisonOperand.algebra.operandA.code = codeArray[0] + comparisonOperand.algebra.operandB.code = codeArray[1] + comparisonOperand.algebra.operator = ' + ' + comparisonOperand.algebra.operatorIndex = 1 + } + + if (comparisonOperand.code.indexOf(' - ') > 0) { + let codeArray = logicOperand.code.split(' - ') + comparisonOperand.algebra.operandA.code = codeArray[0] + comparisonOperand.algebra.operandB.code = codeArray[1] + comparisonOperand.algebra.operator = ' - ' + comparisonOperand.algebra.operatorIndex = 2 + } + + if (comparisonOperand.code.indexOf(' * ') > 0) { + let codeArray = logicOperand.code.split(' * ') + comparisonOperand.algebra.operandA.code = codeArray[0] + comparisonOperand.algebra.operandB.code = codeArray[1] + comparisonOperand.algebra.operator = ' * ' + comparisonOperand.algebra.operatorIndex = 3 + } + + if (comparisonOperand.code.indexOf(' / ') > 0) { + let codeArray = logicOperand.code.split(' / ') + comparisonOperand.algebra.operandA.code = codeArray[0] + comparisonOperand.algebra.operandB.code = codeArray[1] + comparisonOperand.algebra.operator = ' / ' + comparisonOperand.algebra.operatorIndex = 4 + } + + initializePickersSet(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) + initializePickersSet(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) + updatePickers(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) + updatePickers(logicOperand, comparisonOperand, comparisonOperand.algebra.operandA) } - if (code.indexOf(' <= ') > 0) { - let codeArray = code.split(' <= ') - codeA = codeArray[0] - codeB = codeArray[1] - operationPicker.setSelected(undefined, undefined, undefined, 3) + function initializePickersSet (logicOperand, comparisonOperand, algebraOperand) { + /* Get the ySign */ + let ySign + if (algebraOperand.index === 0) { + ySign = -1 + } + if (algebraOperand.index === 1) { + ySign = 1 + } + + let properties + let parent + let current + + 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 + current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] + 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 * 3.0 + algebraOperand.algebraicPicker.container.frame.position.y = 0 - algebraOperand.algebraicPicker.container.frame.height / 2 + algebraOperand.algebraicPicker.container.frame.height * ySign + 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) + 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 + current = scanResult + properties = Object.keys(current) + algebraOperand.dataMinePicker.initialize(properties, current) + parent = current + algebraOperand.dataMinePicker.visible = true + + 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.y = 0 - algebraOperand.botPicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + current = parent[properties[0]] + properties = Object.keys(current) + algebraOperand.botPicker.initialize(properties, current, parent) + parent = current + algebraOperand.botPicker.visible = true + + 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.y = 0 - algebraOperand.productPicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + current = parent[properties[0]] + properties = Object.keys(current) + algebraOperand.productPicker.initialize(properties, current, parent) + parent = current + algebraOperand.productPicker.visible = true + + let productParent = parent + let productProperties = properties + + 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.y = 0 - algebraOperand.propertyPicker.container.frame.height / 2 + algebraOperand.dataMinePicker.container.frame.height * ySign + current = productParent[productProperties[0]] + current = current.properties + properties = Object.keys(current) + algebraOperand.propertyPicker.initialize(properties, current, productParent, 'properties') + parent = current + algebraOperand.propertyPicker.visible = true + + 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.y = 0 - algebraOperand.valuePicker.container.frame.height / 2 + algebraOperand.valuePicker.container.frame.height * 1 + current = parent[properties[0]] + properties = current.possibleValues + algebraOperand.valuePicker.initialize(properties, current, parent, 'possibleValues') + parent = current + algebraOperand.valuePicker.visible = false + + 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.y = 0 - algebraOperand.timeFramePicker.container.frame.height / 2 + algebraOperand.timeFramePicker.container.frame.height * ySign + current = productParent[productProperties[0]] + properties = current.validTimeFrames + algebraOperand.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') + parent = current + algebraOperand.timeFramePicker.visible = true + + algebraOperand.botPicker.eventSuscriptionId = algebraOperand.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.botPicker.onParentChanged) + algebraOperand.productPicker.eventSuscriptionId = algebraOperand.botPicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.productPicker.onParentChanged) + algebraOperand.propertyPicker.eventSuscriptionId = algebraOperand.productPicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.propertyPicker.onParentChanged) + algebraOperand.valuePicker.eventSuscriptionId = algebraOperand.propertyPicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.valuePicker.onParentChanged) + algebraOperand.timeFramePicker.eventSuscriptionId = algebraOperand.productPicker.container.eventHandler.listenToEvent('onParentChanged', algebraOperand.timeFramePicker.onParentChanged) } - if (code.indexOf(' === ') > 0) { - let codeArray = code.split(' === ') - codeA = codeArray[0] - codeB = codeArray[1] - operationPicker.setSelected(undefined, undefined, undefined, 4) - } + function updatePickers (logicOperand, comparisonOperand, algebraOperand) { + let codeArray = algebraOperand.code.split('.') - let codeAArray = codeA.split('.') - let codeBArray = codeB.split('.') - - updatePickers(operatorA, codeAArray) - updatePickers(operatorB, codeBArray) - - function updatePickers (operator, codeArray) { let codeTimeFrame = codeArray[1].substring(2, 4) + '-' + codeArray[1].substring(4, 7) let codeProduct = codeArray[2] @@ -222,15 +338,15 @@ function newConditionEditor () { propertyDisplacement++ codeWhen = '5 Previous' } - operator.whenPicker.setSelected(undefined, undefined, undefined, propertyDisplacement) + algebraOperand.whenPicker.setSelected(undefined, undefined, undefined, propertyDisplacement) let codeProperty = codeArray[3 + propertyDisplacement] - let codeValue = codeBArray[0].replace('"', '').replace('"', '') + let codeValue = comparisonOperand.algebra.operandB.code.replace('"', '').replace('"', '') - let dataMines = Object.keys(operator.selector) + let dataMines = Object.keys(scanResult) for (let i = 0; i < dataMines.length; i++) { let dataMine = dataMines[i] - let dataMineObject = operator.selector[dataMine] + let dataMineObject = scanResult[dataMine] let bots = Object.keys(dataMineObject) for (let j = 0; j < bots.length; j++) { let bot = bots[j] @@ -240,21 +356,21 @@ function newConditionEditor () { let product = products[k] let productObject = botObject[product] if (codeProduct === product) { - operator.dataMinePicker.setSelected(dataMines, operator.selector, undefined, i) - operator.botPicker.setSelected(bots, dataMineObject, operator.selector, j) - operator.productPicker.setSelected(products, botObject, dataMineObject, k) + algebraOperand.dataMinePicker.setSelected(dataMines, scanResult, undefined, i) + algebraOperand.botPicker.setSelected(bots, dataMineObject, scanResult, j) + algebraOperand.productPicker.setSelected(products, botObject, dataMineObject, k) let properties = Object.keys(productObject.properties) for (let m = 0; m < properties.length; m++) { let property = properties[m] let propertyObject = productObject.properties[property] if (codeProperty === property) { - operator.propertyPicker.setSelected(properties, productObject.properties, botObject, m) + algebraOperand.propertyPicker.setSelected(properties, productObject.properties, botObject, m) let values = propertyObject.possibleValues for (let n = 0; n < values.length; n++) { let value = values[n] let valueObject = propertyObject[value] if (codeValue === value) { - operator.valuePicker.setSelected(values, propertyObject, productObject, n) + algebraOperand.valuePicker.setSelected(values, propertyObject, productObject, n) } } } @@ -264,7 +380,7 @@ function newConditionEditor () { let timeFrame = timeFrames[m] let timeFrameObject = productObject.validTimeFrames[timeFrame] if (codeTimeFrame === timeFrame) { - operator.timeFramePicker.setSelected(timeFrames, productObject, botObject, m) + algebraOperand.timeFramePicker.setSelected(timeFrames, productObject, botObject, m) } } } @@ -337,185 +453,142 @@ function newConditionEditor () { selector[dataMineName] = undefined } } - operatorA.selector = JSON.parse(JSON.stringify(selector)) - operatorB.selector = JSON.parse(JSON.stringify(selector)) + scanResult = JSON.parse(JSON.stringify(selector)) } - function initializePickers () { - initializeOperator(operatorA, -1) - initializeOperator(operatorB, 1) + function convertToCode () { + // if (comparisonOperatorA === undefined || comparisonOperatorB === undefined || comparisonPicker === undefined) { return } - operationPicker = newPicker() - operationPicker.name = 'Data Mine' - operationPicker.container.connectToParent(thisObject.container) - operationPicker.container.frame.position.x = 0 - operationPicker.container.frame.width / 2 - operationPicker.container.frame.position.y = 0 - operationPicker.container.frame.height / 2 - current = ['Greater Than', 'Less Than', 'Greater or Equal Than', 'Less or Equal Than', 'Equal To'] - operationPicker.initialize(current, current) + // chart.at01hs.bollingerSubChannel.previous.previous.slope=== "Extreme" + /* + let code = '' - operationPicker.eventSuscriptionId = operationPicker.container.eventHandler.listenToEvent('onParentChanged', onParentChanged) - } + code = code + 'chart.at' + comparisonOperatorA.timeFramePicker.getSelected().replace('-', '') + code = code + '.' + comparisonOperatorA.productPicker.getSelected() + insertWhen(comparisonOperatorA) + code = code + '.' + comparisonOperatorA.propertyPicker.getSelected() - function initializeOperator (operator, ySign) { - let properties - let parent - let current + switch (comparisonPicker.getSelected()) { + case 'Greater Than': { + code = code + ' > ' + break + } + 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 + } + } - operator.whenPicker = newPicker() - operator.whenPicker.name = 'When' - operator.whenPicker.container.connectToParent(thisObject.container) - operator.whenPicker.container.frame.position.x = 0 - operator.whenPicker.container.frame.width / 2 - operator.whenPicker.container.frame.width * 1.0 - operator.whenPicker.container.frame.position.y = 0 - operator.whenPicker.container.frame.height / 2 + operator.whenPicker.container.frame.height * ySign - current = ['Current', '1 Previous', '2 Previous', '3 Previous', '4 Previous', '5 Previous'] - operator.whenPicker.initialize(current, current) - operator.whenPicker.visible = true + 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() + } - operator.algebraicPicker = newPicker() - operator.algebraicPicker.name = 'Algebraic' - operator.algebraicPicker.container.connectToParent(thisObject.container) - operator.algebraicPicker.container.frame.position.x = 0 - operator.algebraicPicker.container.frame.width / 2 + operator.algebraicPicker.container.frame.width * 3.0 - operator.algebraicPicker.container.frame.position.y = 0 - operator.algebraicPicker.container.frame.height / 2 + operator.algebraicPicker.container.frame.height * ySign - current = ['+ - * /', 'Plus', 'Minus', 'Times', 'Divided by'] - operator.algebraicPicker.initialize(current, current) - operator.algebraicPicker.visible = true + thisObject.payload.node.code = code - operator.dataMinePicker = newPicker() - operator.dataMinePicker.name = 'Data Mine' - operator.dataMinePicker.container.connectToParent(thisObject.container) - operator.dataMinePicker.container.frame.position.x = 0 - operator.dataMinePicker.container.frame.width / 2 - operator.dataMinePicker.container.frame.width * 3.0 - operator.dataMinePicker.container.frame.position.y = 0 - operator.dataMinePicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign - current = operator.selector - properties = Object.keys(current) - operator.dataMinePicker.initialize(properties, current) - parent = current - operator.dataMinePicker.visible = true - - operator.botPicker = newPicker() - operator.botPicker.name = 'Bot' - operator.botPicker.container.connectToParent(thisObject.container) - operator.botPicker.container.frame.position.x = 0 - operator.botPicker.container.frame.width / 2 - operator.botPicker.container.frame.width * 2.0 - operator.botPicker.container.frame.position.y = 0 - operator.botPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign - current = parent[properties[0]] - properties = Object.keys(current) - operator.botPicker.initialize(properties, current, parent) - parent = current - operator.botPicker.visible = true - - operator.productPicker = newPicker() - operator.productPicker.name = 'Product' - operator.productPicker.container.connectToParent(thisObject.container) - operator.productPicker.container.frame.position.x = 0 - operator.productPicker.container.frame.width / 2 + operator.productPicker.container.frame.width * 0.0 - operator.productPicker.container.frame.position.y = 0 - operator.productPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign - current = parent[properties[0]] - properties = Object.keys(current) - operator.productPicker.initialize(properties, current, parent) - parent = current - operator.productPicker.visible = true - - let productParent = parent - let productProperties = properties - - operator.propertyPicker = newPicker() - operator.propertyPicker.name = 'Property' - operator.propertyPicker.container.connectToParent(thisObject.container) - operator.propertyPicker.container.frame.position.x = 0 - operator.propertyPicker.container.frame.width / 2 + operator.propertyPicker.container.frame.width * 1.0 - operator.propertyPicker.container.frame.position.y = 0 - operator.propertyPicker.container.frame.height / 2 + operator.dataMinePicker.container.frame.height * ySign - current = productParent[productProperties[0]] - current = current.properties - properties = Object.keys(current) - operator.propertyPicker.initialize(properties, current, productParent, 'properties') - parent = current - operator.propertyPicker.visible = true - - operator.valuePicker = newPicker() - operator.valuePicker.name = 'Value' - operator.valuePicker.container.connectToParent(thisObject.container) - operator.valuePicker.container.frame.position.x = 0 - operator.valuePicker.container.frame.width / 2 - operator.valuePicker.container.frame.position.y = 0 - operator.valuePicker.container.frame.height / 2 + operator.valuePicker.container.frame.height * 1 - current = parent[properties[0]] - properties = current.possibleValues - operator.valuePicker.initialize(properties, current, parent, 'possibleValues') - parent = current - operator.valuePicker.visible = false - - operator.timeFramePicker = newPicker() - operator.timeFramePicker.name = 'Time Frame' - operator.timeFramePicker.container.connectToParent(thisObject.container) - operator.timeFramePicker.container.frame.position.x = 0 - operator.timeFramePicker.container.frame.width / 2 + operator.timeFramePicker.container.frame.width * 2.0 - operator.timeFramePicker.container.frame.position.y = 0 - operator.timeFramePicker.container.frame.height / 2 + operator.timeFramePicker.container.frame.height * ySign - current = productParent[productProperties[0]] - properties = current.validTimeFrames - operator.timeFramePicker.initialize(properties, current, productParent, 'validTimeFrames') - parent = current - operator.timeFramePicker.visible = true - - operator.botPicker.eventSuscriptionId = operator.dataMinePicker.container.eventHandler.listenToEvent('onParentChanged', operator.botPicker.onParentChanged) - operator.productPicker.eventSuscriptionId = operator.botPicker.container.eventHandler.listenToEvent('onParentChanged', operator.productPicker.onParentChanged) - operator.propertyPicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.propertyPicker.onParentChanged) - operator.valuePicker.eventSuscriptionId = operator.propertyPicker.container.eventHandler.listenToEvent('onParentChanged', operator.valuePicker.onParentChanged) - operator.timeFramePicker.eventSuscriptionId = operator.productPicker.container.eventHandler.listenToEvent('onParentChanged', operator.timeFramePicker.onParentChanged) + function insertWhen (operator) { + switch (operator.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 () { - finalizeOperator(operatorA) - finalizeOperator(operatorB) - - operatorA = undefined - operatorB = undefined - - if (operationPicker !== undefined) { - operationPicker.container.eventHandler.stopListening(operationPicker.eventSuscriptionId) - operationPicker.finalize() - operationPicker = undefined + if (conditionStructure === undefined) { return } + for (let i = 0; i < conditionStructure.orOperands.length; i++) { + let logicOperand = conditionStructure.orOperands[i] + finalizeOperator(logicOperand.comparison.operandA.algebra.operandA) + finalizeOperator(logicOperand.comparison.operandA.algebra.operandB) + finalizeOperator(logicOperand.comparison.operandB.algebra.operandA) + finalizeOperator(logicOperand.comparison.operandB.algebra.operandB) } } - function finalizeOperator (operator) { - if (operator === undefined) { return } + function finalizeOperator (operand) { + if (operand === undefined) { return } - if (operator.whenPicker !== undefined) { - operator.whenPicker.finalize() - operator.whenPicker = undefined + if (operand.whenPicker !== undefined) { + operand.whenPicker.finalize() + operand.whenPicker = undefined } - if (operator.algebraicPicker !== undefined) { - operator.algebraicPicker.finalize() - operator.algebraicPicker = undefined + if (operand.algebraicPicker !== undefined) { + operand.algebraicPicker.finalize() + operand.algebraicPicker = undefined } - if (operator.dataMinePicker !== undefined) { - operator.dataMinePicker.container.eventHandler.stopListening(operator.botPicker.eventSuscriptionId) - operator.dataMinePicker.finalize() - operator.dataMinePicker = undefined + if (operand.dataMinePicker !== undefined) { + operand.dataMinePicker.container.eventHandler.stopListening(operand.botPicker.eventSuscriptionId) + operand.dataMinePicker.finalize() + operand.dataMinePicker = undefined } - if (operator.botPicker !== undefined) { - operator.botPicker.container.eventHandler.stopListening(operator.productPicker.eventSuscriptionId) - operator.botPicker.finalize() - operator.botPicker = undefined + if (operand.botPicker !== undefined) { + operand.botPicker.container.eventHandler.stopListening(operand.productPicker.eventSuscriptionId) + operand.botPicker.finalize() + operand.botPicker = undefined } - if (operator.productPicker !== undefined) { - operator.productPicker.container.eventHandler.stopListening(operator.propertyPicker.eventSuscriptionId) - operator.productPicker.container.eventHandler.stopListening(operator.timeFramePicker.eventSuscriptionId) - operator.productPicker.finalize() - operator.productPicker = undefined + if (operand.productPicker !== undefined) { + operand.productPicker.container.eventHandler.stopListening(operand.propertyPicker.eventSuscriptionId) + operand.productPicker.container.eventHandler.stopListening(operand.timeFramePicker.eventSuscriptionId) + operand.productPicker.finalize() + operand.productPicker = undefined } - if (operator.propertyPicker !== undefined) { - operator.propertyPicker.container.eventHandler.stopListening(operator.valuePicker.eventSuscriptionId) - operator.propertyPicker.finalize() - operator.propertyPicker = undefined + if (operand.propertyPicker !== undefined) { + operand.propertyPicker.container.eventHandler.stopListening(operand.valuePicker.eventSuscriptionId) + operand.propertyPicker.finalize() + operand.propertyPicker = undefined } - if (operator.valuePicker !== undefined) { - operator.valuePicker.finalize() - operator.valuePicker = undefined + if (operand.valuePicker !== undefined) { + operand.valuePicker.finalize() + operand.valuePicker = undefined } - if (operator.timeFramePicker !== undefined) { - operator.timeFramePicker.finalize() - operator.timeFramePicker = undefined + if (operand.timeFramePicker !== undefined) { + operand.timeFramePicker.finalize() + operand.timeFramePicker = undefined } } @@ -523,147 +596,41 @@ function newConditionEditor () { if (event.selected === 4) { // this means Equal To - operatorA.valuePicker.visible = true - operatorB.whenPicker.visible = false - operatorB.algebraicPicker.visible = false - operatorB.dataMinePicker.visible = false - operatorB.botPicker.visible = false - operatorB.productPicker.visible = false - operatorB.propertyPicker.visible = false - operatorB.timeFramePicker.visible = false + comparisonOperatorA.valuePicker.visible = true + comparisonOperatorB.whenPicker.visible = false + comparisonOperatorB.algebraicPicker.visible = false + comparisonOperatorB.dataMinePicker.visible = false + comparisonOperatorB.botPicker.visible = false + comparisonOperatorB.productPicker.visible = false + comparisonOperatorB.propertyPicker.visible = false + comparisonOperatorB.timeFramePicker.visible = false } else { - operatorA.valuePicker.visible = false - operatorB.whenPicker.visible = true - operatorB.algebraicPicker.visible = true - operatorB.dataMinePicker.visible = true - operatorB.botPicker.visible = true - operatorB.productPicker.visible = true - operatorB.propertyPicker.visible = true - operatorB.timeFramePicker.visible = true + comparisonOperatorA.valuePicker.visible = false + comparisonOperatorB.whenPicker.visible = true + comparisonOperatorB.algebraicPicker.visible = true + comparisonOperatorB.dataMinePicker.visible = true + comparisonOperatorB.botPicker.visible = true + comparisonOperatorB.productPicker.visible = true + comparisonOperatorB.propertyPicker.visible = true + comparisonOperatorB.timeFramePicker.visible = true } } function getContainer (point) { let container if (thisObject.visible === true) { - if (operationPicker !== undefined) { - container = operationPicker.getContainer(point) + if (conditionStructure === undefined) { return } + + for (let i = 0; i < conditionStructure.orOperands.length; i++) { + let logicOperand = conditionStructure.orOperands[i] + container = operandGetContainer(point, logicOperand.comparison.operandA.algebra.operandA) + if (container !== undefined) { return container } + container = operandGetContainer(point, logicOperand.comparison.operandA.algebra.operandB) + if (container !== undefined) { return container } + container = operandGetContainer(point, logicOperand.comparison.operandB.algebra.operandA) + if (container !== undefined) { return container } + container = operandGetContainer(point, logicOperand.comparison.operandB.algebra.operandB) if (container !== undefined) { return container } - } - - if (operatorA !== undefined) { - if (operatorA.whenPicker !== undefined) { - if (operatorA.whenPicker.visible === true) { - container = operatorA.whenPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.algebraicPicker !== undefined) { - if (operatorA.algebraicPicker.visible === true) { - container = operatorA.algebraicPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.dataMinePicker !== undefined) { - if (operatorA.dataMinePicker.visible === true) { - container = operatorA.dataMinePicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.botPicker !== undefined) { - if (operatorA.botPicker.visible === true) { - container = operatorA.botPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.productPicker !== undefined) { - if (operatorA.productPicker.visible === true) { - container = operatorA.productPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.propertyPicker !== undefined) { - if (operatorA.propertyPicker.visible === true) { - container = operatorA.propertyPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.valuePicker !== undefined) { - if (operatorA.valuePicker.visible === true) { - container = operatorA.valuePicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorA.timeFramePicker !== undefined) { - if (operatorA.timeFramePicker.visible === true) { - container = operatorA.timeFramePicker.getContainer(point) - if (container !== undefined) { return container } - } - } - } - if (operatorB !== undefined) { - if (operatorB.whenPicker !== undefined) { - if (operatorB.whenPicker.visible === true) { - container = operatorB.whenPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.algebraicPicker !== undefined) { - if (operatorB.algebraicPicker.visible === true) { - container = operatorB.algebraicPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.dataMinePicker !== undefined) { - if (operatorB.dataMinePicker.visible === true) { - container = operatorB.dataMinePicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.botPicker !== undefined) { - if (operatorB.botPicker.visible === true) { - container = operatorB.botPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.productPicker !== undefined) { - if (operatorB.productPicker.visible === true) { - container = operatorB.productPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.propertyPicker !== undefined) { - if (operatorB.propertyPicker.visible === true) { - container = operatorB.propertyPicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.valuePicker !== undefined) { - if (operatorB.valuePicker.visible === true) { - container = operatorB.valuePicker.getContainer(point) - if (container !== undefined) { return container } - } - } - - if (operatorB.timeFramePicker !== undefined) { - if (operatorB.timeFramePicker.visible === true) { - container = operatorB.timeFramePicker.getContainer(point) - if (container !== undefined) { return container } - } - } } if (thisObject.container.frame.isThisPointHere(point, true) === true) { @@ -674,57 +641,66 @@ function newConditionEditor () { } } + function operandGetContainer (point, operand) { + let container + if (operand.whenPicker !== undefined) { + if (operand.whenPicker.visible === true) { + container = operand.whenPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + + 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) + if (container !== undefined) { return container } + } + } + + if (operand.botPicker !== undefined) { + if (operand.botPicker.visible === true) { + container = operand.botPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + + if (operand.productPicker !== undefined) { + if (operand.productPicker.visible === true) { + container = operand.productPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + + if (operand.propertyPicker !== undefined) { + if (operand.propertyPicker.visible === true) { + container = operand.propertyPicker.getContainer(point) + if (container !== undefined) { return container } + } + } + + if (operand.valuePicker !== undefined) { + if (operand.valuePicker.visible === true) { + container = operand.valuePicker.getContainer(point) + if (container !== undefined) { return container } + } + } + + if (operand.timeFramePicker !== undefined) { + if (operand.timeFramePicker.visible === true) { + container = operand.timeFramePicker.getContainer(point) + if (container !== undefined) { return container } + } + } + } + function physics () { - thisObjectphysics() - operatorsPhysics(operatorA) - operatorsPhysics(operatorB) - - if (operationPicker !== undefined) { - operationPicker.physics() - } - } - - function selectionPhysics () { - - } - - function operatorsPhysics (operator) { - if (operator === undefined) { return } - - if (operator.whenPicker !== undefined) { - operator.whenPicker.physics() - } - - if (operator.algebraicPicker !== undefined) { - operator.algebraicPicker.physics() - } - - if (operator.dataMinePicker !== undefined) { - operator.dataMinePicker.physics() - } - - if (operator.botPicker !== undefined) { - operator.botPicker.physics() - } - - if (operator.productPicker !== undefined) { - operator.productPicker.physics() - } - - if (operator.propertyPicker !== undefined) { - operator.propertyPicker.physics() - } - - if (operator.valuePicker !== undefined) { - operator.valuePicker.physics() - } - - if (operator.timeFramePicker !== undefined) { - operator.timeFramePicker.physics() - } - } - - function thisObjectphysics () { } @@ -734,62 +710,65 @@ function newConditionEditor () { } function childrenDrawBackground () { - operatorDrawBackground(operatorA) - operatorDrawBackground(operatorB) + if (conditionStructure === undefined) { return } - if (operationPicker !== undefined) { - operationPicker.drawBackground() + for (let i = 0; i < conditionStructure.orOperands.length; i++) { + let logicOperand = conditionStructure.orOperands[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) } } - function operatorDrawBackground (operator) { - if (operator === undefined) { return } + function operandDrawBackground (operand) { + if (operand === undefined) { return } - if (operator.whenPicker !== undefined) { - if (operator.whenPicker.visible === true) { - operator.whenPicker.drawBackground() + if (operand.whenPicker !== undefined) { + if (operand.whenPicker.visible === true) { + operand.whenPicker.drawBackground() } } - if (operator.algebraicPicker !== undefined) { - if (operator.algebraicPicker.visible === true) { - operator.algebraicPicker.drawBackground() + if (operand.algebraicPicker !== undefined) { + if (operand.algebraicPicker.visible === true) { + operand.algebraicPicker.drawBackground() } } - if (operator.dataMinePicker !== undefined) { - if (operator.dataMinePicker.visible === true) { - operator.dataMinePicker.drawBackground() + if (operand.dataMinePicker !== undefined) { + if (operand.dataMinePicker.visible === true) { + operand.dataMinePicker.drawBackground() } } - if (operator.botPicker !== undefined) { - if (operator.botPicker.visible === true) { - operator.botPicker.drawBackground() + if (operand.botPicker !== undefined) { + if (operand.botPicker.visible === true) { + operand.botPicker.drawBackground() } } - if (operator.productPicker !== undefined) { - if (operator.productPicker.visible === true) { - operator.productPicker.drawBackground() + if (operand.productPicker !== undefined) { + if (operand.productPicker.visible === true) { + operand.productPicker.drawBackground() } } - if (operator.propertyPicker !== undefined) { - if (operator.propertyPicker.visible === true) { - operator.propertyPicker.drawBackground() + if (operand.propertyPicker !== undefined) { + if (operand.propertyPicker.visible === true) { + operand.propertyPicker.drawBackground() } } - if (operator.valuePicker !== undefined) { - if (operator.valuePicker.visible === true) { - operator.valuePicker.drawBackground() + if (operand.valuePicker !== undefined) { + if (operand.valuePicker.visible === true) { + operand.valuePicker.drawBackground() } } - if (operator.timeFramePicker !== undefined) { - if (operator.timeFramePicker.visible === true) { - operator.timeFramePicker.drawBackground() + if (operand.timeFramePicker !== undefined) { + if (operand.timeFramePicker.visible === true) { + operand.timeFramePicker.drawBackground() } } } @@ -825,62 +804,65 @@ function newConditionEditor () { } function childrenDrawForeground () { - operatorDrawForeground(operatorA) - operatorDrawForeground(operatorB) + if (conditionStructure === undefined) { return } - if (operationPicker !== undefined) { - operationPicker.drawForeground() + for (let i = 0; i < conditionStructure.orOperands.length; i++) { + let logicOperand = conditionStructure.orOperands[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) } } - function operatorDrawForeground (operator) { - if (operator === undefined) { return } + function operandDrawForeground (operand) { + if (operand === undefined) { return } - if (operator.whenPicker !== undefined) { - if (operator.whenPicker.visible === true) { - operator.whenPicker.drawForeground() + if (operand.whenPicker !== undefined) { + if (operand.whenPicker.visible === true) { + operand.whenPicker.drawForeground() } } - if (operator.algebraicPicker !== undefined) { - if (operator.algebraicPicker.visible === true) { - operator.algebraicPicker.drawForeground() + if (operand.algebraicPicker !== undefined) { + if (operand.algebraicPicker.visible === true) { + operand.algebraicPicker.drawForeground() } } - if (operator.dataMinePicker !== undefined) { - if (operator.dataMinePicker.visible === true) { - operator.dataMinePicker.drawForeground() + if (operand.dataMinePicker !== undefined) { + if (operand.dataMinePicker.visible === true) { + operand.dataMinePicker.drawForeground() } } - if (operator.botPicker !== undefined) { - if (operator.botPicker.visible === true) { - operator.botPicker.drawForeground() + if (operand.botPicker !== undefined) { + if (operand.botPicker.visible === true) { + operand.botPicker.drawForeground() } } - if (operator.productPicker !== undefined) { - if (operator.productPicker.visible === true) { - operator.productPicker.drawForeground() + if (operand.productPicker !== undefined) { + if (operand.productPicker.visible === true) { + operand.productPicker.drawForeground() } } - if (operator.propertyPicker !== undefined) { - if (operator.propertyPicker.visible === true) { - operator.propertyPicker.drawForeground() + if (operand.propertyPicker !== undefined) { + if (operand.propertyPicker.visible === true) { + operand.propertyPicker.drawForeground() } } - if (operator.valuePicker !== undefined) { - if (operator.valuePicker.visible === true) { - operator.valuePicker.drawForeground() + if (operand.valuePicker !== undefined) { + if (operand.valuePicker.visible === true) { + operand.valuePicker.drawForeground() } } - if (operator.timeFramePicker !== undefined) { - if (operator.timeFramePicker.visible === true) { - operator.timeFramePicker.drawForeground() + if (operand.timeFramePicker !== undefined) { + if (operand.timeFramePicker.visible === true) { + operand.timeFramePicker.drawForeground() } } } From a855c7b6ca4823497517f7f715048f452f4e9218 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sun, 3 May 2020 15:44:12 +0200 Subject: [PATCH 55/55] Update EventsServerClient.js --- EventsServerClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventsServerClient.js b/EventsServerClient.js index bdbe7f37b..247636f03 100644 --- a/EventsServerClient.js +++ b/EventsServerClient.js @@ -156,7 +156,7 @@ function newEventsServerClient (host, port, hostName) { } if (thisObject.isConnected() !== true) { - canvas.cockpitSpace.setStatus('Connecting to ' + hostName + ' Network Node. Please hold on until the connection can be stablished.', 100, canvas.cockpitSpace.statusTypes.WARNING) + canvas.cockpitSpace.setStatus('Connecting to ' + hostName + ' Network Node. Please wait until the connection is established.', 100, canvas.cockpitSpace.statusTypes.WARNING) } else { retryCommandsPhysics() }