Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions nightscout@ranneft/files/nightscout@ranneft/applet.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ NightscoutApplet.prototype = {
this.on_settings_changed,
null);

this.settings.bindProperty(Settings.BindingDirection.IN,
"token",
"token",
this.on_settings_changed,
null);

try {
// Set initial value
this.set_applet_icon_path(metadata.path + '/icons/nightscout.png')
Expand Down Expand Up @@ -198,7 +204,10 @@ NightscoutApplet.prototype = {
},

requestCurrentBg() {
return makeHttpRequest('GET', `${this.host}/api/v1/entries/current`, (resolve, response) => {
const url = this.token
? `${this.host}/api/v1/entries/current?token=${this.token}`
: `${this.host}/api/v1/entries/current`;
return makeHttpRequest('GET', url, (resolve, response) => {
let current = {};
log('Requested current state' + response);
if(response.length > 0) {
Expand All @@ -209,7 +218,10 @@ NightscoutApplet.prototype = {
},

requestDeviceStatus() {
return makeHttpRequest('GET', `${this.host}/api/v1/devicestatus?count=1`, (resolve, response) => {
const url = this.token
? `${this.host}/api/v1/devicestatus?count=1?token=${this.token}`
: `${this.host}/api/v1/devicestatus?count=1`;
return makeHttpRequest('GET', url, (resolve, response) => {
let status = {};
log('Requested device status' + response);
if(response.length > 0) {
Expand Down
Loading