Adapted changes from base admin.js to overlayed admin.js in uma-server-webapp

pull/1187/head
Sebastian Schuster 2017-01-12 13:27:30 +01:00 committed by Justin Richer
parent 0c821fcb51
commit 99d1b0cfec
1 changed files with 64 additions and 1 deletions

View File

@ -366,6 +366,66 @@ var UserProfileView = Backbone.View.extend({
}
});
// error handler
var ErrorHandlerView = Backbone.View.extend({
initialize:function(options) {
this.options = options;
if (!this.template) {
this.template = _.template($('#tmpl-error-box').html());
}
if (!this.headerTemplate) {
this.headerTemplate = _.template($('#tmpl-error-header').html());
}
},
reloadPage:function(event) {
event.preventDefault();
window.location.reload(true);
},
handleError:function(message) {
if (!message) {
message = {};
}
if (message.log) {
console.log(message.log);
}
var _self = this;
return function(model, response, options) {
_self.showErrorMessage(
_self.headerTemplate({message: message, model: model, response: response, options: options}),
_self.template({message: message, model: model, response: response, options: options})
);
$('#modalAlert .modal-body .page-reload').on('click', _self.reloadPage);
}
},
showErrorMessage:function(header, message) {
// hide the sheet if it's visible
$('#loadingbox').sheet('hide');
$('#modalAlert').i18n();
$('#modalAlert div.modal-header').html(header);
$('#modalAlert .modal-body').html(message);
$('#modalAlert').modal({
'backdrop': 'static',
'keyboard': true,
'show': true
});
}
});
// Router
var AppRouter = Backbone.Router.extend({
@ -431,6 +491,8 @@ var AppRouter = Backbone.Router.extend({
this.breadCrumbView.render();
this.errorHandlerView = new ErrorHandlerView();
var base = $('base').attr('href');
$.getJSON(base + '.well-known/openid-configuration', function(data) {
app.serverConfiguration = data;
@ -1142,9 +1204,10 @@ $(function () {
});
window.onerror = function ( message, filename, lineno, colno, error ){
console.log(message);
//Display an alert with an error message
$('#modalAlert div.modal-header').html($.t('error.title'));
$('#modalAlert div.modal-body').html($.t('error.message') + ' <br /> ' [filename, lineno, colno, error]);
$('#modalAlert div.modal-body').html($.t('error.message') + message + ' <br /> ' + [filename, lineno, colno, error]);
$("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog
"backdrop" : "static",