Save the Device ID (ident) in credentials

This commit is contained in:
Antoine Aflalo
2014-04-20 15:04:10 +03:00
parent 022ec67ea7
commit 3e854d63d7
2 changed files with 26 additions and 13 deletions

View File

@@ -38,6 +38,7 @@
</script>
<script type="text/x-red" data-help-name="pushbullet">
@@ -49,6 +50,7 @@
</script>
@@ -70,6 +72,7 @@
</script>
<script type="text/javascript">
@@ -82,15 +85,18 @@
RED.nodes.registerType('bullet-device', {
category: 'config',
defaults: {
name: {value: "", required: true},
name: {value: "", required: true}
//apikey: -> credentials
deviceid: {value: "", required: true}
//deviceid -> 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.hasApiKey) {
$('#node-config-input-apikey').val('__PWRD__');
} else {
@@ -101,17 +107,19 @@
},
oneditsave: function () {
var newApiKey = $('#node-config-input-apikey').val();
var credentials = {};
if (newApiKey != '__PWRD__') {
var credentials = {};
credentials.apikey = newApiKey;
$.ajax({
url: 'pushbullet-api/' + this.id,
type: 'POST',
data: credentials,
success: function (result) {
}
});
}
credentials.deviceid = $('#node-config-input-deviceid').val();
$.ajax({
url: 'pushbullet-api/' + this.id,
type: 'POST',
data: credentials,
success: function (result) {
}
});
},
ondelete: function () {
$.ajax({