1
0
mirror of https://github.com/node-red/node-red-nodes.git synced 2023-10-10 13:36:58 +02:00

Add url field to Prowl node

Npm pub v 0.0.5 to Close #169
This commit is contained in:
Dave Conway-Jones 2016-01-24 18:30:45 +00:00
parent cf66edd35c
commit 6a9cb79670
4 changed files with 12 additions and 6 deletions

View File

@ -22,6 +22,10 @@
<div class="form-row">
<label for="node-input-priority"><i class="fa fa-star"></i> Priority</label>
<input type="text" id="node-input-priority" placeholder="0">
</div>
<div class="form-row">
<label for="node-input-url"><i class="fa fa-globe"></i> URL</label>
<input type="text" id="node-input-url" placeholder="optional web page url">
</div>
<div class="form-row">
<label for="node-input-pushkey"><i class="fa fa-key"></i> API Key</label>
@ -37,9 +41,7 @@
<script type="text/x-red" data-help-name="prowl">
<p>Uses Prowl to push the <b>msg.payload</b> to an Apple device that has the prowl app installed.</p>
<p>Optionally uses <b>msg.topic</b> to set the title. You can also set <b>msg.priority</b> to confgure the urgency from -2 (low), through 0 (normal) to 2 (urgent).</p>
<p>The API Key is stored in a separate credentials file.</p>
<p>The old method of storing your Prowl API key in the pushkey.js file in the directory <b>above</b> node-red has been deprecated.</p>
<!-- <p><pre>module.exports = { prowlkey:'My-API-KEY' }</pre></p> -->
<p>You may use <b>msg.url</b> to set a url to redirect the user to on receipt of the message.</p>
<p>Uses Prowl. See <i><a href="https://www.prowlapp.com" target="_new">this link</a></i> for more details.</p>
</script>
@ -49,6 +51,7 @@
defaults: {
title: {value:""},
priority: {value:0,required:true,validate:RED.validators.number()},
url: {value:""},
name: {value:""}
},
credentials: {

View File

@ -42,13 +42,16 @@ module.exports = function(RED) {
this.on("input",function(msg) {
var titl = this.title||msg.topic||"Node-RED";
var pri = msg.priority||this.priority;
var url = this.url||msg.url;
var options = { priority:pri };
if (url) { options.url = url };
if (typeof(msg.payload) === 'object') {
msg.payload = JSON.stringify(msg.payload);
}
else { msg.payload = msg.payload.toString(); }
if (node.pushkey) {
try {
node.prowl.push(msg.payload, titl, { priority: pri }, function(err, remaining) {
node.prowl.push(msg.payload, titl, options, function(err, remaining) {
if (err) { node.error(err); }
node.log( remaining + ' calls to Prowl api during current hour.' );
});

View File

@ -18,6 +18,6 @@ Uses Prowl to push the **msg.payload** to an Apple device that has the prowl app
Optionally uses **msg.topic** to set the title. You can also set **msg.priority** to confgure the urgency from -2 (low), through 0 (normal) to 2 (urgent).
The API Key is stored in a separate credentials file.
You may use **msg.url** to set a url to redirect the user to on receipt of the message if you don't set one in the edit dialogue.
Uses Prowl. See <a href="https://www.prowlapp.com" target="_new">this link</a> for more details.

View File

@ -1,6 +1,6 @@
{
"name" : "node-red-node-prowl",
"version" : "0.0.4",
"version" : "0.0.5",
"description" : "A Node-RED node to send alerts via Prowl",
"dependencies" : {
"node-prowl" : "0.1.7"