mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
remove client side validation & tidy up
This commit is contained in:
parent
5a21f026f2
commit
bdff1e4883
@ -23,6 +23,12 @@
|
||||
</select>
|
||||
<span data-i18n="tcpin.label.port"></span> <input type="text" id="node-input-port" style="width:65px">
|
||||
</div>
|
||||
|
||||
<div class="form-row inbound-disabled-tip">
|
||||
<label> </label>
|
||||
<div class="form-tips" data-i18n="tcpin.tip.inbound-disabled"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-row hidden" id="node-input-host-row" style="padding-left:110px;">
|
||||
<span data-i18n="tcpin.label.host"></span> <input type="text" id="node-input-host" placeholder="localhost" style="width: 60%;">
|
||||
</div>
|
||||
@ -72,13 +78,6 @@
|
||||
name: {value:""},
|
||||
server: {
|
||||
value: RED.settings.tcpInAllowInboundConnections === false ? "client" : "server",
|
||||
validate: function(v, opt) {
|
||||
console.log("validating client/server mode")
|
||||
if (v === 'server' && RED.settings.tcpInAllowInboundConnections === false) {
|
||||
return RED._("node-red:tcpin.errors.inbound-disabled");
|
||||
}
|
||||
return ["client", "server"].indexOf(v) >= 0
|
||||
}
|
||||
},
|
||||
host: {
|
||||
value:"",
|
||||
@ -116,8 +115,14 @@
|
||||
var sockettype = $("#node-input-server").val();
|
||||
if (sockettype == "client") {
|
||||
$("#node-input-host-row").show();
|
||||
$(".form-row.inbound-disabled-tip").addClass("hide")
|
||||
} else {
|
||||
$("#node-input-host-row").hide();
|
||||
if(RED.settings.tcpInAllowInboundConnections === false) {
|
||||
$(".form-row.inbound-disabled-tip").removeClass("hide")
|
||||
} else {
|
||||
$(".form-row.inbound-disabled-tip").addClass("hide")
|
||||
}
|
||||
}
|
||||
var datamode = $("#node-input-datamode").val();
|
||||
var datatype = $("#node-input-datatype").val();
|
||||
@ -151,6 +156,11 @@
|
||||
$("#node-input-usetls").on("click",function() {
|
||||
updateTLSOptions();
|
||||
});
|
||||
setTimeout(function() {
|
||||
// form tips have a max-width to prevent the initial edit form size calc making it overly large.
|
||||
// once the form is built and displayed, remove the size limit so that it sizes with the other elements.
|
||||
$('.form-tips').css({"max-width": "unset"})
|
||||
}, 500)
|
||||
},
|
||||
oneditsave: function() {
|
||||
if (!$("#node-input-usetls").is(':checked')) {
|
||||
@ -171,7 +181,10 @@
|
||||
</select>
|
||||
<span id="node-input-port-row"><span data-i18n="tcpin.label.port"></span> <input type="text" id="node-input-port" style="width: 65px"></span>
|
||||
</div>
|
||||
|
||||
<div class="form-row inbound-disabled-tip">
|
||||
<label> </label>
|
||||
<div class="form-tips" data-i18n="tcpin.tip.inbound-disabled"></div>
|
||||
</div>
|
||||
<div class="form-row hidden" id="node-input-host-row" style="padding-left: 110px;">
|
||||
<span data-i18n="tcpin.label.host"></span> <input type="text" id="node-input-host" style="width: 60%;">
|
||||
</div>
|
||||
@ -227,16 +240,7 @@
|
||||
return RED._("node-red:tcpin.errors.invalid-port");
|
||||
}
|
||||
},
|
||||
beserver: {
|
||||
value: "client",
|
||||
validate: function(v, opt) {
|
||||
console.log("validating client/server mode")
|
||||
if (v === 'server' && RED.settings.tcpInAllowInboundConnections === false) {
|
||||
return RED._("node-red:tcpin.errors.inbound-disabled");
|
||||
}
|
||||
return ["client", "server", "reply"].indexOf(v) >= 0
|
||||
}
|
||||
},
|
||||
beserver: {value:"client", required:true},
|
||||
base64: {value:false, required:true},
|
||||
end: {value:false, required:true},
|
||||
tls: {type:"tls-config", value:'', required:false,
|
||||
@ -260,16 +264,23 @@
|
||||
$("#node-input-host-row").hide();
|
||||
$("#node-input-end-row").hide();
|
||||
$("#node-input-tls-enable").hide();
|
||||
$(".form-row.inbound-disabled-tip").addClass("hide")
|
||||
} else if (sockettype == "client"){
|
||||
$("#node-input-port-row").show();
|
||||
$("#node-input-host-row").show();
|
||||
$("#node-input-end-row").show();
|
||||
$("#node-input-tls-enable").show();
|
||||
$(".form-row.inbound-disabled-tip").addClass("hide")
|
||||
} else {
|
||||
$("#node-input-port-row").show();
|
||||
$("#node-input-host-row").hide();
|
||||
$("#node-input-end-row").show();
|
||||
$("#node-input-tls-enable").show();
|
||||
if(RED.settings.tcpInAllowInboundConnections === false) {
|
||||
$(".form-row.inbound-disabled-tip").removeClass("hide")
|
||||
} else {
|
||||
$(".form-row.inbound-disabled-tip").addClass("hide")
|
||||
}
|
||||
}
|
||||
};
|
||||
updateOptions();
|
||||
@ -290,6 +301,11 @@
|
||||
$("#node-input-usetls").on("click",function() {
|
||||
updateTLSOptions();
|
||||
});
|
||||
setTimeout(function() {
|
||||
// form tips have a max-width to prevent the initial edit form size calc making it overly large.
|
||||
// once the form is built and displayed, remove the size limit so that it sizes with the other elements.
|
||||
$('.form-tips').css({"max-width": "unset"})
|
||||
}, 500)
|
||||
},
|
||||
oneditsave: function() {
|
||||
if (!$("#node-input-usetls").is(':checked')) {
|
||||
|
@ -309,8 +309,8 @@ module.exports = function(RED) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
node.warn(RED._("tcpin.errors.inbound-disabled",{host:node.host,port:node.port}));
|
||||
node.status({fill:"red",shape:"dot",text:"tcpin.errors.inbound-disabled"});
|
||||
node.warn(RED._("tcpin.status.inbound-disabled",{host:node.host,port:node.port}));
|
||||
node.status({fill:"gray",shape:"circle",text:"tcpin.status.inbound-disabled"});
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType("tcp in",TcpIn, {
|
||||
@ -518,8 +518,8 @@ module.exports = function(RED) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
node.warn(RED._("tcpin.errors.inbound-disabled",{host:node.host,port:node.port}));
|
||||
node.status({fill:"red",shape:"dot",text:"tcpin.errors.inbound-disabled"});
|
||||
node.warn(RED._("tcpin.status.inbound-disabled",{host:node.host,port:node.port}));
|
||||
node.status({fill:"gray",shape:"circle",text:"tcpin.status.inbound-disabled"});
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType("tcp out",TcpOut);
|
||||
|
@ -23,6 +23,10 @@
|
||||
<option value="true" data-i18n="udp.mcmsgs"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row inbound-disabled-tip">
|
||||
<label> </label>
|
||||
<div class="form-tips" data-i18n="udp.tip.inbound-disabled"></div>
|
||||
</div>
|
||||
<div class="form-row node-input-group">
|
||||
<label for="node-input-group"><i class="fa fa-list"></i> <span data-i18n="udp.label.group"></span></label>
|
||||
<input type="text" id="node-input-group" placeholder="225.0.18.83">
|
||||
@ -68,16 +72,7 @@
|
||||
validate:RED.validators.number(false)
|
||||
},
|
||||
ipv: {value:"udp4"},
|
||||
multicast: {
|
||||
value:"false",
|
||||
validate: function(v, opt) {
|
||||
console.log("validating client/server mode")
|
||||
if (RED.settings.udpInAllowInboundConnections === false) {
|
||||
return RED._("node-red:udp.errors.inbound-disabled");
|
||||
}
|
||||
return true
|
||||
}
|
||||
},
|
||||
multicast: {value:"false"},
|
||||
group: {
|
||||
value:"",
|
||||
validate:function(v,opt) {
|
||||
@ -104,6 +99,11 @@
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
if(RED.settings.udpInAllowInboundConnections === false) {
|
||||
$(".form-row.inbound-disabled-tip").removeClass("hide")
|
||||
} else {
|
||||
$(".form-row.inbound-disabled-tip").addClass("hide")
|
||||
}
|
||||
$("#node-input-multicast").on("change", function() {
|
||||
var id = $("#node-input-multicast").val();
|
||||
if (id == "false") {
|
||||
@ -130,6 +130,11 @@
|
||||
RED.notify(alreadyused+" "+$("#node-input-port").val(),"warn");
|
||||
}
|
||||
});
|
||||
setTimeout(function() {
|
||||
// form tips have a max-width to prevent the initial edit form size calc making it overly large.
|
||||
// once the form is built and displayed, remove the size limit so that it sizes with the other elements.
|
||||
$('.form-tips').css({"max-width": "unset"})
|
||||
}, 500)
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
@ -116,8 +116,8 @@ module.exports = function(RED) {
|
||||
|
||||
});
|
||||
} else {
|
||||
node.warn(RED._("udp.errors.inbound-disabled",{host:node.host,port:node.port}));
|
||||
node.status({fill:"red",shape:"dot",text:"udp.errors.inbound-disabled"});
|
||||
node.warn(RED._("udp.status.inbound-disabled",{host:node.host,port:node.port}));
|
||||
node.status({fill:"gray",shape:"circle",text:"udp.status.inbound-disabled"});
|
||||
}
|
||||
node.on("close", function() {
|
||||
try {
|
||||
|
@ -636,6 +636,9 @@
|
||||
"never": "never - keep connection open",
|
||||
"immed": "immediately - don't wait for reply"
|
||||
},
|
||||
"tip": {
|
||||
"inbound-disabled": "inbound connections are disabled for this Node-RED instance"
|
||||
},
|
||||
"status": {
|
||||
"connecting": "connecting to __host__:__port__",
|
||||
"connected": "connected to __host__:__port__",
|
||||
@ -644,10 +647,10 @@
|
||||
"connection-from": "connection from __host__:__port__",
|
||||
"connection-closed": "connection closed from __host__:__port__",
|
||||
"connections": "__count__ connection",
|
||||
"connections_plural": "__count__ connections"
|
||||
"connections_plural": "__count__ connections",
|
||||
"inbound-disabled": "inbound connections are disabled"
|
||||
},
|
||||
"errors": {
|
||||
"inbound-disabled": "inbound connections are disabled",
|
||||
"connection-lost": "connection lost to __host__:__port__",
|
||||
"timeout": "timeout closed socket port __port__",
|
||||
"cannot-listen": "unable to listen on port __port__, error: __error__",
|
||||
@ -698,7 +701,8 @@
|
||||
"tip": {
|
||||
"in": "Tip: Make sure your firewall will allow the data in.",
|
||||
"out": "Tip: leave address and port blank if you want to set using <code>msg.ip</code> and <code>msg.port</code>.",
|
||||
"port": "Ports already in use: "
|
||||
"port": "Ports already in use: ",
|
||||
"inbound-disabled": "inbound connections are disabled for this Node-RED instance"
|
||||
},
|
||||
"status": {
|
||||
"listener-at": "udp listener at __host__:__port__",
|
||||
@ -709,10 +713,10 @@
|
||||
"bc-ready": "udp broadcast ready: __outport__ -> __host__:__port__",
|
||||
"ready": "udp ready: __outport__ -> __host__:__port__",
|
||||
"ready-nolocal": "udp ready: __host__:__port__",
|
||||
"re-use": "udp re-use socket: __outport__ -> __host__:__port__"
|
||||
"re-use": "udp re-use socket: __outport__ -> __host__:__port__",
|
||||
"inbound-disabled": "inbound connections are disabled"
|
||||
},
|
||||
"errors": {
|
||||
"inbound-disabled": "inbound connections are disabled",
|
||||
"access-error": "UDP access error, you may need root access for ports below 1024",
|
||||
"error": "error: __error__",
|
||||
"bad-mcaddress": "Bad Multicast Address",
|
||||
|
Loading…
x
Reference in New Issue
Block a user