Commit 62022a2e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when user doesn't have access to map error message is improved,

moreover when anonymous user tries to access secured map redirection is in place
parent 9cecb389
......@@ -159,33 +159,40 @@ GuiConnector.hideProcessing = function () {
$(self._processingDialog).dialog("close");
};
GuiConnector.alert = function (error) {
var self = GuiConnector;
logger.error(error);
if (self._errorDialog === undefined) {
self._errorDialog = document.createElement("div");
self._errorDialogContent = document.createElement("div");
self._errorDialog.appendChild(self._errorDialogContent);
document.body.appendChild(self._errorDialog);
$(self._errorDialog).dialog({
classes: {
"ui-dialog": "ui-state-error"
},
modal: true,
title: "ERROR"
}).siblings('.ui-dialog-titlebar').css("background", "red");
GuiConnector.alert = function (error, redirectIfSecurityError) {
if (redirectIfSecurityError === undefined) {
redirectIfSecurityError = false;
}
var message = error;
if (message instanceof SecurityError) {
message = error.message + "<p>Please <a href=\"login.xhtml?from="+encodeURI(window.location.href)+"\">login</a> to access this resource</p>";
} else if (message instanceof NetworkError && (error.message === "XHR error" || error.message === "Failed to fetch")) {
message = "File to big.<br>Please reduce file size or contact administrators.";
} else if (message instanceof Error) {
message = "Unexpected error occurred:<p>" + error.message + "</p>";
if (redirectIfSecurityError && error instanceof SecurityError && ServerConnector.getSessionData().getLogin() === "anonymous") {
window.location.href = ServerConnector.getServerBaseUrl() + "login.xhtml?from=" + encodeURI(window.location.href);
} else {
var self = GuiConnector;
logger.error(error);
if (self._errorDialog === undefined) {
self._errorDialog = document.createElement("div");
self._errorDialogContent = document.createElement("div");
self._errorDialog.appendChild(self._errorDialogContent);
document.body.appendChild(self._errorDialog);
$(self._errorDialog).dialog({
classes: {
"ui-dialog": "ui-state-error"
},
modal: true,
title: "ERROR"
}).siblings('.ui-dialog-titlebar').css("background", "red");
}
var message = error;
if (message instanceof SecurityError) {
message = error.message + "<p>Please <a href=\"login.xhtml?from=" + encodeURI(window.location.href) + "\">login</a> " +
"as a different user or ask your administrator to change the permissions to access this resource.</p>";
} else if (message instanceof NetworkError && (error.message === "XHR error" || error.message === "Failed to fetch")) {
message = "File to big.<br>Please reduce file size or contact administrators.";
} else if (message instanceof Error) {
message = "Unexpected error occurred:<p>" + error.message + "</p>";
}
self._errorDialogContent.innerHTML = message;
$(self._errorDialog).dialog("open");
}
self._errorDialogContent.innerHTML = message;
$(self._errorDialog).dialog("open");
};
module.exports = GuiConnector;
This diff is collapsed.
......@@ -39,7 +39,7 @@ function initMap(){
customMap = result;
document.title = result.getProject().getName();
}).catch(function(rejectReason){
minerva.GuiConnector.alert(rejectReason);
minerva.GuiConnector.alert(rejectReason, true);
});
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment