Updates to Twilio Node

Fixes #28
Make edit panel work, and then fix it so the things edited do what they say.
Slight tweak to shrink icon to similar size as others.
This commit is contained in:
Dave C-J 2014-02-09 11:55:01 +00:00
parent e5af41ba2b
commit f64358262a
3 changed files with 40 additions and 39 deletions

View File

@ -15,15 +15,16 @@
limitations under the License.
-->
<script type="text/x-red" data-template-name="twilio">
<script type="text/x-red" data-template-name="twilio out">
<div class="form-row">
<label for="node-input-title"><i class="icon-flag"></i> Title</label>
<input type="text" id="node-input-title" placeholder="Node-RED">
<label for="node-input-number"><i class="icon-envelope"></i> SMS to</label>
<input type="text" id="node-input-number" placeholder="01234 5678901">
</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>
<div class="form-tips">Tip - leave Number blank to use <b>msg.topic</b> to set the number.</div>
</script>
<script type="text/x-red" data-help-name="twilio out">
@ -39,7 +40,7 @@
RED.nodes.registerType('twilio out',{
category: 'output',
defaults: {
title: {value:""},
number: {value:""},
name: {value:""}
},
color:"#ed1c24",
@ -48,7 +49,7 @@
icon: "twilio.png",
align: "right",
label: function() {
return this.name||this.title||"twilio out";
return this.name||this.title||"twilio";
},
labelStyle: function() {
return this.name?"node_label_italic":"";

View File

@ -37,7 +37,7 @@ if (twiliokey) {
function TwilioOutNode(n) {
RED.nodes.createNode(this,n);
this.title = n.title;
this.number = n.number;
var node = this;
this.on("input",function(msg) {
if (typeof(msg.payload) == 'object') {
@ -46,7 +46,8 @@ function TwilioOutNode(n) {
if (twiliokey) {
try {
// Send SMS
twilioClient.sendMessage( {to: msg.topic, from: fromNumber, body: msg.payload}, function(err, response) {
var tonum = node.number || msg.topic;
twilioClient.sendMessage( {to: tonum, from: fromNumber, body: msg.payload}, function(err, response) {
if (err) node.error(err);
//console.log(response);
});
@ -60,5 +61,4 @@ function TwilioOutNode(n) {
}
});
}
RED.nodes.registerType("twilio out",TwilioOutNode);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 717 B

After

Width:  |  Height:  |  Size: 553 B