Skip to content
Snippets Groups Projects
Commit c1bb5fd9 authored by Sascha Herzinger's avatar Sascha Herzinger Committed by Piotr Gawron
Browse files

Wired report dialog together with API call (untested)

parent a13bd122
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!589Feature error reporting
......@@ -293,10 +293,6 @@ GuiConnector.prototype.alert = function (error, redirectIfSecurityError) {
} else {
var self = returnThisOrSingleton(this);
logger.error(error);
if (self._errorDialog === undefined) {
var errorData = self.getErrorMessageForError(error);
var message = errorData.message;
......@@ -312,18 +308,21 @@ GuiConnector.prototype.alert = function (error, redirectIfSecurityError) {
self._errorDialogData = document.createElement('div');
self._errorDialog.appendChild(self._errorDialogData);
Object.keys(data).forEach(function (key, i) {
Object.keys(data).forEach(function (key) {
self._errorDialogData.innerHTML += '<label>' +
data[key].value +
'<input class="report-check" type="checkbox"/>' +
'<input class="report-check" type="checkbox" data-key="' + key + '" data-value="' + data[key].value + '"/>' +
'<span class="ui-icon ui-icon-info" style="float: right;" title="' + data[key].tooltip + '"></span>' +
'</label>';
});
self._errorDialogData.innerHTML += '<div id="report-stacktrace">' +
'<h3>Stacktrace</h3>' +
'<div><p>' + stacktrace.value + '</p></div>' +
'</div>';
if (typeof stacktrace.value !== 'undefined') {
self._errorDialogData.innerHTML += '<div id="report-stacktrace">' +
'<h3>Stacktrace<span class="ui-icon ui-icon-info" style="float: right;" title="' + stacktrace.tooltip + '"></span></h3>' +
'<div><p>' + stacktrace.value + '</p></div>' +
'</div>';
$('#report-stacktrace')
.accordion({active: false, collapsible: true});
}
$('.report-check')
.checkboxradio()
.prop('checked', true)
......@@ -332,8 +331,6 @@ GuiConnector.prototype.alert = function (error, redirectIfSecurityError) {
.controlgroup({direction: 'vertical'});
$(self._errorDialog)
.tooltip();
$('#report-stacktrace')
.accordion({active: false, collapsible: true});
});
document.body.appendChild(self._errorDialog);
$(self._errorDialog).dialog({
......@@ -345,6 +342,14 @@ GuiConnector.prototype.alert = function (error, redirectIfSecurityError) {
modal: true,
buttons: {
'Submit': function () {
var report = {stacktrace: stacktrace.value};
$('.report-check').each(function () {
var check = $(this);
if (check.is(':checked')) {
report[check.attr('data-key')] = check.attr('data-value');
}
});
ServerConnector.submitErrorToMinervaNet(report);
$(this).dialog('close');
},
'Cancel': function () {
......@@ -354,34 +359,34 @@ GuiConnector.prototype.alert = function (error, redirectIfSecurityError) {
}).dialog("open");
}
}
};
/**
*
* @param {Error|string} error
* @returns {string}
* @returns {Object}
*/
GuiConnector.prototype.getErrorMessageForError = function (error) {
var message = error;
if (message instanceof SecurityError) {
if (error instanceof SecurityError) {
if (ServerConnector.getSessionData().getLogin() === "anonymous") {
message = error.message + "<p>Please <a href=\"login.xhtml?from=" + encodeURI(window.location.href) + "\">login</a> to access this resource</p>";
return {
message: error.message + "<p>Please <a href=\"login.xhtml?from=" + encodeURI(window.location.href) + "\">login</a> to access this resource</p>",
stack: error.stack
};
} else {
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>";
return {
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>",
stack: error.stack
};
}
} else if (message instanceof ValidationError) {
message = error.message;
} else if (message instanceof GuiMessageError) {
message = error.message;
} else if (message instanceof Error) {
message = "Unexpected error occurred:<p>" + error.message + "</p>";
} else if (error instanceof ValidationError || error instanceof GuiMessageError || error instanceof Error) {
return {
message: error.message,
stack: error.stack
};
}
return message;
return { message: error };
};
/**
......
......@@ -738,6 +738,10 @@ ServerConnector.getFullOverlayElementUrl = function (queryParams, filterParams)
};
ServerConnector.getSubmitErrorToMinervaNetUrl = function () {
return this.getApiBaseUrl() + 'minervanet/submitError';
};
ServerConnector.idsToString = function (ids) {
var result = "";
if (ids !== undefined) {
......@@ -2679,5 +2683,10 @@ ServerConnector.getSubmapConnections = function () {
});
};
ServerConnector.submitErrorToMinervaNet = function (report) {
var self = this;
return self.sendPostRequest(self.getSubmitErrorToMinervaNetUrl(), report);
};
module.exports = ServerConnector;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment