mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Improve node info properties table
This commit is contained in:
parent
79d4b32e3f
commit
75fc46c05d
@ -499,6 +499,23 @@ RED.view = function() {
|
||||
}
|
||||
}
|
||||
|
||||
function jsonFilter(key,value) {
|
||||
if (key == "") {
|
||||
return value;
|
||||
}
|
||||
var t = typeof value;
|
||||
if ($.isArray(value)) {
|
||||
return "[array:"+value.length+"]";
|
||||
} else if (t === "object") {
|
||||
return "[object]"
|
||||
} else if (t === "string") {
|
||||
if (value.length > 30) {
|
||||
return value.substring(0,30)+" ...";
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function buildInfo(node) {
|
||||
var table = '<table class="node-info"><tbody>';
|
||||
|
||||
@ -506,13 +523,30 @@ RED.view = function() {
|
||||
table += "<tr><td>ID</td><td> "+node.id+"</td></tr>";
|
||||
table += '<tr class="blank"><td colspan="2"> Properties</td></tr>';
|
||||
for (var n in node._def.defaults) {
|
||||
if ((n != "func")&&(n != "template")) {
|
||||
var safe = (node[n]||"").toString().replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||
table += "<tr><td> "+n+"</td><td>"+safe+"</td></tr>";
|
||||
var val = node[n]||"";
|
||||
var type = typeof val;
|
||||
if (type === "string") {
|
||||
if (val.length > 30) {
|
||||
val = val.substring(0,30)+" ...";
|
||||
}
|
||||
if ((n == "func")||(n == "template")) {
|
||||
table += "<tr><td> "+n+"</td><td>(...)</td></tr>";
|
||||
} else if (type === "number") {
|
||||
val = val.toString();
|
||||
} else if ($.isArray(val)) {
|
||||
val = "[<br/>";
|
||||
for (var i=0;i<Math.min(node[n].length,10);i++) {
|
||||
var vv = JSON.stringify(node[n][i],jsonFilter," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||
val += " "+i+": "+vv+"<br/>";
|
||||
}
|
||||
if (node[n].length > 10) {
|
||||
val += " ... "+node[n].length+" items<br/>";
|
||||
}
|
||||
val += "]";
|
||||
} else {
|
||||
val = JSON.stringify(val,jsonFilter," ");
|
||||
val = val.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");
|
||||
}
|
||||
|
||||
table += "<tr><td> "+n+"</td><td>"+val+"</td></tr>";
|
||||
}
|
||||
table += "</tbody></table><br/>";
|
||||
table += '<div class="node-help">'+($("script[data-help-name|='"+node.type+"']").html()||"")+"</div>";
|
||||
|
@ -546,8 +546,11 @@ table.node-info td:first-child{
|
||||
color: #000;
|
||||
vertical-align: top;
|
||||
width: 90px;
|
||||
padding: 0 3px;
|
||||
border-right: 1px solid #ddd;
|
||||
}
|
||||
table.node-info td:last-child{
|
||||
padding-left: 5px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user