changeset 809:3bc19188fc3a

Added some todos, Enhanced Proge-Generation Success Msg.
author Dustin Demuth <dustin@intevation.de>
date Fri, 22 May 2015 16:14:14 +0200
parents c135201940ee
children a5373ee662e2
files app.js app/controller/FilterResult.js app/view/window/FileUpload.js app/view/window/GenProbenFromMessprogramm.js resources/i18n/Lada_de-DE.properties
diffstat 5 files changed, 55 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/app.js	Fri May 22 15:59:40 2015 +0200
+++ b/app.js	Fri May 22 16:14:14 2015 +0200
@@ -107,7 +107,6 @@
     },
 
     onLoginSuccess: function(response) {
-        Lada.serverversion = this.getServerVersion();
 
         if (!Ext.isIE9m) {
           /* Strip out the openid query params to look nicers. */
@@ -123,6 +122,8 @@
         Lada.userroles = json.data.roles;
         Lada.logintime = json.data.servertime;
         Lada.mst = json.data.mst; //Store Messstellen this user may select
+        //Lada.serverVersion
+        this.getServerVersion();
 
         Ext.create('Lada.store.Datenbasis', {
             storeId: 'datenbasis'
--- a/app/controller/FilterResult.js	Fri May 22 15:59:40 2015 +0200
+++ b/app/controller/FilterResult.js	Fri May 22 16:14:14 2015 +0200
@@ -133,6 +133,7 @@
                 saveAs(blob, 'export.laf');
             },
             failure: function() {
+                // TODO handle Errors correctly, especially AuthenticationTimeouts
                 Ext.Msg.create(i18n.getMsg('err.msg.generic.title'),
                     i18n.getMsg('err.msg.laf.filecreatefailed'));
             }
--- a/app/view/window/FileUpload.js	Fri May 22 15:59:40 2015 +0200
+++ b/app/view/window/FileUpload.js	Fri May 22 16:14:14 2015 +0200
@@ -59,6 +59,7 @@
     },
 
     uploadFile: function(button) {
+        // TODO Error handling ?
         var win = button.up('window');
         var uploader = Ext.create('Ext.ux.upload.uploader.ExtJsUploader', {
             extraHeaders: {
@@ -86,6 +87,7 @@
     },
 
     uploadFailure: function(file, response) {
+        // TODO handle Errors correctly, especially AuthenticationTimeouts
         this.close();
         var win = Ext.create('Lada.view.window.ImportResponse', {
             data: response.response.responseText,
--- a/app/view/window/GenProbenFromMessprogramm.js	Fri May 22 15:59:40 2015 +0200
+++ b/app/view/window/GenProbenFromMessprogramm.js	Fri May 22 16:14:14 2015 +0200
@@ -48,11 +48,36 @@
                         'X-OPENID-PARAMS': Lada.openIDParams
                     },
                     jsonData: jsondata,
-                    success: function(form, action) {
-                        Ext.Msg.alert('Success', action.result.msg);
+                    success: function(response) {
+                        var json = Ext.JSON.decode(response.responseText);
+                        console.log(json);
+                        Ext.Msg.show({
+                            title: i18n.getMsg('success'),
+                            autoScroll: true,
+                            msg: me.evalResponse(json),
+                            buttons: Ext.Msg.OK,
+                        });
                     },
-                    failure: function(form, action) {
-                        Ext.Msg.alert('Failed', action.result.msg);
+                    failure: function(response) {
+                    // TODO handle Errors correctly, especially AuthenticationTimeouts
+                        var json = Ext.JSON.decode(response.responseText);
+                        if (json) {
+                            if(json.errors.totalCount > 0 || json.warnings.totalCount > 0){
+                                formPanel.setMessages(json.errors, json.warnings);
+                            }
+
+                            if(json.message){
+                                Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title')
+                                    +' #'+json.message,
+                                    Lada.getApplication().bundle.getMsg(json.message));
+                            } else {
+                                Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
+                                    Lada.getApplication().bundle.getMsg('err.msg.generic.body'));
+                            }
+                        } else {
+                            Ext.Msg.alert(Lada.getApplication().bundle.getMsg('err.msg.save.title'),
+                                Lada.getApplication().bundle.getMsg('err.msg.response.body'));
+                        }
                     }
                 });
             }
@@ -120,4 +145,22 @@
         var i18n = Lada.getApplication().bundle;
         me = this;
     },
+
+    /**
+     * Parse ServerResponse when Proben have been generated
+     */
+    evalResponse: function(response) {
+        var i18n = Lada.getApplication().bundle;
+        var r = '';
+            r += response.totalCount;
+            r += ' ' + i18n.getMsg('probecreated');
+            r += '<br/>';
+            r += i18n.getMsg('probeids');
+        var i;
+            for (i in response.data){
+                r += '<br/>';
+                r += response.data[i].probeIdAlt
+            }
+        return r;
+    }
 });
--- a/resources/i18n/Lada_de-DE.properties	Fri May 22 15:59:40 2015 +0200
+++ b/resources/i18n/Lada_de-DE.properties	Fri May 22 16:14:14 2015 +0200
@@ -117,6 +117,7 @@
 ##
 # Msg:
 ##
+success:Erfolg
 err.msg.save.title:Fehler beim Speichern
 err.msg.delete.title:Fehler beim Löschen
 err.msg.generic.title:Fehler
@@ -126,7 +127,8 @@
 err.msg.novalidmessprogramm:Es wurd kein valides Messprogramm ausgewählt
 
 err.msg.deskriptorvalidation:Die Deskriptoren haben das falsche Format.<br />Richtig wäre: D: 99 99 99 99 99 99 99 99 99 99 99 99'
-
+probecreated:Probe(n) wurde(n) erzeugt.
+probeids:Die ID(s) der Probe(n) ist/sind:
 
 ##
 # Probenintervalle:

http://lada.wald.intevation.org