mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Refactor deviceId -> deviceIdent
Since the deviceId will be deprecated, better move to the deviceIdent
This commit is contained in:
parent
02d2b152e2
commit
d4debc330d
@ -64,8 +64,8 @@
|
||||
<input type="password" id="node-config-input-apikey" >
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-config-input-deviceid"><i class="icon-tasks"></i>Device Ident</label>
|
||||
<input type="text" id="node-config-input-deviceid" >
|
||||
<label for="node-config-input-deviceIdent"><i class="icon-tasks"></i>Device Ident</label>
|
||||
<input type="text" id="node-config-input-deviceIdent" >
|
||||
</div>
|
||||
<div class="form-tips">The API key can be found on the <a target="_blank" href="https://www.pushbullet.com/account">Account Settings</a></div>
|
||||
|
||||
@ -87,15 +87,15 @@
|
||||
defaults: {
|
||||
name: {value: "", required: true}
|
||||
//apikey: -> credentials
|
||||
//deviceid -> credentials
|
||||
//deviceIdent -> credentials
|
||||
},
|
||||
label: function () {
|
||||
return this.name;
|
||||
},
|
||||
oneditprepare: function () {
|
||||
$.getJSON('pushbullet-api/' + this.id, function (data) {
|
||||
if (data.deviceid) {
|
||||
$('#node-config-input-deviceid').val(data.deviceid);
|
||||
if (data.deviceIdent) {
|
||||
$('#node-config-input-deviceIdent').val(data.deviceIdent);
|
||||
}
|
||||
if (data.hasApiKey) {
|
||||
$('#node-config-input-apikey').val('__PWRD__');
|
||||
@ -111,7 +111,7 @@
|
||||
if (newApiKey != '__PWRD__') {
|
||||
credentials.apikey = newApiKey;
|
||||
}
|
||||
credentials.deviceid = $('#node-config-input-deviceid').val();
|
||||
credentials.deviceIdent = $('#node-config-input-deviceIdent').val();
|
||||
$.ajax({
|
||||
url: 'pushbullet-api/' + this.id,
|
||||
type: 'POST',
|
||||
|
@ -33,7 +33,7 @@ RED.httpAdmin.get('/pushbullet-api/global', function (req, res) {
|
||||
RED.httpAdmin.get('/pushbullet-api/:id', function (req, res) {
|
||||
var credentials = RED.nodes.getCredentials(req.params.id);
|
||||
if (credentials) {
|
||||
res.send(JSON.stringify({hasApiKey: (credentials.apikey && credentials.apikey != ""), deviceid: credentials.deviceid}));
|
||||
res.send(JSON.stringify({hasApiKey: (credentials.apikey && credentials.apikey != ""), deviceIdent: credentials.deviceIdent}));
|
||||
} else {
|
||||
res.send(JSON.stringify({}));
|
||||
}
|
||||
@ -57,10 +57,10 @@ RED.httpAdmin.post('/pushbullet-api/:id', function (req, res) {
|
||||
} else {
|
||||
credentials.apikey = newCreds.apikey || credentials.apikey;
|
||||
}
|
||||
if (newCreds.deviceid == "" || newCreds.deviceid == null) {
|
||||
delete credentials.deviceid;
|
||||
if (newCreds.deviceIdent == "" || newCreds.deviceIdent == null) {
|
||||
delete credentials.deviceIdent;
|
||||
} else {
|
||||
credentials.deviceid = newCreds.deviceid;
|
||||
credentials.deviceIdent = newCreds.deviceIdent;
|
||||
}
|
||||
RED.nodes.addCredentials(req.params.id, credentials);
|
||||
res.send(200);
|
||||
@ -73,7 +73,7 @@ function PushBulletDevice(n) {
|
||||
var credentials = RED.nodes.getCredentials(n.id);
|
||||
if (credentials) {
|
||||
this.apikey = credentials.apikey;
|
||||
this.deviceid = credentials.deviceid;
|
||||
this.deviceIdent = credentials.deviceIdent;
|
||||
}
|
||||
}
|
||||
RED.nodes.registerType("bullet-device", PushBulletDevice);
|
||||
@ -86,10 +86,10 @@ function PushbulletNode(n) {
|
||||
|
||||
if (this.api) {
|
||||
this.pusher = new PushBullet(this.api.apikey);
|
||||
this.deviceId = this.api.deviceid;
|
||||
this.deviceIdent = this.api.deviceIdent;
|
||||
} else if (pushkey) {
|
||||
this.pusher = new PushBullet(pushkey.pushbullet);
|
||||
this.deviceId = pushkey.deviceid;
|
||||
this.deviceIdent = pushkey.deviceid;
|
||||
} else {
|
||||
this.error("missing pushbullet credentials");
|
||||
return;
|
||||
@ -105,7 +105,7 @@ function PushbulletNode(n) {
|
||||
msg.payload = msg.payload.toString();
|
||||
}
|
||||
try {
|
||||
this.pusher.note(this.deviceId, titl, msg.payload, function (err, response) {
|
||||
this.pusher.note(this.deviceIdent, titl, msg.payload, function (err, response) {
|
||||
if (err) node.error("Pushbullet error: " + err);
|
||||
//console.log(response);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user