mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
NLS status text in editor not runtime
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
@@ -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"));
|
||||
|
@@ -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(); }
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user