comparison app/controller/FilterResult.js @ 812:188a9faf96e0

Added Errorhandling for AJAX-Requests, especially Authentication Issues.
author Dustin Demuth <dustin@intevation.de>
date Wed, 27 May 2015 16:59:23 +0200
parents 5cdfe0ff1df3
children af54733a6d48
comparison
equal deleted inserted replaced
811:5cdfe0ff1df3 812:188a9faf96e0
134 success: function(response) { 134 success: function(response) {
135 var content = response.responseText; 135 var content = response.responseText;
136 var blob = new Blob([content],{type: 'text/plain'}); 136 var blob = new Blob([content],{type: 'text/plain'});
137 saveAs(blob, 'export.laf'); 137 saveAs(blob, 'export.laf');
138 }, 138 },
139 failure: function() { 139 failure: function(response) {
140 // TODO handle Errors correctly, especially AuthenticationTimeouts 140 var json = Ext.JSON.decode(response.responseText);
141 Ext.Msg.create(i18n.getMsg('err.msg.generic.title'), 141 if (json) {
142 if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
143 formPanel.setMessages(json.errors, json.warnings);
144 }
145 // TODO Move this handling of 699 and 698 to a more central place!
146 // TODO i18n
147 if (json.message === "699" || json.message === "698") {
148 /* This is the unauthorized message with the authentication
149 * redirect in the data */
150
151 /* We decided to handle this with a redirect to the identity
152 * provider. In which case we have no other option then to
153 * handle it here with relaunch. */
154 Ext.MessageBox.confirm('Erneutes Login erforderlich',
155 'Der Server konnte die Anfrage nicht authentifizieren.<br/>'+
156 'Für ein erneutes Login muss die Anwendung neu geladen werden.<br/>' +
157 'Alle ungesicherten Daten gehen dabei verloren.<br/>' +
158 'Soll die Anwendung jetzt neu geladen werden?', this.reload); //TODO Scope?
159 }
160 else if(json.message){
161 Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.generic.title')
162 +' #'+json.message,
163 Lada.getApplication().bundle.getMsg(json.message));
164 } else {
165 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
166 i18n.getMsg('err.msg.laf.filecreatefailed'));
167 }
168 } else {
169 Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
142 i18n.getMsg('err.msg.laf.filecreatefailed')); 170 i18n.getMsg('err.msg.laf.filecreatefailed'));
171 }
143 } 172 }
144 }); 173 });
174 },
175
176 reload: function(btn) {
177 if (btn === 'yes') {
178 location.reload();
179 }
145 } 180 }
146 }); 181 });

http://lada.wald.intevation.org