WebThingsIO / gateway-addon-python

Python bindings for developing add-ons for WebThings Gateway
Mozilla Public License 2.0
16 stars 10 forks source link

What are the JS options when creating an interface extending UI? #72

Closed flatsiedatsie closed 4 years ago

flatsiedatsie commented 4 years ago

The javascript currently has the show() function. Are there others? Specifically, is there an 'official' way to unload the add-on when the user navigates away? A hide() function as it were?

If there a location in the gateway code where all the option can be explored?

mrstegeman commented 4 years ago

I initially had hide(), but it seemed unnecessary. The entire panel just gets a hidden class added, so your extension can go on updating things in the background without affecting the rest of the UI.

The code for the Extension class lives here: https://github.com/mozilla-iot/gateway/blob/master/static/js/extension.js

flatsiedatsie commented 4 years ago

Ii would actually love the hide() function! Right now my code checks the visibility of the section every 100 milliseconds. It ain't pretty :-)

I vote for bringing it back!

I'm not worried about the effects on the gateway interface. There are other reasons I want to unload it. It means the add-on can stop scanning the USB ports, which means there's less chance someone else on the same Gateway (another workshop participant that wants to upload code to an Arduino) will be denied access to those USB ports.

Basically, it would allow to stop heavy serverside processes then the user isn't engaged with the add-on anyway.

mrstegeman commented 4 years ago

Why not just put a timeout on your scan and add a button to re-scan?

flatsiedatsie commented 4 years ago

It's not a situation like you describe.

Basically, it continously scans while the UI is visible in order to provide a seamless experience. It's pretty nice actually.

flatsiedatsie commented 4 years ago

More generally, I can imagine all kinds of serverside processes that can be spooled down if the user it no longer actually looking at the UI. E.g. machine learning on security camera footage (only show smart overlays while the user is looking at the feed), and so forth. Only downloading a stream from the internet while the user it watching the add-on, etc.

mrstegeman commented 4 years ago

https://github.com/mozilla-iot/gateway/pull/2275

flatsiedatsie commented 4 years ago

So awesome.