EpnTapModule.js 2.37 KB
/**
 * Project  : AMDA-NG
 * Name	 : EpnTapModule.js
 * @class   amdaDesktop.EpnTapModule
 * @extends amdaDesktop.AmdaModule
 * @brief   EpnTap Module controller definition
 * @author  Nathanael Jourdane
 */

function onWindowLoaded() {
}

function onSearchBtnClicked() {
	var targetName = Ext.getCmp('targetNameCB').value;
	var productType = Ext.getCmp('productTypeCB').value;
	var startTime = Ext.getCmp('startTimeDF').rawValue;
	var stopTime = Ext.getCmp('stopTimeDF').rawValue;

	for(let service of Ext.getCmp('servicesPanel').getStore().getRange()) {
		var filter = Array(service.data.table_name, service.data.access_url, targetName, productType, startTime, stopTime);
		AmdaAction.epnTapMgr('getServiceNbResults', filter, function(epnTapServices) {
			service.set('nb_responses', epnTapServices);
			// console.log(epnTapServices[1]);
		});
	}
}

// var grid = Ext.getCmp('servicesPanel');
// var selection = grid.getSelectionModel();
// access_url = [];
// table_name = [];
// for(i=0 ; i<grid.store.getCount() ; i++) {
// 	if(selection.isSelected(i)) {
// 		table_name.push(grid.store.getAt(i).data.table_name);
// 		access_url.push(grid.store.getAt(i).data.access_url);
// 	}
//
// }

function onServiceSelected(service) {
	var filter = Array(service['table_name'], service['access_url'], Ext.getCmp('targetNameCB').value,
			Ext.getCmp('productTypeCB').value, Ext.getCmp('startTimeDF').rawValue, Ext.getCmp('stopTimeDF').rawValue);

	AmdaAction.epnTapMgr('getGranules', filter, function(granules) {
		console.log(granules);
	});
}

function onGranuleSelected(granule) {
	console.log('selected granule: ' + granule.target_name);
}

Ext.define('amdaDesktop.EpnTapModule', {

	extend: 'amdaDesktop.AmdaModule',

	requires: ['amdaUI.EpnTapUI'],
	contentId : 'EpnTapUI',

	/** The alias name of the module view. */
	uiType: 'panelEpnTap',

	/** The text displayed on the *help button* tooltip. */
	helpTitle: 'Help on EPN-TAP Module',

	/** The name of the documentation file related to the module. */
	helpFile : 'epnTapHelp',

	width : 600,
	height: 550,

	/** @class Module initialisation. */
	init: function() {
		this.launcher = {
			text: this.title,
			iconCls: this.icon,
			handler: this.createWindow,
			scope: this
		};
		this.onWindowLoaded = onWindowLoaded;
		this.onSearchBtnClicked = onSearchBtnClicked;
		this.onGranuleSelected = onGranuleSelected;
		this.onServiceSelected = onServiceSelected;
	}
});