Automatically adjust node deployment

This commit is contained in:
nakanishi
2018-10-23 14:01:23 +09:00
committed by Yuma Matsuura
parent 4a081bf125
commit c2aa9a5337
5 changed files with 165 additions and 139 deletions

View File

@@ -21,12 +21,32 @@ var events = require("nr-test-utils").require("@node-red/runtime/lib/events.js")
var palette = require("./palette_page");
var nodeFactory = require("../nodes/nodefactory_page");
var flowLayout = {
flowRightEnd : 600,
widthInterval : 300,
heightInterval : 80
};
var previousX = -flowLayout.widthInterval;
var previousY = 0;
function addNode(type, x, y) {
var offsetX = x ? x : 0;
var offsetY = y ? y : 0;
if (x !== undefined) {
previousX = x;
if (y !== undefined) {
previousY = y;
}
} else {
if (previousX < flowLayout.flowRightEnd) {
previousX = previousX + flowLayout.widthInterval;
} else {
previousX = 0;
previousY = previousY + flowLayout.heightInterval;
}
}
browser.moveToObject(palette.getId(type));
browser.buttonDown();
browser.moveToObject("#palette-search", offsetX + 300, offsetY + 100); // adjust to the top-left corner of workspace.
browser.moveToObject("#palette-search", previousX + 300, previousY + 100); // adjust to the top-left corner of workspace.
browser.buttonUp();
// Last node is the one that has been created right now.
var nodeElement = browser.elements('//*[@class="node nodegroup"][last()]');
@@ -55,8 +75,21 @@ function deploy() {
browser.waitForText('#btn-deploy', 2000);
}
function init(width, height) {
deleteAllNodes();
if (width !== undefined) {
flowLayout.widthInterval = width;
}
if (height !== undefined) {
flowLayout.heightInterval = height;
}
previousX = -flowLayout.widthInterval;
previousY = 0;
}
module.exports = {
addNode: addNode,
deleteAllNodes: deleteAllNodes,
deploy: deploy
deploy: deploy,
init: init
};