1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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"),
type: "POST",
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) {
RED.notify(node._("debug.notification.activated",{label:label}),"success");
} else if (xhr.status == 201) {

View File

@ -100,6 +100,10 @@ module.exports = function(RED) {
var seenAts = [];
try {
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) {
msg.format = "Object";
}
@ -116,7 +120,7 @@ module.exports = function(RED) {
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) {
if (key === '_req' || key === '_res') {
return "[internal]"

View File

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

View File

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

View File

@ -80,6 +80,8 @@ function getLocalFile(file) {
* @return an array of fully-qualified paths to .js files
*/
function getLocalNodeFiles(dir) {
dir = path.resolve(dir);
var result = [];
var files = [];
try {
@ -218,7 +220,7 @@ function getNodeFiles(disableNodePathScan) {
if (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");
}

View File

@ -36,6 +36,7 @@ describe("red/nodes/registry/localfilesystem",function() {
for (var i=0;i<shouldHaveNodes.length;i++) {
nodes.should.have.a.property(shouldHaveNodes[i]);
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('name',shouldHaveNodes[i]);
}
@ -95,6 +96,17 @@ describe("red/nodes/registry/localfilesystem",function() {
nm.should.have.a.property("nodes");
checkNodes(nm.nodes,['TestNode5'],['TestNode1']);
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}});