Mercurial > lada > lada-client
annotate app/view/window/FileUpload.js @ 887:786c8b7e5ecc
Removed obsolete store listeners.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Thu, 23 Jul 2015 16:22:31 +0200 |
parents | 3bc19188fc3a |
children | def27cdd0dfa |
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 /** |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
10 */ |
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 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
|
12 extend: 'Ext.window.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
|
13 |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
14 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
|
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 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
|
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 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
|
19 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
|
20 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
|
21 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
|
22 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
|
23 }); |
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 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 }); |
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.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
|
31 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
|
32 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
|
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.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
|
35 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
|
36 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
|
37 }, { |
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 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
|
39 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
|
40 }]; |
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.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
|
42 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
|
43 }, 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
|
44 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
|
45 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
|
46 }, |
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 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
|
49 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
|
50 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
|
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 |
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 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
|
54 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
|
55 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
|
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 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
|
58 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
|
59 }, |
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 uploadFile: function(button) { |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
730
diff
changeset
|
62 // 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
|
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 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
|
65 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
|
66 '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
|
67 }, |
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 method: 'POST', |
727
e002234d7da5
Corrected URL for lada-server in export and import
Dustin Demuth <dustin@intevation.de>
parents:
725
diff
changeset
|
69 url: 'lada-server/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
|
70 }); |
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.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
|
72 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
|
73 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
|
74 uploader.uploadItem(button.up('window').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
|
75 } |
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 }, |
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 |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
78 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
|
79 this.close(); |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
80 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
|
81 data: response.response.responseText, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
82 message: response.message, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
83 fileName: file.config.fileApiObject.name, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
84 title: 'Importergebnis' |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
85 }); |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
86 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
|
87 }, |
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 |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
89 uploadFailure: function(file, response) { |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
730
diff
changeset
|
90 // 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
|
91 this.close(); |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
92 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
|
93 data: response.response.responseText, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
94 message: response.message, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
95 fileName: file.config.fileApiObject.name, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
96 title: 'Importergebnis' |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
97 }); |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
98 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
|
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 }); |