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

Display config nodes in Info sidebar table

This commit is contained in:
Nick O'Leary 2017-04-10 11:29:52 +01:00
parent 4b05a9bb6f
commit aefae79186
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
4 changed files with 52 additions and 23 deletions

View File

@ -134,7 +134,7 @@ RED.sidebar.info = (function() {
$(propRow.children()[1]).html(' '+(node.label||"")) $(propRow.children()[1]).html(' '+(node.label||""))
propRow = $('<tr class="node-info-node-row"><td>'+RED._("sidebar.info.id")+"</td><td></td></tr>").appendTo(tableBody); propRow = $('<tr class="node-info-node-row"><td>'+RED._("sidebar.info.id")+"</td><td></td></tr>").appendTo(tableBody);
RED.utils.createObjectElement(node.id).appendTo(propRow.children()[1]); RED.utils.createObjectElement(node.id).appendTo(propRow.children()[1]);
propRow = $('<tr class="node-info-node-row"><td>State</td><td></td></tr>').appendTo(tableBody); propRow = $('<tr class="node-info-node-row"><td>Status</td><td></td></tr>').appendTo(tableBody);
$(propRow.children()[1]).html((!!!node.disabled)?"Enabled":"Disabled") $(propRow.children()[1]).html((!!!node.disabled)?"Enabled":"Disabled")
} else { } else {
nodeSection.title.html("Node"); nodeSection.title.html("Node");
@ -150,15 +150,36 @@ RED.sidebar.info = (function() {
if (!m && node.type != "subflow" && node.type != "comment") { if (!m && node.type != "subflow" && node.type != "comment") {
if (node._def) { if (node._def) {
var count = 0; var count = 0;
for (var n in node._def.defaults) { var defaults = node._def.defaults;
if (n != "name" && node._def.defaults.hasOwnProperty(n)) { for (var n in defaults) {
if (n != "name" && defaults.hasOwnProperty(n)) {
var val = node[n]; var val = node[n];
var type = typeof val; var type = typeof val;
count++; count++;
propRow = $('<tr class="node-info-property-row'+(expandedSections.property?"":" hide")+'"><td>'+n+"</td><td></td></tr>").appendTo(tableBody); propRow = $('<tr class="node-info-property-row'+(expandedSections.property?"":" hide")+'"><td>'+n+"</td><td></td></tr>").appendTo(tableBody);
if (defaults[n].type) {
var configNode = RED.nodes.node(val);
if (!configNode) {
RED.utils.createObjectElement(undefined).appendTo(propRow.children()[1]);
} else {
var configLabel = RED.utils.getNodeLabel(configNode,val);
var nodeContainer = $('<span></span>').appendTo(propRow.children()[1]);
var entry = $('<span class="palette_node config_node"></span>')
.css({marginLeft:"5px",width:"calc(100% - 20px)"}).appendTo(nodeContainer);
$('<div class="palette_label"></div>').text(configLabel).appendTo(entry);
var icon_url = RED.utils.getNodeIcon(node._def);
var iconContainer = $('<div/>',{class:"palette_icon_container"}).appendTo(entry);
$('<div/>',{class:"palette_icon",style:"background-image: url("+icon_url+")"}).appendTo(iconContainer);
entry.dblclick(function(e) {
RED.editor.editConfig("", configNode.type, configNode.id);
})
}
} else {
RED.utils.createObjectElement(val).appendTo(propRow.children()[1]); RED.utils.createObjectElement(val).appendTo(propRow.children()[1]);
} }
} }
}
if (count > 0) { if (count > 0) {
$('<tr class="node-info-property-expand blank"><td colspan="2"><a href="#" class=" node-info-property-header'+(expandedSections.property?" expanded":"")+'"><span class="node-info-property-show-more">show more</span><span class="node-info-property-show-less">show less</span> <i class="fa fa-caret-down"></i></a></td></tr>').appendTo(tableBody); $('<tr class="node-info-property-expand blank"><td colspan="2"><a href="#" class=" node-info-property-header'+(expandedSections.property?" expanded":"")+'"><span class="node-info-property-show-more">show more</span><span class="node-info-property-show-less">show less</span> <i class="fa fa-caret-down"></i></a></td></tr>').appendTo(tableBody);
} }
@ -172,7 +193,7 @@ RED.sidebar.info = (function() {
subflowNode = node; subflowNode = node;
} }
$('<tr class="blank"><th colspan="2"><a href="#" class="node-info-subflow-header">'+RED._("sidebar.info.subflow")+'</a></th></tr>').appendTo(tableBody); $('<tr class="blank"><th colspan="2">'+RED._("sidebar.info.subflow")+'</th></tr>').appendTo(tableBody);
var userCount = 0; var userCount = 0;
var subflowType = "subflow:"+subflowNode.id; var subflowType = "subflow:"+subflowNode.id;

View File

@ -114,16 +114,18 @@
} }
.palette_label { .palette_label {
font-size: 13px; font-size: 13px;
margin: 4px 0 4px 28px; margin: 4px 0 4px 32px;
line-height: 20px; line-height: 20px;
overflow: hidden; overflow: hidden;
text-align: center; text-align: center;
@include disable-selection;
} }
.palette_label_right { .palette_label_right {
margin: 4px 28px 4px 0; margin: 4px 32px 4px 0;
} }
.palette_node { .palette_node {
display: block;
cursor:move; cursor:move;
background: #ddd; background: #ddd;
margin: 10px auto; margin: 10px auto;

View File

@ -25,13 +25,6 @@
.config-node-list { .config-node-list {
margin: 0; margin: 0;
list-style-type: none; list-style-type: none;
}
.config_node {
width: 160px;
height: 30px;
background: #f3f3f3;
color: #666;
cursor: pointer;
.palette_label { .palette_label {
margin-left: 8px; margin-left: 8px;
@ -49,6 +42,13 @@
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
} }
} }
.config_node {
width: 160px;
height: 30px;
background: #f3f3f3;
color: #666;
cursor: pointer;
}
.config_node_type { .config_node_type {
color: #999; color: #999;
text-align: right; text-align: right;

View File

@ -258,3 +258,9 @@ div.node-info {
margin-left: 4px; margin-left: 4px;
} }
} }
.node-info-property-config-node {
border: 1px solid #eee;
border-radius: 4px;
padding: 2px 4px 2px;
}