Ext.define('treps.controller.Steps.ExportDefinitionStep', { extend: 'treps.controller.Steps.BaseStep', views: [ 'Steps.ExportDefinition.ExportDefinitionPanel' ], init: function() { var me = this }, onAfterLoad: function(store, records, successful, eOpts) { var gridController = treps.app.getController('Data.Grid.ResultDataGrid'); gridController.setTotalInHeader(store.totalCount); }, doRequest: function(afterrequest) { var timeController = treps.app.getController('Times.ExportTimeSelection'); var exportController = treps.app.getController('Export.ExportSelection'); var args = { 'id' : treps.model.Session.get('id'), 'format' : exportController.getExportFormat(), 'structure' : exportController.getExportStructure(), 'timeformat' : timeController.getTimeFormat(), 'timepattern' : timeController.getTimePattern() }; treps.LoadMask.show("Build exported file. please wait ... "); TREPSAction.exportOperation(args, function(result, event) { treps.LoadMask.hide(); if (!result) { treps.Messages.showError("Internal error during exportOperation request"); return; } else if (!result.success) { treps.Messages.showError(result.error); return; } treps.model.Session.set('exportFormat',exportController.getExportFormat()); afterrequest.call(); } ); }, doInitStep: function() { var me = this; var session = treps.model.Session; var timeController = treps.app.getController('Times.ExportTimeSelection'); var gridController = treps.app.getController('Data.Grid.ResultDataGrid'); var plotController = treps.app.getController('Data.Plot.ResultDataPlot'); var exportController = treps.app.getController('Export.ExportSelection'); var dataStoreManager = treps.controller.Data.Store.DataStoreManager; //get format and structure file list treps.LoadMask.show("Load export structures list. Please wait ..."); exportController.initStores(function (formatsStore, structuresStore) { treps.LoadMask.hide(); //load times list treps.LoadMask.show("Load time formats list. Please wait ..."); timeController.initStore(function (timesStore) { treps.LoadMask.hide(); timeController.setTime(session.get('sourceTimeFormat')); //get result data info, create result data store, and reconfigure the data grid treps.LoadMask.show("Get result data info. Please wait ..."); TREPSAction.getResultInfo({'id' : session.get('id')}, function(result, event) { treps.LoadMask.hide(); if (!result) { treps.Messages.showError("Internal error during resultInfo request"); return; } else if (!result.success) { treps.Messages.showError(result.error); return; } //create model fields var modelFields = dataStoreManager.createModelFields(result.info.fields); //create result data model dataStoreManager.defineModel(gridController.getDataModelName(),modelFields); //reconfigure the result data store var store = dataStoreManager.reconfigureStore( gridController.getDataStoreId(), gridController.getDataModelName(), TREPSAction.getResultData, me.onAfterLoad); if (!store) { treps.Messages.showError("Error during result data store reconfiguration"); return; } //reconfigure grid gridController.reconfigureDataGrid(result.info.nbRecords, result.info.fields); var resVectors = result.info.vectors; //get transformation info treps.LoadMask.show("Get transformation info. Please wait ..."); TREPSAction.getRunInfo({'id' : session.get('id')}, function(result, event) { treps.LoadMask.hide(); if (!result) { treps.Messages.showError("Internal error during runInfo request"); return; } else if (!result.success) { treps.Messages.showError(result.error); return; } exportController.setExportStructureEnabled(result.info.srcFrame != result.info.dstFrame); //reconfigure plot plotController.reconfigureDataPlot(result.info.vectors, resVectors, result.info.srcFrame, result.info.dstFrame); }); } ); } ); } ); }, isValidStep: function() { var timeController = treps.app.getController('Times.ExportTimeSelection'); if (!timeController.isValid()) return false; var exportController = treps.app.getController('Export.ExportSelection'); if (!exportController.isValid()) return false; return true; } });