mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
NLS /red/nodes
NLS other js files under /red NLS /red files (changed based on Nick's review)
This commit is contained in:
parent
203bc41b06
commit
2563649b3e
@ -54,6 +54,11 @@
|
|||||||
"error-send": "Communication send error: __message__"
|
"error-send": "Communication send error: __message__"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"settings": {
|
||||||
|
"not-available": "Settings not available",
|
||||||
|
"property-read-only": "Property '__prop__' is read-only"
|
||||||
|
},
|
||||||
|
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"credentials": {
|
"credentials": {
|
||||||
"error":"Error loading credentials: __message__",
|
"error":"Error loading credentials: __message__",
|
||||||
@ -77,15 +82,39 @@
|
|||||||
"stopped": "Stopped",
|
"stopped": "Stopped",
|
||||||
"missing-types": "Waiting for missing types to be registered:"
|
"missing-types": "Waiting for missing types to be registered:"
|
||||||
|
|
||||||
|
},
|
||||||
|
"flow": {
|
||||||
|
"unknown-type": "Unknown type: __type__",
|
||||||
|
"missing-types": "missing types"
|
||||||
|
},
|
||||||
|
"index": {
|
||||||
|
"unrecognised-id": "Unrecognised id: __id__",
|
||||||
|
"type-in-use": "Type in use: __msg__",
|
||||||
|
"unrecognised-module": "Unrecognised module: __module__"
|
||||||
|
},
|
||||||
|
"registry": {
|
||||||
|
"localfilesystem": {
|
||||||
|
"module-not-found": "Cannot find module '__module__'"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"storage": {
|
"storage": {
|
||||||
|
"index": {
|
||||||
|
"forbidden-flow-name": "forbidden flow name"
|
||||||
|
},
|
||||||
"localfilesystem": {
|
"localfilesystem": {
|
||||||
"user-dir": "User directory : __path__",
|
"user-dir": "User directory : __path__",
|
||||||
"flows-file": "Flows file : __path__",
|
"flows-file": "Flows file : __path__",
|
||||||
"create": "Creating new flow file"
|
"create": "Creating new flow file"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
"httpadminauth-deprecated": "use of httpAdminAuth is deprecated. Use adminAuth instead",
|
||||||
|
"unable-to-listen": "Unable to listen on __listenpath__",
|
||||||
|
"port-in-use": "Error: port in use",
|
||||||
|
"uncaught-exception": "Uncaught Exception:",
|
||||||
|
"admin-ui-disabled": "Admin UI disabled",
|
||||||
|
"server-now-running": "Server now running at __listenpath__",
|
||||||
|
"failed-to-start-server": "Failed to start server:"
|
||||||
}
|
}
|
||||||
|
14
red.js
14
red.js
@ -166,7 +166,7 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (settings.httpAdminRoot !== false && settings.httpAdminAuth) {
|
if (settings.httpAdminRoot !== false && settings.httpAdminAuth) {
|
||||||
RED.log.warn("use of httpAdminAuth is deprecated. Use adminAuth instead");
|
RED.log.warn(log._("httpadminauth-deprecated"));
|
||||||
app.use(settings.httpAdminRoot,
|
app.use(settings.httpAdminRoot,
|
||||||
express.basicAuth(function(user, pass) {
|
express.basicAuth(function(user, pass) {
|
||||||
return user === settings.httpAdminAuth.user && crypto.createHash('md5').update(pass,'utf8').digest('hex') === settings.httpAdminAuth.pass;
|
return user === settings.httpAdminAuth.user && crypto.createHash('md5').update(pass,'utf8').digest('hex') === settings.httpAdminAuth.pass;
|
||||||
@ -216,10 +216,10 @@ RED.start().then(function() {
|
|||||||
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
if (settings.httpAdminRoot !== false || settings.httpNodeRoot !== false || settings.httpStatic) {
|
||||||
server.on('error', function(err) {
|
server.on('error', function(err) {
|
||||||
if (err.errno === "EADDRINUSE") {
|
if (err.errno === "EADDRINUSE") {
|
||||||
RED.log.error('Unable to listen on '+getListenPath());
|
RED.log.error(log._("unable-to-listen", {listenpath:getListenPath()}));
|
||||||
RED.log.error('Error: port in use');
|
RED.log.error(log._("port-in-use"));
|
||||||
} else {
|
} else {
|
||||||
RED.log.error('Uncaught Exception:');
|
RED.log.error(log._("uncaught-exception"));
|
||||||
if (err.stack) {
|
if (err.stack) {
|
||||||
RED.log.error(err.stack);
|
RED.log.error(err.stack);
|
||||||
} else {
|
} else {
|
||||||
@ -230,16 +230,16 @@ RED.start().then(function() {
|
|||||||
});
|
});
|
||||||
server.listen(settings.uiPort,settings.uiHost,function() {
|
server.listen(settings.uiPort,settings.uiHost,function() {
|
||||||
if (settings.httpAdminRoot === false) {
|
if (settings.httpAdminRoot === false) {
|
||||||
RED.log.info('Admin UI disabled');
|
RED.log.info(log._("admin-ui-disabled"));
|
||||||
}
|
}
|
||||||
process.title = 'node-red';
|
process.title = 'node-red';
|
||||||
RED.log.info('Server now running at '+getListenPath());
|
RED.log.info(log._("server-now-running", {listenpath:getListenPath()}));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
util.log('[red] Running in headless mode');
|
util.log('[red] Running in headless mode');
|
||||||
}
|
}
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
RED.log.error("Failed to start server:");
|
RED.log.error(log._("failed-to-start-server"));
|
||||||
if (err.stack) {
|
if (err.stack) {
|
||||||
RED.log.error(err.stack);
|
RED.log.error(err.stack);
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@ function createLibrary(type) {
|
|||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.warn(log._("api.library.error-load-entry",{path:path,message:err}));
|
log.warn(log._("api.library.error-load-entry",{path:path,message:err}));
|
||||||
if (err.message.indexOf('forbidden') === 0) {
|
if (err.code === 'forbidden') {
|
||||||
log.audit({event: "library.get",type:type,error:"forbidden"},req);
|
log.audit({event: "library.get",type:type,error:"forbidden"},req);
|
||||||
res.send(403);
|
res.send(403);
|
||||||
return;
|
return;
|
||||||
@ -58,7 +58,7 @@ function createLibrary(type) {
|
|||||||
res.send(204);
|
res.send(204);
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
log.warn(log._("api.library.error-save-entry",{path:path,message:err}));
|
log.warn(log._("api.library.error-save-entry",{path:path,message:err}));
|
||||||
if (err.message.indexOf('forbidden') === 0) {
|
if (err.code === 'forbidden') {
|
||||||
log.audit({event: "library.set",type:type,error:"forbidden"},req);
|
log.audit({event: "library.set",type:type,error:"forbidden"},req);
|
||||||
res.send(403);
|
res.send(403);
|
||||||
return;
|
return;
|
||||||
@ -90,7 +90,7 @@ module.exports = {
|
|||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
log.warn(log._("api.library.error-load-flow",{path:req.params[0],message:err}));
|
log.warn(log._("api.library.error-load-flow",{path:req.params[0],message:err}));
|
||||||
if (err.message.indexOf('forbidden') === 0) {
|
if (err.code === 'forbidden') {
|
||||||
log.audit({event: "library.get",type:"flow",path:req.params[0],error:"forbidden"},req);
|
log.audit({event: "library.get",type:"flow",path:req.params[0],error:"forbidden"},req);
|
||||||
res.send(403);
|
res.send(403);
|
||||||
return;
|
return;
|
||||||
@ -107,7 +107,7 @@ module.exports = {
|
|||||||
res.send(204);
|
res.send(204);
|
||||||
}).otherwise(function(err) {
|
}).otherwise(function(err) {
|
||||||
log.warn(log._("api.library.error-save-flow",{path:req.params[0],message:err}));
|
log.warn(log._("api.library.error-save-flow",{path:req.params[0],message:err}));
|
||||||
if (err.message.indexOf('forbidden') === 0) {
|
if (err.code === 'forbidden') {
|
||||||
log.audit({event: "library.set",type:"flow",path:req.params[0],error:"forbidden"},req);
|
log.audit({event: "library.set",type:"flow",path:req.params[0],error:"forbidden"},req);
|
||||||
res.send(403);
|
res.send(403);
|
||||||
return;
|
return;
|
||||||
|
@ -43,7 +43,7 @@ function createNode(type,config) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.error("Unknown type: "+type);
|
Log.error(Log._("nodes.flow.unknown-type", {type:type}));
|
||||||
}
|
}
|
||||||
return nn;
|
return nn;
|
||||||
}
|
}
|
||||||
@ -368,7 +368,7 @@ Flow.prototype.start = function(configDiff) {
|
|||||||
|
|
||||||
this.started = true;
|
this.started = true;
|
||||||
if (this.missingTypes.length > 0) {
|
if (this.missingTypes.length > 0) {
|
||||||
throw new Error("missing types");
|
throw new Error(Log._("nodes.flow.missing-types"));
|
||||||
}
|
}
|
||||||
events.emit("nodes-starting");
|
events.emit("nodes-starting");
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ var registry = require("./registry");
|
|||||||
var credentials = require("./credentials");
|
var credentials = require("./credentials");
|
||||||
var flows = require("./flows");
|
var flows = require("./flows");
|
||||||
var Node = require("./Node");
|
var Node = require("./Node");
|
||||||
|
var log = require("../log");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a node constructor
|
* Registers a node constructor
|
||||||
@ -61,7 +62,7 @@ function init(_settings,storage,app) {
|
|||||||
function checkTypeInUse(id) {
|
function checkTypeInUse(id) {
|
||||||
var nodeInfo = registry.getNodeInfo(id);
|
var nodeInfo = registry.getNodeInfo(id);
|
||||||
if (!nodeInfo) {
|
if (!nodeInfo) {
|
||||||
throw new Error("Unrecognised id: "+id);
|
throw new Error(log._("nodes.index.unrecognised-id", {id:id}));
|
||||||
} else {
|
} else {
|
||||||
var inUse = {};
|
var inUse = {};
|
||||||
var config = flows.getFlows();
|
var config = flows.getFlows();
|
||||||
@ -76,7 +77,7 @@ function checkTypeInUse(id) {
|
|||||||
});
|
});
|
||||||
if (nodesInUse.length > 0) {
|
if (nodesInUse.length > 0) {
|
||||||
var msg = nodesInUse.join(", ");
|
var msg = nodesInUse.join(", ");
|
||||||
var err = new Error("Type in use: "+msg);
|
var err = new Error(log._("nodes.index.type-in-use", {msg:msg}));
|
||||||
err.code = "type_in_use";
|
err.code = "type_in_use";
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
@ -91,7 +92,7 @@ function removeNode(id) {
|
|||||||
function removeModule(module) {
|
function removeModule(module) {
|
||||||
var info = registry.getModuleInfo(module);
|
var info = registry.getModuleInfo(module);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
throw new Error("Unrecognised module: "+module);
|
throw new Error(log._("nodes.index.unrecognised-module", {module:module}));
|
||||||
} else {
|
} else {
|
||||||
for (var i=0;i<info.nodes.length;i++) {
|
for (var i=0;i<info.nodes.length;i++) {
|
||||||
checkTypeInUse(module+"/"+info.nodes[i].name);
|
checkTypeInUse(module+"/"+info.nodes[i].name);
|
||||||
|
@ -302,7 +302,8 @@ function addModule(module) {
|
|||||||
}
|
}
|
||||||
var nodes = [];
|
var nodes = [];
|
||||||
if (registry.getModuleInfo(module)) {
|
if (registry.getModuleInfo(module)) {
|
||||||
var e = new Error("Module already loaded");
|
// TODO: nls
|
||||||
|
var e = new Error("module_already_loaded");
|
||||||
e.code = "module_already_loaded";
|
e.code = "module_already_loaded";
|
||||||
return when.reject(e);
|
return when.reject(e);
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ var fs = require("fs");
|
|||||||
var path = require("path");
|
var path = require("path");
|
||||||
|
|
||||||
var events = require("../../events");
|
var events = require("../../events");
|
||||||
|
var log = require("../../log");
|
||||||
|
|
||||||
var settings;
|
var settings;
|
||||||
var defaultNodesDir = path.resolve(path.join(__dirname,"..","..","..","nodes"));
|
var defaultNodesDir = path.resolve(path.join(__dirname,"..","..","..","nodes"));
|
||||||
@ -251,7 +252,7 @@ function getModuleFiles(module) {
|
|||||||
|
|
||||||
var moduleFiles = scanTreeForNodesModules(module);
|
var moduleFiles = scanTreeForNodesModules(module);
|
||||||
if (moduleFiles.length === 0) {
|
if (moduleFiles.length === 0) {
|
||||||
var err = new Error("Cannot find module '" + module + "'");
|
var err = new Error(log._("nodes.registry.localfilesystem.module-not-found", {module:module}));
|
||||||
err.code = 'MODULE_NOT_FOUND';
|
err.code = 'MODULE_NOT_FOUND';
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
var when = require("when");
|
var when = require("when");
|
||||||
var clone = require("clone");
|
var clone = require("clone");
|
||||||
var assert = require("assert");
|
var assert = require("assert");
|
||||||
|
var log = require("./log");
|
||||||
|
|
||||||
var userSettings = null;
|
var userSettings = null;
|
||||||
var globalSettings = null;
|
var globalSettings = null;
|
||||||
@ -48,17 +49,17 @@ var persistentSettings = {
|
|||||||
return clone(userSettings[prop]);
|
return clone(userSettings[prop]);
|
||||||
}
|
}
|
||||||
if (globalSettings === null) {
|
if (globalSettings === null) {
|
||||||
throw new Error("Settings not available");
|
throw new Error(log._("settings.not-available"));
|
||||||
}
|
}
|
||||||
return clone(globalSettings[prop]);
|
return clone(globalSettings[prop]);
|
||||||
},
|
},
|
||||||
|
|
||||||
set: function(prop,value) {
|
set: function(prop,value) {
|
||||||
if (userSettings.hasOwnProperty(prop)) {
|
if (userSettings.hasOwnProperty(prop)) {
|
||||||
throw new Error("Property '"+prop+"' is read-only");
|
throw new Error(log._("settings.property-read-only", {prop:prop}));
|
||||||
}
|
}
|
||||||
if (globalSettings === null) {
|
if (globalSettings === null) {
|
||||||
throw new Error("Settings not available");
|
throw new Error(log._("settings.not-available"));
|
||||||
}
|
}
|
||||||
var current = globalSettings[prop];
|
var current = globalSettings[prop];
|
||||||
globalSettings[prop] = value;
|
globalSettings[prop] = value;
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
var when = require('when');
|
var when = require('when');
|
||||||
var Path = require('path');
|
var Path = require('path');
|
||||||
|
var log = require("../log");
|
||||||
|
|
||||||
var storageModule;
|
var storageModule;
|
||||||
var settingsAvailable;
|
var settingsAvailable;
|
||||||
@ -96,13 +97,17 @@ var storageModuleInterface = {
|
|||||||
|
|
||||||
getLibraryEntry: function(type, path) {
|
getLibraryEntry: function(type, path) {
|
||||||
if (is_malicious(path)) {
|
if (is_malicious(path)) {
|
||||||
return when.reject(new Error('forbidden flow name'));
|
var err = new Error();
|
||||||
|
err.code = "forbidden";
|
||||||
|
return when.reject(err);
|
||||||
}
|
}
|
||||||
return storageModule.getLibraryEntry(type, path);
|
return storageModule.getLibraryEntry(type, path);
|
||||||
},
|
},
|
||||||
saveLibraryEntry: function(type, path, meta, body) {
|
saveLibraryEntry: function(type, path, meta, body) {
|
||||||
if (is_malicious(path)) {
|
if (is_malicious(path)) {
|
||||||
return when.reject(new Error('forbidden flow name'));
|
var err = new Error();
|
||||||
|
err.code = "forbidden";
|
||||||
|
return when.reject(err);
|
||||||
}
|
}
|
||||||
return storageModule.saveLibraryEntry(type, path, meta, body);
|
return storageModule.saveLibraryEntry(type, path, meta, body);
|
||||||
},
|
},
|
||||||
@ -117,7 +122,9 @@ var storageModuleInterface = {
|
|||||||
},
|
},
|
||||||
getFlow: function(fn) {
|
getFlow: function(fn) {
|
||||||
if (is_malicious(fn)) {
|
if (is_malicious(fn)) {
|
||||||
return when.reject(new Error('forbidden flow name'));
|
var err = new Error();
|
||||||
|
err.code = "forbidden";
|
||||||
|
return when.reject(err);
|
||||||
}
|
}
|
||||||
if (storageModule.hasOwnProperty("getFlow")) {
|
if (storageModule.hasOwnProperty("getFlow")) {
|
||||||
return storageModule.getFlow(fn);
|
return storageModule.getFlow(fn);
|
||||||
@ -128,7 +135,9 @@ var storageModuleInterface = {
|
|||||||
},
|
},
|
||||||
saveFlow: function(fn, data) {
|
saveFlow: function(fn, data) {
|
||||||
if (is_malicious(fn)) {
|
if (is_malicious(fn)) {
|
||||||
return when.reject(new Error('forbidden flow name'));
|
var err = new Error();
|
||||||
|
err.code = "forbidden";
|
||||||
|
return when.reject(err);
|
||||||
}
|
}
|
||||||
if (storageModule.hasOwnProperty("saveFlow")) {
|
if (storageModule.hasOwnProperty("saveFlow")) {
|
||||||
return storageModule.saveFlow(fn, data);
|
return storageModule.saveFlow(fn, data);
|
||||||
|
Loading…
Reference in New Issue
Block a user