mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Minimise filtering of nodes on redraw
This commit is contained in:
parent
ab3e64271b
commit
eacf41a4f6
@ -192,7 +192,7 @@ RED.history = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
RED.view.dirty(ev.dirty);
|
RED.view.dirty(ev.dirty);
|
||||||
RED.view.redraw();
|
RED.view.redraw(true);
|
||||||
RED.palette.refresh();
|
RED.palette.refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ var RED = (function() {
|
|||||||
success: function(nodes) {
|
success: function(nodes) {
|
||||||
RED.nodes.import(nodes);
|
RED.nodes.import(nodes);
|
||||||
RED.view.dirty(false);
|
RED.view.dirty(false);
|
||||||
RED.view.redraw();
|
RED.view.redraw(true);
|
||||||
RED.comms.subscribe("status/#",function(topic,msg) {
|
RED.comms.subscribe("status/#",function(topic,msg) {
|
||||||
var parts = topic.split("/");
|
var parts = topic.split("/");
|
||||||
var node = RED.nodes.node(parts[1]);
|
var node = RED.nodes.node(parts[1]);
|
||||||
@ -359,21 +359,6 @@ var RED = (function() {
|
|||||||
RED.subflow.init();
|
RED.subflow.init();
|
||||||
RED.view.init();
|
RED.view.init();
|
||||||
|
|
||||||
RED.view.on("selection-changed",function(selection) {
|
|
||||||
if (!selection.nodes) {
|
|
||||||
RED.menu.setDisabled("btn-export-menu",true);
|
|
||||||
RED.menu.setDisabled("btn-export-clipboard",true);
|
|
||||||
RED.menu.setDisabled("btn-export-library",true);
|
|
||||||
RED.menu.setDisabled("btn-convert-subflow",true);
|
|
||||||
} else {
|
|
||||||
RED.menu.setDisabled("btn-export-menu",false);
|
|
||||||
RED.menu.setDisabled("btn-export-clipboard",false);
|
|
||||||
RED.menu.setDisabled("btn-export-library",false);
|
|
||||||
RED.menu.setDisabled("btn-convert-subflow",false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();});
|
RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();});
|
||||||
RED.comms.connect();
|
RED.comms.connect();
|
||||||
loadNodeList();
|
loadNodeList();
|
||||||
|
@ -382,6 +382,18 @@ RED.library = (function() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
init: function() {
|
init: function() {
|
||||||
|
RED.view.on("selection-changed",function(selection) {
|
||||||
|
if (!selection.nodes) {
|
||||||
|
RED.menu.setDisabled("btn-export-menu",true);
|
||||||
|
RED.menu.setDisabled("btn-export-clipboard",true);
|
||||||
|
RED.menu.setDisabled("btn-export-library",true);
|
||||||
|
} else {
|
||||||
|
RED.menu.setDisabled("btn-export-menu",false);
|
||||||
|
RED.menu.setDisabled("btn-export-clipboard",false);
|
||||||
|
RED.menu.setDisabled("btn-export-library",false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
loadFlowLibrary();
|
loadFlowLibrary();
|
||||||
},
|
},
|
||||||
create: createUI,
|
create: createUI,
|
||||||
|
@ -174,6 +174,15 @@ RED.subflow = (function() {
|
|||||||
RED.view.dirty(true);
|
RED.view.dirty(true);
|
||||||
RED.view.redraw();
|
RED.view.redraw();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RED.view.on("selection-changed",function(selection) {
|
||||||
|
if (!selection.nodes) {
|
||||||
|
RED.menu.setDisabled("btn-convert-subflow",true);
|
||||||
|
} else {
|
||||||
|
RED.menu.setDisabled("btn-convert-subflow",false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createSubflow() {
|
function createSubflow() {
|
||||||
@ -379,7 +388,7 @@ RED.subflow = (function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
RED.view.dirty(true);
|
RED.view.dirty(true);
|
||||||
RED.view.redraw();
|
RED.view.redraw(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ RED.view = (function() {
|
|||||||
|
|
||||||
var activeWorkspace = 0;
|
var activeWorkspace = 0;
|
||||||
var activeSubflow = null;
|
var activeSubflow = null;
|
||||||
|
var activeNodes = [];
|
||||||
|
var activeLinks = [];
|
||||||
|
|
||||||
var workspaceScrollPositions = {};
|
var workspaceScrollPositions = {};
|
||||||
|
|
||||||
@ -231,6 +233,15 @@ RED.view = (function() {
|
|||||||
|
|
||||||
var drag_line = vis.append("svg:path").attr("class", "drag_line");
|
var drag_line = vis.append("svg:path").attr("class", "drag_line");
|
||||||
|
|
||||||
|
function updateActiveNodes() {
|
||||||
|
activeNodes = RED.nodes.nodes.filter(function(d) {
|
||||||
|
return d.z == activeWorkspace;
|
||||||
|
});
|
||||||
|
activeLinks = RED.nodes.links.filter(function(d) {
|
||||||
|
return d.source.z == activeWorkspace && d.target.z == activeWorkspace;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var workspace_tabs = RED.tabs.create({
|
var workspace_tabs = RED.tabs.create({
|
||||||
id: "workspace-tabs",
|
id: "workspace-tabs",
|
||||||
onchange: function(tab) {
|
onchange: function(tab) {
|
||||||
@ -276,6 +287,7 @@ RED.view = (function() {
|
|||||||
n.dirty = true;
|
n.dirty = true;
|
||||||
});
|
});
|
||||||
updateSelection();
|
updateSelection();
|
||||||
|
updateActiveNodes();
|
||||||
redraw();
|
redraw();
|
||||||
},
|
},
|
||||||
ondblclick: function(tab) {
|
ondblclick: function(tab) {
|
||||||
@ -294,10 +306,12 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
RED.menu.setDisabled("btn-workspace-delete",workspace_tabs.count() == 1);
|
RED.menu.setDisabled("btn-workspace-delete",workspace_tabs.count() == 1);
|
||||||
|
updateActiveNodes();
|
||||||
},
|
},
|
||||||
onremove: function(tab) {
|
onremove: function(tab) {
|
||||||
RED.menu.setDisabled("btn-workspace-delete",workspace_tabs.count() == 1);
|
RED.menu.setDisabled("btn-workspace-delete",workspace_tabs.count() == 1);
|
||||||
RED.menu.removeItem("btn-workspace-menu-"+tab.id.replace(".","-"));
|
RED.menu.removeItem("btn-workspace-menu-"+tab.id.replace(".","-"));
|
||||||
|
updateActiveNodes();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -327,6 +341,7 @@ RED.view = (function() {
|
|||||||
RED.menu.setAction('btn-workspace-delete',function() {
|
RED.menu.setAction('btn-workspace-delete',function() {
|
||||||
deleteWorkspace(activeWorkspace);
|
deleteWorkspace(activeWorkspace);
|
||||||
});
|
});
|
||||||
|
updateActiveNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteWorkspace(id) {
|
function deleteWorkspace(id) {
|
||||||
@ -563,6 +578,7 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
if (mouse_mode == RED.state.IMPORT_DRAGGING) {
|
if (mouse_mode == RED.state.IMPORT_DRAGGING) {
|
||||||
RED.keyboard.remove(/* ESCAPE */ 27);
|
RED.keyboard.remove(/* ESCAPE */ 27);
|
||||||
|
updateActiveNodes();
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
}
|
}
|
||||||
redraw();
|
redraw();
|
||||||
@ -644,6 +660,7 @@ RED.view = (function() {
|
|||||||
clearSelection();
|
clearSelection();
|
||||||
nn.selected = true;
|
nn.selected = true;
|
||||||
moving_set.push({n:nn});
|
moving_set.push({n:nn});
|
||||||
|
updateActiveNodes();
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
@ -886,6 +903,7 @@ RED.view = (function() {
|
|||||||
RED.history.push({t:'delete',nodes:removedNodes,links:removedLinks,subflowOutputs:removedSubflowOutputs,subflowInputs:removedSubflowInputs,dirty:startDirty});
|
RED.history.push({t:'delete',nodes:removedNodes,links:removedLinks,subflowOutputs:removedSubflowOutputs,subflowInputs:removedSubflowInputs,dirty:startDirty});
|
||||||
|
|
||||||
selected_link = null;
|
selected_link = null;
|
||||||
|
updateActiveNodes();
|
||||||
updateSelection();
|
updateSelection();
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
@ -980,6 +998,7 @@ RED.view = (function() {
|
|||||||
var link = {source: src, sourcePort:src_port, target: dst};
|
var link = {source: src, sourcePort:src_port, target: dst};
|
||||||
RED.nodes.addLink(link);
|
RED.nodes.addLink(link);
|
||||||
RED.history.push({t:'add',links:[link],dirty:dirty});
|
RED.history.push({t:'add',links:[link],dirty:dirty});
|
||||||
|
updateActiveNodes();
|
||||||
setDirty(true);
|
setDirty(true);
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
@ -1220,7 +1239,8 @@ RED.view = (function() {
|
|||||||
vis.selectAll(".subflowinput").remove();
|
vis.selectAll(".subflowinput").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
var node = vis.selectAll(".nodegroup").data(RED.nodes.nodes.filter(function(d) { return d.z == activeWorkspace }),function(d){return d.id});
|
//var node = vis.selectAll(".nodegroup").data(RED.nodes.nodes.filter(function(d) { return d.z == activeWorkspace }),function(d){return d.id});
|
||||||
|
var node = vis.selectAll(".nodegroup").data(activeNodes,function(d){return d.id});
|
||||||
node.exit().remove();
|
node.exit().remove();
|
||||||
|
|
||||||
var nodeEnter = node.enter().insert("svg:g").attr("class", "node nodegroup");
|
var nodeEnter = node.enter().insert("svg:g").attr("class", "node nodegroup");
|
||||||
@ -1579,9 +1599,7 @@ RED.view = (function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var link = vis.selectAll(".link").data(
|
var link = vis.selectAll(".link").data(
|
||||||
RED.nodes.links.filter(function(d) {
|
activeLinks,
|
||||||
return d.source.z == activeWorkspace && d.target.z == activeWorkspace;
|
|
||||||
}),
|
|
||||||
function(d) {
|
function(d) {
|
||||||
return d.source.id+":"+d.sourcePort+":"+d.target.id+":"+d.target.i;
|
return d.source.id+":"+d.sourcePort+":"+d.target.id+":"+d.target.i;
|
||||||
}
|
}
|
||||||
@ -1756,7 +1774,7 @@ RED.view = (function() {
|
|||||||
dirty:RED.view.dirty()
|
dirty:RED.view.dirty()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
updateActiveNodes();
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
} catch(error) {
|
} catch(error) {
|
||||||
@ -1972,7 +1990,10 @@ RED.view = (function() {
|
|||||||
showWorkspace: function(id) {
|
showWorkspace: function(id) {
|
||||||
workspace_tabs.activateTab(id);
|
workspace_tabs.activateTab(id);
|
||||||
},
|
},
|
||||||
redraw: function() {
|
redraw: function(updateActive) {
|
||||||
|
if (updateActive) {
|
||||||
|
updateActiveNodes();
|
||||||
|
}
|
||||||
RED.nodes.eachSubflow(function(sf) {
|
RED.nodes.eachSubflow(function(sf) {
|
||||||
if (workspace_tabs.contains(sf.id)) {
|
if (workspace_tabs.contains(sf.id)) {
|
||||||
workspace_tabs.renameTab(sf.id,"Subflow: "+sf.name);
|
workspace_tabs.renameTab(sf.id,"Subflow: "+sf.name);
|
||||||
|
Loading…
Reference in New Issue
Block a user