Refinements to Unknown-node handling

Refinement to #113
This commit is contained in:
Nick O'Leary
2013-12-12 15:51:15 +00:00
parent 4fff3ce448
commit 344660dfee
7 changed files with 67 additions and 30 deletions

View File

@@ -22,14 +22,26 @@ var RED = function() {
if (!force) {
var invalid = false;
var unknownNodes = [];
RED.nodes.eachNode(function(node) {
invalid = invalid || !node.valid;
if (node.type === "unknown") {
RED.notify('Unknown node type <b>'+node.name+'</b> found',"error");
if (unknownNodes.indexOf(node.name) == -1) {
unknownNodes.push(node.name);
}
invalid = true;
}
});
if (invalid) {
if (unknownNodes.length > 0) {
$( "#node-dialog-confirm-deploy-config" ).hide();
$( "#node-dialog-confirm-deploy-unknown" ).show();
var list = "<li>"+unknownNodes.join("</li><li>")+"</li>";
$( "#node-dialog-confirm-deploy-unknown-list" ).html(list);
} else {
$( "#node-dialog-confirm-deploy-config" ).show();
$( "#node-dialog-confirm-deploy-unknown" ).hide();
}
$( "#node-dialog-confirm-deploy" ).dialog( "open" );
return;
}

View File

@@ -222,20 +222,26 @@ RED.nodes = function() {
if (!$.isArray(newNodes)) {
newNodes = [newNodes];
}
var unknownTypes = [];
for (var i in newNodes) {
var n = newNodes[i];
// TODO: remove workspace in next release+1
if (n.type != "workspace" && n.type != "tab" && !getType(n.type)) {
// TODO: get this UI thing out of here! (see below as well)
//return null; //
n.name = "( "+n.type+" )"; // DCJ - mod to make it load, but will lose all "self knowledge".
n.type = "unknown"; //
} //
if (n.type == "unknown") { //
RED.notify("<strong>Failed to import node</strong>: unrecognised type <b>'"+n.name+"'</b><br/>DO NOT DEPLOY while in this state.<br/>Either, add missing types to Node-RED, restart and then reload page,<br/>or delete unknown "+n.name+", rewire as required, and then deploy.","error");
} //
n.name = n.type;
n.type = "unknown";
if (unknownTypes.indexOf(n.name)==-1) {
unknownTypes.push(n.name);
}
}
}
if (unknownTypes.length > 0) {
var typeList = "<ul><li>"+unknownTypes.join("</li><li>")+"</li></ul>";
var type = "type"+(unknownTypes.length > 1?"s":"");
RED.notify("<strong>Imported unrecognised "+type+":</strong>"+typeList,"error",false,10000);
//"DO NOT DEPLOY while in this state.<br/>Either, add missing types to Node-RED, restart and then reload page,<br/>or delete unknown "+n.name+", rewire as required, and then deploy.","error");
}
for (var i in newNodes) {
var n = newNodes[i];
// TODO: remove workspace in next release+1

View File

@@ -16,7 +16,7 @@
RED.notify = function() {
var currentNotifications = [];
var c = 0;
return function(msg,type,fixed) {
return function(msg,type,fixed,timeout) {
if (currentNotifications.length > 4) {
var ll = currentNotifications.length;
for (var i = 0;ll > 4 && i<currentNotifications.length;i+=1) {
@@ -49,7 +49,7 @@ RED.notify = function() {
};
}();
if (!fixed) {
n.timeoutid = window.setTimeout(n.close,3000);
n.timeoutid = window.setTimeout(n.close,timeout||3000);
}
currentNotifications.push(n);
c+=1;

View File

@@ -722,6 +722,7 @@ RED.view = function() {
var mainRect = node.append("rect")
.attr("class", "node")
.classed("node_unknown",function(d) { return d.type == "unknown"; })
.attr("rx", 6)
.attr("ry", 6)
.attr("fill",function(d) { return d._def.color;})
@@ -952,7 +953,8 @@ RED.view = function() {
})
link.classed("link_selected", function(d) { return d === selected_link || d.selected; });
link.classed("link_unknown",function(d) { return d.target.type == "unknown" || d.source.type == "unknown"});
if (d3.event) {
d3.event.preventDefault();
}