Merge branch 'master' into 0.17

This commit is contained in:
Nick O'Leary 2017-04-11 14:53:44 +01:00
commit bfb548636e
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
6 changed files with 40 additions and 7 deletions

View File

@ -83,6 +83,19 @@
url: "debug/"+this.id+"/"+(this.active?"enable":"disable"), url: "debug/"+this.id+"/"+(this.active?"enable":"disable"),
type: "POST", type: "POST",
success: function(resp, textStatus, xhr) { success: function(resp, textStatus, xhr) {
var historyEvent = {
t:'edit',
node:node,
changes:{
active: !node.active
},
dirty:node.dirty,
changed:node.changed
};
node.changed = true;
RED.nodes.dirty(true);
RED.history.push(historyEvent);
if (xhr.status == 200) { if (xhr.status == 200) {
RED.notify(node._("debug.notification.activated",{label:label}),"success"); RED.notify(node._("debug.notification.activated",{label:label}),"success");
} else if (xhr.status == 201) { } else if (xhr.status == 201) {

View File

@ -100,6 +100,10 @@ module.exports = function(RED) {
var seenAts = []; var seenAts = [];
try { try {
msg.format = msg.msg.constructor.name || "Object"; msg.format = msg.msg.constructor.name || "Object";
// Handle special case of msg.req/res objects from HTTP In node
if (msg.format === "IncomingMessage" || msg.format === "ServerResponse") {
msg.format = "Object";
}
} catch(err) { } catch(err) {
msg.format = "Object"; msg.format = "Object";
} }
@ -116,7 +120,7 @@ module.exports = function(RED) {
msg.msg = msg.msg.slice(0,debuglength); msg.msg = msg.msg.slice(0,debuglength);
} }
} }
if (isArray || (msg.format === "Object")) { if (isArray || msg.format === "Object") {
msg.msg = safeJSONStringify(msg.msg, function(key, value) { msg.msg = safeJSONStringify(msg.msg, function(key, value) {
if (key === '_req' || key === '_res') { if (key === '_req' || key === '_res') {
return "[internal]" return "[internal]"

View File

@ -132,14 +132,14 @@ function start() {
if (anonymousUser) { if (anonymousUser) {
log.audit({event: "comms.auth",user:anonymousUser}); log.audit({event: "comms.auth",user:anonymousUser});
completeConnection(anonymousUser.permissions,false); completeConnection(anonymousUser.permissions,false);
//TODO: duplicated code - pull non-auth message handling out
if (msg.subscribe) {
handleRemoteSubscription(ws,msg.subscribe);
}
} else { } else {
log.audit({event: "comms.auth.fail"}); log.audit({event: "comms.auth.fail"});
completeConnection(null,false); completeConnection(null,false);
} }
//TODO: duplicated code - pull non-auth message handling out
if (msg.subscribe) {
handleRemoteSubscription(ws,msg.subscribe);
}
} }
} }
}); });

View File

@ -17,6 +17,7 @@
var when = require("when"); var when = require("when");
var path = require("path"); var path = require("path");
var fs = require("fs"); var fs = require("fs");
var clone = require("clone");
var registry = require("./registry"); var registry = require("./registry");
var credentials = require("./credentials"); var credentials = require("./credentials");
@ -79,6 +80,7 @@ function createNode(node,def) {
} }
var creds = credentials.get(id); var creds = credentials.get(id);
if (creds) { if (creds) {
creds = clone(creds);
//console.log("Attaching credentials to ",node.id); //console.log("Attaching credentials to ",node.id);
// allow $(foo) syntax to substitute env variables for credentials also... // allow $(foo) syntax to substitute env variables for credentials also...
for (var p in creds) { for (var p in creds) {

View File

@ -80,6 +80,8 @@ function getLocalFile(file) {
* @return an array of fully-qualified paths to .js files * @return an array of fully-qualified paths to .js files
*/ */
function getLocalNodeFiles(dir) { function getLocalNodeFiles(dir) {
dir = path.resolve(dir);
var result = []; var result = [];
var files = []; var files = [];
try { try {
@ -218,7 +220,7 @@ function getNodeFiles(disableNodePathScan) {
if (settings.coreNodesDir) { if (settings.coreNodesDir) {
nodeFiles = getLocalNodeFiles(path.resolve(settings.coreNodesDir)); nodeFiles = getLocalNodeFiles(path.resolve(settings.coreNodesDir));
var defaultLocalesPath = path.resolve(path.join(settings.coreNodesDir,"core","locales")); var defaultLocalesPath = path.join(settings.coreNodesDir,"core","locales");
i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json"); i18n.registerMessageCatalog("node-red",defaultLocalesPath,"messages.json");
} }

View File

@ -36,6 +36,7 @@ describe("red/nodes/registry/localfilesystem",function() {
for (var i=0;i<shouldHaveNodes.length;i++) { for (var i=0;i<shouldHaveNodes.length;i++) {
nodes.should.have.a.property(shouldHaveNodes[i]); nodes.should.have.a.property(shouldHaveNodes[i]);
nodes[shouldHaveNodes[i]].should.have.a.property('file'); nodes[shouldHaveNodes[i]].should.have.a.property('file');
nodes[shouldHaveNodes[i]].file.should.equal(path.resolve(nodes[shouldHaveNodes[i]].file));
nodes[shouldHaveNodes[i]].should.have.a.property('module',module||'node-red'); nodes[shouldHaveNodes[i]].should.have.a.property('module',module||'node-red');
nodes[shouldHaveNodes[i]].should.have.a.property('name',shouldHaveNodes[i]); nodes[shouldHaveNodes[i]].should.have.a.property('name',shouldHaveNodes[i]);
} }
@ -96,7 +97,18 @@ describe("red/nodes/registry/localfilesystem",function() {
checkNodes(nm.nodes,['TestNode5'],['TestNode1']); checkNodes(nm.nodes,['TestNode5'],['TestNode1']);
done(); done();
}); });
it("Finds nodes in settings.nodesDir (array)",function(done) { it("Finds nodes in settings.nodesDir (string,relative path)",function(done) {
var relativeUserDir = path.join("test","red","runtime","nodes","resources","userDir");
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:relativeUserDir,coreNodesDir:__dirname}});
var nodeList = localfilesystem.getNodeFiles(true);
nodeList.should.have.a.property("node-red");
var nm = nodeList['node-red'];
nm.should.have.a.property('name','node-red');
nm.should.have.a.property("nodes");
checkNodes(nm.nodes,['TestNode5'],['TestNode1']);
done();
});
it("Finds nodes in settings.nodesDir (array)",function(done) {
localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:[userDir],coreNodesDir:__dirname}}); localfilesystem.init({i18n:{registerMessageCatalog:function(){}},events:{emit:function(){}},settings:{nodesDir:[userDir],coreNodesDir:__dirname}});
var nodeList = localfilesystem.getNodeFiles(true); var nodeList = localfilesystem.getNodeFiles(true);
nodeList.should.have.a.property("node-red"); nodeList.should.have.a.property("node-red");