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

Only redraw node status when it has changed

This commit is contained in:
Nick O'Leary 2019-05-16 14:42:41 +01:00
parent 68b94737ed
commit 8567f1655e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 22 additions and 17 deletions

View File

@ -353,6 +353,7 @@ var RED = (function() {
} }
} }
node.status = msg; node.status = msg;
node.dirtyStatus = true;
node.dirty = true; node.dirty = true;
RED.view.redraw(); RED.view.redraw();
} }

View File

@ -3036,23 +3036,27 @@ RED.view = (function() {
// }); // });
} }
if (!showStatus || !d.status) { if (d.dirtyStatus) {
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","none"); if (!showStatus || !d.status) {
} else { thisNode.selectAll(".red-ui-flow-node-status-group").style("display","none");
var fill = status_colours[d.status.fill]; // Only allow our colours for now
if (d.status.shape == null && fill == null) {
thisNode.selectAll(".red-ui-flow-node-status").style("display","none");
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline").attr("transform","translate(-14,"+(d.h+3)+")");
} else { } else {
thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline").attr("transform","translate(3,"+(d.h+3)+")"); thisNode.selectAll(".red-ui-flow-node-status-group").style("display","inline");
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill; var fill = status_colours[d.status.fill]; // Only allow our colours for now
thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass); if (d.status.shape == null && fill == null) {
} thisNode.selectAll(".red-ui-flow-node-status").style("display","none");
if (d.status.text) { thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(-14,"+(d.h+3)+")");
thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text); } else {
} else { thisNode.selectAll(".red-ui-flow-node-status-group").attr("transform","translate(3,"+(d.h+3)+")");
thisNode.selectAll(".red-ui-flow-node-status-label").text(""); var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
thisNode.selectAll(".red-ui-flow-node-status").attr("class","red-ui-flow-node-status "+statusClass);
}
if (d.status.text) {
thisNode.selectAll(".red-ui-flow-node-status-label").text(d.status.text);
} else {
thisNode.selectAll(".red-ui-flow-node-status-label").text("");
}
} }
delete d.dirtyStatus;
} }
d.dirty = false; d.dirty = false;
@ -3454,7 +3458,7 @@ RED.view = (function() {
} }
function toggleStatus(s) { function toggleStatus(s) {
showStatus = s; showStatus = s;
RED.nodes.eachNode(function(n) { n.dirty = true;}); RED.nodes.eachNode(function(n) { n.dirtyStatus = true; n.dirty = true;});
//TODO: subscribe/unsubscribe here //TODO: subscribe/unsubscribe here
redraw(); redraw();
} }