Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR address a few oddities of the UI/UX mentioned in #2101 by introducing form submission with live updates. Its function is described below.
Backend
The backend has a new class
LiveFormthat contains reusable code to be able to create the stream of information to be used by the front end.There are a few functions in the
LiveFromclass that have important purposes.initAjax()- Should be run at the start of the file to set important headers and required settings for a successful stream.sendStartMessage()- Sends a message to the frontend to be handled by code that the stream is starting.sendCompleteMessage()- Sends a message to the frontend to be handled by code that the stream is complete and the page should refresh.sendFailedMessage()- Sends a message to the frontend to be handled by code that something in the submission had a critical error and did not finish what was inteneded.sendUpdateMessage()- Sends a message to the frontend with text to show the user as well as an optional update of the percentage the progress bar should show.saveStatusMessage()- Saves a status message to show when the page reloads. Ideally should only be run once at the end of each logic flow. This function has an option to show a collapsable history that shows the messages sent.When converting forms to use live form submisison certain functions may still use the old
StatusMessageclass to give updates. To get around rewriting everything a helper classLiveFormStatusMessageexists to pass to necessary functions and forward the message as a live update instead of a standard bootstrap alert on page load.In the page's builder file (often in
includes) be sure to run the static functionloadStatusMessages()to pull the saved status messages from the session and add them to the page's$statusmessages.Frontend
Note: Images shown may not reflect final look
To have a form use live form submission, add the class
.live-formto the form element. If bootstrap validation is needed it will run before the live form submission is run. Set the action to a new ajax file to process the submitted form.Live Update Modal
The modal contains a dynamic progress bar and the most update message. Below it is a collapsable scrollable history of messages sent. The modal is configured so that it cannot be hidden or dismissed.
Modal Options
data-modal-title- Can be applied to either theformor the submitting button if there are multiple buttons to submit the same form with different outcomes.Refreshed Page Alert with Details
Once the live form submission stream receives the complete message it will refresh the page. Assuming
loadStatusMessages()is called any saved status messages will be shown. If the status message was configured to show the message history it will have a collapsible details button.Implementing
This isn't something that necessarily needs to be used on all form submissions, but is useful for transparency to the user on what is happening.
Forms converted:
Issues
Frontend feedback when ajax failsBackend handling of php error to send failed messageBug Fixes
use functionstatements to give more clear error messages when global functions aren'trequire_onceDhcpcdManager.phpDnsmasqManager.phpWiFiManager.phpHostapdManager.phpHotspotService.php$thisforgetIfaceMetric()function call inDhcpcdManager.php