mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Propagate Status/Error events from global config nodes
This commit is contained in:
parent
c99b35428b
commit
4baaaa8d59
@ -327,14 +327,14 @@ class Flow {
|
|||||||
* @param {Node} reportingNode The node emitting the status event.
|
* @param {Node} reportingNode The node emitting the status event.
|
||||||
* This could be a subflow instance node when the status
|
* This could be a subflow instance node when the status
|
||||||
* is being delegated up.
|
* is being delegated up.
|
||||||
* @param {boolean} muteStatus Whether to emit the status event
|
* @param {boolean} muteStatusEvent Whether to emit the status event
|
||||||
* @return {[type]} [description]
|
* @return {[type]} [description]
|
||||||
*/
|
*/
|
||||||
handleStatus(node,statusMessage,reportingNode,muteStatus) {
|
handleStatus(node,statusMessage,reportingNode,muteStatusEvent) {
|
||||||
if (!reportingNode) {
|
if (!reportingNode) {
|
||||||
reportingNode = node;
|
reportingNode = node;
|
||||||
}
|
}
|
||||||
if (!muteStatus) {
|
if (!muteStatusEvent) {
|
||||||
events.emit("node-status",{
|
events.emit("node-status",{
|
||||||
id: node.id,
|
id: node.id,
|
||||||
status:statusMessage
|
status:statusMessage
|
||||||
@ -343,6 +343,16 @@ class Flow {
|
|||||||
|
|
||||||
let handled = false;
|
let handled = false;
|
||||||
|
|
||||||
|
if (this.id === 'global' && node.users) {
|
||||||
|
// This is a global config node
|
||||||
|
// Delegate status to any nodes using this config node
|
||||||
|
for (let userNode in node.users) {
|
||||||
|
if (node.users.hasOwnProperty(userNode)) {
|
||||||
|
node.users[userNode]._flow.handleStatus(node,statusMessage,node.users[userNode],true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handled = true;
|
||||||
|
} else {
|
||||||
this.statusNodes.forEach(function(targetStatusNode) {
|
this.statusNodes.forEach(function(targetStatusNode) {
|
||||||
if (targetStatusNode.scope && targetStatusNode.scope.indexOf(reportingNode.id) === -1) {
|
if (targetStatusNode.scope && targetStatusNode.scope.indexOf(reportingNode.id) === -1) {
|
||||||
return;
|
return;
|
||||||
@ -363,6 +373,7 @@ class Flow {
|
|||||||
targetStatusNode.receive(message);
|
targetStatusNode.receive(message);
|
||||||
handled = true;
|
handled = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +403,18 @@ class Flow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var handled = false;
|
let handled = false;
|
||||||
|
|
||||||
|
if (this.id === 'global' && node.users) {
|
||||||
|
// This is a global config node
|
||||||
|
// Delegate status to any nodes using this config node
|
||||||
|
for (let userNode in node.users) {
|
||||||
|
if (node.users.hasOwnProperty(userNode)) {
|
||||||
|
node.users[userNode]._flow.handleError(node,logMessage,msg,node.users[userNode]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
handled = true;
|
||||||
|
} else {
|
||||||
this.catchNodes.forEach(function(targetCatchNode) {
|
this.catchNodes.forEach(function(targetCatchNode) {
|
||||||
if (targetCatchNode.scope && targetCatchNode.scope.indexOf(reportingNode.id) === -1) {
|
if (targetCatchNode.scope && targetCatchNode.scope.indexOf(reportingNode.id) === -1) {
|
||||||
return;
|
return;
|
||||||
@ -421,6 +443,7 @@ class Flow {
|
|||||||
targetCatchNode.receive(errorMessage);
|
targetCatchNode.receive(errorMessage);
|
||||||
handled = true;
|
handled = true;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
return handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user