comparison app/view/window/ImportResponse.js @ 1222:4e62bc6e7250

Fixed parsing of empty data and require the import response window.
author Raimund Renkert <raimund.renkert@intevation.de>
date Thu, 27 Oct 2016 16:26:07 +0200
parents 746915a63a11
children 4c443efd5587
comparison
equal deleted inserted replaced
1221:4b456449029c 1222:4e62bc6e7250
20 var download; 20 var download;
21 var i18n = Lada.getApplication().bundle; 21 var i18n = Lada.getApplication().bundle;
22 if (me.data && me.message) { 22 if (me.data && me.message) {
23 html = me.parseShortResponse(me.message, me.data); 23 html = me.parseShortResponse(me.message, me.data);
24 } 24 }
25 else {
26 html = 'Der Import der Datei ' + this.fileName +
27 ' war nicht erfolgreich.';
28 }
25 this.bodyStyle = {background: '#fff'}; 29 this.bodyStyle = {background: '#fff'};
26 me.items = [{ 30 me.items = [{
27 xtype: 'panel', 31 xtype: 'panel',
28 html: html, 32 html: html,
29 margin: 10, 33 margin: 10,
43 var blob = new Blob([download],{type: 'text/html'}); 47 var blob = new Blob([download],{type: 'text/html'});
44 saveAs(blob, 'report.html'); 48 saveAs(blob, 'report.html');
45 } 49 }
46 }]; 50 }];
47 this.callParent(arguments); 51 this.callParent(arguments);
48 download = me.parseResponse(me.message, me.data); 52 if (me.data && me.message) {
53 download = me.parseResponse(me.message, me.data);
54 }
49 }, 55 },
50 56
51 /** 57 /**
52 * Parse the response and create a summary of the result 58 * Parse the response and create a summary of the result
53 * @param msg 59 * @param msg
54 * @param data 60 * @param data
55 */ 61 */
56 parseShortResponse: function(msg, data) { 62 parseShortResponse: function(msg, data) {
57 data = Ext.JSON.decode(data); 63 data = Ext.JSON.decode(data, true);
58 var errors = data.data.errors; 64 var errors = data.data.errors;
59 var warnings = data.data.warnings; 65 var warnings = data.data.warnings;
60 var out = []; 66 var out = [];
61 // There is a entry for each imported proben in the errors dict (might be 67 // There is a entry for each imported proben in the errors dict (might be
62 // empty) 68 // empty)
108 * Parse the Response 114 * Parse the Response
109 * @param msg the Lada-Erro-Code 115 * @param msg the Lada-Erro-Code
110 * @param data the payload of the response 116 * @param data the payload of the response
111 */ 117 */
112 parseResponse: function(msg, data) { 118 parseResponse: function(msg, data) {
113 console.log(Ext.JSON.decode(data)); 119 data = Ext.JSON.decode(data, true);
114 data = Ext.JSON.decode(data);
115 var errors = data.data.errors; 120 var errors = data.data.errors;
116 var warnings = data.data.warnings; 121 var warnings = data.data.warnings;
117 var out = []; 122 var out = [];
118 // There is a entry for each imported proben in the errors dict (might be 123 // There is a entry for each imported proben in the errors dict (might be
119 // empty) 124 // empty)
205 out.push('<br/>'); 210 out.push('<br/>');
206 if (numWarnings > 0 || numErrors > 0) { 211 if (numWarnings > 0 || numErrors > 0) {
207 this.down('button[name=download]').enable(); 212 this.down('button[name=download]').enable();
208 } 213 }
209 } 214 }
210 console.log(out.join(''));
211 return out.join(''); 215 return out.join('');
212 } 216 }
213 }); 217 });

http://lada.wald.intevation.org