mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Automatically adjust node deployment
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
Reference in New Issue
Block a user