Partial Implementation of getting plotters definition from UI

This commit is contained in:
Luis Fernando Molina committed 2019-12-03 12:18:23 +01:00
1 parent e1c6eb0ce1
commit 0b308b7e4b
4 files changed
+191 -63

No files matched your search

@@ -1593,6 +1593,7 @@ function newProtocolNode () {
type: node.type,
subType: node.subType,
name: node.name,
code: node.code,
modules: []
}
if (node.modules !== undefined) {
@@ -1382,6 +1382,7 @@ function newUiObjectsFromNodes () {
let object = {
type: 'Plotter',
name: 'New Plotter',
code: '{}',
modules: []
}
if (node.plotters === undefined) {
@@ -1397,6 +1398,7 @@ function newUiObjectsFromNodes () {
let object = {
type: 'Plotter Module',
name: 'New Plotter Module',
code: '{}',
panels: []
}
if (node.modules === undefined) {
+101 -63
View File
@@ -1539,7 +1539,26 @@ function newUiObjectConstructor () {
break
}
case 'Plotter': {
uiObject.codeEditor = newCodeEditor()
uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction
uiObject.codeEditor.initialize()
uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false)
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Edit Plotter',
actionFunction: uiObject.codeEditor.activate,
label: 'Edit Plotter',
visible: true,
iconPathOn: 'html',
iconPathOff: 'html',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -30,
dontShowAtFullscreen: true
}
)
menuItemsInitialValues.push(
{
action: 'Add Plotter Module',
@@ -1550,7 +1569,7 @@ function newUiObjectConstructor () {
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -20
angle: -10
}
)
menuItemsInitialValues.push(
@@ -1566,68 +1585,6 @@ function newUiObjectConstructor () {
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 0
}
)
menuItemsInitialValues.push(
{
action: 'Share',
actionFunction: payload.onMenuItemClick,
label: 'Share',
visible: true,
iconPathOn: 'menu-share',
iconPathOff: 'menu-share',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 20
}
)
break
}
case 'Plotter Module': {
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Add Code',
disableIfPropertyIsDefined: true,
propertyToCheckFor: 'code',
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -30
}
)
menuItemsInitialValues.push(
{
action: 'Add Plotter Panel',
actionFunction: payload.onMenuItemClick,
label: 'Add Plotter Panel',
visible: true,
relatedUiObject: 'Plotter Panel',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -10
}
)
menuItemsInitialValues.push(
{
action: 'Delete Plotter Module',
askConfirmation: true,
confirmationLabel: 'Confirm to Delete',
actionFunction: payload.onMenuItemClick,
label: 'Delete Plotter Module',
visible: true,
iconPathOn: 'delete',
iconPathOff: 'delete',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 10
}
)
@@ -1647,6 +1604,87 @@ function newUiObjectConstructor () {
)
break
}
case 'Plotter Module': {
uiObject.codeEditor = newCodeEditor()
uiObject.codeEditor.isVisibleFunction = uiObject.isVisibleFunction
uiObject.codeEditor.initialize()
uiObject.codeEditor.container.connectToParent(uiObject.container, false, false, true, true, false, false, false, false)
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Edit Plotter Module',
actionFunction: uiObject.codeEditor.activate,
label: 'Edit Plotter Module',
visible: true,
iconPathOn: 'html',
iconPathOff: 'html',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -40,
dontShowAtFullscreen: true
}
)
menuItemsInitialValues.push(
{
action: 'Add Code',
disableIfPropertyIsDefined: true,
propertyToCheckFor: 'code',
actionFunction: payload.onMenuItemClick,
label: 'Add Code',
visible: true,
relatedUiObject: 'Code',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: -20
}
)
menuItemsInitialValues.push(
{
action: 'Add Plotter Panel',
actionFunction: payload.onMenuItemClick,
label: 'Add Plotter Panel',
visible: true,
relatedUiObject: 'Plotter Panel',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 0
}
)
menuItemsInitialValues.push(
{
action: 'Delete Plotter Module',
askConfirmation: true,
confirmationLabel: 'Confirm to Delete',
actionFunction: payload.onMenuItemClick,
label: 'Delete Plotter Module',
visible: true,
iconPathOn: 'delete',
iconPathOff: 'delete',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 20
}
)
menuItemsInitialValues.push(
{
action: 'Share',
actionFunction: payload.onMenuItemClick,
label: 'Share',
visible: true,
iconPathOn: 'menu-share',
iconPathOff: 'menu-share',
rawRadius: 8,
targetRadius: 0,
currentRadius: 0,
angle: 40
}
)
break
}
case 'Plotter Panel': {
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
+87
View File
@@ -66,6 +66,7 @@ function newProductsPanel () {
ecosystem = getUserEcosystem()
}
/* For legacy plotters, we will add product cards based on the old ecosystem file */
for (let i = 0; i < ecosystem.devTeams.length; i++) {
let devTeam = ecosystem.devTeams[i]
@@ -83,6 +84,92 @@ function newProductsPanel () {
}
}
/* For new plotters defined at the UI, we will add product cards based on what we find at the workspace */
let workspaceNode = canvas.designerSpace.workspace.workspaceNode
for (let i = 0; i < workspaceNode.rootNodes.length; i++) {
let rootNode = workspaceNode.rootNodes[i]
if (rootNode.type === 'Team') {
let teamNode = rootNode
let team = {}
if (teamNode.code === undefined) { continue }
try {
let code = JSON.parse(teamNode.code)
team.codeName = code.codeName
} catch (err) {
continue
}
for (let j = 0; j < teamNode.indicatorBots.length; j++) {
let botNode = teamNode.indicatorBots[j]
let bot = {}
if (botNode.code === undefined) { continue }
try {
let code = JSON.parse(botNode.code)
bot.codeName = code.codeName
} catch (err) {
continue
}
for (let k = 0; k < botNode.products; k++) {
let productNode = botNode.products[k]
let product = {}
if (productNode.code === undefined) { continue }
try {
let code = JSON.parse(productNode.code)
product.codeName = code.codeName
} catch (err) {
continue
}
if (productNode.referenceParent === undefined) { continue }
let plotterModuleNode = productNode.referenceParent
let plotterModule = {}
if (plotterModuleNode.code === undefined) { continue }
try {
let code = JSON.parse(plotterModuleNode.code)
plotterModule.codeName = code.codeName
} catch (err) {
continue
}
if (plotterModuleNode.payload.parentNode === undefined) { continue }
let plotterNode = plotterModuleNode.payload.parentNode
let plotter = {}
if (plotterNode.code === undefined) { continue }
try {
let code = JSON.parse(plotterNode.code)
plotter.codeName = code.codeName
} catch (err) {
continue
}
if (plotterNode.payload.parentNode === undefined) { continue }
let plotterTeamNode = plotterNode.payload.parentNode
let plotterTeam = {}
if (plotterTeamNode.code === undefined) { continue }
try {
let code = JSON.parse(plotterTeamNode.code)
plotterTeam.codeName = code.codeName
} catch (err) {
continue
}
/* Conversion to fit old format */
prduct.plotter = plotter
prduct.plotter.devTeam = plotterTeam.codeName
product.plotter.moduleName = plotterModule.codeName
addProductCard(team, bot, product)
}
}
}
}
thisObject.container.eventHandler.listenToEvent('onMouseWheel', onMouseWheel)
isInitialized = true
}