pandora/static/js/errorDialog.js

79 lines
2.9 KiB
JavaScript
Raw Permalink Normal View History

2013-03-03 05:34:44 +00:00
'use strict';
pandora.ui.errorDialog = function(data) {
var that, error, showLogsButton;
2013-03-03 05:34:44 +00:00
//dont open dialog on unload or if antoher error is open
//fixme: error dialog should updated instead
if ($('.OxErrorDialog').length || pandora.isUnloading) {
return;
}
if (data.status.code == 401 || data.status.code == 403) {
that = pandora.ui.iconDialog({
buttons: [
Ox.Button({
id: 'close',
2013-05-09 10:13:58 +00:00
title: Ox._('Close')
2013-03-03 05:34:44 +00:00
})
.bindEvent({
click: function() {
that.close();
}
})
],
content: Ox._('Sorry, you have made an unauthorized request.'),
2013-03-03 05:34:44 +00:00
keys: {enter: 'close', escape: 'close'},
title: Ox.toTitleCase(data.status.text)
})
.addClass('OxErrorDialog')
.open();
} else {
// 0 (timeout) or 500 (error)
error = data.status.code == 0 ? 'timeout' : 'error';
// on window unload, pending request will time out, so
// in order to keep the dialog from appearing, delay it
setTimeout(function() {
if ($('.OxErrorDialog').length == 0 && !pandora.isUnloading) {
showLogsButton = error == 'error'
2017-11-04 09:53:27 +00:00
&& pandora.hasCapability('canSeeDebugMenu')
2013-03-03 05:34:44 +00:00
that = pandora.ui.iconDialog({
buttons: (showLogsButton ? [
Ox.Button({
title: Ox._('View Error Logs...')
})
.bindEvent({
click: function() {
that.close();
pandora.$ui.errorlogsDialog = pandora.ui.errorlogsDialog().open();
}
}),
{}
] : []).concat([
2013-03-03 05:34:44 +00:00
Ox.Button({
id: 'close',
2013-05-09 10:13:58 +00:00
title: Ox._('Close')
2013-03-03 05:34:44 +00:00
})
.bindEvent({
click: function() {
that.close();
}
})
]),
content: Ox._('Sorry, a server {0}'
2014-05-08 06:58:58 +00:00
+ ' occurred while handling your request.'
2013-03-03 05:34:44 +00:00
+ ' To help us find out what went wrong,'
+ ' you may want to report this error to an administrator.'
2013-05-09 10:13:58 +00:00
+ ' Otherwise, please try again later.', [error]),
keys: {enter: 'close', escape: 'close'},
2013-05-09 10:13:58 +00:00
title: Ox._('Server {0}', [Ox.toTitleCase(error)])
2013-03-03 05:34:44 +00:00
})
.addClass('OxErrorDialog')
.open();
}
}, 250);
}
};