scan Data Mines

This commit is contained in:
Luis Fernando Molina committed 2020-04-26 10:52:01 +02:00
1 parent 40968b0175
commit b8453d03a9
2 files changed
+70 -2

No files matched your search

+11
View File
@@ -152,6 +152,17 @@ function newWorkspace () {
}
function saveWorkspace () {
/* When there is an exception while loading the app, the rootNodes of the workspace get into null value. To avoid saving a corrupt staate we are going to verufy we are not in that situation before saving. */
let workspace = canvas.designSpace.workspace.workspaceNode
for (let i = 0; i < workspace.rootNodes.length; i++) {
let rootNode = workspace.rootNodes[i]
if (rootNode === null) {
canvas.cockpitSpace.setStatus('Could not save the Workspace. The state of the workspace in memory is corrupt, please reload the App.', 150, canvas.cockpitSpace.statusTypes.WARNING)
return
}
}
let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp')
if (Number(savedSessionTimestamp) !== sessionTimestamp) {
canvas.cockpitSpace.setStatus('Could not save the Workspace. You have more that one instance of the Superlagos User Interface open at the same time. Plese close this instance as it is older than the others.', 150, canvas.cockpitSpace.statusTypes.WARNING)
+59 -2
View File
@@ -34,6 +34,8 @@ function newConditionEditor () {
thisObject.container.frame.position.y = 0
let isMouseOver = false
let operator1
let operator2
return thisObject
@@ -92,15 +94,70 @@ function newConditionEditor () {
'overflow:hidden;' +
'font-family: ' + UI_FONT.PRIMARY + ';' +
'font-size: 14px;' +
'background-color: rgb(' + UI_COLOR.GREEN + ');' +
'background-color: rgb(' + UI_COLOR.GREY + ');' +
'color:rgb(255, 255, 255);' +
'width: ' + thisObject.container.frame.width + 'px;' +
'height: ' + thisObject.container.frame.height + 'px'
textArea.style.display = 'block'
textArea.focus()
scanDataMines()
EDITOR_ON_FOCUS = true
}
function scanDataMines () {
let selector = {}
let workspace = canvas.designSpace.workspace.workspaceNode
for (let i = 0; i < workspace.rootNodes.length; i++) {
let rootNode = workspace.rootNodes[i]
if (rootNode.type !== 'Data Mine') { continue }
let dataMine = rootNode
let dataMineName = loadPropertyFromNodeConfig(dataMine.payload, 'codeName')
selector[dataMineName] = {}
let bots = dataMine.sensorBots.concat(dataMine.indicatorBots)
for (let j = 0; j < bots.length; j++) {
let bot = bots[j]
let botName = loadPropertyFromNodeConfig(bot.payload, 'codeName')
let selectorDataMine = selector[dataMineName]
selectorDataMine[botName] = {}
for (let k = 0; k < bot.products.length; k++) {
let product = bot.products[k]
let productName = loadPropertyFromNodeConfig(product.payload, 'singularVariableName')
if (productName === undefined) { continue }
let selectorProduct = selectorDataMine[botName]
selectorProduct[productName] = {}
if (product.record === undefined) { continue }
for (let m = 0; m < product.record.properties.length; m++) {
let property = product.record.properties[m]
let propertyName = loadPropertyFromNodeConfig(property.payload, 'codeName')
let selectorProperty = selectorProduct[productName]
selectorProperty[propertyName] = {}
let possibleValues = loadPropertyFromNodeConfig(property.payload, 'possibleValues')
if (possibleValues === undefined) { possibleValues = [] }
let selectorPossibleValue = selectorProperty[propertyName]
selectorPossibleValue.possibleValues = possibleValues
}
let productKeys = Object.keys(selectorProduct[productName])
if (productKeys.length === 0) {
selectorProduct[productName] = undefined
}
}
let botKeys = Object.keys(selectorDataMine[botName])
if (botKeys.length === 0) {
selectorDataMine[botName] = undefined
}
}
let dataMineKeys = Object.keys(selector[dataMineName])
if (dataMineKeys.length === 0) {
selector[dataMineName] = undefined
}
}
operator1 = JSON.parse(JSON.stringify(selector))
operator2 = JSON.parse(JSON.stringify(selector))
}
function getContainer (point) {
let container
if (thisObject.visible === true) {
@@ -176,7 +233,7 @@ function newConditionEditor () {
browserCanvasContext.beginPath()
browserCanvasContext.arc(position.x, position.y, radius * 1.3, 0, Math.PI * 2, true)
browserCanvasContext.closePath()
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREEN + ', ' + 1 + ')'
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.GREY + ', ' + 1 + ')'
browserCanvasContext.fill()
}
}