mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
improve session and error handling, see #23
This commit is contained in:
@@ -491,7 +491,13 @@ if (Sonia.scm.Main){
|
|||||||
sectionLogoutText: 'Abmelden',
|
sectionLogoutText: 'Abmelden',
|
||||||
navLogoutText: 'Abmelden',
|
navLogoutText: 'Abmelden',
|
||||||
|
|
||||||
logoutFailedText: 'Abmeldung Fehlgeschlagen!'
|
logoutFailedText: 'Abmeldung Fehlgeschlagen!',
|
||||||
|
|
||||||
|
errorTitle: 'Fehler',
|
||||||
|
errorMessage: 'Es ist ein unbekannter Fehler aufgetreten.',
|
||||||
|
|
||||||
|
errorSessionExpiredTitle: 'Session abgelaufen',
|
||||||
|
errorSessionExpiredMessage: 'Ihre Session ist abgelaufen. Bitte melden sie sich neu an.'
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,15 +270,13 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
success: function(){
|
success: function(){
|
||||||
this.el.unmask();
|
this.el.unmask();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
this.el.unmask();
|
this.el.unmask();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.errorMsgText,
|
this.errorTitleText,
|
||||||
scope: this,
|
this.errorMsgText
|
||||||
buttons: Ext.MessageBox.OK,
|
);
|
||||||
icon:Ext.MessageBox.ERROR
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -306,16 +304,14 @@ Sonia.config.ScmConfigPanel = Ext.extend(Sonia.config.ConfigPanel,{
|
|||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
el.unmask();
|
el.unmask();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
el.unmask();
|
el.unmask();
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.errorMsgText,
|
this.errorTitleText,
|
||||||
scope: this,
|
this.errorMsgText
|
||||||
buttons: Ext.MessageBox.OK,
|
);
|
||||||
icon:Ext.MessageBox.ERROR
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -441,9 +437,13 @@ Sonia.config.SimpleConfigForm = Ext.extend(Sonia.config.ConfigForm,{
|
|||||||
success: function(response){
|
success: function(response){
|
||||||
this.el.unmask();
|
this.el.unmask();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
this.el.unmask();
|
this.el.unmask();
|
||||||
Ext.Msg.alert( this.failedText );
|
main.handleFailure(
|
||||||
|
result.status,
|
||||||
|
null,
|
||||||
|
this.failedText
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -461,10 +461,14 @@ Sonia.config.SimpleConfigForm = Ext.extend(Sonia.config.ConfigForm,{
|
|||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
el.unmask();
|
el.unmask();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
el.unmask();
|
el.unmask();
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
Ext.Msg.alert( this.failedText );
|
main.handleFailure(
|
||||||
|
result.status,
|
||||||
|
null,
|
||||||
|
this.failedText
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -348,15 +348,14 @@ Sonia.group.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
el.unmask();
|
el.unmask();
|
||||||
this.execCallback(this.onUpdate, group);
|
this.execCallback(this.onUpdate, group);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
el.unmask();
|
el.unmask();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.updateErrorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.updateErrorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -388,15 +387,14 @@ Sonia.group.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
el.unmask();
|
el.unmask();
|
||||||
this.execCallback(this.onCreate, item);
|
this.execCallback(this.onCreate, item);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
el.unmask();
|
el.unmask();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.createErrorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.createErrorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -494,13 +492,12 @@ Sonia.group.Panel = Ext.extend(Ext.Panel, {
|
|||||||
this.reload();
|
this.reload();
|
||||||
this.resetPanel();
|
this.resetPanel();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.errorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.errorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,17 +97,16 @@ Sonia.plugin.Center = Ext.extend(Ext.util.Observable, {
|
|||||||
this.restartText);
|
this.restartText);
|
||||||
this.fireEvents('installed', pluginId);
|
this.fireEvents('installed', pluginId);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug('plugin installation failed');
|
console.debug('plugin installation failed');
|
||||||
}
|
}
|
||||||
loadingBox.hide();
|
loadingBox.hide();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.installFailedText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.installFailedText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -132,17 +131,16 @@ Sonia.plugin.Center = Ext.extend(Ext.util.Observable, {
|
|||||||
this.restartText);
|
this.restartText);
|
||||||
this.fireEvents('uninstalled', pluginId);
|
this.fireEvents('uninstalled', pluginId);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug('plugin uninstallation failed');
|
console.debug('plugin uninstallation failed');
|
||||||
}
|
}
|
||||||
loadingBox.hide();
|
loadingBox.hide();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.uninstallFailedText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.uninstallFailedText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -168,17 +166,16 @@ Sonia.plugin.Center = Ext.extend(Ext.util.Observable, {
|
|||||||
this.restartText);
|
this.restartText);
|
||||||
this.fireEvents('updated', pluginId);
|
this.fireEvents('updated', pluginId);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
if ( debug ){
|
if ( debug ){
|
||||||
console.debug('plugin update failed');
|
console.debug('plugin update failed');
|
||||||
}
|
}
|
||||||
loadingBox.hide();
|
loadingBox.hide();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.updateFailedText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.updateFailedText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -439,16 +439,15 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
el.unmask();
|
el.unmask();
|
||||||
this.execCallback(this.onUpdate, item);
|
this.execCallback(this.onUpdate, item);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
this.fireEvent('updateFailed', item);
|
this.fireEvent('updateFailed', item);
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
el.unmask();
|
el.unmask();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.updateErrorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.updateErrorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -478,16 +477,15 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
el.unmask();
|
el.unmask();
|
||||||
this.execCallback(this.onCreate, item);
|
this.execCallback(this.onCreate, item);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
this.fireEvent('creationFailed', item);
|
this.fireEvent('creationFailed', item);
|
||||||
clearTimeout(tid);
|
clearTimeout(tid);
|
||||||
el.unmask();
|
el.unmask();
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.createErrorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.createErrorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -841,13 +839,12 @@ Sonia.repository.Panel = Ext.extend(Ext.Panel, {
|
|||||||
this.reload();
|
this.reload();
|
||||||
this.resetPanel();
|
this.resetPanel();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.errorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.errorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,12 +50,11 @@ Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, {
|
|||||||
}
|
}
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
} else {
|
} else {
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
status,
|
||||||
msg: String.format( this.errorMsgText, status ),
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.errorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: this
|
scope: this
|
||||||
|
|||||||
@@ -59,6 +59,12 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
|
|
||||||
logoutFailedText: 'Logout Failed!',
|
logoutFailedText: 'Logout Failed!',
|
||||||
|
|
||||||
|
errorTitle: 'Error',
|
||||||
|
errorMessage: 'Unknown error occurred.',
|
||||||
|
|
||||||
|
errorSessionExpiredTitle: 'Session expired',
|
||||||
|
errorSessionExpiredMessage: 'Your session is expired. Please relogin.',
|
||||||
|
|
||||||
mainTabPanel: null,
|
mainTabPanel: null,
|
||||||
|
|
||||||
infoPanels: [],
|
infoPanels: [],
|
||||||
@@ -334,6 +340,38 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
|||||||
console.debug( "callback is not a function or object. " + callback );
|
console.debug( "callback is not a function or object. " + callback );
|
||||||
}
|
}
|
||||||
}, this);
|
}, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleFailure: function(status, title, message){
|
||||||
|
if (debug){
|
||||||
|
console.debug( 'handle failure for status code: ' + status );
|
||||||
|
}
|
||||||
|
if ( status == 401 ){
|
||||||
|
Ext.Msg.show({
|
||||||
|
title: this.errorSessionExpiredTitle,
|
||||||
|
msg: this.errorSessionExpiredMessage,
|
||||||
|
buttons: Ext.Msg.OKCANCEL,
|
||||||
|
fn: function(btn){
|
||||||
|
if ( btn == 'ok' ){
|
||||||
|
this.login();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scope: this
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if ( title == null ){
|
||||||
|
title = this.errorTitle;
|
||||||
|
}
|
||||||
|
if ( message == null ){
|
||||||
|
message = this.errorMessage;
|
||||||
|
}
|
||||||
|
Ext.MessageBox.show({
|
||||||
|
title: title,
|
||||||
|
msg: String.format(message, status),
|
||||||
|
buttons: Ext.MessageBox.OK,
|
||||||
|
icon:Ext.MessageBox.ERROR
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -264,13 +264,12 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
}
|
}
|
||||||
this.execCallback(this.onUpdate, item);
|
this.execCallback(this.onUpdate, item);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.updateErrorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.updateErrorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -296,13 +295,12 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
|||||||
this.getForm().reset();
|
this.getForm().reset();
|
||||||
this.execCallback(this.onCreate, user);
|
this.execCallback(this.onCreate, user);
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.createErrorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.createErrorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -421,13 +419,12 @@ Sonia.user.Panel = Ext.extend(Ext.Panel, {
|
|||||||
this.reload();
|
this.reload();
|
||||||
this.resetPanel();
|
this.resetPanel();
|
||||||
},
|
},
|
||||||
failure: function(){
|
failure: function(result){
|
||||||
Ext.MessageBox.show({
|
main.handleFailure(
|
||||||
title: this.errorTitleText,
|
result.status,
|
||||||
msg: this.errorMsgText,
|
this.errorTitleText,
|
||||||
buttons: Ext.MessageBox.OK,
|
this.errorMsgText
|
||||||
icon:Ext.MessageBox.ERROR
|
);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user