Skip to content

Commit

Permalink
Review the UX when a JavaScript error occurred
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustry committed Sep 26, 2024
1 parent 82450c3 commit e3ecaa7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
27 changes: 19 additions & 8 deletions assets/src/legacy/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3914,16 +3914,27 @@ window.lizMap = function() {
})
.catch((error) => {
console.error(error);
// Generic error message
let errorMsg = `
<p class="error-msg">${lizDict['startup.error']}
<br><a href="${globalThis['lizUrls'].basepath}">${lizDict['startup.goToProject']}</a>`;
if (document.body.dataset.lizmapUserDefinedJsCount > 0 && document.body.dataset.lizmapAdminUser == 1) {
errorMsg += '<br>'+`${lizDict['startup.user_defined_js']}<br>
${lizDict['startup.error.administrator']}<br>
${lizDict['startup.error.developer.tools']}<br>
<a href="${globalThis['lizUrls'].repositoryAdmin}">${lizDict['startup.goToRepositoryAdmin']}</a><br>
<a href="`+ window.location+`&no_user_defined_js=1">${lizDict['startup.projectWithoutJSLink']}</a>`
<p class="error-msg">
${lizDict['startup.error']}<br>
`;
if (document.body.dataset.lizmapAdminUser == 1) {
// The user is an administrator, we add more infos and buttons.
errorMsg += `${lizDict['startup.error.developer.tools']}<br>`;
if (document.body.dataset.lizmapUserDefinedJsCount > 0) {
errorMsg += `${lizDict['startup.user_defined_js']}<br>
<a href="${globalThis['lizUrls'].repositoryAdmin}"><button class="btn btn-primary" type="button">${lizDict['startup.goToRepositoryAdmin']}</button></a>
<a href="`+ window.location+`&no_user_defined_js=1"><button class="btn btn-primary" type="button">${lizDict['startup.projectWithoutJSLink']}</button></a>
`;
}
// If the flag no_user_defined_js=1, we could give more info ?
} else {
// The user is not an administrator, we invite the admin, and button to get back home
errorMsg += `${lizDict['startup.error.administrator']}<br>
<a href="${globalThis['lizUrls'].basepath}"><button class="btn btn-primary" type="button">${lizDict['startup.goToProject']}</button></a>`;
}
errorMsg += `</p>`;
document.getElementById('header').insertAdjacentHTML('afterend', errorMsg);
})
Expand Down
10 changes: 5 additions & 5 deletions lizmap/modules/view/locales/en_US/dictionnary.UTF-8.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
startup.error=An error occurred while loading this map. Some necessary resources may temporarily be unavailable. Please try again later.
startup.error.administrator=Please notify the administrator of this map to <strong>connect</strong> and <strong>visit</strong> this map.
startup.error.developer.tools=Sorry for the inconvenience, maybe you will have a clue by opening your "Developer tools" in your web-browser. It's usually F12. Check "Console" and "Networks".
startup.user_defined_js=There's some user defined JavaScript scripts, that can be the cause of this message, try disabling them.
startup.goToProject=Go back to the home page.
startup.goToRepositoryAdmin=Go to maps management page
startup.projectWithoutJSLink=Project with user's scripts disabled
startup.error.developer.tools=Maybe you will have a clue by opening your "Developer tools" in your web-browser. It's usually <kbd>F12</kbd>. Check "Console" and "Networks".
startup.user_defined_js=This map contains some users additional JavaScript scripts. This can be the cause of this message, try disabling them.
startup.goToProject=Home
startup.goToRepositoryAdmin=Maps management page
startup.projectWithoutJSLink=Project without additional JavaScript
project.has.warnings=The project has some warnings in the QGIS desktop Lizmap plugin which must be fixed.
project.plugin.outdated.warning=The project has been recently updated in QGIS Desktop, but with an outdated version of the Lizmap plugin. You must upgrade your plugin in QGIS Desktop.
Expand Down

0 comments on commit e3ecaa7

Please sign in to comment.