diff --git a/js/app/controllers/EpnTapModule.js b/js/app/controllers/EpnTapModule.js index d4993f3..b330a24 100644 --- a/js/app/controllers/EpnTapModule.js +++ b/js/app/controllers/EpnTapModule.js @@ -265,7 +265,16 @@ Ext.define('amdaDesktop.EpnTapModule', { Trigerred when the 'Get results' button is clicked. */ onGetBtnClicked: function() { - console.log('Getting results...'); + var targetName = this.targetNameCB.rawValue; + var productType = this.productTypeCB.value; + var timeMin = Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'); // start time + var timeMax = Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s'); // stop time + + this.servicesStore.each(function(record) { + var url = record.data['access_url']; + var tableName = record.data['table_name']; + AmdaAction.epnTapGetNbResults(url, tableName, targetName, productType, timeMin, timeMax, this.updateNbResults); + }, this); }, /******************* @@ -313,21 +322,22 @@ Ext.define('amdaDesktop.EpnTapModule', { /** Update the nb_result field of the services store (see `EpnTapUI.servicesStore`), according to the field values in `serviceFilterPanel`. */ - updateNbResults: function() { - if(this.productTypeCB.value === 'all' && !this.launchedFromTree ) { - var filter = [ - {property: "dataproduct_type", value: this.productTypeCB.value} - ]; - } else if(this.targetNameCB.value === 'all') { - var filter = [ - {property: "dataproduct_type", value: this.productTypeCB.value} - ]; - } else { - var filter = [ - {property: "dataproduct_type", value: this.productTypeCB.value}, - {property: "target_name", value: this.targetNameCB.value} - ]; - } + updateNbResults: function(nbResults) { + console.log(' php:' + nbResults + ' ; js:' + (new Date()).getSeconds()); + // if(this.productTypeCB.value === 'all' && !this.launchedFromTree ) { + // var filter = [ + // {property: "dataproduct_type", value: this.productTypeCB.value} + // ]; + // } else if(this.targetNameCB.value === 'all') { + // var filter = [ + // {property: "dataproduct_type", value: this.productTypeCB.value} + // ]; + // } else { + // var filter = [ + // {property: "dataproduct_type", value: this.productTypeCB.value}, + // {property: "target_name", value: this.targetNameCB.value} + // ]; + // } // this.servicesStore.each(function(record, idx) { // this.metadataStore.filter(filter.concat({property: 'service_id', value: record.get('id')})); @@ -338,8 +348,10 @@ Ext.define('amdaDesktop.EpnTapModule', { // // var timeMin = this.metadataStore.min('time_min'); // var timeMax = this.metadataStore.max('time_max'); - this.timeSelector.setLimits(timeMin, timeMax); - this.timeSelector.setInterval(timeMin, timeMax); + + + // this.timeSelector.setLimits(timeMin, timeMax); + // this.timeSelector.setInterval(timeMin, timeMax); }, /** diff --git a/js/app/views/EpnTapUI.js b/js/app/views/EpnTapUI.js index 7ad4bad..eabb2cb 100644 --- a/js/app/views/EpnTapUI.js +++ b/js/app/views/EpnTapUI.js @@ -190,7 +190,7 @@ Ext.define('amdaUI.EpnTapUI', { */ createServiceFilterPanel: function() { return { - xtype: 'panel', + xtype: 'form', id: 'epnTapServiceFilterPanel', layout: { type: 'hbox', pack: 'start', align: 'stretch' }, region: 'north', diff --git a/js/app/views/IntervalUI.js b/js/app/views/IntervalUI.js index 0b2c2fb..9639d3d 100644 --- a/js/app/views/IntervalUI.js +++ b/js/app/views/IntervalUI.js @@ -191,6 +191,7 @@ Ext.define('amdaUI.IntervalUI', { enforceMaxLength: true, maxLength: 19, fieldLabel: fieldText, + labelAlign: 'left', labelWidth: 60, listeners: { change: onChangeField, @@ -221,6 +222,7 @@ Ext.define('amdaUI.IntervalUI', { margin: 0, defaults: { xtype: 'textfield', + labelAlign: 'left', width: 35, margin: '0 5 0 0', allowBlank: false, maxLength:2, enforceMaxLength : true, diff --git a/php/classes/AmdaAction.php b/php/classes/AmdaAction.php index 95303eb..7cf5ea0 100644 --- a/php/classes/AmdaAction.php +++ b/php/classes/AmdaAction.php @@ -1341,16 +1341,14 @@ class AmdaAction { return array('success' => true, 'alreadyUsed' => $alreadyUsed); } - public function epnTapGetGranules($table_name, $access_url, $filter, $limit, $offset) { - return (new EpnTapMgr)->getGranules($table_name, $access_url, $filter, $limit, $offset); + public function epnTapGetNbResults( $url, $tableName, $targetName, $productType, $timeMin, $timeMax) { + // return (new EpnTapMgr)->getNbResults($url, $tableName, $targetName, $productType, $timeMin, $timeMax); + (new EpnTapMgr)->getNbResults($url, $tableName, $targetName, $productType, $timeMin, $timeMax); + return date('s'); } - public function epnTapGetNbRows($table_name, $access_url, $filter) { - return (new EpnTapMgr)->getNbRows($table_name, $access_url, $filter); - } - - public function epnTapGetServices() { - return (new EpnTapMgr)->getServices(); + public function epnTapGetGranules( $url, $tableName, $targetName, $productType, $timeMin, $timeMax, $limit, $offset) { + return (new EpnTapMgr)->getGranules($url, $tableName, $targetName, $productType, $timeMin, $timeMax, $limit, $offset); } } diff --git a/php/classes/EpnTapMgr.php b/php/classes/EpnTapMgr.php index 171761e..5068eb7 100644 --- a/php/classes/EpnTapMgr.php +++ b/php/classes/EpnTapMgr.php @@ -20,16 +20,20 @@ class EpnTapMgr { return ($date == '0000/00/00') ? '' : $date; } - public function createFilter($dataproduct_type, $target_name, $time_min, $time_max) { + public function createFilter($targetName, $productTypes, $timeMin, $timeMax) { $filter = array(); - if($dataproduct_type) - array_push($filter, "dataproduct_type = '$dataproduct_type'"); - if($target_name) - array_push($filter, "target_name = '$target_name'"); - if($time_min) - array_push($filter, "time_min >= " . $this->dateToJD($time_min)); - if($time_max) - array_push($filter, "time_max <= " . $this->dateToJD($time_max)); + if($targetName) { + array_push($filter, "target_name = '$targetName'"); + } + if($productTypes) { + array_push($filter, "dataproduct_type IN ('" . join("', '", $productTypes) . "')"); + } + if($timeMin) { + array_push($filter, "time_min >= " . $this->dateToJD($timeMin)); + } + if($timeMax) { + array_push($filter, "time_max <= " . $this->dateToJD($timeMax)); + } return (count($filter) > 0 ? ' WHERE ' . join(' AND ', $filter) : ''); } @@ -76,10 +80,11 @@ class EpnTapMgr { return $result; } - /* filter order: product type, target name, time min, time max */ - public function getNbRows($table_name, $access_url, $filter) { - $query = "SELECT COUNT(*) AS nb_rows FROM {$table_name} " . $this->createFilter($filter[0], $filter[1], $filter[2], $filter[3]); - $result = $this->request($access_url, $query)[0]['nb_rows']; + public function getNbResults($url, $tableName, $targetName, $productTypes, $timeMin, $timeMax) { + $query = "SELECT COUNT(*) AS nb_rows FROM $tableName" . $this->createFilter($targetName, $productTypes, $timeMin, $timeMax); + // error_log('Query: ' . $query); + $result = $this->request($url, $query)[0]['nb_rows']; + // error_log('Query result: ' . json_encode($result)); return $result; } diff --git a/php/config.php b/php/config.php index c9a70a6..2f29286 100644 --- a/php/config.php +++ b/php/config.php @@ -384,9 +384,8 @@ $API = array( 'isSharedObjectNameAlreadyUsed' => array( 'len'=>1 ), - 'epnTapGetGranules' => array('len'=>5), - 'epnTapGetNbRows' => array('len'=>3), - 'epnTapGetServices' => array('len'=>0) + 'epnTapGetNbResults' => array('len' => 6), + 'epnTapGetGranules' => array('len' => 8) ) ) ); diff --git a/php/my_config.php b/php/my_config.php index 27bed85..ebee723 100644 --- a/php/my_config.php +++ b/php/my_config.php @@ -7,7 +7,7 @@ */ //AKKA - Path to AMDA_Integration base dir -define('INTEGRATION_BASE_PATH', '/home/benjamin/AMDA-GIT/AMDA_Integration/'); +define('INTEGRATION_BASE_PATH', '/home/nathanael/CDPP/AMDA_CLIENT/AMDA_Integration/'); require_once(INTEGRATION_BASE_PATH.'config/AMDAIntegrationConfig.php'); // @@ -19,12 +19,14 @@ define('ROOT_PATH', '/usr/local/AMDA/DDHTML/'); //AKKA - For compatibility with IHM define('DDHOME', NEWKERNEL_BASE_PATH.'/build/Debug/'); - + define('CEFLIB', '/usr/local/cef/lib'); define('CDFLIB', '/opt/local/lib'); define('SYS_LIBS', '/lib:/usr/lib:/usr/local/lib64'); define('SYS_BIN','/bin:/usr/bin/:/usr/local/bin/'); +define('LOG_DIR', '/home/nathanael/CDPP/AMDA_CLIENT/AMDA_IHM/logs'); + //DD WebServices define('INFOSITE', 'http://cdpp1.cesr.fr/BASE/'); //log for AmdaUpdate/AmdaInstall @@ -32,9 +34,9 @@ define('log', IHM_SRC_DIR.'LOG'); // User apache define('APACHE_USER', 'apache'); // Alias for name of AMDA -define('APACHE_ALIAS', '/NEWAMDA-BENJAMIN/'); +define('APACHE_ALIAS', '/AMDA_JOURDANE/'); //email to send errors from AmdaUpdate/AmdaInstall -define('email','brenard@irap.omp.eu'); +define('email','nathanael.jourdane@irap.omp.eu'); //DDPATH define('DDBIN','/opt/local/bin/'); diff --git a/php/router.php b/php/router.php index c0ad19d..a387c4c 100644 --- a/php/router.php +++ b/php/router.php @@ -1,10 +1,10 @@ <?php /** * router.php - * http://www.ibm.com/developerworks/opensource/library/wa-aj-streamline/ + * http://www.ibm.com/developerworks/opensource/library/wa-aj-streamline/ * @version $Id: router.php 687 2011-12-24 14:36:27Z elena $ */ - + require('config.php'); class ExtAction { @@ -13,17 +13,17 @@ public $data; public $tid; } - + function doRpc($cdata){ global $API; - + try { if(!isset($API[$cdata->action])) { throw new Exception('Call to undefined action: ' . $cdata->action); } $action = $cdata->action; $a = $API[$action]; - + doAroundCalls($a['before'], $cdata); $method = $cdata->method; @@ -41,12 +41,12 @@ ); $o = new $action(); - - $params = isset($cdata->data) && is_array($cdata->data) ? - $cdata->data : array(); - + + $params = isset($cdata->data) && is_array($cdata->data) ? + $cdata->data : array(); + $r['result'] = call_user_func_array(array($o, $method), $params); - + doAroundCalls($mdef['after'], $cdata, $r); doAroundCalls($a['after'], $cdata, $r); } catch(Exception $e) { @@ -54,7 +54,7 @@ $r['message'] = $e->getMessage(); $r['where'] = $e->getTraceAsString(); } - + return $r; } @@ -72,20 +72,20 @@ } -/** +/** * Main */ - define('log',fopen('log','w')); + // define('log',fopen('log','w')); $isForm = false; $isUpload = false; - - + + /* * artificial truc to get $HTTP_RAW_POST_DATA from POST AJAX */ - if ($_SERVER['REQUEST_METHOD'] === 'POST' && !isset($_POST['extAction'])) { -// Read the input from stdin + if ($_SERVER['REQUEST_METHOD'] === 'POST' && !isset($_POST['extAction'])) { +// Read the input from stdin $HTTP_RAW_POST_DATA = trim(file_get_contents('php://input')); } @@ -93,7 +93,7 @@ $usrMgr = new UserMgr(); $usrMgr->setPath(); - + if (isset($HTTP_RAW_POST_DATA)) { header('Content-Type: text/javascript'); $data = json_decode($HTTP_RAW_POST_DATA); @@ -103,18 +103,18 @@ $data = new ExtAction(); $data->action = $_POST['extAction']; $data->method = $_POST['extMethod']; - $data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null; + $data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null; $data->data = array($_POST, $_FILES); - - } - else { + + } + else { die('INVALID REQUEST'); } - - // $RRR = print_r($data->data, true); - // $RRR = print_r($data, true); -// fwrite(log,$RRR.PHP_EOL); - + + // $RRR = print_r($data->data, true); + // $RRR = print_r($data, true); +// fwrite(log,$RRR.PHP_EOL); + $response = null; if(is_array($data)) { @@ -123,7 +123,7 @@ $response[] = doRpc($d); } } else { - + $response = doRpc($data); } @@ -132,8 +132,8 @@ echo json_encode($response); echo '</textarea></body></html>'; } else { - echo json_encode($response); + echo json_encode($response); } - fclose(log); -?> \ No newline at end of file + // fclose(log); +?> -- libgit2 0.21.2