mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add rest endpoint for add/remove and send updates to editor
This commit is contained in:
@@ -176,6 +176,27 @@ var RED = function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
RED.comms.subscribe("node/#",function(topic,msg) {
|
||||
if (topic == "node/added") {
|
||||
for (var i=0;i<msg.length;i++) {
|
||||
var m = msg[i];
|
||||
var id = m.id;
|
||||
$.get('nodes/'+id, function(data) {
|
||||
$("body").append(data);
|
||||
var typeList = "<ul><li>"+m.types.join("</li><li>")+"</li></ul>";
|
||||
RED.notify("Node"+(m.types.length!=1 ? "s":"")+" added to palette:"+typeList,"success");
|
||||
});
|
||||
}
|
||||
} else if (topic == "node/removed") {
|
||||
if (msg.types) {
|
||||
for (var i=0;i<msg.types.length;i++) {
|
||||
RED.palette.remove(msg.types[i]);
|
||||
}
|
||||
var typeList = "<ul><li>"+msg.types.join("</li><li>")+"</li></ul>";
|
||||
RED.notify("Node"+(msg.types.length!=1 ? "s":"")+" removed from palette:"+typeList,"success");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user