Tidy up ping notes for pub

This commit is contained in:
Dave Conway-Jones 2020-04-03 16:50:09 +01:00
parent f276de252e
commit 7667de5ced
No known key found for this signature in database
GPG Key ID: 302A6725C594817F
4 changed files with 40 additions and 29 deletions

View File

@ -19,6 +19,7 @@
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label> <label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name"> <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div> </div>
<div class="form-tips" id="node-ping-tip"><span data-i18n="ping.label.tip"></span></div>
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
@ -46,7 +47,7 @@ var timerParameterValidator = function(node,v){
} else { } else {
let $mode = $( "#node-input-mode" ); let $mode = $( "#node-input-mode" );
return $mode.val(); return $mode.val();
} }
} }
RED.nodes.registerType("ping",{ RED.nodes.registerType("ping",{
@ -61,7 +62,7 @@ var timerParameterValidator = function(node,v){
}, },
timer: {value:"20", validate: function(v){ timer: {value:"20", validate: function(v){
return timerParameterValidator(this,v) ; return timerParameterValidator(this,v) ;
} }
}, },
inputs: {value:0} inputs: {value:0}
}, },
@ -84,20 +85,23 @@ var timerParameterValidator = function(node,v){
oneditprepare: function () { oneditprepare: function () {
let node = this; let node = this;
let $timer = $("#div-node-input-timer"); let $timer = $("#div-node-input-timer");
let $tip = $("#node-ping-tip");
$("#node-input-mode").val(node.mode); $("#node-input-mode").val(node.mode);
let $mode = $( "#node-input-mode" ); let $mode = $( "#node-input-mode" );
function updateControlsVisibility(){ function updateControlsVisibility(){
node.mode = $mode.val(); node.mode = $mode.val();
switch (node.mode) { switch (node.mode) {
case "triggered": case "triggered":
node.inputs = 1; node.inputs = 1;
node._def.inputs = 1 node._def.inputs = 1
$timer.hide(); $timer.hide();
$tip.show();
break; break;
default: default:
node.inputs = 0; node.inputs = 0;
node._def.inputs = 0; node._def.inputs = 0;
$timer.show(); $timer.show();
$tip.hide();
break; break;
} }
} }

View File

@ -3,11 +3,13 @@
<h3>Output</h3> <h3>Output</h3>
<dl class="message-properties"> <dl class="message-properties">
<dt>payload <span class="property-type">number</span></dt> <dt>payload <span class="property-type">number</span></dt>
<dd> the trip time in mS.</dd> <dd> the trip time in mS, or boolean <i>false</i> if no response.</dd>
<dt>topic <span class="property-type">string</span></dt> <dt>topic <span class="property-type">string</span></dt>
<dd> the target host/ip</dd> <dd> the target host or ip address.</dd>
<dt>ping <span class="property-type">object</span></dt> <dt>[ping] <span class="property-type">object</span></dt>
<dd> an object containing <code>host</code> and any other properties sent in the array object. <br>NOTE: This object is only appended when using triggered mode and an array for input payload. It is intended for adavanced users and permits scenarios where you need additional properties to be tagged into your result for use downstream.</dd> <dd> an object containing <code>host</code> and any other properties sent in the array object.<br>
<b>Note</b>: This object is only appended when using triggered mode and an array for input payload. It is
intended for advanced users and permits scenarios where you need additional properties to be tagged into your result for use downstream.</dd>
</dl> </dl>
<h3>Details</h3> <h3>Details</h3>
<p>Returns <b>false</b> if no response received, or if the host is unresolveable.</p> <p>Returns <b>false</b> if no response received, or if the host is unresolveable.</p>
@ -16,27 +18,31 @@
<h4>Mode...</h4> <h4>Mode...</h4>
<ul> <ul>
<li><b>Timed</b><br> <li><b>Timed</b><br>
<P>In <code>Timed</code> mode, the fields <code>Target</code> and <code>Ping (S)</code> must be populated.</P> <P>In Timed mode, the fields <code>Target</code> and <code>Ping (S)</code> must be populated.</P>
<p><code>Target</code> must be a CSV list of hosts / IPs e.g. <code>"192.168.0.1"</code> or <code>"192.168.0.1, www.google.com"</code></p> <p>Target must be a CSV list of hosts / IPs e.g. <code>"192.168.0.1"</code> or <code>"192.168.0.1, www.google.com"</code></p>
<p><code>Ping (S)</code> is the number of seconds between pings</p> <p>Ping (S) is the number of seconds between pings</p>
</li> </li>
<li><b>Triggered</b><br> <li><b>Triggered</b><br>
<p>In <code>Triggered</code> mode, you must connect an input wire and pass a <code>msg</code> in to trigger the ping operation.</p> <p>In Triggered mode, you must connect an input wire and pass a <code>msg</code> in to trigger the ping operation.</p>
<p>If <code>Target</code> is populated, this will be used as the host/ip. The Target must be is a CSV list of hosts / IPs e.g. <code>"192.168.0.1"</code> or <code>"192.168.0.1, www.google.com"</code></p> <p>If <code>Target</code> is populated, this will be used as the host/ip. The Target must be is a CSV list of
hosts / IPs e.g. <code>"192.168.0.1"</code> or <code>"192.168.0.1, www.google.com"</code></p>
<p>If <code>Target</code> is left empty, you can pass a CSV string or an array of hosts in `msg.payload`
<p>If Target is left empty, you can pass a CSV string or an array of hosts in <code>msg.payload</code>.
<ul> <ul>
<li><code>string</code> - a CSV list of hosts / IPs e.g. <code>"192.168.0.1"</code> or <code>"192.168.0.1, www.google.com"</code> </li> <li><b>string</b> - a CSV list of hosts / IPs e.g. <code>"192.168.0.1"</code> or <code>"192.168.0.1, www.google.com"</code> </li>
<li><code>array</code> - an array of hosts as string or object. NOTE: The object must contain at minimum <code>.host</code>. Optionally, you can add a <code>timeout</code> property between 1000 & 30000 (default is 5000 / 5 seconds). Additionally, you can add whatever other properties you wish to this object and when the ping result is returned, it will be passed to the next node in <code>msg.ping</code> for use downstream</li> <li><b>array</b> - an array of hosts as strings or objects. <b>Note</b>: The object must contain at minimum <code>.host</code>.
Optionally, you can add a <code>timeout</code> property between 1000 & 30000 (default is 5000 / 5 seconds).
Additionally, you can add whatever other properties you wish to this object and when the ping result is returned, it will
be passed to the next node in <code>msg.ping</code> for use downstream</li>
<li>Example array payload input: <pre>[ <li>Example array payload input: <pre>[
"192.168.0.99", "192.168.0.99",
{ {
"host":"192.168.0.1", "host":"192.168.0.1",
"name":"The router" "name":"The router"
}, },
{ {
"host":"myapiserver.com", "host":"myapiserver.com",
"name":"external API", "name":"external API",
"timeout": 20000, "timeout": 20000,
"support":"support@myapiserver.com" "support":"support@myapiserver.com"
} }
@ -45,9 +51,6 @@
</p> </p>
</li> </li>
</ul> </ul>
<p><b>Note</b>: if running inside Ubuntu Snap you will need to manually start the network-observe interface.
<code>snap connect node-red:network-observe</code>.</p>
<p>Note: if running inside Ubuntu Snap you will need to manually start the network-observe interface.
`snap connect node-red:network-observe`</p>
</script> </script>

View File

@ -8,7 +8,8 @@
"mode_option": { "mode_option": {
"timed": "Timed", "timed": "Timed",
"triggered": "Triggered" "triggered": "Triggered"
} },
"tip": "Note: Leave Target field blank to allow msg.payload to set hosts dynamically."
} }
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name" : "node-red-node-ping", "name" : "node-red-node-ping",
"version" : "0.1.0", "version" : "0.2.0",
"description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.", "description" : "A Node-RED node to ping a remote server, for use as a keep-alive check.",
"dependencies" : { "dependencies" : {
}, },
@ -19,5 +19,8 @@
"name": "Dave Conway-Jones", "name": "Dave Conway-Jones",
"email": "ceejay@vnet.ibm.com", "email": "ceejay@vnet.ibm.com",
"url": "http://nodered.org" "url": "http://nodered.org"
} },
"contributors": [
{ "name": "@Steve-Mcl" }
]
} }