Mercurial > lada > lada-client
view app/view/window/FileUpload.js @ 764:ba8c0e754979
Some work was done on the nuklidegrid, added a checkbox model to select the nuklide. Looks OK, but has no function right now
author | Dustin Demuth <dustin@intevation.de> |
---|---|
date | Fri, 08 May 2015 15:31:58 +0200 |
parents | 66812ad4b720 |
children | 3bc19188fc3a |
line wrap: on
line source
/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz * Software engineering by Intevation GmbH * * This file is Free Software under the GNU GPL (v>=3) * and comes with ABSOLUTELY NO WARRANTY! Check out * the documentation coming with IMIS-Labordaten-Application for details. */ /** */ Ext.define('Lada.view.window.FileUpload', { extend: 'Ext.window.Window', layout: 'hbox', file: null, initComponent: function() { var me = this; this.browseButton = Ext.create('Ext.ux.upload.BrowseButton', { buttonText: 'Durchsuchen...', margin: '3, 3, 3, 3' }); this.fileInput = Ext.create('Ext.form.field.Text', { allowBlank: false, emptyText: 'Wählen Sie eine Datei', hideLabel: true, margin: '3, 3, 3, 3' }); this.items = [ this.fileInput, this.browseButton ]; this.buttons = [{ text: 'Speichern', handler: this.uploadFile }, { text: 'Abbrechen', handler: this.abort }]; this.on('afterrender', function() { this.browseButton.fileInputEl.dom.removeAttribute('multiple', '0'); }, this); this.browseButton.on('fileselected', this.fileSelected, this); this.callParent(arguments); }, abort: function(button) { var win = button.up('window'); win.close(); }, fileSelected: function(input, file) { var item = Ext.create('Ext.ux.upload.Item', { fileApiObject: file[0] }); this.fileInput.setValue(item.getName()); this.file = item; }, uploadFile: function(button) { var win = button.up('window'); var uploader = Ext.create('Ext.ux.upload.uploader.ExtJsUploader', { extraHeaders: { 'X-OPENID-PARAMS': Lada.openIDParams }, method: 'POST', url: 'lada-server/import/laf' }); this.mon(uploader, 'uploadsuccess', win.uploadSuccess, win); this.mon(uploader, 'uploadfailure', win.uploadFailure, win); if (button.up('window').file !== null) { uploader.uploadItem(button.up('window').file); } }, uploadSuccess: function(file, response) { this.close(); var win = Ext.create('Lada.view.window.ImportResponse', { data: response.response.responseText, message: response.message, fileName: file.config.fileApiObject.name, title: 'Importergebnis' }); win.show(); }, uploadFailure: function(file, response) { this.close(); var win = Ext.create('Lada.view.window.ImportResponse', { data: response.response.responseText, message: response.message, fileName: file.config.fileApiObject.name, title: 'Importergebnis' }); win.show(); } });