Show error message when compose node failed

Previously when compose node failed, only the console logs that there
was an error but nothing appears in the UI. This patch show dialog to
user about reason of their compose request failed.

Change-Id: Icfe7a9eb8cfa8a68f81257410b87b82afadee382
Closes-Bug: #1632491
This commit is contained in:
Lin Yang 2016-10-13 08:00:44 +08:00
parent ae2a6b642f
commit fa0ab061d9
3 changed files with 36 additions and 5 deletions

View File

@ -167,6 +167,23 @@ const Layout = React.createClass({
<p class="text-muted">Version: 0.1</p>
</div>
</footer>
<div class="modal fade" id="errorModal" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Error:</h4>
</div>
<div class="modal-body">
<p></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
);
}

View File

@ -32,8 +32,15 @@ const ComposeDisplay = React.createClass({
this.props.onUpdateNodes();
this.props.onHideCompose();
}.bind(this),
error: function(xhr, status, err) {
console.error(url, status, err.toString());
error: function (xhr, status, error) {
var response = JSON.parse(xhr.responseText)['error'];
var errorTitle = 'Compose Node Error: ' + response['message'];
var errorDetail = '';
for (var i = 0; i < response['@Message.ExtendedInfo'].length; i++)
{
errorDetail += response['@Message.ExtendedInfo'][i]['Message'] + ' ';
}
util.showErrorModal(errorTitle, errorDetail);
}.bind(this)
});
},

View File

@ -140,10 +140,10 @@ exports.filterChassis = function(memberList, filter) {
chassisType = memberList[i]["ChassisType"];
if (chassisType == filter) {
returnMembers.push(memberList[i]);
}
}
}
}
return returnMembers;
};
};
exports.readAndReturn = function(resource) {
var url = config.url + resource;
@ -155,3 +155,10 @@ exports.readAndReturn = function(resource) {
async: false,
}).responseText;
};
exports.showErrorModal = function(title, message) {
$("#errorModal .modal-title").html(title);
$("#errorModal .modal-body p:first").html(message);
$("#errorModal").modal('show');
};