Add a preference to temporarily disable Nightscout readings, for example if connectivity goes down
This commit is contained in:
parent
3f4b473c25
commit
de85d1867f
@ -36,6 +36,7 @@ export default class NightscoutExtension extends Extension {
|
||||
this._httpSession = new Soup.Session();
|
||||
this._indicator = new PanelMenu.Button(0.0, this.metadata.name, false);
|
||||
this._systemSource = MessageTray.getSystemSource();
|
||||
this._active = this._settings.get_boolean('update-data');
|
||||
|
||||
this._label = new St.Label({
|
||||
text: "Loading...",
|
||||
@ -44,8 +45,8 @@ export default class NightscoutExtension extends Extension {
|
||||
});
|
||||
this._indicator.add_child(this._label);
|
||||
|
||||
//this._indicator.menu.addAction(_('Preferences'),
|
||||
// () => this.openPreferences());
|
||||
this._indicator.menu.addAction(_('Preferences'),
|
||||
() => this.openPreferences());
|
||||
|
||||
Main.panel.addToStatusArea(this.uuid, this._indicator);
|
||||
|
||||
@ -61,6 +62,9 @@ export default class NightscoutExtension extends Extension {
|
||||
return GLib.SOURCE_CONTINUE;
|
||||
});
|
||||
|
||||
this._settings.connect('changed::update-data', (settings, key) => {
|
||||
this._active = settings.get_boolean(key);
|
||||
});
|
||||
this._settings.connect('changed::url', () => {
|
||||
this._update();
|
||||
});
|
||||
@ -85,6 +89,11 @@ export default class NightscoutExtension extends Extension {
|
||||
};
|
||||
|
||||
_update() {
|
||||
if (!this._active) {
|
||||
this._label.set_text("Disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
//console.log("nightscout-follower: updating...")
|
||||
// Watch for changes to a specific setting
|
||||
this._fetch((status, data) => {
|
||||
|
@ -19,6 +19,16 @@ export default class NightscoutPreferences extends ExtensionPreferences {
|
||||
page.add(group);
|
||||
|
||||
|
||||
const update_row = new Adw.SwitchRow({
|
||||
title: _('Connect to Nightscout'),
|
||||
subtitle: _('Update current data from Nightscout'),
|
||||
});
|
||||
group.add(update_row);
|
||||
|
||||
window._settings.bind('update-data', update_row, 'active',
|
||||
Gio.SettingsBindFlags.DEFAULT);
|
||||
|
||||
|
||||
const url_row = new Adw.EntryRow({
|
||||
title: _('Nightscout URL'),
|
||||
});
|
||||
@ -26,8 +36,6 @@ export default class NightscoutPreferences extends ExtensionPreferences {
|
||||
url_row.set_show_apply_button(true);
|
||||
group.add(url_row);
|
||||
|
||||
//window._settings.bind('url', url_row, 'text',
|
||||
// Gio.SettingsBindFlags.DEFAULT);
|
||||
url_row.set_text(window._settings.get_string('url'));
|
||||
url_row.connect('apply', () => {
|
||||
window._settings.set_string('url', url_row.text);
|
||||
|
@ -1,6 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist>
|
||||
<schema id="org.gnome.shell.extensions.nightscout-follower" path="/org/gnome/shell/extensions/nightscout-follower/">
|
||||
<key name="update-data" type="b">
|
||||
<default>false</default>
|
||||
<summary>Connect to Nightscout</summary>
|
||||
<description>Update current data</description>
|
||||
</key>
|
||||
<key name="url" type="s">
|
||||
<default>"https://API_SECRET@sitename.yourprovider.com"</default>
|
||||
<summary>Nightscout URL</summary>
|
||||
|
Loading…
Reference in New Issue
Block a user