[Lada-commits] [PATCH 4 of 4] Error messages from LADA server are not related to HTTP errors
Wald Commits
scm-commit at wald.intevation.org
Fri Sep 30 10:57:19 CEST 2016
# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1475225778 -7200
# Node ID 613e48a3fef95bcde090938c5d29953b6f715383
# Parent 95d24315d68eca1a282b652341f2447b7d91b6b2
Error messages from LADA server are not related to HTTP errors.
diff -r 95d24315d68e -r 613e48a3fef9 app/view/window/GenProbenFromMessprogramm.js
--- a/app/view/window/GenProbenFromMessprogramm.js Fri Sep 30 10:36:47 2016 +0200
+++ b/app/view/window/GenProbenFromMessprogramm.js Fri Sep 30 10:56:18 2016 +0200
@@ -143,142 +143,149 @@
var i18n = Lada.getApplication().bundle;
var json = Ext.JSON.decode(response.responseText);
- var radio = Ext.ComponentQuery.query('modeswitcher')[0]
- .down('radiofield[inputValue=proben]');
- radio.setValue(true);
- var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0]
- .down('panel[name=contentpanel]');
- contentPanel.removeAll(); //clear the panel: make space for new grids
- var gridstore = Ext.create('Lada.store.Proben');
- var frgrid = Ext.create('Lada.view.grid.ProbeList', {
- plugins: [{
- ptype: 'gridrowexpander',
- gridType: 'Lada.view.grid.Messung',
- expandOnDblClick: false,
- gridConfig: {
- bottomBar: false
+ if (json.message != '200') {
+ // handle LADA server errors
+ Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
+ i18n.getMsg(json.message));
+ } else {
+ var radio = Ext.ComponentQuery.query('modeswitcher')[0]
+ .down('radiofield[inputValue=proben]');
+ radio.setValue(true);
+
+ var contentPanel = Ext.ComponentQuery.query('panel[name=main]')[0]
+ .down('panel[name=contentpanel]');
+ contentPanel.removeAll(); //clear panel: make space for new grids
+ var gridstore = Ext.create('Lada.store.Proben');
+ var frgrid = Ext.create('Lada.view.grid.ProbeList', {
+ plugins: [{
+ ptype: 'gridrowexpander',
+ gridType: 'Lada.view.grid.Messung',
+ expandOnDblClick: false,
+ gridConfig: {
+ bottomBar: false
+ }
+ }]
+ });
+
+ var columns = [{
+ header: i18n.getMsg('prnId'),
+ dataIndex: 'probeIdAlt'
+ }, {
+ header: i18n.getMsg('netzbetreiberId'),
+ dataIndex: 'netzbetreiberId',
+ renderer: function(value) {
+ var r = '';
+ if (!value || value === '') {
+ r = 'Error';
+ }
+ var store = Ext.data.StoreManager.get('netzbetreiber');
+ var record = store.getById(value);
+ if (record) {
+ r = record.get('netzbetreiber');
+ }
+ return r;
}
- }]
- });
+ }, {
+ header: i18n.getMsg('mstId'),
+ dataIndex: 'mstId',
+ renderer: function(value) {
+ var r = '';
+ if (!value || value === '') {
+ r = 'Error';
+ }
+ var store = Ext.data.StoreManager.get('messstellen');
+ var record = store.getById(value);
+ if (record) {
+ r = record.get('messStelle');
+ }
+ return r;
+ }
+ }, {
+ header: i18n.getMsg('datenbasisId'),
+ dataIndex: 'datenbasisId',
+ renderer: function(value) {
+ var r = '';
+ if (!value || value === '') {
+ r = value;
+ }
+ var store = Ext.data.StoreManager.get('datenbasis');
+ var record = store.getById(value);
+ if (record) {
+ r = record.get('datenbasis');
+ }
+ return r;
+ }
+ }, {
+ header: i18n.getMsg('baId'),
+ dataIndex: 'baId',
+ renderer: function(value) {
+ var r = '';
+ if (!value || value === '') {
+ r = '';
+ }
+ var store = Ext.create('Ext.data.Store', {
+ fields: ['betriebsartId', 'betriebsart'],
+ data: [{
+ 'betriebsartId': '1',
+ 'betriebsart': 'Normal-/Routinebetrieb'
+ }, {
+ 'betriebsartId': '2',
+ 'betriebsart': 'Störfall/Intensivbetrieb'
+ }]
+ });
+ var record = store.getById(value);
+ if (record) {
+ r = record.get('betriebsart');
+ }
+ return r;
+ }
+ }, {
+ header: i18n.getMsg('probenartId'),
+ dataIndex: 'probenartId',
+ renderer: function(value) {
+ var r = '';
+ if (!value || value === '') {
+ r = value;
+ }
+ var store = Ext.data.StoreManager.get('probenarten');
+ var record = store.getById(value);
+ if (record) {
+ r = record.get('probenart');
+ }
+ return r;
+ }
+ }, {
+ header: i18n.getMsg('sollVon'),
+ dataIndex: 'solldatumBeginn',
+ renderer: function(value) {
+ if (!value) {
+ return '';
+ }
+ return Ext.Date.format(value, 'd.m.Y');
+ }
+ }, {
+ header: i18n.getMsg('sollBis'),
+ dataIndex: 'solldatumEnde',
+ renderer: function(value) {
+ if (!value) {
+ return '';
+ }
+ return Ext.Date.format(value, 'd.m.Y');
+ }
+ }];
+ frgrid.reconfigure(gridstore, columns);
- var columns = [{
- header: i18n.getMsg('prnId'),
- dataIndex: 'probeIdAlt'
- }, {
- header: i18n.getMsg('netzbetreiberId'),
- dataIndex: 'netzbetreiberId',
- renderer: function(value) {
- var r = '';
- if (!value || value === '') {
- r = 'Error';
- }
- var store = Ext.data.StoreManager.get('netzbetreiber');
- var record = store.getById(value);
- if (record) {
- r = record.get('netzbetreiber');
- }
- return r;
- }
- }, {
- header: i18n.getMsg('mstId'),
- dataIndex: 'mstId',
- renderer: function(value) {
- var r = '';
- if (!value || value === '') {
- r = 'Error';
- }
- var store = Ext.data.StoreManager.get('messstellen');
- var record = store.getById(value);
- if (record) {
- r = record.get('messStelle');
- }
- return r;
- }
- }, {
- header: i18n.getMsg('datenbasisId'),
- dataIndex: 'datenbasisId',
- renderer: function(value) {
- var r = '';
- if (!value || value === '') {
- r = value;
- }
- var store = Ext.data.StoreManager.get('datenbasis');
- var record = store.getById(value);
- if (record) {
- r = record.get('datenbasis');
- }
- return r;
- }
- }, {
- header: i18n.getMsg('baId'),
- dataIndex: 'baId',
- renderer: function(value) {
- var r = '';
- if (!value || value === '') {
- r = '';
- }
- var store = Ext.create('Ext.data.Store', {
- fields: ['betriebsartId', 'betriebsart'],
- data: [{
- 'betriebsartId': '1',
- 'betriebsart': 'Normal-/Routinebetrieb'
- }, {
- 'betriebsartId': '2',
- 'betriebsart': 'Störfall/Intensivbetrieb'
- }]
- });
- var record = store.getById(value);
- if (record) {
- r = record.get('betriebsart');
- }
- return r;
- }
- }, {
- header: i18n.getMsg('probenartId'),
- dataIndex: 'probenartId',
- renderer: function(value) {
- var r = '';
- if (!value || value === '') {
- r = value;
- }
- var store = Ext.data.StoreManager.get('probenarten');
- var record = store.getById(value);
- if (record) {
- r = record.get('probenart');
- }
- return r;
- }
- }, {
- header: i18n.getMsg('sollVon'),
- dataIndex: 'solldatumBeginn',
- renderer: function(value) {
- if (!value) {
- return '';
- }
- return Ext.Date.format(value, 'd.m.Y');
- }
- }, {
- header: i18n.getMsg('sollBis'),
- dataIndex: 'solldatumEnde',
- renderer: function(value) {
- if (!value) {
- return '';
- }
- return Ext.Date.format(value, 'd.m.Y');
- }
- }];
- frgrid.reconfigure(gridstore, columns);
-
- gridstore.loadData(json.data);
- contentPanel.add(frgrid);
- Ext.Msg.show({
- title: i18n.getMsg('success'),
- autoScroll: true,
- msg: me.evalResponse(json),
- buttons: Ext.Msg.OK
- });
- me.close();
+ gridstore.loadData(json.data);
+ contentPanel.add(frgrid);
+ Ext.Msg.show({
+ title: i18n.getMsg('success'),
+ autoScroll: true,
+ msg: me.evalResponse(json),
+ buttons: Ext.Msg.OK
+ });
+ me.close();
+ }
},
/**
@@ -316,14 +323,8 @@
this.reload);
}
// further error handling
- if(json.message){
- Ext.Msg.alert(i18n.getMsg('err.msg.generic.title')
- +' #'+json.message,
- i18n.getMsg(json.message));
- } else {
- Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
- i18n.getMsg('err.msg.generic.body'));
- }
+ Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
+ i18n.getMsg('err.msg.generic.body'));
} else {
Ext.Msg.alert(i18n.getMsg('err.msg.generic.title'),
i18n.getMsg('err.msg.response.body'));
More information about the Lada-commits
mailing list