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

tidy up tab-info so subflows show more useful information

(was broken before but no-one noticed ;-)
(and reorder fields in HTTP and XML nodes so name comes out first - ocd)
This commit is contained in:
dceejay 2015-02-10 16:55:50 +00:00
parent c6157687c9
commit e2911078e3
3 changed files with 22 additions and 17 deletions

View File

@ -56,10 +56,10 @@
category: 'function', category: 'function',
color:"#DEBD5C", color:"#DEBD5C",
defaults: { defaults: {
name: {value:""},
tag: {value:""}, tag: {value:""},
ret: {value:"html"}, ret: {value:"html"},
as: {value:"single"}, as: {value:"single"}
name: {value:""}
}, },
inputs:1, inputs:1,
outputs:1, outputs:1,

View File

@ -61,9 +61,9 @@
category: 'function', category: 'function',
color:"#DEBD5C", color:"#DEBD5C",
defaults: { defaults: {
name: {value:""},
attr: {value:'$',required:true}, attr: {value:'$',required:true},
chr: {value:'_',required:true}, chr: {value:'_',required:true}
name: {value:""}
}, },
inputs:1, inputs:1,
outputs:1, outputs:1,

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
**/ **/
RED.sidebar.info = (function() { RED.sidebar.info = (function() {
marked.setOptions({ marked.setOptions({
renderer: new marked.Renderer(), renderer: new marked.Renderer(),
gfm: true, gfm: true,
@ -25,7 +25,7 @@ RED.sidebar.info = (function() {
smartLists: true, smartLists: true,
smartypants: false smartypants: false
}); });
var content = document.createElement("div"); var content = document.createElement("div");
content.id = "tab-info"; content.id = "tab-info";
content.style.paddingTop = "4px"; content.style.paddingTop = "4px";
@ -38,7 +38,7 @@ RED.sidebar.info = (function() {
} }
RED.sidebar.show("info"); RED.sidebar.show("info");
} }
function jsonFilter(key,value) { function jsonFilter(key,value) {
if (key === "") { if (key === "") {
return value; return value;
@ -58,25 +58,29 @@ RED.sidebar.info = (function() {
function refresh(node) { function refresh(node) {
var table = '<table class="node-info"><tbody>'; 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>'; if (node.type.indexOf("subflow") === 0) {
table += "<tr><td>Type</td><td>&nbsp;"+node.type+"</td></tr>"; 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>ID</td><td>&nbsp;"+node.id+"</td></tr>";
table += '<tr class="blank"><td colspan="2">Properties</td></tr>';
if (node.type == "subflow") {
var userCount = 0; var userCount = 0;
var subflowType = "subflow:"+node.id;
RED.nodes.eachNode(function(n) { RED.nodes.eachNode(function(n) {
if (n.type === subflowType) { console.log(n);
if (n.type === node.type) {
userCount++; userCount++;
} }
}); });
node.name = node.name || "";
table += "<tr><td>name</td><td>"+node.name+"</td></tr>"; table += "<tr><td>name</td><td>"+node.name+"</td></tr>";
table += "<tr><td>inputs</td><td>"+node.in.length+"</td></tr>"; table += "<tr><td>inputs</td><td>"+node.inputs+"</td></tr>";
table += "<tr><td>outputs</td><td>"+node.out.length+"</td></tr>"; table += "<tr><td>outputs</td><td>"+node.outputs+"</td></tr>";
table += "<tr><td>instances</td><td>"+userCount+"</td></tr>"; table += "<tr><td>instances</td><td>"+userCount+"</td></tr>";
} }
if (node._def) { 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>";
table += '<tr class="blank"><td colspan="2">Properties</td></tr>';
for (var n in node._def.defaults) { for (var n in node._def.defaults) {
if (node._def.defaults.hasOwnProperty(n)) { if (node._def.defaults.hasOwnProperty(n)) {
var val = node[n]||""; var val = node[n]||"";
@ -106,6 +110,7 @@ RED.sidebar.info = (function() {
table += "<tr><td>"+n+"</td><td>"+val+"</td></tr>"; table += "<tr><td>"+n+"</td><td>"+val+"</td></tr>";
} }
} }
}
} }
table += "</tbody></table><br/>"; table += "</tbody></table><br/>";
var helpText = $("script[data-help-name|='"+node.type+"']").html()||""; var helpText = $("script[data-help-name|='"+node.type+"']").html()||"";