-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
introduce React Hooks for handling state in WebUI #124
Comments
First implementation is a hook for loading and saving settings data instead of extending RestControllerProps and using the HOC. The hook loads the data on mount and exposes the data, error message (if applicable) and save/load functions and a saving flag (boolean). This saving flag can be used so the form inputs may be disabled instead of the loading indicator which we currently use which causes the annoying "Loading..." flicker on form submits. Doing this work in the |
at the same time I'm upgrading to MUI5 (material-ui) |
and while I'm at it, I'll use JSON msgpack as default to compress the payloads. |
Most of the work is done, a lot in the backend and a very cosmetic changes. This will be the basis for v3.4. The UI looks a little different now. It's in https://github.com/emsesp/EMS-ESP32/tree/ft_reacthooks if anyone wants to test drive it (@bbqkees, @MichaelDvP) |
Look great I'll try it out this week. |
First test results:
|
Thanks Michael. This is great feedback. I've been working on the UI since that last push to the branch so a few things have improved. I'll check in tomorrow when I'm back from travelling
This was fixed. The dynamic font loading didn't work and increased the size of the package so it's back to hardcoding the fonts in the app and including them in the public folder.
React-Router 6 is a beast. It changes the logic so a lot needed to be adjusted. It's done though and in my latest build. You'll see now that the code is even easier to read which is nice.
To be honest I hadn't checked the access when using a non-admin user. I checked just now and yes the MQTT form would break so I'll fix that. Thanks for pointing it out.
Settings should be 'greyed' out - it should be fixed in the latest
Not sure, can't remember! I will ill look into it and get back to you. I'm all for optimizing for performance where possible.
Pretty sure that has been fixed too in my latest. If not let me know.
This has been on my list for a while (#178) and I have a working prototype. I'll see if I can merge it later this week.
Yes that was one of the many fixes I made in the last weeks.
This has also been top of mind for a while. The proper way to do this is using WebSockets and keeping a connection over, and have EMS-ESP push out the changes. It's not hard to implement for a simple form but my design is quite complex as there are two feeds. This is worthy of a separate GH issue to spend some time designing the right solution. Personally, I don't like the interval() and forced refresh() - this is how I implemented it back in version 1.9., So, a lot of changes in this branch, also in the core C++ code so watch out if you plan to merge with your dev branch. This branch has a new customization service so I refactored some of your Dallas code into that |
it's all in https://github.com/proddy/EMS-ESP32/tree/ft_reacthooks if you want to take a first look. When I've finished changing the HA MQTT for Dallas I'll create a PR for the official ft_reacthooks and then probably merge it with dev to get feedback from other power users. |
I've merged the latest build. Please @MichaelDvP and @bbqkees take a look at let me know what you think. A lot of changes and of course not fully tested yet. @MichaelDvP this build should address all your points above, except for the auto-refresh of the deviceData. Also your comment on |
Tested a bit more.. Some remarks: Dallas refactor:
others:
|
thanks for testing. I've done some more work since which I'll upload tonight if i can
Fixed a while back, need to re-test
I didn't see the point since the web is used to configure and telnet only for debugging and critical system commands like initializing a board or connecting to the wifi. Looks like you could do with a new feature to load customization settings
but that's like renaming a file that doesn't exist? I don't see the use case yet...
good point, not critical but worth purging the list at some point, or resetting the customization or loading a previous file
haven't seen that. How can I simulate it?
can you comment in #211
also comment in #211 please
good point! I'll change
Fixed a while back, need to re-test |
unplug a sensor and wait 30 sec, the sensorvalue goes to NOT_SET. My solution is in WebDataService.ccp:
and in DashboardData.tsx, formatValue:
|
got it, made the change. called it offline. uploading now... |
@MichaelDvP I wasn't sure what you first meant by
So I had a look at your fork. You're correct and I've adapted your change to |
The fahrenheit implementation is a mess, as i started is seems easy, but it's getting more and more.. (like checks for relative/absolut values, etc).
You're wellcome, that's why it is online. The publish single is optimal for ioBroker, i don't want to miss it. For HA i think it's better to use the json, scheduled publish. I think it works, but never tested with HA. (Without HA schedule time zero disables json publish if publish on change is done by single). |
I started to find a nicer way to render the Fahrenheit temperatures and gave up, went back to your way by adding the Fahrenheit parameter to the Helper render functions. If it works, its fine for now. We can always refactor later. |
also @MichaelDvP shall I add the analog to the new customization service like it is with the Sensors (you can change the name) or not? Or do you want to do it later? |
I've added it, not tested yet, but merged your code. I always assumed setting MQTT formatting "as individual topics' did the same thing? |
yes there it belongs now. I've added this a few days ago before you've made the custum. |
ok i'll add it to the customization, just to rename the name and we can add the expansion to the ports later. I saw that adc-scale fix aswell. It was included in the last tasmota release a few weeks ago. |
I'll create a new class called analog.cpp like I did with dallas |
it's part of the v3.4 branch. I'll remove ft_reacthooks at some point. |
One thing I wanted to try out is replacing the class-based functions (HOCs) that handle local component states with React Hooks. Essentially using functional components to handle the setting of, listening to and updating state. It would make the code slightly easier to read, reduce the boilerplate size (e.g. the onComponent* calls can be replaced with useEffect()) and the state won't be passed around the map.
The text was updated successfully, but these errors were encountered: