Mercurial > lada > lada-client
annotate app/view/window/FileUpload.js @ 1186:a1c480be0b79 schema-update
Load status_kombi store on application launch.
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 31 Aug 2016 15:59:28 +0200 |
parents | f73ca04d73a7 |
children | 4b456449029c |
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', |
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 |
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 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
|
16 |
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 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
|
18 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
19 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
20 * This function initialises the Window |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
21 */ |
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
|
22 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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 }); |
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 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
|
29 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
|
30 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
|
31 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
|
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.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
|
35 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
|
36 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
|
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 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
|
39 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
|
40 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
|
41 }, { |
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 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
|
43 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
|
44 }]; |
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.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
|
46 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
|
47 }, 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
|
48 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
|
49 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
|
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 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
52 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
53 * @private |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
54 * A handler for a Abort-Button |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
55 */ |
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
|
56 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
|
57 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
|
58 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
|
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 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
61 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
62 * @private |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
63 * A handler for the Input field |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
64 */ |
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
|
65 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
|
66 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
|
67 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
|
68 }); |
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 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
|
70 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
|
71 }, |
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 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
73 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
74 * @private |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
75 * A handler for the Upload-Button |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
76 */ |
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
|
77 uploadFile: function(button) { |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
730
diff
changeset
|
78 // 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
|
79 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
|
80 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
|
81 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
|
82 '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
|
83 }, |
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 method: 'POST', |
999 | 85 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
|
86 }); |
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 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
|
88 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
|
89 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
|
90 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
|
91 } |
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 }, |
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 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
94 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
95 * @private |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
96 */ |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
97 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
|
98 this.close(); |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
99 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
|
100 data: response.response.responseText, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
101 message: response.message, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
102 fileName: file.config.fileApiObject.name, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
103 title: 'Importergebnis' |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
104 }); |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
105 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
|
106 }, |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
107 |
890
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
108 /** |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
109 * @private |
def27cdd0dfa
Added Documentation to Windows
Dustin Demuth <dustin@intevation.de>
parents:
809
diff
changeset
|
110 */ |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
111 uploadFailure: function(file, response) { |
809
3bc19188fc3a
Added some todos, Enhanced Proge-Generation Success Msg.
Dustin Demuth <dustin@intevation.de>
parents:
730
diff
changeset
|
112 // 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
|
113 this.close(); |
730
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
114 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
|
115 data: response.response.responseText, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
116 message: response.message, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
117 fileName: file.config.fileApiObject.name, |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
118 title: 'Importergebnis' |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
119 }); |
66812ad4b720
Show the window for importer response messages.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
727
diff
changeset
|
120 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
|
121 } |
83c571b022f3
Added window for laf file upload and use filtergrid buttons to export or import.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff
changeset
|
122 }); |