Commit 97159c44 authored by Dimitris Moraitis's avatar Dimitris Moraitis
Browse files

display error if backend does not respond to actions - Refs #213

parent 81426833
......@@ -17,10 +17,14 @@ function ISODateString(d){
function parse_error(responseText){
var errors = [];
responseObj = JSON.parse(responseText);
//console.info(inp);
for (var err in responseObj){
errors[errors.length] = responseObj[err];
if (responseText.length == 0){
errors[0] = {'code': 503};
} else {
responseObj = JSON.parse(responseText);
//console.info(inp);
for (var err in responseObj){
errors[errors.length] = responseObj[err];
}
}
return errors;
}
......
......@@ -68,17 +68,24 @@
var serverName = '';
if (serverID != undefined) {
serverName = $("#"+serverID).parent().parent().find("span.name").text();
// standard view
serverName = $("#"+serverID).find("span.name").text();
if (serverName == "") { // list view
serverName = $("#"+serverID).parent().parent().find("span.name").text();
}
}
// prepare the error message
$("#error-success h3").text(ERRORS['HEADER']);
if (responseText != undefined){
var errors = parse_error(responseText);
var errors = parse_error(responseText), details = '';
if (serverName){
serverName="<p><strong>Server:</strong> " + serverName + "</p>";
}
$("#error-success div").html("<p>"+(errors[0].message || ERRORS[errors[0].code]) +"</p>"+serverName +"<p><strong>Action:</strong> " + action + "</p><p><strong>Code</strong>: " + errors[0].code + "</p><p><strong>Details:</strong> " + errors[0].details +"</p>");
if (errors[0].details != undefined) {
details = "<p><strong>Details:</strong> " + errors[0].details +"</p>";
}
$("#error-success div").html("<p>"+(errors[0].message || ERRORS[errors[0].code]) +"</p>"+serverName +"<p><strong>Action:</strong> " + action + "</p><p><strong>Code</strong>: " + errors[0].code + "</p>" + details);
} else if (ERRORS[status] != undefined) {
if (serverID == undefined){
$("#error-success p").text(ERRORS[status]);
......
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