raimund@729: /**
dustin@890: * This Window is shown, when Proben could be imported from a LAF file
raimund@729: */
raimund@729: Ext.define('Lada.view.window.ImportResponse', {
raimund@729: extend: 'Ext.window.Window',
raimund@729: alias: 'widget.importresponse',
raimund@729:
raimund@729: data: null,
raimund@729: message: null,
raimund@729: fileName: '',
raimund@729:
raimund@729: layout: 'fit',
raimund@729: /**
raimund@729: * @private
raimund@729: * Initialize the view.
raimund@729: */
raimund@729: initComponent: function() {
raimund@729: var me = this;
raimund@729: var html;
raimund@729: if (me.data && me.message) {
raimund@729: html = me.parseResponse(me.message, me.data);
raimund@729: }
raimund@729: this.bodyStyle = {background: '#fff'};
raimund@729: me.items = [{
raimund@729: xtype: 'panel',
raimund@729: html: html,
raimund@729: margin: 10,
raimund@729: border: false
raimund@729: }];
raimund@729:
raimund@729: this.callParent(arguments);
raimund@729: },
raimund@729:
dustin@890: /**
dustin@890: * Parse the Response
dustin@890: * @param msg the Lada-Erro-Code
dustin@890: * @param data the payload of the response
dustin@890: */
raimund@729: parseResponse: function(msg, data) {
raimund@729: console.log(Ext.JSON.decode(data));
raimund@729: data = Ext.JSON.decode(data);
raimund@729: var errors = data.data.errors;
raimund@729: var warnings = data.data.warnings;
raimund@729: var out = [];
raimund@729: // There is a entry for each imported proben in the errors dict (might be
raimund@729: // empty)
raimund@729:
raimund@729: var numErrors;
raimund@729: var numWarnings;
raimund@729: if (Ext.isEmpty(Object.keys(errors))) {
raimund@729: numErrors = 0;
raimund@729: }
raimund@729: else {
raimund@729: numErrors = Object.keys(errors).length;
raimund@729: }
raimund@729: if (Ext.isEmpty(Object.keys(warnings))) {
raimund@729: numWarnings = 0;
raimund@729: }
raimund@729: else {
raimund@729: numWarnings = Object.keys(warnings).length;
raimund@729: }
raimund@729: if (msg !== '200') {
raimund@729: out.push('Der Import der Datei ' + this.fileName +
raimund@729: ' war nicht erfolgreich. Der Importvorgang konnte ' +
raimund@729: 'aufgrund eines Fehlers im Server nicht beendet werden.');
raimund@729: }
raimund@729: else {
raimund@729: if (numErrors > 0) {
raimund@729: out.push('Folgende Proben konnten nicht erfolgreich ' +
raimund@729: 'importiert werden:');
raimund@729: out.push('
');
raimund@729: out.push('