annotate app/view/window/FileUpload.js @ 1225:19855757a950

Fix status reset.
author Tom Gottfried <tom@intevation.de>
date Thu, 27 Oct 2016 19:28:41 +0200
parents 4e62bc6e7250
children 848b50a4a4eb
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',
1222
4e62bc6e7250 Fixed parsing of empty data and require the import response window.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1221
diff changeset
14 requires: ['Lada.view.window.ImportResponse'],
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
15
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 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
17
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 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
19
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
20 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
21 * This function initialises the Window
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
22 */
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
23 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
24 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
25 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
26 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
27 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
28 });
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 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
30 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
31 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
32 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
33 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
34 });
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 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
36 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
37 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
38 ];
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 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
40 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
41 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
42 }, {
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 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
44 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
45 }];
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 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
47 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
48 }, 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
49 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
50 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
51 },
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
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
53 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
54 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
55 * A handler for a Abort-Button
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
56 */
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
57 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
58 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
59 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
60 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
62 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
63 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
64 * A handler for the Input field
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
65 */
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
66 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
67 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
68 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
69 });
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 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
71 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
72 },
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
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
74 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
75 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
76 * A handler for the Upload-Button
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
77 */
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
78 uploadFile: function(button) {
809
3bc19188fc3a Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents: 730
diff changeset
79 // 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
80 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
81 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
82 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
83 '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
84 },
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 method: 'POST',
1221
4b456449029c Increased request timeout and set loading mask.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 999
diff changeset
86 timeout: 600 * 1000,
999
f73ca04d73a7 Refactored Server URL
Dustin Demuth <dustin@intevation.de>
parents: 890
diff changeset
87 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
88 });
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 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
90 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
91 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
92 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
93 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
94 }
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 },
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
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
97 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
98 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
99 */
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
100 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
101 this.close();
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
102 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
103 data: response.response.responseText,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
104 message: response.message,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
105 fileName: file.config.fileApiObject.name,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
106 title: 'Importergebnis'
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
107 });
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
108 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
109 },
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110
890
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
111 /**
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
112 * @private
def27cdd0dfa Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents: 809
diff changeset
113 */
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
114 uploadFailure: function(file, response) {
809
3bc19188fc3a Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents: 730
diff changeset
115 // 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
116 this.close();
730
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
117 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
118 data: response.response.responseText,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
119 message: response.message,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
120 fileName: file.config.fileApiObject.name,
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
121 title: 'Importergebnis'
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
122 });
66812ad4b720 Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 727
diff changeset
123 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
124 }
83c571b022f3 Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 });

http://lada.wald.intevation.org