Mercurial > lada > lada-client
changeset 357:94884cd8f8c0
Added logic to upload a file to the server.
author | Torsten Irländer <torsten.irlaender@intevation.de> |
---|---|
date | Tue, 13 Aug 2013 16:21:08 +0200 |
parents | 166203f7119d |
children | 2b4ba307dae1 |
files | app/controller/Proben.js app/view/Viewport.js app/view/proben/Import.js app/view/proben/ImportForm.js app/view/proben/List.js |
diffstat | 5 files changed, 90 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/app/controller/Proben.js Tue Aug 13 12:37:03 2013 +0200 +++ b/app/controller/Proben.js Tue Aug 13 16:21:08 2013 +0200 @@ -5,7 +5,8 @@ extend: 'Lada.controller.Base', views: [ 'proben.Edit', - 'proben.Create' + 'proben.Create', + 'proben.Import' ], stores: [ 'Proben', @@ -27,12 +28,18 @@ 'probenlist toolbar button[action=add]': { click: this.addItem }, + 'probenlist toolbar button[action=import]': { + click: this.selectUploadFile + }, 'probencreate button[action=save]': { click: this.saveItem }, 'probenedit button[action=save]': { click: this.saveItem }, + 'probenimport button[action=save]': { + click: this.uploadItem + }, 'probencreate form': { savesuccess: this.createSuccess, savefailure: this.createFailure @@ -47,6 +54,37 @@ console.log('Adding new Probe'); var view = Ext.widget('probencreate'); }, + /** + * Opens a window with a file chooser to select the file to upload + * @private + */ + selectUploadFile: function(button) { + console.log('Importing'); + var view = Ext.widget('probenimport'); + }, + /** Uploads the selected file the the server + * @private + */ + uploadItem: function(button) { + var win = button.up('window'); + var form = win.down('form'); + if(form.isValid()){ + form.submit({ + url: 'server/rest/proben/import', + waitMsg: 'Importiere...', + // TODO: Handle the response correct. o must must contain the + // filename (None) <2013-08-13 16:17> + success: function(fp, resp) { + Ext.Msg.alert('Erfolg! ', 'Die Datei"' + resp.result.file + '" wurde erfolgreich importiert.'); + win.close(); + }, + failure: function(fp, resp) { + Ext.Msg.alert('Fehler! ', 'Die Datei"' + resp.result.file + '" wurde nicht importiert.'); + win.close(); + } + }); + } + }, editItem: function(grid, record) { console.log('Editing Probe'); var id = record.get('probeId');
--- a/app/view/Viewport.js Tue Aug 13 12:37:03 2013 +0200 +++ b/app/view/Viewport.js Tue Aug 13 16:21:08 2013 +0200 @@ -17,7 +17,7 @@ ], initComponent: function() { console.log('Setting up Viewport'); - //this.initSearch(); + this.initSearch(); // Development related: // Disable "initSearch" call and enable one of the following init @@ -26,9 +26,9 @@ //this.initProbe(); //this.initOrt(); //this.initMessung(); - this.initMesswert(); + //this.initMesswert(); - //this.setInfo(); + this.setInfo(); this.callParent(arguments); }, /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/proben/Import.js Tue Aug 13 16:21:08 2013 +0200 @@ -0,0 +1,28 @@ +/* + * Window to import a Probe + */ +Ext.define('Lada.view.proben.Import', { + extend: 'Ext.window.Window', + alias: 'widget.probenimport', + + title: 'Maske für §3-Proben Import', + autoShow: true, + autoScroll: true, + modal: true, + initComponent: function() { + this.buttons = [ + { + text: 'Speichern', + action: 'save', + }, + { + text: 'Abbrechen', + scope: this, + handler: this.close, + } + ]; + var form = Ext.create('Lada.view.proben.ImportForm'); + this.items = [form]; + this.callParent(); + } +});
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/view/proben/ImportForm.js Tue Aug 13 16:21:08 2013 +0200 @@ -0,0 +1,15 @@ +/* + * Formular to create a Probe + */ +Ext.define('Lada.view.proben.ImportForm', { + extend: 'Ext.form.Panel', + initComponent: function() { + this.items = [ + { + xtype: 'fileuploadfield', + title: 'Importdate' + } + ]; + this.callParent(); + } +});