mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
188 lines
7.3 KiB
HTML
188 lines
7.3 KiB
HTML
<!--
|
|
Copyright 2013 IBM Corp.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<script type="text/x-red" data-template-name="tcp in">
|
|
<div class="form-row">
|
|
<label for="node-input-server"><i class="icon-resize-small"></i> Type</label>
|
|
<select id="node-input-server" style="width:120px; margin-right:5px;">
|
|
<option value="server">Listen on</option>
|
|
<option value="client">Connect to</option>
|
|
</select>
|
|
port <input type="text" id="node-input-port" style="width: 50px">
|
|
</div>
|
|
<div class="form-row hidden" id="node-input-host-row" style="padding-left: 110px;">
|
|
at host <input type="text" id="node-input-host" placeholder="localhost" style="width: 40%;">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label><i class="icon-th"></i> Output</label>
|
|
a
|
|
<select id="node-input-datamode" style="width:110px;">
|
|
<option value="stream">stream of</option>
|
|
<option value="single">single</option>
|
|
</select>
|
|
<select id="node-input-datatype" style="width:140px;">
|
|
<option value="buffer">Buffer</option>
|
|
<option value="utf8">String</option>
|
|
<option value="base64">Base64 String</option>
|
|
</select>
|
|
payload<span id="node-input-datamode-plural">s</span>
|
|
</div>
|
|
|
|
<div id="node-row-newline" class="form-row hidden" style="padding-left: 110px;">
|
|
delimited by <input type="text" id="node-input-newline" style="width: 110px;">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-topic"><i class="icon-tasks"></i> Topic</label>
|
|
<input type="text" id="node-input-topic" placeholder="Topic">
|
|
</div>
|
|
<div class="form-row">
|
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/x-red" data-help-name="tcp in">
|
|
<p>Provides a choice of tcp inputs. Can either connect to a remote tcp port,
|
|
or accept incoming connections.</p>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('tcp in',{
|
|
category: 'input',
|
|
color:"Silver",
|
|
defaults: {
|
|
server: {value:"server",required:true},
|
|
host: {value:"",validate:function(v) { return (this.server == "server")||v.length > 0;} },
|
|
port: {value:"",required:true,validate:RED.validators.number()},
|
|
datamode:{value:"stream"},
|
|
datatype:{value:"buffer"},
|
|
newline:{value:""},
|
|
topic: {value:""},
|
|
name: {value:""},
|
|
base64: {/*deprecated*/ value:false,required:true}
|
|
},
|
|
inputs:0,
|
|
outputs:1,
|
|
icon: "bridge-dash.png",
|
|
label: function() {
|
|
return this.name || "tcp:"+(this.host?this.host+":":"")+this.port;
|
|
},
|
|
labelStyle: function() {
|
|
return this.name?"node_label_italic":"";
|
|
},
|
|
oneditprepare: function() {
|
|
var updateOptions = function() {
|
|
var sockettype = $("#node-input-server option:selected").val();
|
|
if (sockettype == "client") {
|
|
$("#node-input-host-row").show();
|
|
} else {
|
|
$("#node-input-host-row").hide();
|
|
}
|
|
var datamode = $("#node-input-datamode option:selected").val();
|
|
var datatype = $("#node-input-datatype option:selected").val();
|
|
if (datamode == "stream") {
|
|
$("#node-input-datamode-plural").show();
|
|
if (datatype == "utf8") {
|
|
$("#node-row-newline").show();
|
|
} else {
|
|
$("#node-row-newline").hide();
|
|
}
|
|
} else {
|
|
$("#node-input-datamode-plural").hide();
|
|
$("#node-row-newline").hide();
|
|
}
|
|
};
|
|
updateOptions();
|
|
$("#node-input-server").change(updateOptions);
|
|
$("#node-input-datatype").change(updateOptions);
|
|
$("#node-input-datamode").change(updateOptions);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<script type="text/x-red" data-template-name="tcp out">
|
|
<div class="form-row">
|
|
<label for="node-input-beserver"><i class="icon-resize-small"></i> Type</label>
|
|
<select id="node-input-beserver" style="width:120px; margin-right:5px;">
|
|
<option value="server">Listen on</option>
|
|
<option value="client">Connect to</option>
|
|
</select>
|
|
port <input type="text" id="node-input-port" style="width: 50px">
|
|
</div>
|
|
|
|
<div class="form-row hidden" id="node-input-host-row" style="padding-left: 110px;">
|
|
at host <input type="text" id="node-input-host" placeholder="localhost" style="width: 40%;">
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label> </label>
|
|
<input type="checkbox" id="node-input-base64" placeholder="base64" style="display: inline-block; width: auto; vertical-align: top;">
|
|
<label for="node-input-base64" style="width: 70%;">Decode Base64 message ?</label>
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
|
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
</div>
|
|
</script>
|
|
|
|
<script type="text/x-red" data-help-name="tcp out">
|
|
<p>Provides a choice of tcp outputs. Can either connect to a remote tcp port,
|
|
or accept incoming connections.</p>
|
|
<p>Only <b>msg.payload</b> is sent.</p>
|
|
<p>If <b>msg.payload</b> is a string containing a base64 encoding of binary
|
|
data, the Base64 decoding option will cause it to be converted back to binary
|
|
before being sent.</p>
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
RED.nodes.registerType('tcp out',{
|
|
category: 'output',
|
|
color:"Silver",
|
|
defaults: {
|
|
host: {value:"",validate:function(v) { return (this.beserver == "server")||v.length > 0;} },
|
|
port: {value:"",required:true},
|
|
beserver: {value:"client",required:true},
|
|
base64: {value:false,required:true},
|
|
name: {value:""}
|
|
},
|
|
inputs:1,
|
|
outputs:0,
|
|
icon: "bridge-dash.png",
|
|
align: "right",
|
|
label: function() {
|
|
return this.name || "tcp:"+(this.host?this.host+":":"")+this.port;
|
|
},
|
|
labelStyle: function() {
|
|
return (this.name)?"node_label_italic":"";
|
|
},
|
|
oneditprepare: function() {
|
|
var updateOptions = function() {
|
|
var sockettype = $("#node-input-beserver option:selected").val();
|
|
if (sockettype == "client") {
|
|
$("#node-input-host-row").show();
|
|
} else {
|
|
$("#node-input-host-row").hide();
|
|
}
|
|
};
|
|
updateOptions();
|
|
$("#node-input-beserver").change(updateOptions);
|
|
}
|
|
});
|
|
</script>
|