From 1cc06a28eb7697938c34f014bc6158b9a5e28649 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 6 Nov 2019 10:46:28 +0100 Subject: [PATCH] Procees Output and Process Dependencies Implemented --- .../FunctionLibraries/ChainAttachDetach.js | 24 +++ .../FunctionLibraries/NodeChildren.js | 33 ++++ .../FunctionLibraries/NodeDeleter.js | 32 ++++ .../Workspace/FunctionLibraries/OnFocus.js | 24 +++ .../FunctionLibraries/ProtocolNode.js | 38 +++- .../FunctionLibraries/ShortcutKeys.js | 24 +++ .../FunctionLibraries/UiObjectsFromNodes.js | 56 +++++- DesignerSpace/Workspace/Workspace.js | 18 ++ FloatingSpace/UiObject.js | 14 +- FloatingSpace/UiObjectConstructor.js | 164 +++++++++++++----- Spaces/DesignerSpace.js | 2 + 11 files changed, 370 insertions(+), 59 deletions(-) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js index c9547d6a0..9e19ae313 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ChainAttachDetach.js @@ -61,6 +61,16 @@ function newChainAttachDetach () { completeDetachment(node, rootNodes) return } + case 'Process Output': { + node.payload.parentNode.processOutput = undefined + completeDetachment(node, rootNodes) + return + } + case 'Process Dependencies': { + node.payload.parentNode.processDependencies = undefined + completeDetachment(node, rootNodes) + return + } case 'Status Report': { node.payload.parentNode.statusReport = undefined completeDetachment(node, rootNodes) @@ -572,6 +582,20 @@ function newChainAttachDetach () { completeAttachment(node, rootNodes) } break + case 'Process Output': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.processOutput = node + completeAttachment(node, rootNodes) + } + break + case 'Process Dependencies': { + node.payload.parentNode = attachToNode + node.payload.chainParent = attachToNode + node.payload.parentNode.processDependencies = node + completeAttachment(node, rootNodes) + } + break case 'Status Report': { node.payload.parentNode = attachToNode node.payload.chainParent = attachToNode diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js index 215e30551..ff6490334 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeChildren.js @@ -29,6 +29,12 @@ function newNodeChildren () { case 'Process Definition': { return countChildrenProcessDefinition(parentNode, childNode) } + case 'Process Output': { + return countChildrenProcessOutput(parentNode, childNode) + } + case 'Process Dependencies': { + return countChildrenProcessDependencies(parentNode, childNode) + } case 'Status Rerport': { return countChildrenStatusRerport(parentNode, childNode) } @@ -394,6 +400,18 @@ function newNodeChildren () { childrenCount: 0, childIndex: undefined } + if (parentNode.processOutput !== undefined) { + response.childrenCount++ + if (parentNode.processOutput.id === childNode.id) { + response.childIndex = response.childrenCount + } + } + if (parentNode.processDependencies !== undefined) { + response.childrenCount++ + if (parentNode.processDependencies.id === childNode.id) { + response.childIndex = response.childrenCount + } + } if (parentNode.statusReport !== undefined) { response.childrenCount++ if (parentNode.statusReport.id === childNode.id) { @@ -424,7 +442,14 @@ function newNodeChildren () { response.childIndex = response.childrenCount } } + return response + } + function countChildrenProcessOutput (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } if (parentNode.outputDatasets !== undefined) { for (let i = 0; i < parentNode.outputDatasets.length; i++) { let child = parentNode.outputDatasets[i] @@ -434,6 +459,14 @@ function newNodeChildren () { } } } + return response + } + + function countChildrenProcessDependencies (parentNode, childNode) { + let response = { + childrenCount: 0, + childIndex: undefined + } if (parentNode.statusDependencies !== undefined) { for (let i = 0; i < parentNode.statusDependencies.length; i++) { let child = parentNode.statusDependencies[i] diff --git a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js index b953bacec..fa18dc0c9 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js +++ b/DesignerSpace/Workspace/FunctionLibraries/NodeDeleter.js @@ -115,6 +115,14 @@ function newNodeDeleter () { deleteProcessDefinition(rootNode, rootNodes) break } + case 'Process Output': { + deleteProcessOutput(rootNode, rootNodes) + break + } + case 'Process Dependencies': { + deleteProcessDependencies(rootNode, rootNodes) + break + } case 'Status Report': { deleteStatusReport(rootNode, rootNodes) break @@ -566,6 +574,14 @@ function newNodeDeleter () { } } + if (node.processOutput !== undefined) { + deleteProcessOutput(node.processOutput, rootNodes) + } + + if (node.processDependencies !== undefined) { + deleteProcessDependencies(node.processDependencies, rootNodes) + } + if (node.statusReport !== undefined) { deleteStatusReport(node.statusReport, rootNodes) } @@ -586,12 +602,28 @@ function newNodeDeleter () { deleteDataBuildingProcedure(node.dataBuilding, rootNodes) } + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcessOutput (node, rootNodes) { + let payload = node.payload + if (node.outputDatasets !== undefined) { while (node.outputDatasets.length > 0) { deleteOutputDataset(node.outputDatasets[0], rootNodes) } } + completeDeletion(node, rootNodes) + destroyUiObject(node) + cleanNode(node) + } + + function deleteProcessDependencies (node, rootNodes) { + let payload = node.payload + if (node.statusDependencies !== undefined) { while (node.statusDependencies.length > 0) { deleteStatusDependency(node.statusDependencies[0], rootNodes) diff --git a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js index faa814eff..41e14064d 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js +++ b/DesignerSpace/Workspace/FunctionLibraries/OnFocus.js @@ -824,6 +824,14 @@ function newOnFocus () { } case 'Process Definition': { let child + child = getNodeThatIsOnFocus(node.processOutput) + if (child !== undefined) { + return child + } + child = getNodeThatIsOnFocus(node.processDependencies) + if (child !== undefined) { + return child + } child = getNodeThatIsOnFocus(node.statusReport) if (child !== undefined) { return child @@ -844,12 +852,28 @@ function newOnFocus () { if (child !== undefined) { return child } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Process Output': { + let child for (let m = 0; m < node.outputDatasets.length; m++) { child = getNodeThatIsOnFocus(node.outputDatasets[m]) if (child !== undefined) { return child } } + if (node.payload.uiObject.isOnFocus === true) { + return node + } else { + return + } + } + case 'Process Dependencies': { + let child for (let m = 0; m < node.statusDependencies.length; m++) { child = getNodeThatIsOnFocus(node.statusDependencies[m]) if (child !== undefined) { diff --git a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js index 09ff5f75a..4a8aec783 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -1171,14 +1171,28 @@ function newProtocolNode () { subType: node.subType, name: node.name, code: node.code, + processOutput: getProtocolNode(node.processOutput, removePersonalData, parseCode, includeIds, includePayload, includeReferences), + processDependencies: getProtocolNode(node.processDependencies, removePersonalData, parseCode, includeIds, includePayload, includeReferences), statusReport: getProtocolNode(node.statusReport, removePersonalData, parseCode, includeIds, includePayload, includeReferences), executionStartedEvent: getProtocolNode(node.executionStartedEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences), executionFinishedEvent: getProtocolNode(node.executionFinishedEvent, removePersonalData, parseCode, includeIds, includePayload, includeReferences), calculations: getProtocolNode(node.calculations, removePersonalData, parseCode, includeIds, includePayload, includeReferences), - dataBuilding: getProtocolNode(node.dataBuilding, removePersonalData, parseCode, includeIds, includePayload, includeReferences), - outputDatasets: [], - statusDependencies: [], - dataDependencies: [] + dataBuilding: getProtocolNode(node.dataBuilding, removePersonalData, parseCode, includeIds, includePayload, includeReferences) + } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Process Output': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + outputDatasets: [] } if (node.outputDatasets !== undefined) { for (let m = 0; m < node.outputDatasets.length; m++) { @@ -1188,6 +1202,22 @@ function newProtocolNode () { } } } + if (includeIds) { + object.id = node.id + } + if (includePayload) { + object.savedPayload = getSavedPayload(node, includeReferences) + } + return object + } + case 'Process Dependencies': { + let object = { + type: node.type, + subType: node.subType, + name: node.name, + statusDependencies: [], + dataDependencies: [] + } if (node.statusDependencies !== undefined) { for (let m = 0; m < node.statusDependencies.length; m++) { let statusDependency = getProtocolNode(node.statusDependencies[m], removePersonalData, parseCode, includeIds, includePayload, includeReferences) diff --git a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js index e9fed8d1e..96f399a43 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js +++ b/DesignerSpace/Workspace/FunctionLibraries/ShortcutKeys.js @@ -808,6 +808,14 @@ function newShortcutKeys () { } case 'Process Definition': { let child + child = getNodeByShortcutKey(node.processOutput, searchingKey) + if (child !== undefined) { + return child + } + child = getNodeByShortcutKey(node.processDependencies, searchingKey) + if (child !== undefined) { + return child + } child = getNodeByShortcutKey(node.statusReport, searchingKey) if (child !== undefined) { return child @@ -828,12 +836,28 @@ function newShortcutKeys () { if (child !== undefined) { return child } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Process Output': { + let child for (let m = 0; m < node.outputDatasets.length; m++) { child = getNodeByShortcutKey(node.outputDatasets[m], searchingKey) if (child !== undefined) { return child } } + if (node.payload.uiObject.shortcutKey === searchingKey) { + return node + } else { + return + } + } + case 'Process Dependencies': { + let child for (let m = 0; m < node.statusDependencies.length; m++) { child = getNodeByShortcutKey(node.statusDependencies[m], searchingKey) if (child !== undefined) { diff --git a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index 3c1a77195..362c263c2 100644 --- a/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignerSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -8,6 +8,8 @@ function newUiObjectsFromNodes () { addTradingBot: addTradingBot, addProcessDefinition: addProcessDefinition, addMissingProcessDefinitionItems: addMissingProcessDefinitionItems, + addProcessOutput: addProcessOutput, + addProcessDependencies: addProcessDependencies, addStatusReport: addStatusReport, addExecutionStartedEvent: addExecutionStartedEvent, addExecutionFinishedEvent: addExecutionFinishedEvent, @@ -771,6 +773,12 @@ function newUiObjectsFromNodes () { } } createUiObject(node.type, node.name, node, parentNode, chainParent, node.type) + if (node.processOutput !== undefined) { + createUiObjectFromNode(node.processOutput, node, node) + } + if (node.processDependencies !== undefined) { + createUiObjectFromNode(node.processDependencies, node, node) + } if (node.statusReport !== undefined) { createUiObjectFromNode(node.statusReport, node, node) } @@ -786,10 +794,23 @@ function newUiObjectsFromNodes () { if (node.dataBuilding !== undefined) { createUiObjectFromNode(node.dataBuilding, node, node) } + if (referenceChildren !== undefined) { + node.savedPayload = { + referenceChildren: referenceChildren + } + } + return + } + case 'Process Output': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type) for (let m = 0; m < node.outputDatasets.length; m++) { let outputDataset = node.outputDatasets[m] createUiObjectFromNode(outputDataset, node, node) } + return + } + case 'Process Dependencies': { + createUiObject(node.type, node.name, node, parentNode, chainParent, node.type) for (let m = 0; m < node.statusDependencies.length; m++) { let statusDependency = node.statusDependencies[m] createUiObjectFromNode(statusDependency, node, node) @@ -798,11 +819,6 @@ function newUiObjectsFromNodes () { let dataDependency = node.dataDependencies[m] createUiObjectFromNode(dataDependency, node, node) } - if (referenceChildren !== undefined) { - node.savedPayload = { - referenceChildren: referenceChildren - } - } return } case 'Status Report': { @@ -1088,9 +1104,6 @@ function newUiObjectsFromNodes () { type: 'Process Definition', name: 'New Process Definition', code: '{}', - outputDatasets: [], - statusDependencies: [], - dataDependencies: [], referenceChildren: [] } if (node.processes === undefined) { @@ -1103,6 +1116,8 @@ function newUiObjectsFromNodes () { } function addMissingProcessDefinitionItems (node) { + addProcessOutput(node) + addProcessDependencies(node) addStatusReport(node) addExecutionStartedEvent(node) addExecutionFinishedEvent(node) @@ -1110,6 +1125,31 @@ function newUiObjectsFromNodes () { addDataBuildingProcedure(node) } + function addProcessOutput (node) { + if (node.processOutput === undefined) { + node.processOutput = { + type: 'Process Output', + name: 'New Process Output', + outputDatasets: [] + } + createUiObject(node.processOutput.type, node.processOutput.name, node.processOutput, node, node) + } + return node.processOutput + } + + function addProcessDependencies (node) { + if (node.processDependencies === undefined) { + node.processDependencies = { + type: 'Process Dependencies', + name: 'New Process Dependencies', + statusDependencies: [], + dataDependencies: [] + } + createUiObject(node.processDependencies.type, node.processDependencies.name, node.processDependencies, node, node) + } + return node.processDependencies + } + function addStatusReport (node) { if (node.statusReport === undefined) { node.statusReport = { diff --git a/DesignerSpace/Workspace/Workspace.js b/DesignerSpace/Workspace/Workspace.js index 1783221ed..4e15e283c 100644 --- a/DesignerSpace/Workspace/Workspace.js +++ b/DesignerSpace/Workspace/Workspace.js @@ -346,6 +346,16 @@ function newWorkspace () { functionLibraryUiObjectsFromNodes.addMissingProcessDefinitionItems(payload.node) } break + case 'Add Process Output': + { + functionLibraryUiObjectsFromNodes.addProcessOutput(payload.node) + } + break + case 'Add Process Dependencies': + { + functionLibraryUiObjectsFromNodes.addProcessDependencies(payload.node) + } + break case 'Add Status Report': { functionLibraryUiObjectsFromNodes.addStatusReport(payload.node) @@ -636,6 +646,14 @@ function newWorkspace () { functionLibraryNodeDeleter.deleteProcessDefinition(payload.node, thisObject.workspaceNode.rootNodes) break } + case 'Delete Process Output': { + functionLibraryNodeDeleter.deleteProcessOutput(payload.node, thisObject.workspaceNode.rootNodes) + break + } + case 'Delete Process Dependencies': { + functionLibraryNodeDeleter.deleteProcessDependencies(payload.node, thisObject.workspaceNode.rootNodes) + break + } case 'Delete Status Report': { functionLibraryNodeDeleter.deleteStatusReport(payload.node, thisObject.workspaceNode.rootNodes) break diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index eae98c25e..d0f94a789 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -228,6 +228,14 @@ function newUiObject () { compatibleType = '->' + 'Sensor Bot' + '->' + 'Indicator Bot' + '->' + 'Trading Bot' + '->' compatibleSubType = undefined break + case 'Process Output': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break + case 'Process Dependencies': + compatibleType = '->' + 'Process Definition' + '->' + compatibleSubType = undefined + break case 'Status Report': compatibleType = '->' + 'Process Definition' + '->' compatibleSubType = undefined @@ -257,15 +265,15 @@ function newUiObject () { compatibleSubType = undefined break case 'Output Dataset': - compatibleType = '->' + 'Process Definition' + '->' + compatibleType = '->' + 'Process Output' + '->' compatibleSubType = undefined break case 'Status Dependency': - compatibleType = '->' + 'Process Definition' + '->' + compatibleType = '->' + 'Process Dependencies' + '->' compatibleSubType = undefined break case 'Data Dependency': - compatibleType = '->' + 'Process Definition' + '->' + compatibleType = '->' + 'Process Dependencies' + '->' compatibleSubType = undefined break case 'Product Definition': diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 2898afc2f..c3bb37d3f 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -663,7 +663,7 @@ function newUiObjectConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -70, + angle: -60, dontShowAtFullscreen: true } ) @@ -677,48 +677,9 @@ function newUiObjectConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -40 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Output Dataset', - actionFunction: payload.onMenuItemClick, - label: 'Add Output Dataset', - visible: true, - relatedUiObject: 'Output Dataset', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, angle: -20 } - ) - menuItemsInitialValues.push( - { - action: 'Add Status Dependency', - actionFunction: payload.onMenuItemClick, - label: 'Add Status Dependency', - visible: true, - relatedUiObject: 'Status Dependency', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 0 - } - ) - menuItemsInitialValues.push( - { - action: 'Add Data Dependency', - actionFunction: payload.onMenuItemClick, - label: 'Add Data Dependency', - visible: true, - relatedUiObject: 'Data Dependency', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 20 - } - ) + ) menuItemsInitialValues.push( { action: 'Delete Process Definition', @@ -732,7 +693,7 @@ function newUiObjectConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 40 + angle: 20 } ) menuItemsInitialValues.push( @@ -746,7 +707,114 @@ function newUiObjectConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 70 + angle: 60 + } + ) + break + } + case 'Process Output': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Output Dataset', + actionFunction: payload.onMenuItemClick, + label: 'Add Output Dataset', + visible: true, + relatedUiObject: 'Output Dataset', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -30 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process Output', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process Output', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 0 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 30 + } + ) + break + } + case 'Process Dependencies': { + addLeftIcons(menuItemsInitialValues, floatingObject) + menuItemsInitialValues.push( + { + action: 'Add Status Dependency', + actionFunction: payload.onMenuItemClick, + label: 'Add Status Dependency', + visible: true, + relatedUiObject: 'Status Dependency', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -60 + } + ) + menuItemsInitialValues.push( + { + action: 'Add Data Dependency', + actionFunction: payload.onMenuItemClick, + label: 'Add Data Dependency', + visible: true, + relatedUiObject: 'Data Dependency', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -20 + } + ) + menuItemsInitialValues.push( + { + action: 'Delete Process Dependencies', + askConfirmation: true, + confirmationLabel: 'Confirm to Delete', + actionFunction: payload.onMenuItemClick, + label: 'Delete Process Dependencies', + visible: true, + iconPathOn: 'delete', + iconPathOff: 'delete', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 + } + ) + menuItemsInitialValues.push( + { + action: 'Share', + actionFunction: payload.onMenuItemClick, + label: 'Share', + visible: true, + iconPathOn: 'menu-share', + iconPathOff: 'menu-share', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 60 } ) break @@ -4488,7 +4556,15 @@ function newUiObjectConstructor () { break } case 'Process Definition': { - level_0() + level_2() + break + } + case 'Process Output': { + level_3() + break + } + case 'Process Dependencies': { + level_3() break } case 'Status Report': { diff --git a/Spaces/DesignerSpace.js b/Spaces/DesignerSpace.js index f5142e240..f8fea61cc 100644 --- a/Spaces/DesignerSpace.js +++ b/Spaces/DesignerSpace.js @@ -95,6 +95,8 @@ function newDesignerSpace () { ['Indicator Bot', 'bot-indicator'], ['Trading Bot', 'bot-trading'], ['Process Definition', 'process-definition'], + ['Process Output', 'image'], + ['Process Dependencies', 'headphones'], ['Status Report', 'text'], ['Execution Started Event', 'pantone'], ['Execution Finished Event', 'pantone'],