1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Tidy up info tab handling of subflows and comments

This commit is contained in:
Nick O'Leary 2015-02-10 21:29:27 +00:00
parent 0accfade02
commit e357352240
2 changed files with 53 additions and 50 deletions

View File

@ -30,7 +30,7 @@
</script>
<script type="text/x-red" data-help-name="comment">
<p>Comment</p>
<p>A node you can use to add comments to your flows.</p>
</script>
<script type="text/javascript">

View File

@ -58,34 +58,35 @@ RED.sidebar.info = (function() {
function refresh(node) {
var table = '<table class="node-info"><tbody>';
//table += '<tr class="blank"><td colspan="2">Node</td></tr>';
table += '<tr class="blank"><td colspan="2">Node</td></tr>';
table += "<tr><td>Type</td><td>&nbsp;"+node.type+"</td></tr>";
table += "<tr><td>ID</td><td>&nbsp;"+node.id+"</td></tr>";
var m = /^subflow(:(.+))?$/.exec(node.type);
if (m) {
var subflowNode;
if (m[2]) {
subflowNode = RED.nodes.subflow(m[2]);
} else {
subflowNode = node;
}
table += '<tr class="blank"><td colspan="2">Subflow</td></tr>';
if (node.type.indexOf("subflow") === 0) {
var userCount = 0;
var subflowType = "subflow:"+subflowNode.id;
RED.nodes.eachNode(function(n) {
if (n.type === node.type) {
if (n.type === subflowType) {
userCount++;
}
});
node.name = node.name || "";
if (node.type !== "subflow") {
table += "<tr><td>Type</td><td>&nbsp;"+(RED.nodes.subflow(node.type.split(":")[1]).name||node.type)+"</td></tr>";
table += "<tr><td>ID</td><td>&nbsp;"+node.id+"</td></tr>";
table += "<tr><td>name</td><td>"+node.name+"</td></tr>";
table += "<tr><td>inputs</td><td>"+node.inputs+"</td></tr>";
table += "<tr><td>outputs</td><td>"+node.outputs+"</td></tr>";
table += "<tr><td>name</td><td>"+subflowNode.name+"</td></tr>";
table += "<tr><td>instances</td><td>"+userCount+"</td></tr>";
} else {
table += "<tr><td>Type</td><td>&nbsp;"+node.type+"</td></tr>";
table += "<tr><td>ID</td><td>&nbsp;"+node.id+"</td></tr>";
table += "<tr><td>name</td><td>"+node.name+"</td></tr>";
}
}
else if (node._def) {
if (node.type !== "comment") {
table += "<tr><td>Type</td><td>&nbsp;"+node.type+"</td></tr>";
table += "<tr><td>ID</td><td>&nbsp;"+node.id+"</td></tr>";
if (node.type != "subflow" && node.type != "comment") {
table += '<tr class="blank"><td colspan="2">Properties</td></tr>';
if (node._def) {
for (var n in node._def.defaults) {
if (node._def.defaults.hasOwnProperty(n)) {
var val = node[n]||"";
@ -118,8 +119,10 @@ RED.sidebar.info = (function() {
}
}
table += "</tbody></table><br/>";
if (node.type != "comment") {
var helpText = $("script[data-help-name|='"+node.type+"']").html()||"";
table += '<div class="node-help">'+helpText+"</div>";
}
if (node._def && node._def.info) {
var info = node._def.info;