|
|
|
|
|
|
|
|
d.w = Math.max(node_width,calculateTextWidth(l)+(d._def.inputs>0?7:0) ); |
|
|
d.w = Math.max(node_width,calculateTextWidth(l)+(d._def.inputs>0?7:0) ); |
|
|
d.h = Math.max(node_height,(Math.max(d.outputs,d._def.inputs)||0) * 15); |
|
|
d.h = Math.max(node_height,(Math.max(d.outputs,d._def.inputs)||0) * 15); |
|
|
|
|
|
|
|
|
|
|
|
node.append("dfn").attr("class", "tooltip").append("span").attr("role","tooltip"); |
|
|
|
|
|
|
|
|
if (d._def.badge) { |
|
|
if (d._def.badge) { |
|
|
var badge = node.append("svg:g").attr("class","node_badge_group"); |
|
|
var badge = node.append("svg:g").attr("class","node_badge_group"); |
|
|
var badgeRect = badge.append("rect").attr("class","node_badge").attr("rx",5).attr("ry",5).attr("width",40).attr("height",15); |
|
|
var badgeRect = badge.append("rect").attr("class","node_badge").attr("rx",5).attr("ry",5).attr("width",40).attr("height",15); |
|
|
|
|
|
|
|
|
.on("touchstart",nodeButtonClicked) |
|
|
.on("touchstart",nodeButtonClicked) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var mainRect = node.append("rect") |
|
|
var mainRect = node.append("rect") |
|
|
.attr("class", "node") |
|
|
.attr("class", "node") |
|
|
.classed("node_unknown",function(d) { return d.type == "unknown"; }) |
|
|
.classed("node_unknown",function(d) { return d.type == "unknown"; }) |
|
|
|
|
|
|
|
|
node.append("image").attr("class","node_reqerror hidden").attr("xlink:href","icons/error.png").attr("x",0).attr("y",-12).attr("width",20).attr("height",20); |
|
|
node.append("image").attr("class","node_reqerror hidden").attr("xlink:href","icons/error.png").attr("x",0).attr("y",-12).attr("width",20).attr("height",20); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node.each(function(d,i) { |
|
|
node.each(function(d,i) { |
|
|
|
|
|
|
|
|
/**********************************************************************/ |
|
|
/**********************************************************************/ |
|
|
//Add requirements |
|
|
//Add requirements |
|
|
d.requirementError = false; |
|
|
d.requirementError = false; |
|
|
|
|
|
d.conflicts = new Array(); |
|
|
d.requirements = new Array(); |
|
|
d.requirements = new Array(); |
|
|
requirements.forEach(function(r) { |
|
|
requirements.forEach(function(r) { |
|
|
if (r.type == d.type) d.requirements.push(r); |
|
|
if (r.type == d.type) d.requirements.push(r); |
|
|
|
|
|
|
|
|
if (n2 != d && n2.requirements != null ) { |
|
|
if (n2 != d && n2.requirements != null ) { |
|
|
n2.requirements.forEach(function(r2) { |
|
|
n2.requirements.forEach(function(r2) { |
|
|
if (r["resource"] == r2["resource"]) { |
|
|
if (r["resource"] == r2["resource"]) { |
|
|
if (r["shareable"] == false || r2["shareable"] == false) { |
|
|
|
|
|
console.log("Conflict: shareable '"+r["resource"]+"' "+d.name+" and "+n2.name); |
|
|
|
|
|
|
|
|
if (r["shareable"] == false ) { |
|
|
|
|
|
var msg = "Conflict: shareable '"+r["resource"]+"' "+d.name+" and "+n2.name; |
|
|
|
|
|
console.log(msg); |
|
|
|
|
|
msg = n2.name + " uses " + r["resource"] + ", too"; |
|
|
|
|
|
d.conflicts.push(msg); |
|
|
d.requirementError = true; |
|
|
d.requirementError = true; |
|
|
n2.requirementError = true; |
|
|
|
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
|
|
|
//else |
|
|
if (r["setting"] != r2["setting"]) { |
|
|
if (r["setting"] != r2["setting"]) { |
|
|
console.log("Conflict: "+ d.name + " setting['"+r["setting"]+"'] and "+n2.name+" setting['"+r2["setting"]+"']"); |
|
|
|
|
|
|
|
|
var msg = "Conflict: "+ d.name + " setting['"+r["setting"]+"'] and "+n2.name+" setting['"+r2["setting"]+"']"; |
|
|
|
|
|
console.log(msg); |
|
|
|
|
|
msg = n2.name + " has different settings: " + r["setting"] + " ./. " + r2["setting"]; |
|
|
|
|
|
d.conflicts.push(msg); |
|
|
d.requirementError = true; |
|
|
d.requirementError = true; |
|
|
n2.requirementError = true; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************/ |
|
|
/**********************************************************************/ |
|
|
|
|
|
|
|
|
if (d.dirty || d.requirementError != undefined) { |
|
|
if (d.dirty || d.requirementError != undefined) { |
|
|
|
|
|
|
|
|
port.attr("y",y) |
|
|
port.attr("y",y) |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thisNode.selectAll(".node_reqerror") |
|
|
thisNode.selectAll(".node_reqerror") |
|
|
.attr("x",function(d){return d.w-25-(d.changed?13:0)}) |
|
|
.attr("x",function(d){return d.w-25-(d.changed?13:0)}) |
|
|
.classed("hidden",function(d) { return !d.requirementError; }); |
|
|
|
|
|
|
|
|
.classed("hidden",function(d){ return !d.requirementError; }) |
|
|
|
|
|
.on("click", function(){RED.notify( |
|
|
|
|
|
|
|
|
|
|
|
'Conflicts:<ul><li>'+d.conflicts.join('</li><li>')+'</li></ul>' |
|
|
|
|
|
|
|
|
|
|
|
)}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
thisNode.selectAll(".node_icon").attr("y",function(d){return (d.h-d3.select(this).attr("height"))/2;}); |
|
|
thisNode.selectAll(".node_icon").attr("y",function(d){return (d.h-d3.select(this).attr("height"))/2;}); |
|
|
thisNode.selectAll(".node_icon_shade").attr("height",function(d){return d.h;}); |
|
|
thisNode.selectAll(".node_icon_shade").attr("height",function(d){return d.h;}); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function conflict(a) { alert(a); } |
|
|
|
|
|
|
|
|
function doSort (arr) { |
|
|
function doSort (arr) { |
|
|
arr.sort(function (a, b) { |
|
|
arr.sort(function (a, b) { |
|
|
var nameA = a.name ? a.name : a.id; |
|
|
var nameA = a.name ? a.name : a.id; |