Change in Code Indentation
This commit is contained in:
1 parent
1a52e5494e
commit
199a71a4e5
89 files changed
+22093
-22093
No files matched your search
@@ -1,224 +1,224 @@
|
||||
function newCCXTFunctions () {
|
||||
thisObject = {
|
||||
addMissingExchanges: addMissingExchanges,
|
||||
addMissingAssets: addMissingAssets,
|
||||
addMissingMarkets: addMissingMarkets
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function addMissingExchanges (node, functionLibraryUiObjectsFromNodes) {
|
||||
currentExchanges = new Map()
|
||||
let parent = node.payload.parentNode
|
||||
if (parent !== undefined) {
|
||||
for (let i = 0; i < parent.cryptoExchanges.length; i++) {
|
||||
let cryptoExchanges = parent.cryptoExchanges[i]
|
||||
for (let j = 0; j < cryptoExchanges.exchanges.length; j++) {
|
||||
let exchange = cryptoExchanges.exchanges[j]
|
||||
let codeName = loadPropertyFromNodeConfig(exchange.payload, 'codeName')
|
||||
currentExchanges.set(codeName, exchange)
|
||||
}
|
||||
}
|
||||
function newCCXTFunctions() {
|
||||
thisObject = {
|
||||
addMissingExchanges: addMissingExchanges,
|
||||
addMissingAssets: addMissingAssets,
|
||||
addMissingMarkets: addMissingMarkets
|
||||
}
|
||||
|
||||
let params = {
|
||||
method: 'listExchanges',
|
||||
has: {
|
||||
fetchOHLCV: true,
|
||||
fetchMarkets: true
|
||||
}
|
||||
}
|
||||
return thisObject
|
||||
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse (err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
return
|
||||
}
|
||||
|
||||
let exchanges = JSON.parse(data)
|
||||
for (let i = 0; i < exchanges.length; i++) {
|
||||
let exchange = exchanges[i]
|
||||
let existingExchange = currentExchanges.get(exchange.id)
|
||||
if (existingExchange === undefined) {
|
||||
let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange')
|
||||
newExchange.name = exchange.name
|
||||
newExchange.config = '{ \n\"codeName\": \"' + exchange.id + '\"\n}'
|
||||
newExchange.payload.floatingObject.collapseToggle()
|
||||
newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeAccounts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeAssets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newExchange.exchangeMarkets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newExchange.exchangeAccounts.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
|
||||
newExchange.exchangeAssets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newExchange.exchangeMarkets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newExchange.exchangeAccounts.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addMissingAssets (node, functionLibraryUiObjectsFromNodes) {
|
||||
if (node.payload.parentNode === undefined) { return }
|
||||
|
||||
let currentAssets = new Map()
|
||||
for (let j = 0; j < node.assets.length; j++) {
|
||||
let asset = node.assets[j]
|
||||
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
|
||||
currentAssets.set(codeName, asset)
|
||||
}
|
||||
|
||||
let exchangeId = loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
|
||||
|
||||
try {
|
||||
let params = {
|
||||
exchangeId: exchangeId,
|
||||
method: 'fetchMarkets'
|
||||
}
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse (err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
return
|
||||
}
|
||||
let queryParams = loadPropertyFromNodeConfig(node.payload, 'addMissingAssets')
|
||||
|
||||
let markets = JSON.parse(data)
|
||||
for (let i = 0; i < markets.length; i++) {
|
||||
let market = markets[i]
|
||||
|
||||
if (queryParams !== undefined) {
|
||||
if (queryParams.baseAsset !== undefined) {
|
||||
if (market.base.indexOf(queryParams.baseAsset) < 0) {
|
||||
continue
|
||||
}
|
||||
function addMissingExchanges(node, functionLibraryUiObjectsFromNodes) {
|
||||
currentExchanges = new Map()
|
||||
let parent = node.payload.parentNode
|
||||
if (parent !== undefined) {
|
||||
for (let i = 0; i < parent.cryptoExchanges.length; i++) {
|
||||
let cryptoExchanges = parent.cryptoExchanges[i]
|
||||
for (let j = 0; j < cryptoExchanges.exchanges.length; j++) {
|
||||
let exchange = cryptoExchanges.exchanges[j]
|
||||
let codeName = loadPropertyFromNodeConfig(exchange.payload, 'codeName')
|
||||
currentExchanges.set(codeName, exchange)
|
||||
}
|
||||
}
|
||||
if (queryParams.quotedAsset !== undefined) {
|
||||
if (market.quote.indexOf(queryParams.quotedAsset) < 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
let params = {
|
||||
method: 'listExchanges',
|
||||
has: {
|
||||
fetchOHLCV: true,
|
||||
fetchMarkets: true
|
||||
}
|
||||
}
|
||||
if (currentAssets.get(market.base) === undefined) {
|
||||
addAsset(market.base)
|
||||
currentAssets.set(market.base, market.base)
|
||||
}
|
||||
if (currentAssets.get(market.quote) === undefined) {
|
||||
addAsset(market.quote)
|
||||
currentAssets.set(market.quote, market.quote)
|
||||
}
|
||||
|
||||
function addAsset (name) {
|
||||
let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset')
|
||||
newAsseet.name = name
|
||||
newAsseet.config = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
console.log(err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function addMissingMarkets (node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning) {
|
||||
if (node.payload.parentNode === undefined) { return }
|
||||
if (node.payload.parentNode.exchangeAssets === undefined) { return }
|
||||
if (node.payload.parentNode.payload.parentNode === undefined) { return }
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { return }
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode.superActions === undefined) { return }
|
||||
|
||||
let currentAssets = new Map()
|
||||
let exchangeAssets = node.payload.parentNode.exchangeAssets
|
||||
for (let j = 0; j < exchangeAssets.assets.length; j++) {
|
||||
let asset = exchangeAssets.assets[j]
|
||||
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
|
||||
currentAssets.set(codeName, asset)
|
||||
}
|
||||
|
||||
let currentMarkets = new Map()
|
||||
let exchangeMarkets = node
|
||||
for (let j = 0; j < exchangeMarkets.markets.length; j++) {
|
||||
let asset = exchangeMarkets.markets[j]
|
||||
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
|
||||
currentMarkets.set(codeName, asset)
|
||||
}
|
||||
|
||||
let exchangeId = loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
|
||||
|
||||
try {
|
||||
let params = {
|
||||
exchangeId: exchangeId,
|
||||
method: 'fetchMarkets'
|
||||
}
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse (err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
return
|
||||
}
|
||||
|
||||
let markets = JSON.parse(data)
|
||||
for (let i = 0; i < markets.length; i++) {
|
||||
let market = markets[i]
|
||||
let baseAsset = currentAssets.get(market.base)
|
||||
let quotedAsset = currentAssets.get(market.quote)
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
if (baseAsset === undefined) {
|
||||
continue
|
||||
}
|
||||
if (quotedAsset === undefined) {
|
||||
continue
|
||||
}
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
return
|
||||
}
|
||||
|
||||
if (currentMarkets.get(market.symbol) === undefined) {
|
||||
addMarket(market.symbol, baseAsset, quotedAsset)
|
||||
}
|
||||
|
||||
function addMarket (name, baseAsset, quotedAsset) {
|
||||
let newMarket = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Market')
|
||||
newMarket.name = name
|
||||
newMarket.config = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.baseAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
newMarket.quotedAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
newMarket.baseAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newMarket.quotedAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_150X
|
||||
newMarket.baseAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.quotedAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.baseAsset.payload.referenceParent = baseAsset
|
||||
newMarket.quotedAsset.payload.referenceParent = quotedAsset
|
||||
|
||||
currentMarkets.set(name, newMarket)
|
||||
|
||||
let superActions = node.payload.parentNode.payload.parentNode.payload.parentNode.superActions
|
||||
|
||||
for (let j = 0; j < superActions.superActions.length; j++) {
|
||||
let superAction = superActions.superActions[j]
|
||||
let clone = functionLibraryNodeCloning.getNodeClone(superAction)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(clone, newMarket, newMarket)
|
||||
newMarket.superActions.push(clone)
|
||||
switch (j) {
|
||||
case 0:
|
||||
clone.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
|
||||
break
|
||||
case 1:
|
||||
clone.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
break
|
||||
}
|
||||
let exchanges = JSON.parse(data)
|
||||
for (let i = 0; i < exchanges.length; i++) {
|
||||
let exchange = exchanges[i]
|
||||
let existingExchange = currentExchanges.get(exchange.id)
|
||||
if (existingExchange === undefined) {
|
||||
let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange')
|
||||
newExchange.name = exchange.name
|
||||
newExchange.config = '{ \n\"codeName\": \"' + exchange.id + '\"\n}'
|
||||
newExchange.payload.floatingObject.collapseToggle()
|
||||
newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeAccounts.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newExchange.exchangeAssets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newExchange.exchangeMarkets.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newExchange.exchangeAccounts.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
|
||||
newExchange.exchangeAssets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newExchange.exchangeMarkets.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newExchange.exchangeAccounts.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
console.log(err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function addMissingAssets(node, functionLibraryUiObjectsFromNodes) {
|
||||
if (node.payload.parentNode === undefined) { return }
|
||||
|
||||
let currentAssets = new Map()
|
||||
for (let j = 0; j < node.assets.length; j++) {
|
||||
let asset = node.assets[j]
|
||||
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
|
||||
currentAssets.set(codeName, asset)
|
||||
}
|
||||
|
||||
let exchangeId = loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
|
||||
|
||||
try {
|
||||
let params = {
|
||||
exchangeId: exchangeId,
|
||||
method: 'fetchMarkets'
|
||||
}
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
return
|
||||
}
|
||||
let queryParams = loadPropertyFromNodeConfig(node.payload, 'addMissingAssets')
|
||||
|
||||
let markets = JSON.parse(data)
|
||||
for (let i = 0; i < markets.length; i++) {
|
||||
let market = markets[i]
|
||||
|
||||
if (queryParams !== undefined) {
|
||||
if (queryParams.baseAsset !== undefined) {
|
||||
if (market.base.indexOf(queryParams.baseAsset) < 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if (queryParams.quotedAsset !== undefined) {
|
||||
if (market.quote.indexOf(queryParams.quotedAsset) < 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentAssets.get(market.base) === undefined) {
|
||||
addAsset(market.base)
|
||||
currentAssets.set(market.base, market.base)
|
||||
}
|
||||
if (currentAssets.get(market.quote) === undefined) {
|
||||
addAsset(market.quote)
|
||||
currentAssets.set(market.quote, market.quote)
|
||||
}
|
||||
|
||||
function addAsset(name) {
|
||||
let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset')
|
||||
newAsseet.name = name
|
||||
newAsseet.config = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
console.log(err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function addMissingMarkets(node, functionLibraryUiObjectsFromNodes, functionLibraryNodeCloning) {
|
||||
if (node.payload.parentNode === undefined) { return }
|
||||
if (node.payload.parentNode.exchangeAssets === undefined) { return }
|
||||
if (node.payload.parentNode.payload.parentNode === undefined) { return }
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) { return }
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode.superActions === undefined) { return }
|
||||
|
||||
let currentAssets = new Map()
|
||||
let exchangeAssets = node.payload.parentNode.exchangeAssets
|
||||
for (let j = 0; j < exchangeAssets.assets.length; j++) {
|
||||
let asset = exchangeAssets.assets[j]
|
||||
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
|
||||
currentAssets.set(codeName, asset)
|
||||
}
|
||||
|
||||
let currentMarkets = new Map()
|
||||
let exchangeMarkets = node
|
||||
for (let j = 0; j < exchangeMarkets.markets.length; j++) {
|
||||
let asset = exchangeMarkets.markets[j]
|
||||
let codeName = loadPropertyFromNodeConfig(asset.payload, 'codeName')
|
||||
currentMarkets.set(codeName, asset)
|
||||
}
|
||||
|
||||
let exchangeId = loadPropertyFromNodeConfig(node.payload.parentNode.payload, 'codeName')
|
||||
|
||||
try {
|
||||
let params = {
|
||||
exchangeId: exchangeId,
|
||||
method: 'fetchMarkets'
|
||||
}
|
||||
callServer(JSON.stringify(params), 'CCXT', onResponse)
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
return
|
||||
}
|
||||
|
||||
let markets = JSON.parse(data)
|
||||
for (let i = 0; i < markets.length; i++) {
|
||||
let market = markets[i]
|
||||
let baseAsset = currentAssets.get(market.base)
|
||||
let quotedAsset = currentAssets.get(market.quote)
|
||||
|
||||
if (baseAsset === undefined) {
|
||||
continue
|
||||
}
|
||||
if (quotedAsset === undefined) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (currentMarkets.get(market.symbol) === undefined) {
|
||||
addMarket(market.symbol, baseAsset, quotedAsset)
|
||||
}
|
||||
|
||||
function addMarket(name, baseAsset, quotedAsset) {
|
||||
let newMarket = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Market')
|
||||
newMarket.name = name
|
||||
newMarket.config = '{ \n\"codeName\": \"' + name + '\"\n}'
|
||||
newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
|
||||
newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.baseAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
newMarket.quotedAsset.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_45
|
||||
newMarket.baseAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_100X
|
||||
newMarket.quotedAsset.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_150X
|
||||
newMarket.baseAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.quotedAsset.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE
|
||||
newMarket.baseAsset.payload.referenceParent = baseAsset
|
||||
newMarket.quotedAsset.payload.referenceParent = quotedAsset
|
||||
|
||||
currentMarkets.set(name, newMarket)
|
||||
|
||||
let superActions = node.payload.parentNode.payload.parentNode.payload.parentNode.superActions
|
||||
|
||||
for (let j = 0; j < superActions.superActions.length; j++) {
|
||||
let superAction = superActions.superActions[j]
|
||||
let clone = functionLibraryNodeCloning.getNodeClone(superAction)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(clone, newMarket, newMarket)
|
||||
newMarket.superActions.push(clone)
|
||||
switch (j) {
|
||||
case 0:
|
||||
clone.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_025X
|
||||
break
|
||||
case 1:
|
||||
clone.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
node.payload.uiObject.setErrorMessage('Failed to Fetch Assets from the Exchange')
|
||||
console.log(err.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,221 +1,221 @@
|
||||
function newChainAttachDetach () {
|
||||
thisObject = {
|
||||
chainDetachNode: chainDetachNode,
|
||||
chainAttachNode: chainAttachNode
|
||||
}
|
||||
function newChainAttachDetach() {
|
||||
thisObject = {
|
||||
chainDetachNode: chainDetachNode,
|
||||
chainAttachNode: chainAttachNode
|
||||
}
|
||||
|
||||
return thisObject
|
||||
return thisObject
|
||||
|
||||
function chainDetachNode (node, rootNodes) {
|
||||
if (node.payload.parentNode === undefined) { return }
|
||||
switch (node.type) {
|
||||
case 'Phase': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.phases.length; i++) {
|
||||
let phase = payload.parentNode.phases[i]
|
||||
if (phase.id === node.id) {
|
||||
if (i < payload.parentNode.phases.length - 1) {
|
||||
let nextPhase = payload.parentNode.phases[i + 1]
|
||||
if (i > 0) {
|
||||
let previousPhase = payload.parentNode.phases[i - 1]
|
||||
nextPhase.payload.chainParent = previousPhase
|
||||
} else {
|
||||
nextPhase.payload.chainParent = payload.parentNode
|
||||
}
|
||||
}
|
||||
payload.parentNode.phases.splice(i, 1)
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
default: {
|
||||
let nodeDefinition = getNodeDefinition (node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Detach from parent */
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let parentNodeDefinition = getNodeDefinition (node.payload.parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (nodeDefinition.propertyNameAtParent === property.name) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
node.payload.parentNode[property.name] = undefined
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node.payload.parentNode[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let arrayItem = nodePropertyArray[j]
|
||||
if (arrayItem.id === node.id) {
|
||||
nodePropertyArray.splice(j, 1)
|
||||
function chainDetachNode(node, rootNodes) {
|
||||
if (node.payload.parentNode === undefined) { return }
|
||||
switch (node.type) {
|
||||
case 'Phase': {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.phases.length; i++) {
|
||||
let phase = payload.parentNode.phases[i]
|
||||
if (phase.id === node.id) {
|
||||
if (i < payload.parentNode.phases.length - 1) {
|
||||
let nextPhase = payload.parentNode.phases[i + 1]
|
||||
if (i > 0) {
|
||||
let previousPhase = payload.parentNode.phases[i - 1]
|
||||
nextPhase.payload.chainParent = previousPhase
|
||||
} else {
|
||||
nextPhase.payload.chainParent = payload.parentNode
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
payload.parentNode.phases.splice(i, 1)
|
||||
completeDetachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
default: {
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Detach from parent */
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let parentNodeDefinition = getNodeDefinition(node.payload.parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (nodeDefinition.propertyNameAtParent === property.name) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
node.payload.parentNode[property.name] = undefined
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node.payload.parentNode[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let arrayItem = nodePropertyArray[j]
|
||||
if (arrayItem.id === node.id) {
|
||||
nodePropertyArray.splice(j, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
completeDetachment(node, rootNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function chainAttachNode (node, attachToNode, rootNodes) {
|
||||
switch (node.type) {
|
||||
function chainAttachNode(node, attachToNode, rootNodes) {
|
||||
switch (node.type) {
|
||||
|
||||
case 'Exchange Account Key': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
if (node.payload.parentNode.keys !== undefined) {
|
||||
node.payload.parentNode.keys.push(node)
|
||||
} else {
|
||||
node.payload.parentNode.key = node
|
||||
}
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
|
||||
case 'Phase': {
|
||||
switch (attachToNode.type) {
|
||||
case 'Stop': {
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Take Profit': {
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Initial Stop': {
|
||||
if (attachToNode.phases.length >= 1) {
|
||||
return
|
||||
}
|
||||
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Initial Take Profit': {
|
||||
if (attachToNode.phases.length >= 1) {
|
||||
return
|
||||
}
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
node.payload.parentNode = attachToNode.payload.parentNode
|
||||
for (let i = 0; i < node.payload.parentNode.phases.length; i++) {
|
||||
let phase = node.payload.parentNode.phases[i]
|
||||
if (attachToNode.id === phase.id) {
|
||||
if (i === node.payload.parentNode.phases.length - 1) {
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
case 'Exchange Account Key': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
if (node.payload.parentNode.keys !== undefined) {
|
||||
node.payload.parentNode.keys.push(node)
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
let nextPhase = node.payload.parentNode.phases[i + 1]
|
||||
nextPhase.payload.chainParent = node
|
||||
node.payload.parentNode.phases.splice(i + 1, 0, node)
|
||||
completeAttachment(node, rootNodes)
|
||||
return
|
||||
node.payload.parentNode.key = node
|
||||
}
|
||||
}
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
default: {
|
||||
let nodeDefinition = getNodeDefinition (node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
/* Attach to new parent */
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let parentNodeDefinition = getNodeDefinition (node.payload.parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (nodeDefinition.propertyNameAtParent === property.name) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
node.payload.parentNode[property.name] = node
|
||||
}
|
||||
break
|
||||
|
||||
case 'Phase': {
|
||||
switch (attachToNode.type) {
|
||||
case 'Stop': {
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
if (node.payload.parentNode[property.name] === undefined) {
|
||||
node.payload.parentNode[property.name] = []
|
||||
case 'Take Profit': {
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Initial Stop': {
|
||||
if (attachToNode.phases.length >= 1) {
|
||||
return
|
||||
}
|
||||
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Initial Take Profit': {
|
||||
if (attachToNode.phases.length >= 1) {
|
||||
return
|
||||
}
|
||||
node.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
node.payload.chainParent = phase
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
node.payload.parentNode = attachToNode.payload.parentNode
|
||||
for (let i = 0; i < node.payload.parentNode.phases.length; i++) {
|
||||
let phase = node.payload.parentNode.phases[i]
|
||||
if (attachToNode.id === phase.id) {
|
||||
if (i === node.payload.parentNode.phases.length - 1) {
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.phases.push(node)
|
||||
completeAttachment(node, rootNodes)
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
let nextPhase = node.payload.parentNode.phases[i + 1]
|
||||
nextPhase.payload.chainParent = node
|
||||
node.payload.parentNode.phases.splice(i + 1, 0, node)
|
||||
completeAttachment(node, rootNodes)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
let nodePropertyArray = node.payload.parentNode[property.name]
|
||||
nodePropertyArray.push(node)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
completeAttachment(node, rootNodes)
|
||||
break
|
||||
default: {
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
/* Attach to new parent */
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let parentNodeDefinition = getNodeDefinition(node.payload.parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (nodeDefinition.propertyNameAtParent === property.name) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
node.payload.parentNode[property.name] = node
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
if (node.payload.parentNode[property.name] === undefined) {
|
||||
node.payload.parentNode[property.name] = []
|
||||
}
|
||||
let nodePropertyArray = node.payload.parentNode[property.name]
|
||||
nodePropertyArray.push(node)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
completeAttachment(node, rootNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function completeDetachment (node, rootNodes) {
|
||||
node.payload.parentNode = undefined
|
||||
node.payload.chainParent = undefined
|
||||
rootNodes.push(node)
|
||||
}
|
||||
function completeDetachment(node, rootNodes) {
|
||||
node.payload.parentNode = undefined
|
||||
node.payload.chainParent = undefined
|
||||
rootNodes.push(node)
|
||||
}
|
||||
|
||||
function completeAttachment (node, rootNodes) {
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode.id === node.id) {
|
||||
rootNodes.splice(i, 1)
|
||||
return
|
||||
}
|
||||
function completeAttachment(node, rootNodes) {
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode.id === node.id) {
|
||||
rootNodes.splice(i, 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +1,74 @@
|
||||
function newDependenciesFilter () {
|
||||
thisObject = {
|
||||
createFilter: createFilter
|
||||
}
|
||||
function newDependenciesFilter() {
|
||||
thisObject = {
|
||||
createFilter: createFilter
|
||||
}
|
||||
|
||||
return thisObject
|
||||
return thisObject
|
||||
|
||||
function createFilter (node) {
|
||||
let filters = new Map()
|
||||
recursiveFilter(node)
|
||||
function createFilter(node) {
|
||||
let filters = new Map()
|
||||
recursiveFilter(node)
|
||||
|
||||
return Array.from(filters.keys())
|
||||
return Array.from(filters.keys())
|
||||
|
||||
function recursiveFilter (node) {
|
||||
filter(node.code)
|
||||
function recursiveFilter(node) {
|
||||
filter(node.code)
|
||||
|
||||
let nodeDefinition = getNodeDefinition (node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.
|
||||
for (let i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.
|
||||
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
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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 }
|
||||
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]
|
||||
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)
|
||||
// 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,67 +1,67 @@
|
||||
function newNodeChildren () {
|
||||
thisObject = {
|
||||
childrenCount: childrenCount
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function childrenCount (parentNode, childNode) {
|
||||
return countChildrenUiObject(parentNode, childNode)
|
||||
}
|
||||
|
||||
function countChildrenUiObject (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
function newNodeChildren() {
|
||||
thisObject = {
|
||||
childrenCount: childrenCount
|
||||
}
|
||||
let parentNodeDefinition = getNodeDefinition (parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.
|
||||
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (parentNode[property.name] !== undefined) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (property.name !== previousPropertyName) {
|
||||
response.childrenCount++
|
||||
if (parentNode[property.name].id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodeDefinition = getNodeDefinition (childNode)
|
||||
if (nodeDefinition !== undefined) {
|
||||
let nodePropertyArray = parentNode[property.name]
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let child = nodePropertyArray[j]
|
||||
if (nodeDefinition.chainedToSameType === true) {
|
||||
if (j < 1) {
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function childrenCount(parentNode, childNode) {
|
||||
return countChildrenUiObject(parentNode, childNode)
|
||||
}
|
||||
|
||||
function countChildrenUiObject(parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
let parentNodeDefinition = getNodeDefinition(parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.
|
||||
|
||||
return response
|
||||
}
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (parentNode[property.name] !== undefined) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (property.name !== previousPropertyName) {
|
||||
response.childrenCount++
|
||||
if (parentNode[property.name].id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodeDefinition = getNodeDefinition(childNode)
|
||||
if (nodeDefinition !== undefined) {
|
||||
let nodePropertyArray = parentNode[property.name]
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let child = nodePropertyArray[j]
|
||||
if (nodeDefinition.chainedToSameType === true) {
|
||||
if (j < 1) {
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response.childrenCount++
|
||||
if (child.id === childNode.id) {
|
||||
response.childIndex = response.childrenCount
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
}
|
||||
@@ -1,176 +1,176 @@
|
||||
function newNodeCloning () {
|
||||
const MODULE_NAME = 'Node Cloning'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
function newNodeCloning() {
|
||||
const MODULE_NAME = 'Node Cloning'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
thisObject = {
|
||||
getNodeClone: getNodeClone
|
||||
}
|
||||
return thisObject
|
||||
thisObject = {
|
||||
getNodeClone: getNodeClone
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getNodeClone (node) {
|
||||
let idConversionMap = new Map()
|
||||
function getNodeClone(node) {
|
||||
let idConversionMap = new Map()
|
||||
|
||||
let inmatureClone = cloneNode(node)
|
||||
let matureClone = redirectReferenceParents(inmatureClone)
|
||||
let inmatureClone = cloneNode(node)
|
||||
let matureClone = redirectReferenceParents(inmatureClone)
|
||||
|
||||
return matureClone
|
||||
return matureClone
|
||||
|
||||
function cloneNode (node) {
|
||||
if (node === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
let object = {
|
||||
type: node.type,
|
||||
name: node.name,
|
||||
code: node.code,
|
||||
config: node.config
|
||||
}
|
||||
|
||||
/* 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 (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
object[property.name] = cloneNode(node[property.name])
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
function cloneNode(node) {
|
||||
if (node === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
let object = {
|
||||
type: node.type,
|
||||
name: node.name,
|
||||
code: node.code,
|
||||
config: node.config
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = cloneNode(nodePropertyArray[m])
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
|
||||
/* 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 (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
object[property.name] = cloneNode(node[property.name])
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = cloneNode(nodePropertyArray[m])
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
object.id = newUniqueId()
|
||||
idConversionMap.set(node.id, object.id)
|
||||
|
||||
object.savedPayload = getSavedPayload(node)
|
||||
|
||||
return object
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object.id = newUniqueId()
|
||||
idConversionMap.set(node.id, object.id)
|
||||
|
||||
object.savedPayload = getSavedPayload(node)
|
||||
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
||||
function redirectReferenceParents (node) {
|
||||
if (node === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
let object = {
|
||||
type: node.type,
|
||||
name: node.name,
|
||||
code: node.code,
|
||||
config: node.config
|
||||
}
|
||||
|
||||
/* 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 (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
object[property.name] = redirectReferenceParents(node[property.name])
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
function redirectReferenceParents(node) {
|
||||
if (node === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
let object = {
|
||||
type: node.type,
|
||||
name: node.name,
|
||||
code: node.code,
|
||||
config: node.config
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = redirectReferenceParents(nodePropertyArray[m])
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
|
||||
/* 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 (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
object[property.name] = redirectReferenceParents(node[property.name])
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = redirectReferenceParents(nodePropertyArray[m])
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
object.id = node.id
|
||||
|
||||
object.savedPayload = node.savedPayload
|
||||
|
||||
if (object.savedPayload !== undefined) {
|
||||
if (object.savedPayload.referenceParent !== undefined) {
|
||||
let newId = idConversionMap.get(object.savedPayload.referenceParent.id)
|
||||
if (newId !== undefined) {
|
||||
object.savedPayload.referenceParent.id = newId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return object
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getSavedPayload(node) {
|
||||
if (node.payload === undefined) { return }
|
||||
let savedPayload = {
|
||||
position: {
|
||||
x: node.payload.position.x,
|
||||
y: node.payload.position.y
|
||||
},
|
||||
targetPosition: {
|
||||
x: node.payload.targetPosition.x,
|
||||
y: node.payload.targetPosition.y
|
||||
},
|
||||
floatingObject: {
|
||||
isPinned: node.payload.floatingObject.isPinned,
|
||||
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
|
||||
isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually),
|
||||
angleToParent: (node.payload.floatingObject.angleToParent),
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent),
|
||||
arrangementStyle: (node.payload.floatingObject.arrangementStyle)
|
||||
},
|
||||
uiObject: {
|
||||
isRunning: node.payload.uiObject.isRunning,
|
||||
shortcutKey: node.payload.uiObject.shortcutKey
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object.id = node.id
|
||||
|
||||
object.savedPayload = node.savedPayload
|
||||
|
||||
if (object.savedPayload !== undefined) {
|
||||
if (object.savedPayload.referenceParent !== undefined) {
|
||||
let newId = idConversionMap.get(object.savedPayload.referenceParent.id)
|
||||
if (newId !== undefined) {
|
||||
object.savedPayload.referenceParent.id = newId
|
||||
/* Next for the ones that have a reference parent, we include it */
|
||||
if (node.payload.referenceParent !== undefined) {
|
||||
savedPayload.referenceParent = {
|
||||
type: node.payload.referenceParent.type,
|
||||
name: node.payload.referenceParent.name,
|
||||
id: node.payload.referenceParent.id
|
||||
}
|
||||
} else {
|
||||
/* The referenceParent property can be inherited from the previous saved payload. */
|
||||
if (node.savedPayload !== undefined) {
|
||||
savedPayload.referenceParent = node.savedPayload.referenceParent
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return object
|
||||
}
|
||||
return savedPayload
|
||||
}
|
||||
}
|
||||
|
||||
function getSavedPayload (node) {
|
||||
if (node.payload === undefined) { return }
|
||||
let savedPayload = {
|
||||
position: {
|
||||
x: node.payload.position.x,
|
||||
y: node.payload.position.y
|
||||
},
|
||||
targetPosition: {
|
||||
x: node.payload.targetPosition.x,
|
||||
y: node.payload.targetPosition.y
|
||||
},
|
||||
floatingObject: {
|
||||
isPinned: node.payload.floatingObject.isPinned,
|
||||
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
|
||||
isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually),
|
||||
angleToParent: (node.payload.floatingObject.angleToParent),
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent),
|
||||
arrangementStyle: (node.payload.floatingObject.arrangementStyle)
|
||||
},
|
||||
uiObject: {
|
||||
isRunning: node.payload.uiObject.isRunning,
|
||||
shortcutKey: node.payload.uiObject.shortcutKey
|
||||
}
|
||||
}
|
||||
|
||||
/* Next for the ones that have a reference parent, we include it */
|
||||
if (node.payload.referenceParent !== undefined) {
|
||||
savedPayload.referenceParent = {
|
||||
type: node.payload.referenceParent.type,
|
||||
name: node.payload.referenceParent.name,
|
||||
id: node.payload.referenceParent.id
|
||||
}
|
||||
} else {
|
||||
/* The referenceParent property can be inherited from the previous saved payload. */
|
||||
if (node.savedPayload !== undefined) {
|
||||
savedPayload.referenceParent = node.savedPayload.referenceParent
|
||||
}
|
||||
}
|
||||
|
||||
return savedPayload
|
||||
}
|
||||
}
|
||||
@@ -1,138 +1,138 @@
|
||||
function newNodeDeleter () {
|
||||
thisObject = {
|
||||
deleteWorkspace: deleteWorkspace,
|
||||
deleteUIObject: deleteUIObject
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function destroyUiObject (node) {
|
||||
canvas.floatingSpace.uiObjectConstructor.destroyUiObject(node.payload)
|
||||
}
|
||||
|
||||
function deleteWorkspace (node, rootNodes) {
|
||||
if (node.rootNodes !== undefined) {
|
||||
while (node.rootNodes.length > 0) {
|
||||
let rootNode = node.rootNodes[0]
|
||||
deleteUIObject(rootNode, rootNodes)
|
||||
}
|
||||
function newNodeDeleter() {
|
||||
thisObject = {
|
||||
deleteWorkspace: deleteWorkspace,
|
||||
deleteUIObject: deleteUIObject
|
||||
}
|
||||
|
||||
completeDeletion(node, rootNodes)
|
||||
destroyUiObject(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function deleteUIObject (node, rootNodes) {
|
||||
/* First we restore the reference parent to its default state */
|
||||
if (node.payload !== undefined && node.payload.referenceParent !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) {
|
||||
node.payload.referenceParent.payload.uiObject.isShowing = false
|
||||
function destroyUiObject(node) {
|
||||
canvas.floatingSpace.uiObjectConstructor.destroyUiObject(node.payload)
|
||||
}
|
||||
|
||||
let nodeDefinition = getNodeDefinition (node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Remove all of its own 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 (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
deleteUIObject(node[property.name], rootNodes)
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
function deleteWorkspace(node, rootNodes) {
|
||||
if (node.rootNodes !== undefined) {
|
||||
while (node.rootNodes.length > 0) {
|
||||
let rootNode = node.rootNodes[0]
|
||||
deleteUIObject(rootNode, rootNodes)
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
while (nodePropertyArray.length > 0) {
|
||||
deleteUIObject(nodePropertyArray[0], rootNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove node from parent */
|
||||
if (node.payload !== undefined) {
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let parentNodeDefinition = getNodeDefinition (node.payload.parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (nodeDefinition.propertyNameAtParent === property.name) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
node.payload.parentNode[property.name] = undefined
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node.payload.parentNode[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let arrayItem = nodePropertyArray[j]
|
||||
if (arrayItem.id === node.id) {
|
||||
/* If this object is chained to the ones of the same type we need to give the next in the chain the reference to the current chain parent */
|
||||
if (nodeDefinition.chainedToSameType === true) {
|
||||
if (j < nodePropertyArray.length - 1) {
|
||||
let nextArrayItem = nodePropertyArray[j + 1]
|
||||
nextArrayItem.payload.chainParent = node.payload.chainParent
|
||||
}
|
||||
completeDeletion(node, rootNodes)
|
||||
destroyUiObject(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
|
||||
function deleteUIObject(node, rootNodes) {
|
||||
/* First we restore the reference parent to its default state */
|
||||
if (node.payload !== undefined && node.payload.referenceParent !== undefined && node.payload.referenceParent.payload !== undefined && node.payload.referenceParent.payload.uiObject !== undefined) {
|
||||
node.payload.referenceParent.payload.uiObject.isShowing = false
|
||||
}
|
||||
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Remove all of its own 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 (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
deleteUIObject(node[property.name], rootNodes)
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
|
||||
nodePropertyArray.splice(j, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
while (nodePropertyArray.length > 0) {
|
||||
deleteUIObject(nodePropertyArray[0], rootNodes)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove node from parent */
|
||||
if (node.payload !== undefined) {
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let parentNodeDefinition = getNodeDefinition(node.payload.parentNode)
|
||||
if (parentNodeDefinition !== undefined) {
|
||||
if (parentNodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
|
||||
let property = parentNodeDefinition.properties[i]
|
||||
if (nodeDefinition.propertyNameAtParent === property.name) {
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
node.payload.parentNode[property.name] = undefined
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node.payload.parentNode[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let arrayItem = nodePropertyArray[j]
|
||||
if (arrayItem.id === node.id) {
|
||||
/* If this object is chained to the ones of the same type we need to give the next in the chain the reference to the current chain parent */
|
||||
if (nodeDefinition.chainedToSameType === true) {
|
||||
if (j < nodePropertyArray.length - 1) {
|
||||
let nextArrayItem = nodePropertyArray[j + 1]
|
||||
nextArrayItem.payload.chainParent = node.payload.chainParent
|
||||
}
|
||||
}
|
||||
|
||||
nodePropertyArray.splice(j, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
completeDeletion(node, rootNodes)
|
||||
destroyUiObject(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
completeDeletion(node, rootNodes)
|
||||
destroyUiObject(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
function completeDeletion (node, rootNodes) {
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode.id === node.id) {
|
||||
rootNodes.splice(i, 1)
|
||||
return
|
||||
}
|
||||
function completeDeletion(node, rootNodes) {
|
||||
for (let i = 0; i < rootNodes.length; i++) {
|
||||
let rootNode = rootNodes[i]
|
||||
if (rootNode.id === node.id) {
|
||||
rootNodes.splice(i, 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function cleanNode (node) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node === undefined) { return }
|
||||
function cleanNode(node) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node === undefined) { return }
|
||||
|
||||
node.payload.targetPosition.x = undefined
|
||||
node.payload.targetPosition.y = undefined
|
||||
node.payload.visible = undefined
|
||||
node.payload.subTitle = undefined
|
||||
node.payload.title = undefined
|
||||
node.payload.node = undefined
|
||||
node.payload.parentNode = undefined
|
||||
node.payload.chainParent = undefined
|
||||
node.payload.onMenuItemClick = undefined
|
||||
node.handle = undefined
|
||||
node.payload = undefined
|
||||
node.cleaned = true
|
||||
}
|
||||
node.payload.targetPosition.x = undefined
|
||||
node.payload.targetPosition.y = undefined
|
||||
node.payload.visible = undefined
|
||||
node.payload.subTitle = undefined
|
||||
node.payload.title = undefined
|
||||
node.payload.node = undefined
|
||||
node.payload.parentNode = undefined
|
||||
node.payload.chainParent = undefined
|
||||
node.payload.onMenuItemClick = undefined
|
||||
node.handle = undefined
|
||||
node.payload = undefined
|
||||
node.cleaned = true
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,56 @@
|
||||
function newOnFocus () {
|
||||
thisObject = {
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus
|
||||
}
|
||||
return thisObject
|
||||
function newOnFocus() {
|
||||
thisObject = {
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getNodeThatIsOnFocus (node) {
|
||||
if (node === undefined || node === null) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* First we ask the question to ourself */
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
}
|
||||
function getNodeThatIsOnFocus(node) {
|
||||
if (node === undefined || node === null) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* First we ask the question to ourself */
|
||||
if (node.payload.uiObject.isOnFocus === true) {
|
||||
return node
|
||||
}
|
||||
|
||||
/* Then we check all of its own children nodes. */
|
||||
if (node.payload.floatingObject.isCollapsed !== true) {
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
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]
|
||||
/* Then we check all of its own children nodes. */
|
||||
if (node.payload.floatingObject.isCollapsed !== true) {
|
||||
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) {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node[property.name])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
child = getNodeThatIsOnFocus(nodePropertyArray[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
let child
|
||||
child = getNodeThatIsOnFocus(node[property.name])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
child = getNodeThatIsOnFocus(nodePropertyArray[m])
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,187 +1,187 @@
|
||||
function newProtocolNode () {
|
||||
const MODULE_NAME = 'Protocol Node'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
function newProtocolNode() {
|
||||
const MODULE_NAME = 'Protocol Node'
|
||||
const ERROR_LOG = true
|
||||
const logger = newWebDebugLog()
|
||||
logger.fileName = MODULE_NAME
|
||||
|
||||
thisObject = {
|
||||
getProtocolNode: getProtocolNode
|
||||
}
|
||||
return thisObject
|
||||
thisObject = {
|
||||
getProtocolNode: getProtocolNode
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getProtocolNode (node, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) {
|
||||
if (node === undefined) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
function getProtocolNode(node, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) {
|
||||
if (node === undefined) { return }
|
||||
if (node.payload === undefined) { return }
|
||||
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return }
|
||||
let object = {
|
||||
type: node.type,
|
||||
name: node.name,
|
||||
code: node.code,
|
||||
config: node.config
|
||||
}
|
||||
|
||||
/* Children Nodes */
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (node[property.name] !== undefined) {
|
||||
if (lightingPath === undefined) {
|
||||
object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload)
|
||||
} else {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType)
|
||||
if (newLightingPath !== undefined) {
|
||||
object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return }
|
||||
let object = {
|
||||
type: node.type,
|
||||
name: node.name,
|
||||
code: node.code,
|
||||
config: node.config
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
if (lightingPath === undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload)
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
|
||||
/* Children Nodes */
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
for (let i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (node[property.name] !== undefined) {
|
||||
if (lightingPath === undefined) {
|
||||
object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload)
|
||||
} else {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType)
|
||||
if (newLightingPath !== undefined) {
|
||||
object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
case 'array': {
|
||||
if (node[property.name] !== undefined) {
|
||||
if (lightingPath === undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload)
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType)
|
||||
if (newLightingPath !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType)
|
||||
if (newLightingPath !== undefined) {
|
||||
let nodePropertyArray = node[property.name]
|
||||
object[property.name] = []
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
if (protocolNode !== undefined) {
|
||||
object[property.name].push(protocolNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
/* Parent Nodes */
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.parentNode.type)
|
||||
if (newLightingPath !== undefined) {
|
||||
object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
}
|
||||
}
|
||||
if (node.payload.referenceParent !== undefined) {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.referenceParent.type)
|
||||
if (newLightingPath !== undefined) {
|
||||
object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
}
|
||||
}
|
||||
|
||||
if (parseConfig && object.config !== undefined && nodeDefinition.editors !== undefined) {
|
||||
if (nodeDefinition.editors.config === true) {
|
||||
try {
|
||||
object.config = JSON.parse(node.config)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.type = ' + node.type) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.name = ' + node.name) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.config = ' + node.config) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (includeIds) {
|
||||
object.id = node.id
|
||||
}
|
||||
if (includePayload) {
|
||||
object.savedPayload = getSavedPayload(node, includeReferencesInSavedPayload)
|
||||
}
|
||||
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
||||
/* Parent Nodes */
|
||||
if (node.payload.parentNode !== undefined) {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.parentNode.type)
|
||||
if (newLightingPath !== undefined) {
|
||||
object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
}
|
||||
}
|
||||
if (node.payload.referenceParent !== undefined) {
|
||||
let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.referenceParent.type)
|
||||
if (newLightingPath !== undefined) {
|
||||
object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath)
|
||||
}
|
||||
}
|
||||
|
||||
if (parseConfig && object.config !== undefined && nodeDefinition.editors !== undefined) {
|
||||
if (nodeDefinition.editors.config === true) {
|
||||
try {
|
||||
object.config = JSON.parse(node.config)
|
||||
} catch (err) {
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> err = ' + err.stack) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.type = ' + node.type) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.name = ' + node.name) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.config = ' + node.config) }
|
||||
if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (includeIds) {
|
||||
object.id = node.id
|
||||
}
|
||||
if (includePayload) {
|
||||
object.savedPayload = getSavedPayload(node, includeReferencesInSavedPayload)
|
||||
}
|
||||
|
||||
return object
|
||||
}
|
||||
}
|
||||
|
||||
function getNewLightingPath (lightingPath, currentNodeType, nextNodeType) {
|
||||
if (lightingPath === undefined) { return }
|
||||
|
||||
if (currentNodeType === undefined) { return }
|
||||
if (nextNodeType === undefined) { return }
|
||||
|
||||
let currentNodePosition = lightingPath.indexOf('->' + currentNodeType + '->')
|
||||
let nextNodePosition = lightingPath.indexOf('->' + nextNodeType + '->')
|
||||
|
||||
let newLightingPath = lightingPath.substring(nextNodePosition, lightingPath.length + 1)
|
||||
|
||||
if (nextNodePosition > currentNodePosition) {
|
||||
return newLightingPath
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
function getSavedPayload (node, includeReferencesInSavedPayload) {
|
||||
if (node.payload === undefined) { return }
|
||||
let savedPayload = {
|
||||
position: {
|
||||
x: node.payload.position.x,
|
||||
y: node.payload.position.y
|
||||
},
|
||||
targetPosition: {
|
||||
x: node.payload.targetPosition.x,
|
||||
y: node.payload.targetPosition.y
|
||||
},
|
||||
floatingObject: {
|
||||
isPinned: node.payload.floatingObject.isPinned,
|
||||
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
|
||||
isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually),
|
||||
angleToParent: (node.payload.floatingObject.angleToParent),
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent),
|
||||
arrangementStyle: (node.payload.floatingObject.arrangementStyle)
|
||||
},
|
||||
uiObject: {
|
||||
isRunning: node.payload.uiObject.isRunning,
|
||||
shortcutKey: node.payload.uiObject.shortcutKey
|
||||
}
|
||||
}
|
||||
|
||||
if (node.payload.frame !== undefined) {
|
||||
savedPayload.frame = {
|
||||
position: {
|
||||
x: node.payload.frame.position.x,
|
||||
y: node.payload.frame.position.y
|
||||
},
|
||||
width: node.payload.frame.width,
|
||||
height: node.payload.frame.height,
|
||||
radius: node.payload.frame.radius
|
||||
}
|
||||
function getNewLightingPath(lightingPath, currentNodeType, nextNodeType) {
|
||||
if (lightingPath === undefined) { return }
|
||||
|
||||
if (currentNodeType === undefined) { return }
|
||||
if (nextNodeType === undefined) { return }
|
||||
|
||||
let currentNodePosition = lightingPath.indexOf('->' + currentNodeType + '->')
|
||||
let nextNodePosition = lightingPath.indexOf('->' + nextNodeType + '->')
|
||||
|
||||
let newLightingPath = lightingPath.substring(nextNodePosition, lightingPath.length + 1)
|
||||
|
||||
if (nextNodePosition > currentNodePosition) {
|
||||
return newLightingPath
|
||||
} else {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (includeReferencesInSavedPayload) {
|
||||
/* Next for the ones that have a reference parent, we include it */
|
||||
if (node.payload.referenceParent !== undefined) {
|
||||
savedPayload.referenceParent = {
|
||||
type: node.payload.referenceParent.type,
|
||||
name: node.payload.referenceParent.name,
|
||||
id: node.payload.referenceParent.id
|
||||
function getSavedPayload(node, includeReferencesInSavedPayload) {
|
||||
if (node.payload === undefined) { return }
|
||||
let savedPayload = {
|
||||
position: {
|
||||
x: node.payload.position.x,
|
||||
y: node.payload.position.y
|
||||
},
|
||||
targetPosition: {
|
||||
x: node.payload.targetPosition.x,
|
||||
y: node.payload.targetPosition.y
|
||||
},
|
||||
floatingObject: {
|
||||
isPinned: node.payload.floatingObject.isPinned,
|
||||
isFrozen: (node.payload.floatingObject.isFrozen && node.payload.floatingObject.frozenManually),
|
||||
isCollapsed: (node.payload.floatingObject.isCollapsed && node.payload.floatingObject.collapsedManually),
|
||||
angleToParent: (node.payload.floatingObject.angleToParent),
|
||||
distanceToParent: (node.payload.floatingObject.distanceToParent),
|
||||
arrangementStyle: (node.payload.floatingObject.arrangementStyle)
|
||||
},
|
||||
uiObject: {
|
||||
isRunning: node.payload.uiObject.isRunning,
|
||||
shortcutKey: node.payload.uiObject.shortcutKey
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* The referenceParent property can be inherited from the previous saved payload. */
|
||||
if (node.savedPayload !== undefined) {
|
||||
savedPayload.referenceParent = node.savedPayload.referenceParent
|
||||
|
||||
if (node.payload.frame !== undefined) {
|
||||
savedPayload.frame = {
|
||||
position: {
|
||||
x: node.payload.frame.position.x,
|
||||
y: node.payload.frame.position.y
|
||||
},
|
||||
width: node.payload.frame.width,
|
||||
height: node.payload.frame.height,
|
||||
radius: node.payload.frame.radius
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (includeReferencesInSavedPayload) {
|
||||
/* Next for the ones that have a reference parent, we include it */
|
||||
if (node.payload.referenceParent !== undefined) {
|
||||
savedPayload.referenceParent = {
|
||||
type: node.payload.referenceParent.type,
|
||||
name: node.payload.referenceParent.name,
|
||||
id: node.payload.referenceParent.id
|
||||
}
|
||||
} else {
|
||||
/* The referenceParent property can be inherited from the previous saved payload. */
|
||||
if (node.savedPayload !== undefined) {
|
||||
savedPayload.referenceParent = node.savedPayload.referenceParent
|
||||
}
|
||||
}
|
||||
}
|
||||
return savedPayload
|
||||
}
|
||||
return savedPayload
|
||||
}
|
||||
}
|
||||
@@ -1,37 +1,37 @@
|
||||
function newReferenceAttachDetach () {
|
||||
thisObject = {
|
||||
referenceDetachNode: referenceDetachNode,
|
||||
referenceAttachNode: referenceAttachNode
|
||||
}
|
||||
function newReferenceAttachDetach() {
|
||||
thisObject = {
|
||||
referenceDetachNode: referenceDetachNode,
|
||||
referenceAttachNode: referenceAttachNode
|
||||
}
|
||||
|
||||
return thisObject
|
||||
return thisObject
|
||||
|
||||
function referenceDetachNode (node) {
|
||||
completeDetachment(node)
|
||||
}
|
||||
function referenceDetachNode(node) {
|
||||
completeDetachment(node)
|
||||
}
|
||||
|
||||
function referenceAttachNode (node, attachToNode, rootNodes) {
|
||||
completeAttachment(node, attachToNode)
|
||||
}
|
||||
function referenceAttachNode(node, attachToNode, rootNodes) {
|
||||
completeAttachment(node, attachToNode)
|
||||
}
|
||||
|
||||
function completeAttachment (node, attachToNode) {
|
||||
node.payload.referenceParent = attachToNode
|
||||
}
|
||||
function completeAttachment(node, attachToNode) {
|
||||
node.payload.referenceParent = attachToNode
|
||||
}
|
||||
|
||||
function completeDetachment (node) {
|
||||
if (node.payload !== undefined !== undefined) {
|
||||
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
|
||||
}
|
||||
function completeDetachment(node) {
|
||||
if (node.payload !== undefined !== undefined) {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
node.payload.referenceParent = undefined
|
||||
if (node.savedPayload !== undefined) {
|
||||
node.savedPayload.referenceParent = undefined
|
||||
node.payload.referenceParent = undefined
|
||||
if (node.savedPayload !== undefined) {
|
||||
node.savedPayload.referenceParent = undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,185 +1,185 @@
|
||||
function newSessionFunctions () {
|
||||
thisObject = {
|
||||
runSession: runSession,
|
||||
stopSession: stopSession
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function runSession (node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, resume, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
function newSessionFunctions() {
|
||||
thisObject = {
|
||||
runSession: runSession,
|
||||
stopSession: stopSession
|
||||
}
|
||||
|
||||
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)
|
||||
return thisObject
|
||||
|
||||
node.payload.uiObject.run(eventsServerClient, callBackFunction)
|
||||
function runSession(node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, resume, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
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 lightingPath = '' +
|
||||
'Trading System->' +
|
||||
'Parameters->' +
|
||||
'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->' +
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Trading Strategy->' +
|
||||
'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' +
|
||||
'Announcement->Formula->' +
|
||||
'Open Stage->Initial Definition->Open Execution->' +
|
||||
'Position Size->Position Rate->Formula->' +
|
||||
'Initial Stop->Initial Take Profit->' +
|
||||
'Manage Stage->' +
|
||||
'Managed Stop Loss->Managed Take Profit->' +
|
||||
'Phase->Formula->Next Phase Event->Move To Phase Event->Phase->' +
|
||||
'Situation->Condition->Javascript Code->' +
|
||||
'Close Stage->Close Execution->' +
|
||||
'Announcement->Formula->' +
|
||||
'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' +
|
||||
'Create Order Event->Cancel Order Event->' +
|
||||
'Position Size->Position Rate->Formula->' +
|
||||
'Situation->Condition->Javascript Code->' +
|
||||
'Market Order->Limit Order->' +
|
||||
'Simulated Exchange Events->Simulated Partial Fill->Simulated Actual Rate->Simulated Fees Paid->Formula->'
|
||||
node.payload.uiObject.run(eventsServerClient, callBackFunction)
|
||||
|
||||
let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
|
||||
lightingPath = '' +
|
||||
'Trading Engine->' +
|
||||
'Dynamic Indicators->Indicator Function->Formula->' +
|
||||
'Episode->Current->Last->Previous->' +
|
||||
'Episode Counters->Episode Statistics->' +
|
||||
'Periods->Strategies->Positions->Orders->Hits->Fails->' +
|
||||
'Profit Loss->Hit Ratio->Days->ROI->Anualized Rate Of Return->User Defined Statistic->' +
|
||||
'Formula->' +
|
||||
'Candle->' +
|
||||
'Begin->End->Open->Close->Min->Max->Index->' +
|
||||
'Balance->Base Asset->Quoted Asset->' +
|
||||
'Distance To Event->' +
|
||||
'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Cancel Order->Close Order->' +
|
||||
'Strategy->' +
|
||||
'Serial Number->Identifier->Begin->End->Strategy Name->Index->Trigger Stage Status->Open Stage Status->Manage Stage Status->Close Stage Status->Status->Begin Rate->End Rate->Situation Name->' +
|
||||
'Strategy Counters->Periods->' +
|
||||
'Position->' +
|
||||
'Serial Number->Identifier->Begin->End->Rate->Size->Open Stage Orders Size->Open Stage Filled Size->Close Stage Orders Size->Close Stage Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' +
|
||||
'Stop Loss->Stop Loss Stage->Stop Loss Phase->' +
|
||||
'Take Profit->Take Profit Stage->Take Profit Phase->' +
|
||||
'Position Counters->Periods->' +
|
||||
'Position Statistics->Profit Loss->Days->ROI->Hit Fail->User Defined Statistic->' +
|
||||
'Formula->' +
|
||||
'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' +
|
||||
'Market Order->Limit Order->' +
|
||||
'Serial Number->Identifier->Exchange Id->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' +
|
||||
'Order Counters->Periods->' +
|
||||
'Order Statistics->Size Filled->Percentage Filled->Amount Received->Actual Rate->Fees Paid->Days->User Defined Statistic->'
|
||||
let lightingPath = '' +
|
||||
'Trading System->' +
|
||||
'Parameters->' +
|
||||
'Base Asset->Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->' +
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Trading Strategy->' +
|
||||
'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' +
|
||||
'Announcement->Formula->' +
|
||||
'Open Stage->Initial Definition->Open Execution->' +
|
||||
'Position Size->Position Rate->Formula->' +
|
||||
'Initial Stop->Initial Take Profit->' +
|
||||
'Manage Stage->' +
|
||||
'Managed Stop Loss->Managed Take Profit->' +
|
||||
'Phase->Formula->Next Phase Event->Move To Phase Event->Phase->' +
|
||||
'Situation->Condition->Javascript Code->' +
|
||||
'Close Stage->Close Execution->' +
|
||||
'Announcement->Formula->' +
|
||||
'Execution Algorithm->Market Buy Order->Market Sell Order->Limit Buy Order->Limit Sell Order->' +
|
||||
'Create Order Event->Cancel Order Event->' +
|
||||
'Position Size->Position Rate->Formula->' +
|
||||
'Situation->Condition->Javascript Code->' +
|
||||
'Market Order->Limit Order->' +
|
||||
'Simulated Exchange Events->Simulated Partial Fill->Simulated Actual Rate->Simulated Fees Paid->Formula->'
|
||||
|
||||
let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.tradingSystemReference.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
|
||||
lightingPath = '' +
|
||||
'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' +
|
||||
'Parameters->' +
|
||||
'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Snapshots->User Defined Parameters->' +
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Social Bots->Telegram Bot->'
|
||||
lightingPath = '' +
|
||||
'Trading Engine->' +
|
||||
'Dynamic Indicators->Indicator Function->Formula->' +
|
||||
'Episode->Current->Last->Previous->' +
|
||||
'Episode Counters->Episode Statistics->' +
|
||||
'Periods->Strategies->Positions->Orders->Hits->Fails->' +
|
||||
'Profit Loss->Hit Ratio->Days->ROI->Anualized Rate Of Return->User Defined Statistic->' +
|
||||
'Formula->' +
|
||||
'Candle->' +
|
||||
'Begin->End->Open->Close->Min->Max->Index->' +
|
||||
'Balance->Base Asset->Quoted Asset->' +
|
||||
'Distance To Event->' +
|
||||
'Trigger On->Trigger Off->Take Position->Close Position->Next Phase->Move To Phase->Create Order->Cancel Order->Close Order->' +
|
||||
'Strategy->' +
|
||||
'Serial Number->Identifier->Begin->End->Strategy Name->Index->Trigger Stage Status->Open Stage Status->Manage Stage Status->Close Stage Status->Status->Begin Rate->End Rate->Situation Name->' +
|
||||
'Strategy Counters->Periods->' +
|
||||
'Position->' +
|
||||
'Serial Number->Identifier->Begin->End->Rate->Size->Open Stage Orders Size->Open Stage Filled Size->Close Stage Orders Size->Close Stage Filled Size->Exit Type->Status->Begin Rate->End Rate->Situation Name->' +
|
||||
'Stop Loss->Stop Loss Stage->Stop Loss Phase->' +
|
||||
'Take Profit->Take Profit Stage->Take Profit Phase->' +
|
||||
'Position Counters->Periods->' +
|
||||
'Position Statistics->Profit Loss->Days->ROI->Hit Fail->User Defined Statistic->' +
|
||||
'Formula->' +
|
||||
'Exchange Orders->Market Buy Orders->Market Sell Orders->Limit Buy Orders->Limit Sell Orders->' +
|
||||
'Market Order->Limit Order->' +
|
||||
'Serial Number->Identifier->Exchange Id->Begin->End->Rate->Size->Exit Type->Status->Order Name->Algorithm Name->Situation Name->' +
|
||||
'Order Counters->Periods->' +
|
||||
'Order Statistics->Size Filled->Percentage Filled->Amount Received->Actual Rate->Fees Paid->Days->User Defined Statistic->'
|
||||
|
||||
let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
|
||||
let tradingEngine = functionLibraryProtocolNode.getProtocolNode(node.tradingEngineReference.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
|
||||
let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.tradingSystemReference.payload.referenceParent)
|
||||
lightingPath = '' +
|
||||
'Backtesting Session->Paper Trading Session->Fordward Testing Session->Live Trading Session->' +
|
||||
'Parameters->' +
|
||||
'Session Base Asset->Session Quoted Asset->Time Range->Time Frame->Slippage->Fee Structure->Snapshots->User Defined Parameters->' +
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Social Bots->Telegram Bot->'
|
||||
|
||||
/* Raise event to run the session */
|
||||
let event = {
|
||||
appSchema: JSON.stringify(APP_SCHEMA_ARRAY),
|
||||
session: JSON.stringify(session),
|
||||
tradingSystem: JSON.stringify(tradingSystem),
|
||||
tradingEngine: JSON.stringify(tradingEngine),
|
||||
dependencyFilter: JSON.stringify(dependencyFilter),
|
||||
resume: resume
|
||||
let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
|
||||
|
||||
let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.tradingSystemReference.payload.referenceParent)
|
||||
|
||||
/* Raise event to run the session */
|
||||
let event = {
|
||||
appSchema: JSON.stringify(APP_SCHEMA_ARRAY),
|
||||
session: JSON.stringify(session),
|
||||
tradingSystem: JSON.stringify(tradingSystem),
|
||||
tradingEngine: JSON.stringify(tradingEngine),
|
||||
dependencyFilter: JSON.stringify(dependencyFilter),
|
||||
resume: resume
|
||||
}
|
||||
|
||||
eventsServerClient.raiseEvent(key, 'Run Session', event)
|
||||
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
eventsServerClient.raiseEvent(key, 'Run Session', event)
|
||||
function stopSession(node, functionLibraryProtocolNode, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
|
||||
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)
|
||||
|
||||
function stopSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
eventsServerClient.raiseEvent(key, 'Stop Session')
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
}
|
||||
|
||||
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)
|
||||
function validations(node) {
|
||||
if (node.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.')
|
||||
return
|
||||
}
|
||||
|
||||
let key = node.name + '-' + node.type + '-' + node.id
|
||||
eventsServerClient.raiseEvent(key, 'Stop Session')
|
||||
if (node.payload.parentNode.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs to be inside a Trading Process Instance.')
|
||||
return
|
||||
}
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
}
|
||||
if (node.payload.parentNode.payload.parentNode.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs to be inside a Task.')
|
||||
return
|
||||
}
|
||||
|
||||
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.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.tradingSystemReference === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs a child Trading System Reference.')
|
||||
return
|
||||
}
|
||||
|
||||
if (node.tradingEngineReference === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs a child Trading Engine Reference.')
|
||||
return
|
||||
}
|
||||
|
||||
if (node.tradingSystemReference.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Trading System Reference needs to reference a Trading System.')
|
||||
return
|
||||
}
|
||||
|
||||
if (node.tradingEngineReference.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Trading Engine Reference needs to reference a Trading Engine.')
|
||||
return
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
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.tradingSystemReference === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs a child Trading System Reference.')
|
||||
return
|
||||
}
|
||||
|
||||
if (node.tradingEngineReference === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs a child Trading Engine Reference.')
|
||||
return
|
||||
}
|
||||
|
||||
if (node.tradingSystemReference.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Trading System Reference needs to reference a Trading System.')
|
||||
return
|
||||
}
|
||||
|
||||
if (node.tradingEngineReference.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Trading Engine Reference needs to reference a Trading Engine.')
|
||||
return
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,55 @@
|
||||
function newShortcutKeys () {
|
||||
thisObject = {
|
||||
getNodeByShortcutKey: getNodeByShortcutKey
|
||||
}
|
||||
return thisObject
|
||||
function newShortcutKeys() {
|
||||
thisObject = {
|
||||
getNodeByShortcutKey: getNodeByShortcutKey
|
||||
}
|
||||
return thisObject
|
||||
|
||||
function getNodeByShortcutKey (node, searchingKey) {
|
||||
if (node === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition (node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Check Self first */
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
}
|
||||
function getNodeByShortcutKey(node, searchingKey) {
|
||||
if (node === undefined) { return }
|
||||
let nodeDefinition = getNodeDefinition(node)
|
||||
if (nodeDefinition !== undefined) {
|
||||
/* Check Self first */
|
||||
if (node.payload.uiObject.shortcutKey === searchingKey) {
|
||||
return node
|
||||
}
|
||||
|
||||
/* Check all of its own children nodes. */
|
||||
if (node.payload.floatingObject.isCollapsed !== true) {
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
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]
|
||||
/* Check all of its own children nodes. */
|
||||
if (node.payload.floatingObject.isCollapsed !== true) {
|
||||
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) {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node[property.name], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
child = getNodeByShortcutKey(nodePropertyArray[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
let child
|
||||
child = getNodeByShortcutKey(node[property.name], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let m = 0; m < nodePropertyArray.length; m++) {
|
||||
child = getNodeByShortcutKey(nodePropertyArray[m], searchingKey)
|
||||
if (child !== undefined) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +1,90 @@
|
||||
function newSuperScriptsFunctions () {
|
||||
thisObject = {
|
||||
runSuperScript: runSuperScript
|
||||
}
|
||||
function newSuperScriptsFunctions() {
|
||||
thisObject = {
|
||||
runSuperScript: runSuperScript
|
||||
}
|
||||
|
||||
return thisObject
|
||||
return thisObject
|
||||
|
||||
function runSuperScript (node, rootNodes, functionLibraryNodeCloning, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
|
||||
try {
|
||||
let clone = functionLibraryNodeCloning.getNodeClone
|
||||
let executionResult = true
|
||||
let superAction = node
|
||||
function runSuperScript(node, rootNodes, functionLibraryNodeCloning, functionLibraryUiObjectsFromNodes, functionLibraryNodeDeleter) {
|
||||
try {
|
||||
let clone = functionLibraryNodeCloning.getNodeClone
|
||||
let executionResult = true
|
||||
let superAction = node
|
||||
|
||||
function setup (templateClone, target, exchange, exchangeNodeType, arrayPropertyName) {
|
||||
spawnPosition.x = target.payload.position.x
|
||||
spawnPosition.y = target.payload.position.y
|
||||
function setup(templateClone, target, exchange, exchangeNodeType, arrayPropertyName) {
|
||||
spawnPosition.x = target.payload.position.x
|
||||
spawnPosition.y = target.payload.position.y
|
||||
|
||||
if (exchange === undefined) {
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(templateClone, target, target)
|
||||
} else {
|
||||
let definition = getNodeDefinition (target)
|
||||
for (let i = 0; i < definition.properties.length; i++) {
|
||||
let property = definition.properties[i]
|
||||
if (property.childType === exchangeNodeType) {
|
||||
let exchanges = target[property.name]
|
||||
if (exchanges === undefined) {
|
||||
exchanges = []
|
||||
}
|
||||
let targetExchange
|
||||
for (let j = 0; j < exchanges.length; j++) {
|
||||
let thisExchange = exchanges[j]
|
||||
if (thisExchange.payload.referenceParent !== undefined) {
|
||||
if (thisExchange.payload.referenceParent.id === exchange.id) {
|
||||
targetExchange = thisExchange
|
||||
}
|
||||
if (exchange === undefined) {
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(templateClone, target, target)
|
||||
} else {
|
||||
let definition = getNodeDefinition(target)
|
||||
for (let i = 0; i < definition.properties.length; i++) {
|
||||
let property = definition.properties[i]
|
||||
if (property.childType === exchangeNodeType) {
|
||||
let exchanges = target[property.name]
|
||||
if (exchanges === undefined) {
|
||||
exchanges = []
|
||||
}
|
||||
let targetExchange
|
||||
for (let j = 0; j < exchanges.length; j++) {
|
||||
let thisExchange = exchanges[j]
|
||||
if (thisExchange.payload.referenceParent !== undefined) {
|
||||
if (thisExchange.payload.referenceParent.id === exchange.id) {
|
||||
targetExchange = thisExchange
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetExchange === undefined) {
|
||||
targetExchange = functionLibraryUiObjectsFromNodes.addUIObject(target, exchangeNodeType)
|
||||
targetExchange.payload.referenceParent = exchange
|
||||
}
|
||||
let nodesArray = targetExchange[arrayPropertyName]
|
||||
nodesArray.push(templateClone)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(templateClone, targetExchange, targetExchange)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetExchange === undefined) {
|
||||
targetExchange = functionLibraryUiObjectsFromNodes.addUIObject(target, exchangeNodeType)
|
||||
targetExchange.payload.referenceParent = exchange
|
||||
}
|
||||
let nodesArray = targetExchange[arrayPropertyName]
|
||||
nodesArray.push(templateClone)
|
||||
functionLibraryUiObjectsFromNodes.createUiObjectFromNode(templateClone, targetExchange, targetExchange)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteNode (node) {
|
||||
functionLibraryNodeDeleter.deleteUIObject(node, rootNodes)
|
||||
}
|
||||
function deleteNode(node) {
|
||||
functionLibraryNodeDeleter.deleteUIObject(node, rootNodes)
|
||||
}
|
||||
|
||||
/* Validations */
|
||||
if (executionResult === true && node.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Super Action node needs a Parent Node.')
|
||||
executionResult = false
|
||||
}
|
||||
if (executionResult === true && node.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Super Action node needs to reference a Master Script Node.')
|
||||
executionResult = false
|
||||
}
|
||||
if (executionResult === true && node.payload.referenceParent.javascriptCode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Master Script Node needs to have a child Javascript Code Node.')
|
||||
executionResult = false
|
||||
}
|
||||
/* Validations */
|
||||
if (executionResult === true && node.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Super Action node needs a Parent Node.')
|
||||
executionResult = false
|
||||
}
|
||||
if (executionResult === true && node.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Super Action node needs to reference a Master Script Node.')
|
||||
executionResult = false
|
||||
}
|
||||
if (executionResult === true && node.payload.referenceParent.javascriptCode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Master Script Node needs to have a child Javascript Code Node.')
|
||||
executionResult = false
|
||||
}
|
||||
|
||||
let masterScript = node.payload.referenceParent
|
||||
let masterScript = node.payload.referenceParent
|
||||
|
||||
eval(masterScript.javascriptCode.code)
|
||||
eval(masterScript.javascriptCode.code)
|
||||
|
||||
let masterScriptInstance = newNewMasterScriptInstance()
|
||||
let masterScriptInstance = newNewMasterScriptInstance()
|
||||
|
||||
if (executionResult === true) {
|
||||
executionResult = masterScriptInstance.runValidations(superAction, masterScript)
|
||||
}
|
||||
if (executionResult === true) {
|
||||
executionResult = masterScriptInstance.runScript(superAction, masterScript)
|
||||
}
|
||||
if (executionResult === true) {
|
||||
superAction.payload.uiObject.setValue('Execution Completed Successfully')
|
||||
} else {
|
||||
superAction.payload.uiObject.setValue('Execution Failed')
|
||||
}
|
||||
} catch (err) {
|
||||
superAction.payload.uiObject.setErrorMessage(err.message)
|
||||
superAction.payload.uiObject.setValue('Execution Failed')
|
||||
if (executionResult === true) {
|
||||
executionResult = masterScriptInstance.runValidations(superAction, masterScript)
|
||||
}
|
||||
if (executionResult === true) {
|
||||
executionResult = masterScriptInstance.runScript(superAction, masterScript)
|
||||
}
|
||||
if (executionResult === true) {
|
||||
superAction.payload.uiObject.setValue('Execution Completed Successfully')
|
||||
} else {
|
||||
superAction.payload.uiObject.setValue('Execution Failed')
|
||||
}
|
||||
} catch (err) {
|
||||
superAction.payload.uiObject.setErrorMessage(err.message)
|
||||
superAction.payload.uiObject.setValue('Execution Failed')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,228 +1,228 @@
|
||||
function newTaskFunctions () {
|
||||
thisObject = {
|
||||
runTask: runTask,
|
||||
stopTask: stopTask,
|
||||
runAllTasks: runAllTasks,
|
||||
stopAllTasks: stopAllTasks,
|
||||
runAllTaskManagers: runAllTaskManagers,
|
||||
stopAllTaskManagers: stopAllTaskManagers,
|
||||
runAllExchangeTasks: runAllExchangeTasks,
|
||||
stopAllExchangeTasks: stopAllExchangeTasks
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function runTask (node, functionLibraryProtocolNode, isDebugging, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
function newTaskFunctions() {
|
||||
thisObject = {
|
||||
runTask: runTask,
|
||||
stopTask: stopTask,
|
||||
runAllTasks: runAllTasks,
|
||||
stopAllTasks: stopAllTasks,
|
||||
runAllTaskManagers: runAllTaskManagers,
|
||||
stopAllTaskManagers: stopAllTaskManagers,
|
||||
runAllExchangeTasks: runAllExchangeTasks,
|
||||
stopAllExchangeTasks: stopAllExchangeTasks
|
||||
}
|
||||
|
||||
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
|
||||
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
|
||||
return thisObject
|
||||
|
||||
for (let i = 0; i < node.bot.processes.length; i++) {
|
||||
let process = node.bot.processes[i]
|
||||
process.payload.uiObject.run(eventsServerClient)
|
||||
function runTask(node, functionLibraryProtocolNode, isDebugging, 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)
|
||||
|
||||
for (let i = 0; i < node.bot.processes.length; i++) {
|
||||
let process = node.bot.processes[i]
|
||||
process.payload.uiObject.run(eventsServerClient)
|
||||
}
|
||||
|
||||
let taskLightingPath = '->Task->' +
|
||||
'Sensor Bot Instance->' +
|
||||
'Indicator Bot Instance->Time Frames Filter->' +
|
||||
'Trading Bot Instance->' +
|
||||
'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' +
|
||||
'Market Reference->' +
|
||||
'Key Reference->Exchange Account Key->' +
|
||||
'Market->Exchange Markets->Crypto Exchange->' +
|
||||
'Market Base Asset->Market Quoted Asset->Asset->' +
|
||||
'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' +
|
||||
'Process Definition->' +
|
||||
'Process Output->Output Dataset->Dataset Definition->Product Definition->' +
|
||||
'Process Dependencies->' +
|
||||
'Status Dependency->Status Report->Process Definition->' +
|
||||
'Data Dependency->Dataset Definition->Product Definition->' +
|
||||
'Record Definition->Record Property->Formula->' +
|
||||
'Data Building Procedure->' +
|
||||
'Procedure Initialization->Javascript Code->' +
|
||||
'Procedure Loop->Javascript Code->' +
|
||||
'Calculations Procedure->' +
|
||||
'Procedure Initialization->Javascript Code->' +
|
||||
'Procedure Loop->Javascript Code->' +
|
||||
'Status Report->' +
|
||||
'Execution Finished Event->' +
|
||||
'Execution Started Event->Execution Finished Event->Process Definition->' +
|
||||
'Sensor Bot->' +
|
||||
'Indicator Bot->' +
|
||||
'Trading Bot->' +
|
||||
'Data Mine->'
|
||||
|
||||
let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath)
|
||||
|
||||
let networkLightingPath = '->Network->Network Node->' +
|
||||
'Data Storage->Session Independent Data->Exchange Data Products->' +
|
||||
'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->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->'
|
||||
|
||||
let networkDefinition = functionLibraryProtocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath)
|
||||
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name,
|
||||
taskDefinition: JSON.stringify(taskDefinition),
|
||||
networkDefinition: JSON.stringify(networkDefinition)
|
||||
}
|
||||
|
||||
if (isDebugging === true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
eventsServerClient.raiseEvent('Task Server', 'Debug Task Started', event)
|
||||
return
|
||||
}
|
||||
|
||||
node.payload.uiObject.run(eventsServerClient, callBackFunction)
|
||||
eventsServerClient.raiseEvent('Task Manager', 'Run Task', event)
|
||||
}
|
||||
|
||||
let taskLightingPath = '->Task->' +
|
||||
'Sensor Bot Instance->' +
|
||||
'Indicator Bot Instance->Time Frames Filter->' +
|
||||
'Trading Bot Instance->' +
|
||||
'Sensor Process Instance->Indicator Process Instance->Trading Process Instance->' +
|
||||
'Market Reference->' +
|
||||
'Key Reference->Exchange Account Key->' +
|
||||
'Market->Exchange Markets->Crypto Exchange->' +
|
||||
'Market Base Asset->Market Quoted Asset->Asset->' +
|
||||
'Backtesting Session->Live Trading Session->Paper Trading Session->Fordward Testing Session->' +
|
||||
'Process Definition->' +
|
||||
'Process Output->Output Dataset->Dataset Definition->Product Definition->' +
|
||||
'Process Dependencies->' +
|
||||
'Status Dependency->Status Report->Process Definition->' +
|
||||
'Data Dependency->Dataset Definition->Product Definition->' +
|
||||
'Record Definition->Record Property->Formula->' +
|
||||
'Data Building Procedure->' +
|
||||
'Procedure Initialization->Javascript Code->' +
|
||||
'Procedure Loop->Javascript Code->' +
|
||||
'Calculations Procedure->' +
|
||||
'Procedure Initialization->Javascript Code->' +
|
||||
'Procedure Loop->Javascript Code->' +
|
||||
'Status Report->' +
|
||||
'Execution Finished Event->' +
|
||||
'Execution Started Event->Execution Finished Event->Process Definition->' +
|
||||
'Sensor Bot->' +
|
||||
'Indicator Bot->' +
|
||||
'Trading Bot->' +
|
||||
'Data Mine->'
|
||||
function stopTask(node, functionLibraryProtocolNode, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
}
|
||||
|
||||
let taskDefinition = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, taskLightingPath)
|
||||
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
|
||||
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
|
||||
|
||||
let networkLightingPath = '->Network->Network Node->' +
|
||||
'Data Storage->Session Independent Data->Exchange Data Products->' +
|
||||
'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->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->'
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name
|
||||
}
|
||||
|
||||
let networkDefinition = functionLibraryProtocolNode.getProtocolNode(networkNode.payload.parentNode, false, true, true, false, false, networkLightingPath)
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
eventsServerClient.raiseEvent('Task Manager', 'Stop Task', event)
|
||||
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name,
|
||||
taskDefinition: JSON.stringify(taskDefinition),
|
||||
networkDefinition: JSON.stringify(networkDefinition)
|
||||
if (node.bot === undefined) { return }
|
||||
if (node.bot.processes.length === 0) { return }
|
||||
|
||||
for (let i = 0; i < node.bot.processes.length; i++) {
|
||||
let process = node.bot.processes[i]
|
||||
process.payload.uiObject.stop()
|
||||
}
|
||||
}
|
||||
|
||||
if (isDebugging === true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
eventsServerClient.raiseEvent('Task Server', 'Debug Task Started', event)
|
||||
return
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
node.payload.uiObject.run(eventsServerClient, callBackFunction)
|
||||
eventsServerClient.raiseEvent('Task Manager', 'Run Task', event)
|
||||
}
|
||||
function runAllTasks(taskManager, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < taskManager.tasks.length; i++) {
|
||||
let node = taskManager.tasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
function stopTask (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
if (validations(node) !== true) {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
return
|
||||
menu.internalClick('Run Task')
|
||||
}
|
||||
}
|
||||
|
||||
let networkNode = node.payload.parentNode.payload.parentNode.payload.parentNode.payload.parentNode
|
||||
let eventsServerClient = canvas.designSpace.workspace.eventsServerClients.get(networkNode.id)
|
||||
function stopAllTasks(taskManager, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < taskManager.tasks.length; i++) {
|
||||
let node = taskManager.tasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
let event = {
|
||||
taskId: node.id,
|
||||
taskName: node.name
|
||||
menu.internalClick('Stop Task')
|
||||
}
|
||||
}
|
||||
|
||||
node.payload.uiObject.stop(callBackFunction)
|
||||
eventsServerClient.raiseEvent('Task Manager', 'Stop Task', event)
|
||||
function runAllTaskManagers(parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.taskManagers.length; i++) {
|
||||
let node = parent.taskManagers[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
if (node.bot === undefined) { return }
|
||||
if (node.bot.processes.length === 0) { return }
|
||||
|
||||
for (let i = 0; i < node.bot.processes.length; i++) {
|
||||
let process = node.bot.processes[i]
|
||||
process.payload.uiObject.stop()
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
menu.internalClick('Run All Tasks')
|
||||
menu.internalClick('Run All Tasks')
|
||||
}
|
||||
}
|
||||
|
||||
if (node.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Task needs to be inside a Task Manager.')
|
||||
return
|
||||
function stopAllTaskManagers(parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.taskManagers.length; i++) {
|
||||
let node = parent.taskManagers[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Stop All Tasks')
|
||||
menu.internalClick('Stop All Tasks')
|
||||
}
|
||||
}
|
||||
function runAllExchangeTasks(parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.exchangeTasks.length; i++) {
|
||||
let node = parent.exchangeTasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Run All Task Managers')
|
||||
menu.internalClick('Run All Task Managers')
|
||||
}
|
||||
}
|
||||
|
||||
if (node.payload.parentNode.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Task needs to be inside Exchange Tasks.')
|
||||
return
|
||||
function stopAllExchangeTasks(parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.exchangeTasks.length; i++) {
|
||||
let node = parent.exchangeTasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Stop All Task Managers')
|
||||
menu.internalClick('Stop All Task Managers')
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
function runAllTasks (taskManager, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < taskManager.tasks.length; i++) {
|
||||
let node = taskManager.tasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Run Task')
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllTasks (taskManager, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < taskManager.tasks.length; i++) {
|
||||
let node = taskManager.tasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Stop Task')
|
||||
}
|
||||
}
|
||||
|
||||
function runAllTaskManagers (parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.taskManagers.length; i++) {
|
||||
let node = parent.taskManagers[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Run All Tasks')
|
||||
menu.internalClick('Run All Tasks')
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllTaskManagers (parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.taskManagers.length; i++) {
|
||||
let node = parent.taskManagers[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Stop All Tasks')
|
||||
menu.internalClick('Stop All Tasks')
|
||||
}
|
||||
}
|
||||
function runAllExchangeTasks (parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.exchangeTasks.length; i++) {
|
||||
let node = parent.exchangeTasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Run All Task Managers')
|
||||
menu.internalClick('Run All Task Managers')
|
||||
}
|
||||
}
|
||||
|
||||
function stopAllExchangeTasks (parent, functionLibraryProtocolNode) {
|
||||
for (let i = 0; i < parent.exchangeTasks.length; i++) {
|
||||
let node = parent.exchangeTasks[i]
|
||||
let menu = node.payload.uiObject.menu
|
||||
|
||||
menu.internalClick('Stop All Task Managers')
|
||||
menu.internalClick('Stop All Task Managers')
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,22 +1,22 @@
|
||||
function newWebhookFunctions () {
|
||||
thisObject = {
|
||||
sendTestMessage: sendTestMessage
|
||||
}
|
||||
function newWebhookFunctions() {
|
||||
thisObject = {
|
||||
sendTestMessage: sendTestMessage
|
||||
}
|
||||
|
||||
return thisObject
|
||||
return thisObject
|
||||
|
||||
function sendTestMessage (node, callBackFunction) {
|
||||
let testMessage = loadPropertyFromNodeConfig(node.payload, 'testMessage')
|
||||
let letURL = loadPropertyFromNodeConfig(node.payload, 'webhookURL')
|
||||
function sendTestMessage(node, callBackFunction) {
|
||||
let testMessage = loadPropertyFromNodeConfig(node.payload, 'testMessage')
|
||||
let letURL = loadPropertyFromNodeConfig(node.payload, 'webhookURL')
|
||||
|
||||
callServer(testMessage, letURL, onResponse)
|
||||
callServer(testMessage, letURL, onResponse)
|
||||
|
||||
function onResponse (err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
function onResponse(err) {
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
} else {
|
||||
callBackFunction(GLOBAL.DEFAULT_FAIL_RESPONSE)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user