annotate app/view/window/FileUpload.js @ 1257:9a428be3907b

add action button in Messung grid and Ortszuordnung grid
author Michael Stanko <mstanko@bfs.de>
date Mon, 21 Nov 2016 08:07:54 +0100
parents 848b50a4a4eb
children 3b4dcc83a21b
rev   line source
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 *
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU GPL (v>=3)
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 * the documentation coming with IMIS-Labordaten-Application for details.
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
7 */
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
8
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
9 /**
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
10 * This is a simple Fileupload Window, used to upload LAF-Files
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 */
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
12 Ext.define('Lada.view.window.FileUpload', {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
13 extend: 'Ext.window.Window',
1227
848b50a4a4eb Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents: 1222
diff changeset
14 requires: [
848b50a4a4eb Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents: 1222
diff changeset
15 'Ext.ux.upload.BrowseButton',
848b50a4a4eb Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents: 1222
diff changeset
16 'Ext.ux.upload.Item',
848b50a4a4eb Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents: 1222
diff changeset
17 'Ext.ux.upload.uploader.ExtJsUploader',
848b50a4a4eb Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents: 1222
diff changeset
18 'Lada.view.window.ImportResponse'
848b50a4a4eb Add missing requirements.
Tom Gottfried <tom@intevation.de>
parents: 1222
diff changeset
19 ],
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21 layout: 'hbox',
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
22
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
23 file: null,
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
24
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
25 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
26 * This function initialises the Window
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
27 */
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 initComponent: function() {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 var me = this;
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 this.browseButton = Ext.create('Ext.ux.upload.BrowseButton', {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 buttonText: 'Durchsuchen...',
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 margin: '3, 3, 3, 3'
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 });
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 this.fileInput = Ext.create('Ext.form.field.Text', {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 allowBlank: false,
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 emptyText: 'Wählen Sie eine Datei',
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 hideLabel: true,
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 margin: '3, 3, 3, 3'
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 });
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 this.items = [
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 this.fileInput,
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 this.browseButton
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 ];
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44 this.buttons = [{
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 text: 'Speichern',
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 handler: this.uploadFile
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 }, {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 text: 'Abbrechen',
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49 handler: this.abort
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
50 }];
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
51 this.on('afterrender', function() {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 this.browseButton.fileInputEl.dom.removeAttribute('multiple', '0');
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 }, this);
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 this.browseButton.on('fileselected', this.fileSelected, this);
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55 this.callParent(arguments);
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
58 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
59 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
60 * A handler for a Abort-Button
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
61 */
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62 abort: function(button) {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63 var win = button.up('window');
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 win.close();
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
67 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
68 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
69 * A handler for the Input field
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
70 */
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 fileSelected: function(input, file) {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 var item = Ext.create('Ext.ux.upload.Item', {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 fileApiObject: file[0]
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 });
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 this.fileInput.setValue(item.getName());
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 this.file = item;
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
79 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
80 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
81 * A handler for the Upload-Button
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
82 */
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 uploadFile: function(button) {
809
3bc19188fc3a Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents: 730
diff changeset
84 // TODO Error handling ?
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 var win = button.up('window');
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 var uploader = Ext.create('Ext.ux.upload.uploader.ExtJsUploader', {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 extraHeaders: {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88 'X-OPENID-PARAMS': Lada.openIDParams
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
89 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
90 method: 'POST',
1221
4b456449029c Increased request timeout and set loading mask.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 999
diff changeset
91 timeout: 600 * 1000,
999
f73ca04d73a7 Refactored Server URL
Dustin Demuth <dustin@intevation.de>
parents: 890
diff changeset
92 url: 'lada-server/data/import/laf'
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93 });
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
94 this.mon(uploader, 'uploadsuccess', win.uploadSuccess, win);
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
95 this.mon(uploader, 'uploadfailure', win.uploadFailure, win);
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
96 if (button.up('window').file !== null) {
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
97 uploader.uploadItem(button.up('window').file);
1221
4b456449029c Increased request timeout and set loading mask.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 999
diff changeset
98 win.setLoading(Lada.getApplication().bundle.getMsg('processingData'));
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
99 }
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
100 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
101
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
102 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
103 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
104 */
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
105 uploadSuccess: function(file, response) {
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
106 this.close();
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
107 var win = Ext.create('Lada.view.window.ImportResponse', {
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
108 data: response.response.responseText,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
109 message: response.message,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
110 fileName: file.config.fileApiObject.name,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
111 title: 'Importergebnis'
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
112 });
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
113 win.show();
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
116 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
117 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
118 */
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
119 uploadFailure: function(file, response) {
809
3bc19188fc3a Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents: 730
diff changeset
120 // TODO handle Errors correctly, especially AuthenticationTimeouts
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 this.close();
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
122 var win = Ext.create('Lada.view.window.ImportResponse', {
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
123 data: response.response.responseText,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
124 message: response.message,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
125 fileName: file.config.fileApiObject.name,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
126 title: 'Importergebnis'
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
127 });
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
128 win.show();
725
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 }
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 });

http://lada.wald.intevation.org