mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
No-op and return success on enabling/disabling node by type name
This commit is contained in:
parent
10681f97d9
commit
66213d151d
@ -142,10 +142,8 @@ module.exports = {
|
||||
var info;
|
||||
if (!node) {
|
||||
res.send(404);
|
||||
} else if (!node.err && node.enabled === body.enabled) {
|
||||
res.json(node);
|
||||
} else {
|
||||
res.json(putNode(id, body.enabled));
|
||||
res.json(putNode(node, body.enabled));
|
||||
}
|
||||
} catch(err) {
|
||||
res.send(400,err.toString());
|
||||
@ -169,7 +167,7 @@ module.exports = {
|
||||
var matching = getMatchingNodes(mod);
|
||||
if (matching.length === 1) {
|
||||
// One match, assume correct
|
||||
res.json(putNode(matching[0].id, body.enabled));
|
||||
res.json(putNode(matching[0], body.enabled));
|
||||
return;
|
||||
} else if (matching.length > 1) {
|
||||
// Multiple matches, need clarification
|
||||
@ -229,13 +227,16 @@ function getMatchingNodes(node) {
|
||||
return matching;
|
||||
}
|
||||
|
||||
function putNode(id, enabled) {
|
||||
function putNode(node, enabled) {
|
||||
var info;
|
||||
|
||||
if (enabled) {
|
||||
info = redNodes.enableNode(id);
|
||||
if (!node.err && node.enabled === enabled) {
|
||||
info = node;
|
||||
} else {
|
||||
info = redNodes.disableNode(id);
|
||||
if (enabled) {
|
||||
info = redNodes.enableNode(node.id);
|
||||
} else {
|
||||
info = redNodes.disableNode(node.id);
|
||||
}
|
||||
|
||||
if (info.enabled === enabled && !info.err) {
|
||||
@ -248,6 +249,7 @@ function putNode(id, enabled) {
|
||||
util.log("[red] Failed to enable node:");
|
||||
util.log("[red] - "+info.name+" : "+info.err);
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user