Skip to content

Commit 99d1b0c

Browse files
sschujricher
authored andcommitted
Adapted changes from base admin.js to overlayed admin.js in uma-server-webapp
1 parent 0c821fc commit 99d1b0c

File tree

1 file changed

+64
-1
lines changed
  • uma-server-webapp/src/main/webapp/resources/js

1 file changed

+64
-1
lines changed

uma-server-webapp/src/main/webapp/resources/js/admin.js

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,66 @@ var UserProfileView = Backbone.View.extend({
366366
}
367367
});
368368

369+
// error handler
370+
var ErrorHandlerView = Backbone.View.extend({
371+
372+
initialize:function(options) {
373+
this.options = options;
374+
if (!this.template) {
375+
this.template = _.template($('#tmpl-error-box').html());
376+
}
377+
if (!this.headerTemplate) {
378+
this.headerTemplate = _.template($('#tmpl-error-header').html());
379+
}
380+
},
381+
382+
reloadPage:function(event) {
383+
event.preventDefault();
384+
window.location.reload(true);
385+
},
386+
387+
handleError:function(message) {
388+
389+
if (!message) {
390+
message = {};
391+
}
392+
393+
if (message.log) {
394+
console.log(message.log);
395+
}
396+
397+
var _self = this;
398+
399+
return function(model, response, options) {
400+
401+
_self.showErrorMessage(
402+
_self.headerTemplate({message: message, model: model, response: response, options: options}),
403+
_self.template({message: message, model: model, response: response, options: options})
404+
);
405+
406+
$('#modalAlert .modal-body .page-reload').on('click', _self.reloadPage);
407+
408+
}
409+
},
410+
411+
showErrorMessage:function(header, message) {
412+
// hide the sheet if it's visible
413+
$('#loadingbox').sheet('hide');
414+
415+
$('#modalAlert').i18n();
416+
$('#modalAlert div.modal-header').html(header);
417+
$('#modalAlert .modal-body').html(message);
418+
419+
$('#modalAlert').modal({
420+
'backdrop': 'static',
421+
'keyboard': true,
422+
'show': true
423+
});
424+
425+
}
426+
});
427+
428+
369429
// Router
370430
var AppRouter = Backbone.Router.extend({
371431

@@ -431,6 +491,8 @@ var AppRouter = Backbone.Router.extend({
431491

432492
this.breadCrumbView.render();
433493

494+
this.errorHandlerView = new ErrorHandlerView();
495+
434496
var base = $('base').attr('href');
435497
$.getJSON(base + '.well-known/openid-configuration', function(data) {
436498
app.serverConfiguration = data;
@@ -1142,9 +1204,10 @@ $(function () {
11421204
});
11431205

11441206
window.onerror = function ( message, filename, lineno, colno, error ){
1207+
console.log(message);
11451208
//Display an alert with an error message
11461209
$('#modalAlert div.modal-header').html($.t('error.title'));
1147-
$('#modalAlert div.modal-body').html($.t('error.message') + ' <br /> ' [filename, lineno, colno, error]);
1210+
$('#modalAlert div.modal-body').html($.t('error.message') + message + ' <br /> ' + [filename, lineno, colno, error]);
11481211

11491212
$("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog
11501213
"backdrop" : "static",

0 commit comments

Comments
 (0)