mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
js: When page load fails during install, show it to user
- Currently when HTMX tries to fetch a page and fails, it silently fails and does not perform any further operations. So, the installation page is stuck. This is also leading to functional test case failures. - Handle errors in page response and errors while making requests and reload the entire page. This will result in browser showing appropriate error page. User will understand that the operation has failed. - Also add HTMX event listeners on the body as shown in HTMX documentation. Tests: - Press install. After installation process has started, stop Apache web server. Without the patch, HTMX fails silently and the installation progress is shown indefinitely. - With the patch applied, the connection error page is properly shown. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
68ccb46ecf
commit
5e112bd8bf
@ -292,13 +292,28 @@ document.addEventListener('click', function (event) {
|
||||
* element is not found in the response. However, in htmx:afterSwap event we can
|
||||
* see that the target has no children and choose to refresh the whole page.
|
||||
*/
|
||||
document.addEventListener('htmx:afterSwap', function (event) {
|
||||
document.body.addEventListener('htmx:afterSwap', function (event) {
|
||||
const target = event.detail.target;
|
||||
if (target && target.children.length === 0) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* If an error occurs during a HTMX request, then reload the page. It won't be a
|
||||
* silent failure for the user and will imitate the behavior that was present
|
||||
* before HTMX was introduced. For functional tests, this means that a clear
|
||||
* browser is shown. Tests can decide to reload the page until the error is
|
||||
* resolved.
|
||||
*/
|
||||
document.body.addEventListener('htmx:responseError', function (event) {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
document.body.addEventListener("htmx:sendError", function(event) {
|
||||
window.location.reload();
|
||||
});
|
||||
|
||||
/*
|
||||
* Decrement notification counter badge when a notification is dismissed via
|
||||
* HTMX.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user