nightscout / Trio

MIT License
46 stars 130 forks source link

Add toggle to allow downloads from Nightscout (And improve NS Config UI) #221

Closed dsnallfot closed 1 month ago

dsnallfot commented 1 month ago

Linked to issue #198

Adds a Download toggle (Default setting false) that needs to be flipped on to allow any Nightscout download of Treatments (Carbs, Temp Targets) and Announcements (Remote commands for pump, basal, overrides and bolus).

When the toggle is disabled the functions fetchCarbs, fetchTempTargets and fetchAnnouncements is blocked from running (the same way that the toggle for Upload blocks upload and deletion of Treatments, preferences and settings.

Header renamed from "Allow Uploads" to "Allow up- and downloads"

IMG_3761

This PR do not change the current Allow remote control of Trio toggles since there could be room for discussion if disabling bolus commands maybe should have its own toggle (ie that you want to block Remote bolus announcements but still want to allow fetching carbs and temp targets).

dsnallfot commented 1 month ago

@Sjoerd-Bo3 @aug0211 @MikePlante1 I cannot add reviewers for the PR, so I just tag you here.

This is just a PR for the download treatments toggle. No refactoring of the "allow remote bolus" toggles that was also discussed in discord. That could be of course be added, but I realized that its probably good to discuss if we want to keep the possibility to allow carbs and temp targets downloads, but block remote commands for bolusing for instance. Then we need to keep the allow remote control-toggle (but maybe rename it somehow)

aug0211 commented 1 month ago

@dsnallfot what happens if we enable downloads but disable the other remote treatments toggle? I haven’t fully grokked how these work together yet.

dsnallfot commented 1 month ago

@aug0211 if the download toggle is off, no treatments or announcements gets fetched.

If the download toggle is on, treatments get fetched. But announcements get fetched only if the remote control toggle also is on.

To make this better we could disable and hide the "remote control" toggle when download is off? What do you think?

dsnallfot commented 1 month ago

Converted to draft until decided if I should also hide the remote control toggle/section when download is off.

dsnallfot commented 1 month ago

Demo after latest commit 6e187c1

https://github.com/nightscout/Trio/assets/72826201/c9f506a6-2b36-414d-90f6-432379e437ea

dsnallfot commented 1 month ago

Looks good to me overall. Great work. Maybe add the new isDownloadEnabled settings to the defaults file as well? Small comment regarding multiline text.

Ok. I thought I had added it everywhere? (Used the existing isUploadEnabled as guidance. Can you please point me to where I find the defaults file?

dnzxy commented 1 month ago

I meant this file https://github.com/dsnallfot/Trio/blob/dev-test-stuff/FreeAPS/Resources/json/defaults/freeaps/freeaps_settings.json but just realized I missed that you had added it already. Please disregard that comment 😅