The main goal of this PR is to fix issue #12, which it accomplishes by making the webserver report its current state (busy, command, etc) through a simple JSON API, so the browser is no longer responsible for determining when the printer is working. This also allowed me to do some refactoring and simplification where it made sense in the context of my changes. In particular I've:
Removed the delay(500) from state changes (on the esp32) since the web-ui no longer requires it to show a consistent state.
Consolidated the javascript logic that disables/enables input controls based on the "busy" state into a single method (to avoid duplication)
Moved the UI properties for #progress-bar and #size-helper from javascript into CSS (they get changed based on data attribute selectors)
Changed as much http request-based javascript as possible to use promises (ie the async/await/fetch syntax).
Changed the javascript status polls to only make a new request after the previous one finishes, which prevents requests from queuing up and hammering the webserver during transient disconnections.
Simplified the web server init code, which required updating the AsyncWebServer dependency.
Added some TODO's for areas where I intend to add funtionality later
To the best of my ability this makes no change to the appearance or effective styling of the web interface. One benefit of this PR is that if the page is refreshed while printing its printing status will still be reflected after the refresh, ie preventing you from submitting a label until the previous one finishes. In such a case it won't show the proper label text, but I intend to address that in follow-up PR's as it requires more substantial refactoring to be done cleanly.
The main goal of this PR is to fix issue #12, which it accomplishes by making the webserver report its current state (busy, command, etc) through a simple JSON API, so the browser is no longer responsible for determining when the printer is working. This also allowed me to do some refactoring and simplification where it made sense in the context of my changes. In particular I've:
delay(500)
from state changes (on the esp32) since the web-ui no longer requires it to show a consistent state.To the best of my ability this makes no change to the appearance or effective styling of the web interface. One benefit of this PR is that if the page is refreshed while printing its printing status will still be reflected after the refresh, ie preventing you from submitting a label until the previous one finishes. In such a case it won't show the proper label text, but I intend to address that in follow-up PR's as it requires more substantial refactoring to be done cleanly.