Mercurial > lada > lada-client
annotate app/view/window/ImportResponse.js @ 1434:ff5a402cd63d tip
set version to 2.7-SNAPSHOT for default branch
author | Marco Lechner, Bundesamt fuer Strahlenschutz, SW 2.1 <mlechner@bfs.de> |
---|---|
date | Fri, 07 Apr 2017 11:32:26 +0200 |
parents | c22581d48040 |
children |
rev | line source |
---|---|
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
1 /** |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
729
diff
changeset
|
2 * This Window is shown, when Proben could be imported from a LAF file |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
3 */ |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
4 Ext.define('Lada.view.window.ImportResponse', { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
5 extend: 'Ext.window.Window', |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
6 alias: 'widget.importresponse', |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
7 |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
8 data: null, |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
9 message: null, |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 fileName: '', |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
11 |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
12 layout: 'fit', |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
13 /** |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 * @private |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
15 * Initialize the view. |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
16 */ |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
17 initComponent: function() { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
18 var me = this; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
19 var html; |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
20 var download; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
21 var i18n = Lada.getApplication().bundle; |
1236
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
22 var data = Ext.JSON.decode(me.data, true); |
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
23 if (data) { |
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
24 html = me.parseShortResponse(data); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
25 } |
1222
4e62bc6e7250
Fixed parsing of empty data and require the import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1219
diff
changeset
|
26 else { |
4e62bc6e7250
Fixed parsing of empty data and require the import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1219
diff
changeset
|
27 html = 'Der Import der Datei ' + this.fileName + |
4e62bc6e7250
Fixed parsing of empty data and require the import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1219
diff
changeset
|
28 ' war nicht erfolgreich.'; |
4e62bc6e7250
Fixed parsing of empty data and require the import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1219
diff
changeset
|
29 } |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
30 this.bodyStyle = {background: '#fff'}; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
31 me.items = [{ |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
32 xtype: 'panel', |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
33 html: html, |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
34 margin: 10, |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
35 border: false |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
36 }]; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
37 |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
38 me.buttons = [{ |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
39 text: i18n.getMsg('close'), |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
40 scope: this, |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
41 name: 'close', |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
42 handler: this.close |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
43 }, { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
44 text: i18n.getMsg('download'), |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
45 name: 'download', |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
46 disabled: true, |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
47 handler: function() { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
48 var blob = new Blob([download],{type: 'text/html'}); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
49 saveAs(blob, 'report.html'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
50 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
51 }]; |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
52 this.callParent(arguments); |
1236
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
53 if (data) { |
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
54 download = me.parseResponse(data); |
1222
4e62bc6e7250
Fixed parsing of empty data and require the import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1219
diff
changeset
|
55 } |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
56 }, |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
57 |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
58 /** |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
59 * Parse the response and create a summary of the result |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
60 * @param data |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
61 */ |
1236
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
62 parseShortResponse: function(data) { |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
63 var errors = data.data.errors; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
64 var warnings = data.data.warnings; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
65 var out = []; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
66 // There is a entry for each imported proben in the errors dict (might be |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
67 // empty) |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
68 |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
69 var numErrors; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
70 var numWarnings; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
71 if (!Ext.isObject(errors)) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
72 numErrors = 0; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
73 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
74 else { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
75 numErrors = Object.keys(errors).length; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
76 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
77 if (!Ext.isObject(warnings)) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
78 numWarnings = 0; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
79 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
80 else { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
81 numWarnings = Object.keys(warnings).length; |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
82 } |
1236
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
83 if (!data.success) { |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
84 out.push('Der Import der Datei ' + this.fileName + |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
85 ' war nicht erfolgreich. Der Importvorgang konnte ' + |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
86 'aufgrund eines Fehlers im Server nicht beendet werden.'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
87 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
88 else { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
89 if (numErrors > 0) { |
1239
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
90 if (errors.parser) { |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
91 out.push('Die Probe(n) konnten nicht erfolgreich ' + |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
92 'importiert werden.'); |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
93 } |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
94 else { |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
95 out.push(numErrors + ' Probe(n) konnten nicht ' + |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
96 'erfolgreich importiert werden.'); |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
97 } |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
98 out.push('<br/>'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
99 out.push('<br/>'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
100 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
101 if (numWarnings > 0) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
102 out.push('Bei ' + numWarnings + ' Probe(n) traten Warnungen auf. '); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
103 out.push('<br/>'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
104 out.push('<br/>'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
105 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
106 if (numErrors > 0 || numWarnings > 0) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
107 out.push('Der ausführliche Bericht steht als Download bereit.'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
108 out.push('<br/>'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
109 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
110 else { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
111 out.push('Die Proben wurden importiert.'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
112 out.push('<br/>'); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
113 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
114 } |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
115 return out.join(''); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
116 }, |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
117 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
729
diff
changeset
|
118 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
729
diff
changeset
|
119 * Parse the Response |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
729
diff
changeset
|
120 * @param data the payload of the response |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
729
diff
changeset
|
121 */ |
1236
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
122 parseResponse: function(data) { |
1425 | 123 var i18n = Lada.getApplication().bundle; |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
124 var errors = data.data.errors; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
125 var warnings = data.data.warnings; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
126 var out = []; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
127 // There is a entry for each imported proben in the errors dict (might be |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
128 // empty) |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
129 |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
130 var numErrors; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
131 var numWarnings; |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
132 if (!Ext.isObject(errors)) { |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
133 numErrors = 0; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
134 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
135 else { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
136 numErrors = Object.keys(errors).length; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
137 } |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
138 if (!Ext.isObject(warnings)) { |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
139 numWarnings = 0; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
140 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
141 else { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
142 numWarnings = Object.keys(warnings).length; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
143 } |
1236
cfc24d2ae268
Fix error handling in ImportResponse window.
Tom Gottfried <tom@intevation.de>
parents:
1226
diff
changeset
|
144 if (!data.success) { |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
145 out.push('Der Import der Datei ' + this.fileName + |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
146 ' war nicht erfolgreich. Der Importvorgang konnte ' + |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
147 'aufgrund eines Fehlers im Server nicht beendet werden.'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
148 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
149 else { |
1223
4c443efd5587
Added html tags for more valid html in download file.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1222
diff
changeset
|
150 out.push('<!DOCTYPE html>' + |
4c443efd5587
Added html tags for more valid html in download file.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1222
diff
changeset
|
151 '<head><meta charset="utf-8"></head><body>'); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
152 if (numErrors > 0) { |
1239
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
153 out.push('Folgende Fehler traten beim Import auf:'); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
154 out.push('<br/>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
155 out.push('<ol>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
156 var msgs; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
157 for (var key in errors) { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
158 msgs = errors[key]; |
1239
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
159 if (key !== 'parser') { |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
160 out.push('<li>Probe: ' + key); |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
161 } |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
162 out.push('<ol>'); |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
163 validation = [] |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
164 validation.push('Validierungsfehler: '); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
165 for (var i = msgs.length - 1; i >= 0; i--) { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
166 if (msgs[i].key === 'validation') { |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
167 validation.push('<ol>'); |
1423
ee21d0e1b998
Pipe out more information in import report.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1239
diff
changeset
|
168 var parts = msgs[i].value.split('#'); |
1425 | 169 var str = i18n.getMsg(parts[0]) + |
1427
c22581d48040
In case a value is shown, separate it with a space.
Tom Gottfried <tom@intevation.de>
parents:
1426
diff
changeset
|
170 (parts[1] === undefined ? '' : ' ' + parts[1]); |
1425 | 171 validation.push(str + ' (' |
172 + i18n.getMsg(msgs[i].code.toString()) + ')'); | |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
173 validation.push('</ol>'); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
174 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
175 else { |
1425 | 176 out.push('<li>' + msgs[i].key + ' (' |
177 + i18n.getMsg(msgs[i].code.toString()) | |
178 + '): ' + msgs[i].value + '</li>') | |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
179 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
180 } |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
181 if (validation.length > 1) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
182 out.push('<li>') |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
183 out.push(validation.join('')); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
184 out.push('</li>') |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
185 } |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
186 out.push('</ol>'); |
1239
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
187 if (key !== 'parser') { |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
188 out.push('</li>'); |
1ed5ec9326e6
Report parser errors separately.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1236
diff
changeset
|
189 } |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
190 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
191 out.push('</ol>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
192 out.push('<br/>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
193 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
194 if (numWarnings > 0) { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
195 out.push('<br/>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
196 out.push('Bei folgenden Proben traten Warnungen auf:'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
197 out.push('<br/>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
198 out.push('<ol>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
199 for (key in warnings) { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
200 out.push('<li>' + key); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
201 msgs = warnings[key]; |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
202 out.push('<ol>'); |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
203 validation = [] |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
204 validation.push('Validierungswarnungen: '); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
205 for (var i = msgs.length - 1; i >= 0; i--) { |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
206 if (msgs[i].key === 'validation') { |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
207 validation.push('<ol>'); |
1423
ee21d0e1b998
Pipe out more information in import report.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1239
diff
changeset
|
208 var parts = msgs[i].value.split('#'); |
1425 | 209 var str = i18n.getMsg(parts[0]) + |
1427
c22581d48040
In case a value is shown, separate it with a space.
Tom Gottfried <tom@intevation.de>
parents:
1426
diff
changeset
|
210 (parts[1] === undefined ? '' : ' ' + parts[1]); |
1425 | 211 validation.push(str + ' (' |
212 + i18n.getMsg(msgs[i].code.toString()) + ')'); | |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
213 validation.push('</ol>'); |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
214 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
215 else { |
1425 | 216 out.push('<li>' + msgs[i].key + ' (' |
217 + i18n.getMsg(msgs[i].code.toString()) | |
218 + '): ' + msgs[i].value + '</li>') | |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
219 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
220 } |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
221 if (validation.length > 1) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
222 out.push('<li>') |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
223 out.push(validation.join('')); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
224 out.push('</li>') |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
225 } |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
226 out.push('</ol>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
227 out.push('</li>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
228 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
229 out.push('</ol>'); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
230 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
231 out.push('<br/>'); |
1223
4c443efd5587
Added html tags for more valid html in download file.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
1222
diff
changeset
|
232 out.push('</body></html>') |
1219
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
233 if (numWarnings > 0 || numErrors > 0) { |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
234 this.down('button[name=download]').enable(); |
746915a63a11
Updated import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
890
diff
changeset
|
235 } |
729
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
236 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
237 return out.join(''); |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
238 } |
7eb8ef8e68ca
Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
239 }); |