mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Add credentials capability to PushBullet node
This commit is contained in:
@@ -19,6 +19,15 @@
|
||||
<label for="node-input-title"><i class="icon-flag"></i> Title</label>
|
||||
<input type="text" id="node-input-title" placeholder="Node-RED">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-deviceid"><i class="icon-user"></i> Device ID</label>
|
||||
<input type="text" id="node-config-input-deviceid">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-pushkey"><i class="icon-lock"></i> API Key</label>
|
||||
<input type="password" id="node-config-input-pushkey">
|
||||
</div>
|
||||
<br/>
|
||||
<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">
|
||||
@@ -28,11 +37,10 @@
|
||||
<script type="text/x-red" data-help-name="pushbullet">
|
||||
<p>Uses PushBullet to push the <b>msg.payload</b> to an Android device that has PushBullet app installed.</p>
|
||||
<p>Optionally uses <b>msg.topic</b> to set the title, if not already set in the properties.</p>
|
||||
<p>You MUST configure both your <i>API key</i> and the target <i>device ID</i>. Either into settings.js like this</p>
|
||||
<p><pre>pushbullet: { pushbullet:'My-API-KEY', deviceid:'xyzzyWabc' },</pre></p>
|
||||
<p>Or as a pushkey.js file in the directory <b>above</b> node-red.<p>
|
||||
<p>You MUST configure both your <i>API key</i> and the target <i>device ID</i>. You can set these per node in the edit dialog
|
||||
or as a pushkey.js file in the directory <b>above</b> node-red.<p>
|
||||
<p><pre>module.exports = { pushbullet:'My-API-KEY', deviceid:'xyzzyWabc' }</pre></p>
|
||||
<p>The deviceid can be found by hovering over you required device on the <a href="https://www.pushbullet.com/">PushBullet website</a>.</p>
|
||||
<p>The deviceid can be found by hovering over your required device on the <a href="https://www.pushbullet.com/">PushBullet website</a>.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -52,6 +60,41 @@
|
||||
},
|
||||
labelStyle: function() {
|
||||
return this.name?"node_label_italic":"";
|
||||
},
|
||||
oneditprepare: function() {
|
||||
$.getJSON('pushbullet/'+this.id,function(data) {
|
||||
if (data.deviceid) {
|
||||
$('#node-config-input-deviceid').val(data.deviceid);
|
||||
}
|
||||
if (data.hasPassword) {
|
||||
$('#node-config-input-pushkey').val('__PWRD__');
|
||||
} else {
|
||||
$('#node-config-input-pushkey').val('');
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
oneditsave: function() {
|
||||
var newUser = $('#node-config-input-deviceid').val();
|
||||
var newPass = $('#node-config-input-pushkey').val();
|
||||
var credentials = {};
|
||||
credentials.deviceid = newUser;
|
||||
if (newPass != '__PWRD__') {
|
||||
credentials.pushkey = newPass;
|
||||
}
|
||||
$.ajax({
|
||||
url: 'pushbullet/'+this.id,
|
||||
type: 'POST',
|
||||
data: credentials,
|
||||
success:function(result){}
|
||||
});
|
||||
},
|
||||
ondelete: function() {
|
||||
$.ajax({
|
||||
url: 'pushbullet/'+this.id,
|
||||
type: 'DELETE',
|
||||
success: function(result) {}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user