[Webserver:WebUI] Rework WebUI in Javascript with REST API #13
Labels
No labels
bug
documentation
duplicate
enhancement
help wanted
invalid
question
v0.1.x
v0.2.x
v0.3.x
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Depends on
#39 Shrink image size
DeltaLima/CanGrow
Reference
DeltaLima/CanGrow#13
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Current page handling is a nightmare
I would like to store the basic html page in LittleFS and do all the dynamic things with javascript. WLED and Tasmota have good examples for this
in v0.2 with ESPAsyncWebserver, i couldnt avoid the way of building pages shown above.
I already use the template function, but this is also not super great.
Maybe i should consider building the WebUI completely with javascript and get all the nice data from api endpoints (json).
This topic might be something for v0.3
Enhancement: Rework Web Page handling, get them as static as possibleto [Webserver] Rework Web Page handling, get them as static as possibleThe work on this topic has begun in #39 - some progress is made:
Building the WebUI is done for the root dashboard page and most of the grow settings (dashboard settings missing).
For this GET requests are used, to determine which page has to be shown. This causes always a static request, like
GET /?p=grow&s=lightfor the HTML and a second one for theview.jsonapi request to get the actual contentGET /view.json?p=grow&s=light.After exchanging some thoguhts I will rework this rework again with the following structure:
For the beginning, every page and subpage delivers the same html, so like
later on, this can be replaced within the javascript part, so those "routes" arent used. But for now I think, it is more straight forward for me, to go this way.
The view.json requests will be replaced in a similar way:
For editing stuff, i would introduce another subpage called
edit, same foraddAdding stuff is pretty obvious, for this the webserver routings would look like
A new sensor id here is looked up by the esp code and sent within the view json
For editing something
But this request would require to tell the webserver some ID so it can show the set values in the view json.
For this we can pass a search parameter, so the request would look like
On Javascript side we have then to grab this search parameter
id=2and put it to our view json request as well. This kinda is already done in the actual javascript rework:var params = new URLSearchParams(document.location.search);[Webserver] Rework Web Page handling, get them as static as possibleto [Webserver:WebUI] Rework WebUI in Javascript with REST API