mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Track subflow instances on the subflow node itself
This commit is contained in:
parent
34dfd50702
commit
21866634b3
@ -196,6 +196,11 @@ RED.nodes = (function() {
|
||||
if (n.type.indexOf("subflow") !== 0) {
|
||||
n["_"] = n._def._;
|
||||
} else {
|
||||
var subflowId = n.type.substring(8);
|
||||
var sf = RED.nodes.subflow(subflowId);
|
||||
if (sf) {
|
||||
sf.instances.push(sf);
|
||||
}
|
||||
n["_"] = RED._;
|
||||
}
|
||||
if (n._def.category == "config") {
|
||||
@ -284,6 +289,15 @@ RED.nodes = (function() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (node.type.indexOf("subflow:") === 0) {
|
||||
var subflowId = node.type.substring(8);
|
||||
var sf = RED.nodes.subflow(subflowId);
|
||||
if (sf) {
|
||||
sf.instances.splice(sf.instances.indexOf(node),1);
|
||||
}
|
||||
}
|
||||
|
||||
if (updatedConfigNode) {
|
||||
RED.workspaces.refresh();
|
||||
}
|
||||
@ -297,6 +311,9 @@ RED.nodes = (function() {
|
||||
RED.events.emit('nodes:remove',node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (node && node._def.onremove) {
|
||||
// Deprecated: never documented but used by some early nodes
|
||||
console.log("Deprecated API warning: node type ",node.type," has an onremove function - should be oneditremove - please report");
|
||||
@ -459,6 +476,7 @@ RED.nodes = (function() {
|
||||
module: "node-red"
|
||||
}
|
||||
});
|
||||
sf.instances = [];
|
||||
sf._def = RED.nodes.getType("subflow:"+sf.id);
|
||||
RED.events.emit("subflows:add",sf);
|
||||
}
|
||||
|
@ -883,13 +883,13 @@ RED.editor = (function() {
|
||||
var userCount = 0;
|
||||
var subflowType = "subflow:"+node.id;
|
||||
|
||||
RED.nodes.eachNode(function(n) {
|
||||
if (n.type === subflowType) {
|
||||
userCount++;
|
||||
}
|
||||
});
|
||||
// RED.nodes.eachNode(function(n) {
|
||||
// if (n.type === subflowType) {
|
||||
// userCount++;
|
||||
// }
|
||||
// });
|
||||
$("#red-ui-editor-subflow-user-count")
|
||||
.text(RED._("subflow.subflowInstances", {count:userCount})).show();
|
||||
.text(RED._("subflow.subflowInstances", {count:node.instances.length})).show();
|
||||
}
|
||||
|
||||
$('<div class="form-row">'+
|
||||
|
@ -240,13 +240,8 @@ RED.sidebar.info = (function() {
|
||||
subflowNode = node;
|
||||
}
|
||||
|
||||
subflowUserCount = 0;
|
||||
var subflowType = "subflow:"+subflowNode.id;
|
||||
RED.nodes.eachNode(function(n) {
|
||||
if (n.type === subflowType) {
|
||||
subflowUserCount++;
|
||||
}
|
||||
});
|
||||
subflowUserCount = subflowNode.instances.length;
|
||||
}
|
||||
|
||||
propertiesPanelHeaderIcon.empty();
|
||||
|
Loading…
Reference in New Issue
Block a user