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

Add 'changed' property to nodes to track undeployed changes

Part of #33
This commit is contained in:
Nicholas O'Leary 2013-11-15 23:40:36 +00:00
parent f7fc0760ca
commit e703fa1b6b
4 changed files with 18 additions and 3 deletions

View File

@ -36,8 +36,15 @@ var RED = function() {
if (resp && resp.status == 204) { if (resp && resp.status == 204) {
RED.notify("Successfully deployed","success"); RED.notify("Successfully deployed","success");
RED.view.dirty(false); RED.view.dirty(false);
RED.nodes.eachNode(function(node) {
if (node.changed) {
node.dirty = true;
node.changed = false;
}
});
// Once deployed, cannot undo back to a clean state // Once deployed, cannot undo back to a clean state
RED.history.markAllDirty(); RED.history.markAllDirty();
RED.view.redraw();
} else { } else {
if (resp) { if (resp) {
RED.notify("<strong>Error</strong>: "+resp,"error"); RED.notify("<strong>Error</strong>: "+resp,"error");

View File

@ -274,7 +274,7 @@ RED.nodes = function() {
RED.nodes.add(configNode); RED.nodes.add(configNode);
} }
} else { } else {
var node = {x:n.x,y:n.y,z:n.z,type:0,wires:n.wires}; var node = {x:n.x,y:n.y,z:n.z,type:0,wires:n.wires,changed:false};
if (createNewIds) { if (createNewIds) {
node.z = RED.view.getWorkspace(); node.z = RED.view.getWorkspace();
node.id = getID(); node.id = getID();

View File

@ -213,7 +213,7 @@ RED.editor = function() {
RED.view.dirty(true); RED.view.dirty(true);
RED.history.push({t:'edit',node:editing_node,changes:changes,links:removedLinks,dirty:wasDirty}); RED.history.push({t:'edit',node:editing_node,changes:changes,links:removedLinks,dirty:wasDirty});
} }
editing_node.changed = true;
editing_node.dirty = true; editing_node.dirty = true;
validateNode(editing_node); validateNode(editing_node);
RED.view.redraw(); RED.view.redraw();

View File

@ -359,7 +359,7 @@ RED.view = function() {
nn.type = selected_tool; nn.type = selected_tool;
nn._def = RED.nodes.getType(nn.type); nn._def = RED.nodes.getType(nn.type);
nn.outputs = nn._def.outputs; nn.outputs = nn._def.outputs;
nn.changed = true;
nn.h = Math.max(node_height,(nn.outputs||0) * 15); nn.h = Math.max(node_height,(nn.outputs||0) * 15);
for (var d in nn._def.defaults) { for (var d in nn._def.defaults) {
@ -778,6 +778,7 @@ RED.view = function() {
//node.append("path").attr("class","node_error").attr("d","M 3,-3 l 10,0 l -5,-8 z"); //node.append("path").attr("class","node_error").attr("d","M 3,-3 l 10,0 l -5,-8 z");
node.append("image").attr("class","node_error hidden").attr("xlink:href","icons/node-error.png").attr("x",0).attr("y",-6).attr("width",10).attr("height",9); node.append("image").attr("class","node_error hidden").attr("xlink:href","icons/node-error.png").attr("x",0).attr("y",-6).attr("width",10).attr("height",9);
//node.append("image").attr("class","node_changed hidden").attr("xlink:href","icons/node-error.png").attr("x",12).attr("y",-6).attr("width",10).attr("height",9);
}); });
node.each(function(d,i) { node.each(function(d,i) {
@ -844,6 +845,11 @@ RED.view = function() {
thisNode.selectAll(".node_error") thisNode.selectAll(".node_error")
.attr("x",function(d){return d.w-5}) .attr("x",function(d){return d.w-5})
.classed("hidden",function(d) { return d.valid; }); .classed("hidden",function(d) { return d.valid; });
thisNode.selectAll(".node_changed")
.attr("x",function(d){return d.w-15})
.classed("hidden",function(d) { return !d.changed; });
thisNode.selectAll(".port_input").each(function(d,i) { thisNode.selectAll(".port_input").each(function(d,i) {
var port = d3.select(this); var port = d3.select(this);
port.attr("y",function(d){return (d.h/2)-5;}) port.attr("y",function(d){return (d.h/2)-5;})
@ -994,6 +1000,8 @@ RED.view = function() {
for (var i in new_ms) { for (var i in new_ms) {
new_ms[i].n.selected = true; new_ms[i].n.selected = true;
new_ms[i].n.changed = true;
new_ms[i].n.x -= dx - mouse_position[0]; new_ms[i].n.x -= dx - mouse_position[0];
new_ms[i].n.y -= dy - mouse_position[1]; new_ms[i].n.y -= dy - mouse_position[1];
new_ms[i].dx = new_ms[i].n.x - mouse_position[0]; new_ms[i].dx = new_ms[i].n.x - mouse_position[0];