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

Send status message id to be nls'd in editor

This commit is contained in:
Nick O'Leary 2015-07-07 21:31:28 +01:00
parent fd4b319af9
commit ee5ff8b010
6 changed files with 42 additions and 42 deletions

View File

@ -75,9 +75,9 @@ module.exports = function(RED) {
if (typeof this.serverConfig === "object") { if (typeof this.serverConfig === "object") {
this.board = this.serverConfig.board; this.board = this.serverConfig.board;
var node = this; var node = this;
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.connecting"});
node.board.on('connect', function() { node.board.on('connect', function() {
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
//console.log("i",node.state,node.pin); //console.log("i",node.state,node.pin);
if (node.state == "ANALOG") { if (node.state == "ANALOG") {
node.board.on('analogChange', function(e) { node.board.on('analogChange', function(e) {
@ -122,10 +122,10 @@ module.exports = function(RED) {
if (typeof this.serverConfig === "object") { if (typeof this.serverConfig === "object") {
this.board = this.serverConfig.board; this.board = this.serverConfig.board;
var node = this; var node = this;
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.connecting")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.connecting"});
node.board.on('connect', function() { node.board.on('connect', function() {
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
//console.log("o",node.state,node.pin); //console.log("o",node.state,node.pin);
node.board.pinMode(node.pin, node.state); node.board.pinMode(node.pin, node.state);
node.on("input", function(msg) { node.on("input", function(msg) {

View File

@ -76,10 +76,10 @@ module.exports = function(RED) {
} }
}); });
node.port.on('ready', function() { node.port.on('ready', function() {
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
}); });
node.port.on('closed', function() { node.port.on('closed', function() {
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"});
}); });
} else { } else {
this.error(RED._("serial.errors.missing-conf")); this.error(RED._("serial.errors.missing-conf"));
@ -108,7 +108,7 @@ module.exports = function(RED) {
if (node.serialConfig.out != "count") { buf = new Buffer(bufMaxSize); } if (node.serialConfig.out != "count") { buf = new Buffer(bufMaxSize); }
else { buf = new Buffer(Number(node.serialConfig.newline)); } else { buf = new Buffer(Number(node.serialConfig.newline)); }
var i = 0; var i = 0;
node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.not-connected")}); node.status({fill:"grey",shape:"dot",text:"node-red:common.status.not-connected"});
node.port = serialPool.get(this.serialConfig.serialport, node.port = serialPool.get(this.serialConfig.serialport,
this.serialConfig.serialbaud, this.serialConfig.serialbaud,
this.serialConfig.databits, this.serialConfig.databits,
@ -179,10 +179,10 @@ module.exports = function(RED) {
} }
}); });
this.port.on('ready', function() { this.port.on('ready', function() {
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
}); });
this.port.on('closed', function() { this.port.on('closed', function() {
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.not-connected")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.not-connected"});
}); });
} else { } else {
this.error(RED._("serial.errors.missing-conf")); this.error(RED._("serial.errors.missing-conf"));

View File

@ -71,7 +71,7 @@ module.exports = function(RED) {
this.on("input", function(msg) { this.on("input", function(msg) {
if (msg.hasOwnProperty("payload")) { if (msg.hasOwnProperty("payload")) {
if (smtpTransport) { if (smtpTransport) {
node.status({fill:"blue",shape:"dot",text:RED._("email.status.sending")}); node.status({fill:"blue",shape:"dot",text:"email.status.sending"});
if (msg.to && node.name && (msg.to !== node.name)) { if (msg.to && node.name && (msg.to !== node.name)) {
node.warn(RED._("node-red:common.errors.nooverride")); node.warn(RED._("node-red:common.errors.nooverride"));
} }
@ -103,7 +103,7 @@ module.exports = function(RED) {
smtpTransport.sendMail(sendopts, function(error, info) { smtpTransport.sendMail(sendopts, function(error, info) {
if (error) { if (error) {
node.error(error,msg); node.error(error,msg);
node.status({fill:"red",shape:"ring",text:RED._("email.status.sendfail")}); node.status({fill:"red",shape:"ring",text:"email.status.sendfail"});
} else { } else {
node.log(RED._("email.status.messagesent",{response:info.response})); node.log(RED._("email.status.messagesent",{response:info.response}));
node.status({}); node.status({});
@ -179,11 +179,11 @@ module.exports = function(RED) {
this.on("input", function(msg) { this.on("input", function(msg) {
imap.once('ready', function() { imap.once('ready', function() {
node.status({fill:"blue",shape:"dot",text:RED._("email.status.fetching")}); node.status({fill:"blue",shape:"dot",text:"email.status.fetching"});
var pay = {}; var pay = {};
imap.openBox(node.box, false, function(err, box) { imap.openBox(node.box, false, function(err, box) {
if (err) { if (err) {
node.status({fill:"red",shape:"ring",text:RED._("email.status.foldererror")}); node.status({fill:"red",shape:"ring",text:"email.status.foldererror"});
node.error(RED._("email.errors.fetchfail",{folder:node.box}),err); node.error(RED._("email.errors.fetchfail",{folder:node.box}),err);
} }
else { else {
@ -227,7 +227,7 @@ module.exports = function(RED) {
}); });
f.on('error', function(err) { f.on('error', function(err) {
node.warn(RED._("email.errors.messageerror",{error:err})); node.warn(RED._("email.errors.messageerror",{error:err}));
node.status({fill:"red",shape:"ring",text:RED._("email.status.messageerror")}); node.status({fill:"red",shape:"ring",text:"email.status.messageerror"});
}); });
f.on('end', function() { f.on('end', function() {
delete(pay._msgid); delete(pay._msgid);
@ -237,26 +237,26 @@ module.exports = function(RED) {
node.log(RED._("email.status.newemail",{topic:pay.topic})); node.log(RED._("email.status.newemail",{topic:pay.topic}));
} }
else { node.log(RED._("email.status.duplicate",{topic:pay.topic})); } else { node.log(RED._("email.status.duplicate",{topic:pay.topic})); }
//node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); //node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
node.status({}); node.status({});
}); });
} }
else { else {
node.log(RED._("email.status.inboxzero")); node.log(RED._("email.status.inboxzero"));
//node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); //node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
node.status({}); node.status({});
} }
} }
imap.end(); imap.end();
}); });
}); });
node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
imap.connect(); imap.connect();
}); });
imap.on('error', function(err) { imap.on('error', function(err) {
node.log(err); node.log(err);
node.status({fill:"red",shape:"ring",text:RED._("email.status.connecterror")}); node.status({fill:"red",shape:"ring",text:"email.status.connecterror"});
}); });
this.on("close", function() { this.on("close", function() {

View File

@ -48,7 +48,7 @@ module.exports = function(RED) {
var node = this; var node = this;
if (node.serverConfig.ircclient === null) { if (node.serverConfig.ircclient === null) {
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
node.serverConfig.ircclient.setMaxListeners(0); node.serverConfig.ircclient.setMaxListeners(0);
@ -58,7 +58,7 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.ircclient.addListener('netError', function(message) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); }
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.neterror"});
}); });
node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.ircclient.addListener('connect', function() {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
@ -67,21 +67,21 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.ircclient.addListener('registered', function(message) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server);
node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"});
node.serverConfig.ircclient.join( node.channel, function(data) { node.serverConfig.ircclient.join( node.channel, function(data) {
node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel);
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"});
}); });
}); });
node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.ircclient.addListener('ping', function(server) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); }
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
}); });
node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); }
node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")}); node.status({fill:"grey",shape:"ring",text:"node-red:common.status.quit"});
//node.serverConfig.ircclient.disconnect( function() { //node.serverConfig.ircclient.disconnect( function() {
// node.serverConfig.ircclient.connect(); // node.serverConfig.ircclient.connect();
//}); //});
@ -102,7 +102,7 @@ module.exports = function(RED) {
if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins
//node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.disconnect();
//node.serverConfig.ircclient.connect(); //node.serverConfig.ircclient.connect();
node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")}); node.status({fill:"grey",shape:"ring",text:"node-red:common.status.noconnection"});
if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); }
} }
//node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link
@ -114,10 +114,10 @@ module.exports = function(RED) {
node.ircclient.addListener('registered', function(message) { node.ircclient.addListener('registered', function(message) {
//node.log(node.ircclient.nick+" "+RED._("irc.errors.online")); //node.log(node.ircclient.nick+" "+RED._("irc.errors.online"));
node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"});
node.ircclient.join( node.channel, function(data) { node.ircclient.join( node.channel, function(data) {
// node.log(data+" "+RED._("irc.errors.joined")+" "+node.channel); // node.log(data+" "+RED._("irc.errors.joined")+" "+node.channel);
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"});
}); });
}); });
node.ircclient.addListener('message', function (from, to, message) { node.ircclient.addListener('message', function (from, to, message) {
@ -183,7 +183,7 @@ module.exports = function(RED) {
var node = this; var node = this;
if (node.serverConfig.ircclient === null) { if (node.serverConfig.ircclient === null) {
node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server); node.log(RED._("irc.errors.connect")+": "+node.serverConfig.server);
node.status({fill:"grey",shape:"dot",text:RED._("node-red:common.status.connecting")}); node.status({fill:"grey",shape:"dot",text:"node-red:common.status.connecting"});
var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000}; var options = {autoConnect:true,autoRejoin:false,floodProtection:true,secure:node.serverConfig.ssl,selfSigned:node.serverConfig.cert,port:node.serverConfig.port,retryDelay:20000};
node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options); node.serverConfig.ircclient = new irc.Client(node.serverConfig.server, node.serverConfig.nickname, options);
node.serverConfig.ircclient.setMaxListeners(0); node.serverConfig.ircclient.setMaxListeners(0);
@ -193,7 +193,7 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('netError', function(message) { node.serverConfig.ircclient.addListener('netError', function(message) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); } if (RED.settings.verbose) { node.log(RED._("irc.errors.net")+": "+JSON.stringify(message)); }
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.neterror")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.neterror"});
}); });
node.serverConfig.ircclient.addListener('connect', function() { node.serverConfig.ircclient.addListener('connect', function() {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
@ -202,21 +202,21 @@ module.exports = function(RED) {
node.serverConfig.ircclient.addListener('registered', function(message) { node.serverConfig.ircclient.addListener('registered', function(message) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server); node.log(node.serverConfig.ircclient.nick+" "+RED._("irc.errors.online")+": "+message.server);
node.status({fill:"yellow",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"yellow",shape:"dot",text:"node-red:common.status.connected"});
node.serverConfig.ircclient.join( node.channel, function(data) { node.serverConfig.ircclient.join( node.channel, function(data) {
node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel); node.log(data+" "+RED._("irc.errors.joined")+": "+node.channel);
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.joined")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.joined"});
}); });
}); });
node.serverConfig.ircclient.addListener('ping', function(server) { node.serverConfig.ircclient.addListener('ping', function(server) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); } if (RED.settings.verbose) { node.log(RED._("irc.errors.ping")+" "+JSON.stringify(server)); }
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.ok")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.ok"});
}); });
node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) { node.serverConfig.ircclient.addListener('quit', function(nick, reason, channels, message) {
node.serverConfig.lastseen = Date.now(); node.serverConfig.lastseen = Date.now();
if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); } if (RED.settings.verbose) { node.log(RED._("irc.errors.quit")+": "+nick+" "+reason+" "+channels+" "+JSON.stringify(message)); }
node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.quit")}); node.status({fill:"grey",shape:"ring",text:"node-red:common.status.quit"});
//node.serverConfig.ircclient.disconnect( function() { //node.serverConfig.ircclient.disconnect( function() {
// node.serverConfig.ircclient.connect(); // node.serverConfig.ircclient.connect();
//}); //});
@ -237,7 +237,7 @@ module.exports = function(RED) {
if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins if ((Date.now()-node.serverConfig.lastseen) > 300000) { // If more than 5 mins
//node.serverConfig.ircclient.disconnect(); //node.serverConfig.ircclient.disconnect();
//node.serverConfig.ircclient.connect(); //node.serverConfig.ircclient.connect();
node.status({fill:"grey",shape:"ring",text:RED._("node-red:common.status.noconnection")}); node.status({fill:"grey",shape:"ring",text:"node-red:common.status.noconnection"});
if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); } if (RED.settings.verbose) { node.log(RED._("irc.errors.connectionlost")); }
} }
//node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link //node.serverConfig.ircclient.send.apply(node.serverConfig.ircclient,["TIME"]); // request time to check link

View File

@ -279,7 +279,7 @@ module.exports = function(RED) {
}); });
node.on("input", function(msg) { node.on("input", function(msg) {
if (msg.hasOwnProperty("payload")) { if (msg.hasOwnProperty("payload")) {
node.status({fill:"blue",shape:"dot",text:RED._("twitter.status.tweeting")}); node.status({fill:"blue",shape:"dot",text:"twitter.status.tweeting"});
if (msg.payload.length > 140) { if (msg.payload.length > 140) {
msg.payload = msg.payload.slice(0,139); msg.payload = msg.payload.slice(0,139);
@ -296,13 +296,13 @@ module.exports = function(RED) {
var r = request.post(signedUrl,function(err,httpResponse,body) { var r = request.post(signedUrl,function(err,httpResponse,body) {
if (err) { if (err) {
node.error(err,msg); node.error(err,msg);
node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
} else { } else {
var response = JSON.parse(body); var response = JSON.parse(body);
if (response.errors) { if (response.errors) {
var errorList = response.errors.map(function(er) { return er.code+": "+er.message }).join(", "); var errorList = response.errors.map(function(er) { return er.code+": "+er.message }).join(", ");
node.error(RED._("twitter.errors.sendfail",{error:errorList}),msg); node.error(RED._("twitter.errors.sendfail",{error:errorList}),msg);
node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
} else { } else {
node.status({}); node.status({});
} }
@ -315,7 +315,7 @@ module.exports = function(RED) {
} else { } else {
twit.updateStatus(msg.payload, function (err, data) { twit.updateStatus(msg.payload, function (err, data) {
if (err) { if (err) {
node.status({fill:"red",shape:"ring",text:RED._("twitter.status.failed")}); node.status({fill:"red",shape:"ring",text:"twitter.status.failed"});
node.error(err,msg); node.error(err,msg);
} }
node.status({}); node.status({});

View File

@ -61,17 +61,17 @@ module.exports = function(RED) {
this.client = redisConnectionPool.get(this.hostname,this.port); this.client = redisConnectionPool.get(this.hostname,this.port);
if (this.client.connected) { if (this.client.connected) {
this.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); this.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
} else { } else {
this.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")},true); this.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"},true);
} }
var node = this; var node = this;
this.client.on("end", function() { this.client.on("end", function() {
node.status({fill:"red",shape:"ring",text:RED._("node-red:common.status.disconnected")}); node.status({fill:"red",shape:"ring",text:"node-red:common.status.disconnected"});
}); });
this.client.on("connect", function() { this.client.on("connect", function() {
node.status({fill:"green",shape:"dot",text:RED._("node-red:common.status.connected")}); node.status({fill:"green",shape:"dot",text:"node-red:common.status.connected"});
}); });
this.on("input", function(msg) { this.on("input", function(msg) {