# HG changeset patch # User Dustin Demuth # Date 1432738763 -7200 # Node ID 188a9faf96e0ea8876c3e5aaafb214f1b588a87f # Parent 5cdfe0ff1df381a7ea2076095eb236c0f02435f5 Added Errorhandling for AJAX-Requests, especially Authentication Issues. diff -r 5cdfe0ff1df3 -r 188a9faf96e0 app/controller/FilterResult.js --- a/app/controller/FilterResult.js Wed May 27 16:04:59 2015 +0200 +++ b/app/controller/FilterResult.js Wed May 27 16:59:23 2015 +0200 @@ -136,11 +136,46 @@ var blob = new Blob([content],{type: 'text/plain'}); saveAs(blob, 'export.laf'); }, - failure: function() { - // TODO handle Errors correctly, especially AuthenticationTimeouts - Ext.Msg.create(i18n.getMsg('err.msg.generic.title'), + failure: function(response) { + var json = Ext.JSON.decode(response.responseText); + if (json) { + if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ + formPanel.setMessages(json.errors, json.warnings); + } + // TODO Move this handling of 699 and 698 to a more central place! + // TODO i18n + if (json.message === "699" || json.message === "698") { + /* This is the unauthorized message with the authentication + * redirect in the data */ + + /* We decided to handle this with a redirect to the identity + * provider. In which case we have no other option then to + * handle it here with relaunch. */ + Ext.MessageBox.confirm('Erneutes Login erforderlich', + 'Der Server konnte die Anfrage nicht authentifizieren.
'+ + 'Für ein erneutes Login muss die Anwendung neu geladen werden.
' + + 'Alle ungesicherten Daten gehen dabei verloren.
' + + 'Soll die Anwendung jetzt neu geladen werden?', this.reload); //TODO Scope? + } + else if(json.message){ + Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') + +' #'+json.message, + Lada.getApplication().bundle.getMsg(json.message)); + } else { + Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), + i18n.getMsg('err.msg.laf.filecreatefailed')); + } + } else { + Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'), i18n.getMsg('err.msg.laf.filecreatefailed')); + } } }); + }, + + reload: function(btn) { + if (btn === 'yes') { + location.reload(); + } } }); diff -r 5cdfe0ff1df3 -r 188a9faf96e0 app/view/window/GenProbenFromMessprogramm.js --- a/app/view/window/GenProbenFromMessprogramm.js Wed May 27 16:04:59 2015 +0200 +++ b/app/view/window/GenProbenFromMessprogramm.js Wed May 27 16:59:23 2015 +0200 @@ -50,7 +50,6 @@ jsonData: jsondata, success: function(response) { var json = Ext.JSON.decode(response.responseText); - console.log(json); Ext.Msg.show({ title: i18n.getMsg('success'), autoScroll: true, @@ -59,23 +58,36 @@ }); }, failure: function(response) { - // TODO handle Errors correctly, especially AuthenticationTimeouts var json = Ext.JSON.decode(response.responseText); if (json) { if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){ formPanel.setMessages(json.errors, json.warnings); } + // TODO Move this handling of 699 and 698 to a more central place! + // TODO i18n + if (json.message === "699" || json.message === "698") { + /* This is the unauthorized message with the authentication + * redirect in the data */ - if(json.message){ - Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title') + /* We decided to handle this with a redirect to the identity + * provider. In which case we have no other option then to + * handle it here with relaunch. */ + Ext.MessageBox.confirm('Erneutes Login erforderlich', + 'Der Server konnte die Anfrage nicht authentifizieren.
'+ + 'Für ein erneutes Login muss die Anwendung neu geladen werden.
' + + 'Alle ungesicherten Daten gehen dabei verloren.
' + + 'Soll die Anwendung jetzt neu geladen werden?', this.reload); + } + else if(json.message){ + Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title') +' #'+json.message, Lada.getApplication().bundle.getMsg(json.message)); } else { - Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), + Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title'), Lada.getApplication().bundle.getMsg('err.msg.generic.body')); } } else { - Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'), + Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title'), Lada.getApplication().bundle.getMsg('err.msg.response.body')); } } @@ -152,7 +164,7 @@ evalResponse: function(response) { var i18n = Lada.getApplication().bundle; var r = ''; - r += response.totalCount; + r += response.data.length; r += ' ' + i18n.getMsg('probecreated'); r += '
'; r += i18n.getMsg('probeids'); @@ -162,5 +174,11 @@ r += response.data[i].probeIdAlt } return r; + }, + + reload: function(btn) { + if (btn === 'yes') { + location.reload(); + } } });