annotate app/view/window/ImportResponse.js @ 758:b2fcbdc4969d

Filled MessmethodenGrid with life.
author Dustin Demuth <dustin@intevation.de>
date Wed, 06 May 2015 16:24:23 +0200
parents 7eb8ef8e68ca
children def27cdd0dfa
rev   line source
729
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /**
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 *
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;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 if (me.data && me.message) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 html = me.parseResponse(me.message, me.data);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 this.bodyStyle = {background: '#fff'};
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24 me.items = [{
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
25 xtype: 'panel',
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 html: html,
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 margin: 10,
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 border: false
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 }];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 this.callParent(arguments);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 },
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 parseResponse: function(msg, data) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 console.log(Ext.JSON.decode(data));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 data = Ext.JSON.decode(data);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 var errors = data.data.errors;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 var warnings = data.data.warnings;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 var out = [];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 // 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
41 // empty)
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 var numErrors;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 var numWarnings;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 if (Ext.isEmpty(Object.keys(errors))) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 numErrors = 0;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 numErrors = Object.keys(errors).length;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 if (Ext.isEmpty(Object.keys(warnings))) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 numWarnings = 0;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 numWarnings = Object.keys(warnings).length;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 if (msg !== '200') {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 out.push('Der Import der Datei ' + this.fileName +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 ' war nicht erfolgreich. Der Importvorgang konnte ' +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 'aufgrund eines Fehlers im Server nicht beendet werden.');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 if (numErrors > 0) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 out.push('Folgende Proben konnten nicht erfolgreich ' +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 'importiert werden:');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 var msgs;
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 for (var key in errors) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 out.push('<li>Probe: ' + key);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 msgs = errors[key];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 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
74 if (msgs[i].key === 'validation') {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 out.push('Validierungsfehler: ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 for (var vKey in msgs[i].value) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 out.push(Lada.getApplication().bundle.getMsg(vKey) + ': ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 for (var j = 0; j < msgs[i].value[vKey].length; j++) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 console.log(msgs[i].value[vKey][j]);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81 out.push(Lada.getApplication().bundle.getMsg(msgs[i].value[vKey][j].toString()));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 out.push(msgs[i].key +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 ' (' + Lada.getApplication().bundle.getMsg(
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 msgs[i].code.toString()) +
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 '): ' + msgs[i].value);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 out.push('</li>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
98 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 if (numWarnings > 0) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101 out.push('Bei folgenden Proben traten Warnungen auf:');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
102 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
103 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 for (key in warnings) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 out.push('<li>' + key);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 msgs = warnings[key];
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
107 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 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
109 if (msgs[i].key === 'validation') {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110 out.push('Validierungswarnungen: ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 out.push('<ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 for (var vKey in msgs[i].value) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 out.push(Lada.getApplication().bundle.getMsg(vKey) + ': ');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 for (var j = 0; j < msgs[i].value[vKey].length; j++) {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 console.log(msgs[i].value[vKey][j]);
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 out.push(Lada.getApplication().bundle.getMsg(msgs[i].value[vKey][j].toString()));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 else {
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 out.push('<li>' + msgs[i].key + ' (' + Lada.getApplication().bundle.getMsg(msgs[i].code.toString())+'): '+msgs[i].value+'</li>')
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 out.push('</ol>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126 out.push('</li>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 out.push('</ol>');
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 out.push('<br/>');
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 }
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 console.log(out.join(''));
7eb8ef8e68ca Added window to display importer messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 return out.join('');
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 });

http://lada.wald.intevation.org