mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #3371 from node-red/node-alias
Add _path property to nodes and expose as node.path in Function node
This commit is contained in:
commit
1cea1ced82
@ -60,6 +60,8 @@ declare class node {
|
|||||||
public readonly id:string;
|
public readonly id:string;
|
||||||
/** the name of this node */
|
/** the name of this node */
|
||||||
public readonly name:string;
|
public readonly name:string;
|
||||||
|
/** the path identifier for this node */
|
||||||
|
public readonly path:string;
|
||||||
/** the number of outputs of this node */
|
/** the number of outputs of this node */
|
||||||
public readonly outputCount:number;
|
public readonly outputCount:number;
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,7 @@ module.exports = function(RED) {
|
|||||||
"var node = {"+
|
"var node = {"+
|
||||||
"id:__node__.id,"+
|
"id:__node__.id,"+
|
||||||
"name:__node__.name,"+
|
"name:__node__.name,"+
|
||||||
|
"path:__node__.path,"+
|
||||||
"outputCount:__node__.outputCount,"+
|
"outputCount:__node__.outputCount,"+
|
||||||
"log:__node__.log,"+
|
"log:__node__.log,"+
|
||||||
"error:__node__.error,"+
|
"error:__node__.error,"+
|
||||||
@ -163,6 +164,7 @@ module.exports = function(RED) {
|
|||||||
__node__: {
|
__node__: {
|
||||||
id: node.id,
|
id: node.id,
|
||||||
name: node.name,
|
name: node.name,
|
||||||
|
path: node._path,
|
||||||
outputCount: node.outputs,
|
outputCount: node.outputs,
|
||||||
log: function() {
|
log: function() {
|
||||||
node.log.apply(node, arguments);
|
node.log.apply(node, arguments);
|
||||||
@ -344,6 +346,7 @@ module.exports = function(RED) {
|
|||||||
var node = {
|
var node = {
|
||||||
id:__node__.id,
|
id:__node__.id,
|
||||||
name:__node__.name,
|
name:__node__.name,
|
||||||
|
path:__node__.path,
|
||||||
outputCount:__node__.outputCount,
|
outputCount:__node__.outputCount,
|
||||||
log:__node__.log,
|
log:__node__.log,
|
||||||
error:__node__.error,
|
error:__node__.error,
|
||||||
@ -366,6 +369,7 @@ module.exports = function(RED) {
|
|||||||
var node = {
|
var node = {
|
||||||
id:__node__.id,
|
id:__node__.id,
|
||||||
name:__node__.name,
|
name:__node__.name,
|
||||||
|
path:__node__.path,
|
||||||
outputCount:__node__.outputCount,
|
outputCount:__node__.outputCount,
|
||||||
log:__node__.log,
|
log:__node__.log,
|
||||||
error:__node__.error,
|
error:__node__.error,
|
||||||
|
@ -85,6 +85,7 @@ function createNode(flow,config) {
|
|||||||
try {
|
try {
|
||||||
Object.defineProperty(conf,'_module', {value: typeRegistry.getNodeInfo(type), enumerable: false, writable: true })
|
Object.defineProperty(conf,'_module', {value: typeRegistry.getNodeInfo(type), enumerable: false, writable: true })
|
||||||
Object.defineProperty(conf,'_flow', {value: flow, enumerable: false, writable: true })
|
Object.defineProperty(conf,'_flow', {value: flow, enumerable: false, writable: true })
|
||||||
|
Object.defineProperty(conf,'_path', {value: `${flow.path}/${config._alias||config.id}`, enumerable: false, writable: true })
|
||||||
newNode = new nodeTypeConstructor(conf);
|
newNode = new nodeTypeConstructor(conf);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
Log.log({
|
Log.log({
|
||||||
|
@ -62,6 +62,9 @@ function Node(n) {
|
|||||||
if (n._module) {
|
if (n._module) {
|
||||||
Object.defineProperty(this,'_module', {value: n._module, enumerable: false, writable: true })
|
Object.defineProperty(this,'_module', {value: n._module, enumerable: false, writable: true })
|
||||||
}
|
}
|
||||||
|
if (n._path) {
|
||||||
|
Object.defineProperty(this,'_path', {value: n._path, enumerable: false, writable: true })
|
||||||
|
}
|
||||||
this.updateWires(n.wires);
|
this.updateWires(n.wires);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user