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