NLS status text in editor not runtime

This commit is contained in:
Nick O'Leary 2015-07-01 23:02:50 +01:00
parent fbccf01933
commit 726069bc4b
5 changed files with 36 additions and 33 deletions

View File

@ -85,6 +85,9 @@ var RED = (function() {
var parts = topic.split("/");
var node = RED.nodes.node(parts[1]);
if (node) {
if (msg.text) {
msg.text = node._(msg.text,{defaultValue:msg.text});
}
node.status = msg;
if (statusEnabled) {
node.dirty = true;

View File

@ -67,7 +67,7 @@ module.exports = function(RED) {
node.child = spawn(gpioCommand, ["in",node.pin,node.intype]);
}
node.running = true;
node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")});
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {
data = data.toString().trim();
@ -90,10 +90,10 @@ module.exports = function(RED) {
node.running = false;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:RED._("rpi-gpio.status.closed")});
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:RED._("rpi-gpio.status.stopped")}); }
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
@ -108,7 +108,7 @@ module.exports = function(RED) {
}
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:RED._("rpi-gpio.status.closed")});
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
delete pinsInUse[node.pin];
if (node.child != null) {
node.done = done;
@ -151,7 +151,7 @@ module.exports = function(RED) {
}
else {
node.error(RED._("rpi-gpio.errors.pythoncommandnotfound"),msg);
node.status({fill:"red",shape:"ring",text:RED._("rpi-gpio.status.not-running")});
node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.not-running"});
}
}
else { node.warn(RED._("rpi-gpio.errors.invalidinput")+": "+out); }
@ -164,7 +164,7 @@ module.exports = function(RED) {
node.child = spawn(gpioCommand, [node.out,node.pin]);
}
node.running = true;
node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")});
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.on("input", inputlistener);
@ -181,10 +181,10 @@ module.exports = function(RED) {
node.running = false;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:RED._("rpi-gpio.status.closed")});
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:RED._("rpi-gpio.status.stopped")}); }
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
@ -199,7 +199,7 @@ module.exports = function(RED) {
}
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:RED._("rpi-gpio.status.closed")});
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
delete pinsInUse[node.pin];
if (node.child != null) {
node.done = done;
@ -232,7 +232,7 @@ module.exports = function(RED) {
var node = this;
node.child = spawn(gpioCommand+".py", ["mouse",node.butt]);
node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")});
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {
data = Number(data);
@ -249,10 +249,10 @@ module.exports = function(RED) {
node.running = false;
if (RED.settings.verbose) { node.log(RED._("rpi-gpio.status.closed")); }
if (node.done) {
node.status({fill:"grey",shape:"ring",text:RED._("rpi-gpio.status.closed")});
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
node.done();
}
else { node.status({fill:"red",shape:"ring",text:RED._("rpi-gpio.status.stopped")}); }
else { node.status({fill:"red",shape:"ring",text:"rpi-gpio.status.stopped"}); }
});
node.child.on('error', function (err) {
@ -262,7 +262,7 @@ module.exports = function(RED) {
});
node.on("close", function(done) {
node.status({fill:"grey",shape:"ring",text:RED._("rpi-gpio.status.closed")});
node.status({fill:"grey",shape:"ring",text:"rpi-gpio.status.closed"});
if (node.child != null) {
node.done = done;
node.child.kill('SIGINT');

View File

@ -42,7 +42,7 @@ module.exports = function(RED) {
this.broker = n.broker;
this.brokerConfig = RED.nodes.getNode(this.broker);
if (this.brokerConfig) {
this.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
this.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
this.client = connectionPool.get(this.brokerConfig.broker,this.brokerConfig.port,this.brokerConfig.clientid,this.brokerConfig.username,this.brokerConfig.password);
var node = this;
if (this.topic) {
@ -55,13 +55,13 @@ module.exports = function(RED) {
node.send(msg);
}, this.id);
this.client.on("connectionlost",function() {
node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
node.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
});
this.client.on("connect",function() {
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
if (this.client.isConnected()) {
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
} else {
this.client.connect();
}
@ -90,7 +90,7 @@ module.exports = function(RED) {
this.brokerConfig = RED.nodes.getNode(this.broker);
if (this.brokerConfig) {
this.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
this.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
this.client = connectionPool.get(this.brokerConfig.broker,this.brokerConfig.port,this.brokerConfig.clientid,this.brokerConfig.username,this.brokerConfig.password);
var node = this;
this.on("input",function(msg) {
@ -114,13 +114,13 @@ module.exports = function(RED) {
}
});
this.client.on("connectionlost",function() {
node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
node.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
});
this.client.on("connect",function() {
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
if (this.client.isConnected()) {
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
} else {
this.client.connect();
}

View File

@ -195,7 +195,7 @@ module.exports = function(RED) {
this.on("input",function(msg) {
var preRequestTimestamp = process.hrtime();
node.status({fill:"blue",shape:"dot",text:RED._("httpin.status.requesting")});
node.status({fill:"blue",shape:"dot",text:"httpin.status.requesting"});
var url = nodeUrl || msg.url;
if (msg.url && nodeUrl && (nodeUrl !== msg.url)) { // revert change below when warning is finally removed
node.warn(RED._("common.errors.nooverride"));

View File

@ -44,13 +44,13 @@ module.exports = function(RED) {
var end = false;
var setupTcpClient = function() {
node.log(RED._("tcpin.status.connecting",{host:node.host,port:node.port}));
node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")});
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
var id = (1+Math.random()*4294967295).toString(16);
client = net.connect(node.port, node.host, function() {
buffer = (node.datatype == 'buffer')? new Buffer(0):"";
node.connected = true;
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
connectionPool[id] = client;
@ -96,7 +96,7 @@ module.exports = function(RED) {
client.on('close', function() {
delete connectionPool[id];
node.connected = false;
node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
node.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
if (!node.closing) {
if (end) { // if we were asked to close then try to reconnect once very quick.
end = false;
@ -229,11 +229,11 @@ module.exports = function(RED) {
var setupTcpClient = function() {
node.log(RED._("tcpin.status.connecting",{host:node.host,port:node.port}));
node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")});
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
client = net.connect(node.port, node.host, function() {
node.connected = true;
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
client.on('error', function (err) {
node.log(RED._("tcpin.errors.error",{error:err.toString()}));
@ -241,7 +241,7 @@ module.exports = function(RED) {
client.on('end', function (err) {
});
client.on('close', function() {
node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
node.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
node.connected = false;
client.destroy();
if (!node.closing) {
@ -307,7 +307,7 @@ module.exports = function(RED) {
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
node.log(RED._("tcpin.status.connection-from",{host:socket.remoteAddress, port:socket.remotePort}));
connectedSockets.push(socket);
node.status({text:connectedSockets.length+" "+RED._("tcpin.status.connections")});
node.status({text:connectedSockets.length+" "+"tcpin.status.connections")});
socket.on('timeout', function() {
node.log(RED._("tcpin.errors.timeout",{port:node.port}));
socket.end();
@ -315,12 +315,12 @@ module.exports = function(RED) {
socket.on('close',function() {
node.log(RED._("tcpin.status.connection-closed",{host:socket.remoteAddress, port:socket.remotePort}));
connectedSockets.splice(connectedSockets.indexOf(socket),1);
node.status({text:RED._("common.status.connections",{count:connectedSockets.length})});
node.status({text:RED._("tcpin.status.connections",{count:connectedSockets.length})});
});
socket.on('error',function() {
node.log(RED._("tcpin.errors.socket-error",{host:socket.remoteAddress, port:socket.remotePort}));
connectedSockets.splice(connectedSockets.indexOf(socket),1);
node.status({text:RED._("common.status.connections",{count:connectedSockets.length})});
node.status({text:RED._("tcpin.status.connections",{count:connectedSockets.length})});
});
});
@ -402,7 +402,7 @@ module.exports = function(RED) {
if (host && port) {
client.connect(port, host, function() {
//node.log(RED._("tcpin.errors.client-connected"));
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
node.connected = true;
client.write(msg.payload);
});
@ -477,7 +477,7 @@ module.exports = function(RED) {
client.on('error', function() {
node.error(RED._("tcpin.errors.connect-fail"),msg);
node.status({fill:"red",shape:"ring",text:RED._("common.status.error")});
node.status({fill:"red",shape:"ring",text:"common.status.error"});
if (client) { client.end(); }
});