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

Add RED.view.redrawStatus to avoid full redraw on update

This commit is contained in:
Nick O'Leary 2020-07-10 16:00:18 +01:00
parent 979c5351a8
commit 612c565cfd
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 35 additions and 23 deletions

View File

@ -372,7 +372,7 @@ var RED = (function() {
node.status = msg; node.status = msg;
node.dirtyStatus = true; node.dirtyStatus = true;
node.dirty = true; node.dirty = true;
RED.view.redraw(); RED.view.redrawStatus(node);
} }
}); });
RED.comms.subscribe("notification/node/#",function(topic,msg) { RED.comms.subscribe("notification/node/#",function(topic,msg) {

View File

@ -3424,6 +3424,37 @@ RED.view = (function() {
} }
} }
function redrawStatus(d,nodeEl) {
if (d.z !== RED.workspaces.active()) {
return;
}
if (!nodeEl) {
nodeEl = document.getElementById(d.id);
}
if (nodeEl) {
if (!showStatus || !d.status) {
nodeEl.__statusGroup__.style.display = "none";
} else {
nodeEl.__statusGroup__.style.display = "inline";
var fill = status_colours[d.status.fill]; // Only allow our colours for now
if (d.status.shape == null && fill == null) {
nodeEl.__statusShape__.style.display = "none";
nodeEl.__statusGroup__.setAttribute("transform","translate(-14,"+(d.h+3)+")");
} else {
nodeEl.__statusGroup__.setAttribute("transform","translate(3,"+(d.h+3)+")");
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
nodeEl.__statusShape__.style.display = "inline";
nodeEl.__statusShape__.setAttribute("class","red-ui-flow-node-status "+statusClass);
}
if (d.status.hasOwnProperty('text')) {
nodeEl.__statusLabel__.textContent = d.status.text;
} else {
nodeEl.__statusLabel__.textContent = "";
}
}
delete d.dirtyStatus;
}
}
var pendingRedraw; var pendingRedraw;
@ -3992,27 +4023,7 @@ RED.view = (function() {
} }
if (d.dirtyStatus) { if (d.dirtyStatus) {
if (!showStatus || !d.status) { redrawStatus(d,this);
this.__statusGroup__.style.display = "none";
} else {
this.__statusGroup__.style.display = "inline";
var fill = status_colours[d.status.fill]; // Only allow our colours for now
if (d.status.shape == null && fill == null) {
this.__statusShape__.style.display = "none";
this.__statusGroup__.setAttribute("transform","translate(-14,"+(d.h+3)+")");
} else {
this.__statusGroup__.setAttribute("transform","translate(3,"+(d.h+3)+")");
var statusClass = "red-ui-flow-node-status-"+(d.status.shape||"dot")+"-"+d.status.fill;
this.__statusShape__.style.display = "inline";
this.__statusShape__.setAttribute("class","red-ui-flow-node-status "+statusClass);
}
if (d.status.hasOwnProperty('text')) {
this.__statusLabel__.textContent = d.status.text;
} else {
this.__statusLabel__.textContent = "";
}
}
delete d.dirtyStatus;
} }
d.dirty = false; d.dirty = false;
if (d.g) { if (d.g) {
@ -4928,6 +4939,7 @@ RED.view = (function() {
}, },
clipboard: function() { clipboard: function() {
return clipboard return clipboard
} },
redrawStatus: redrawStatus
}; };
})(); })();