Commit 30281591e40a51f7a319124abfd02d0f96b411f9
1 parent
822d60fe
Exists in
master
and in
112 other branches
[WIP] Send requests when the user clicks on GetResults btn
Showing
8 changed files
with
96 additions
and
78 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
... | ... | @@ -265,7 +265,16 @@ Ext.define('amdaDesktop.EpnTapModule', { |
265 | 265 | Trigerred when the 'Get results' button is clicked. |
266 | 266 | */ |
267 | 267 | onGetBtnClicked: function() { |
268 | - console.log('Getting results...'); | |
268 | + var targetName = this.targetNameCB.rawValue; | |
269 | + var productType = this.productTypeCB.value; | |
270 | + var timeMin = Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'); // start time | |
271 | + var timeMax = Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s'); // stop time | |
272 | + | |
273 | + this.servicesStore.each(function(record) { | |
274 | + var url = record.data['access_url']; | |
275 | + var tableName = record.data['table_name']; | |
276 | + AmdaAction.epnTapGetNbResults(url, tableName, targetName, productType, timeMin, timeMax, this.updateNbResults); | |
277 | + }, this); | |
269 | 278 | }, |
270 | 279 | |
271 | 280 | /******************* |
... | ... | @@ -313,21 +322,22 @@ Ext.define('amdaDesktop.EpnTapModule', { |
313 | 322 | /** |
314 | 323 | Update the nb_result field of the services store (see `EpnTapUI.servicesStore`), according to the field values in `serviceFilterPanel`. |
315 | 324 | */ |
316 | - updateNbResults: function() { | |
317 | - if(this.productTypeCB.value === 'all' && !this.launchedFromTree ) { | |
318 | - var filter = [ | |
319 | - {property: "dataproduct_type", value: this.productTypeCB.value} | |
320 | - ]; | |
321 | - } else if(this.targetNameCB.value === 'all') { | |
322 | - var filter = [ | |
323 | - {property: "dataproduct_type", value: this.productTypeCB.value} | |
324 | - ]; | |
325 | - } else { | |
326 | - var filter = [ | |
327 | - {property: "dataproduct_type", value: this.productTypeCB.value}, | |
328 | - {property: "target_name", value: this.targetNameCB.value} | |
329 | - ]; | |
330 | - } | |
325 | + updateNbResults: function(nbResults) { | |
326 | + console.log(' php:' + nbResults + ' ; js:' + (new Date()).getSeconds()); | |
327 | + // if(this.productTypeCB.value === 'all' && !this.launchedFromTree ) { | |
328 | + // var filter = [ | |
329 | + // {property: "dataproduct_type", value: this.productTypeCB.value} | |
330 | + // ]; | |
331 | + // } else if(this.targetNameCB.value === 'all') { | |
332 | + // var filter = [ | |
333 | + // {property: "dataproduct_type", value: this.productTypeCB.value} | |
334 | + // ]; | |
335 | + // } else { | |
336 | + // var filter = [ | |
337 | + // {property: "dataproduct_type", value: this.productTypeCB.value}, | |
338 | + // {property: "target_name", value: this.targetNameCB.value} | |
339 | + // ]; | |
340 | + // } | |
331 | 341 | |
332 | 342 | // this.servicesStore.each(function(record, idx) { |
333 | 343 | // this.metadataStore.filter(filter.concat({property: 'service_id', value: record.get('id')})); |
... | ... | @@ -338,8 +348,10 @@ Ext.define('amdaDesktop.EpnTapModule', { |
338 | 348 | // |
339 | 349 | // var timeMin = this.metadataStore.min('time_min'); |
340 | 350 | // var timeMax = this.metadataStore.max('time_max'); |
341 | - this.timeSelector.setLimits(timeMin, timeMax); | |
342 | - this.timeSelector.setInterval(timeMin, timeMax); | |
351 | + | |
352 | + | |
353 | + // this.timeSelector.setLimits(timeMin, timeMax); | |
354 | + // this.timeSelector.setInterval(timeMin, timeMax); | |
343 | 355 | }, |
344 | 356 | |
345 | 357 | /** |
... | ... |
js/app/views/EpnTapUI.js
... | ... | @@ -190,7 +190,7 @@ Ext.define('amdaUI.EpnTapUI', { |
190 | 190 | */ |
191 | 191 | createServiceFilterPanel: function() { |
192 | 192 | return { |
193 | - xtype: 'panel', | |
193 | + xtype: 'form', | |
194 | 194 | id: 'epnTapServiceFilterPanel', |
195 | 195 | layout: { type: 'hbox', pack: 'start', align: 'stretch' }, |
196 | 196 | region: 'north', |
... | ... |
js/app/views/IntervalUI.js
... | ... | @@ -191,6 +191,7 @@ Ext.define('amdaUI.IntervalUI', { |
191 | 191 | enforceMaxLength: true, |
192 | 192 | maxLength: 19, |
193 | 193 | fieldLabel: fieldText, |
194 | + labelAlign: 'left', | |
194 | 195 | labelWidth: 60, |
195 | 196 | listeners: { |
196 | 197 | change: onChangeField, |
... | ... | @@ -221,6 +222,7 @@ Ext.define('amdaUI.IntervalUI', { |
221 | 222 | margin: 0, |
222 | 223 | defaults: { |
223 | 224 | xtype: 'textfield', |
225 | + labelAlign: 'left', | |
224 | 226 | width: 35, |
225 | 227 | margin: '0 5 0 0', |
226 | 228 | allowBlank: false, maxLength:2, enforceMaxLength : true, |
... | ... |
php/classes/AmdaAction.php
... | ... | @@ -1341,16 +1341,14 @@ class AmdaAction { |
1341 | 1341 | return array('success' => true, 'alreadyUsed' => $alreadyUsed); |
1342 | 1342 | } |
1343 | 1343 | |
1344 | - public function epnTapGetGranules($table_name, $access_url, $filter, $limit, $offset) { | |
1345 | - return (new EpnTapMgr)->getGranules($table_name, $access_url, $filter, $limit, $offset); | |
1344 | + public function epnTapGetNbResults( $url, $tableName, $targetName, $productType, $timeMin, $timeMax) { | |
1345 | + // return (new EpnTapMgr)->getNbResults($url, $tableName, $targetName, $productType, $timeMin, $timeMax); | |
1346 | + (new EpnTapMgr)->getNbResults($url, $tableName, $targetName, $productType, $timeMin, $timeMax); | |
1347 | + return date('s'); | |
1346 | 1348 | } |
1347 | 1349 | |
1348 | - public function epnTapGetNbRows($table_name, $access_url, $filter) { | |
1349 | - return (new EpnTapMgr)->getNbRows($table_name, $access_url, $filter); | |
1350 | - } | |
1351 | - | |
1352 | - public function epnTapGetServices() { | |
1353 | - return (new EpnTapMgr)->getServices(); | |
1350 | + public function epnTapGetGranules( $url, $tableName, $targetName, $productType, $timeMin, $timeMax, $limit, $offset) { | |
1351 | + return (new EpnTapMgr)->getGranules($url, $tableName, $targetName, $productType, $timeMin, $timeMax, $limit, $offset); | |
1354 | 1352 | } |
1355 | 1353 | |
1356 | 1354 | } |
... | ... |
php/classes/EpnTapMgr.php
... | ... | @@ -20,16 +20,20 @@ class EpnTapMgr { |
20 | 20 | return ($date == '0000/00/00') ? '' : $date; |
21 | 21 | } |
22 | 22 | |
23 | - public function createFilter($dataproduct_type, $target_name, $time_min, $time_max) { | |
23 | + public function createFilter($targetName, $productTypes, $timeMin, $timeMax) { | |
24 | 24 | $filter = array(); |
25 | - if($dataproduct_type) | |
26 | - array_push($filter, "dataproduct_type = '$dataproduct_type'"); | |
27 | - if($target_name) | |
28 | - array_push($filter, "target_name = '$target_name'"); | |
29 | - if($time_min) | |
30 | - array_push($filter, "time_min >= " . $this->dateToJD($time_min)); | |
31 | - if($time_max) | |
32 | - array_push($filter, "time_max <= " . $this->dateToJD($time_max)); | |
25 | + if($targetName) { | |
26 | + array_push($filter, "target_name = '$targetName'"); | |
27 | + } | |
28 | + if($productTypes) { | |
29 | + array_push($filter, "dataproduct_type IN ('" . join("', '", $productTypes) . "')"); | |
30 | + } | |
31 | + if($timeMin) { | |
32 | + array_push($filter, "time_min >= " . $this->dateToJD($timeMin)); | |
33 | + } | |
34 | + if($timeMax) { | |
35 | + array_push($filter, "time_max <= " . $this->dateToJD($timeMax)); | |
36 | + } | |
33 | 37 | return (count($filter) > 0 ? ' WHERE ' . join(' AND ', $filter) : ''); |
34 | 38 | } |
35 | 39 | |
... | ... | @@ -76,10 +80,11 @@ class EpnTapMgr { |
76 | 80 | return $result; |
77 | 81 | } |
78 | 82 | |
79 | - /* filter order: product type, target name, time min, time max */ | |
80 | - public function getNbRows($table_name, $access_url, $filter) { | |
81 | - $query = "SELECT COUNT(*) AS nb_rows FROM {$table_name} " . $this->createFilter($filter[0], $filter[1], $filter[2], $filter[3]); | |
82 | - $result = $this->request($access_url, $query)[0]['nb_rows']; | |
83 | + public function getNbResults($url, $tableName, $targetName, $productTypes, $timeMin, $timeMax) { | |
84 | + $query = "SELECT COUNT(*) AS nb_rows FROM $tableName" . $this->createFilter($targetName, $productTypes, $timeMin, $timeMax); | |
85 | + // error_log('Query: ' . $query); | |
86 | + $result = $this->request($url, $query)[0]['nb_rows']; | |
87 | + // error_log('Query result: ' . json_encode($result)); | |
83 | 88 | return $result; |
84 | 89 | } |
85 | 90 | |
... | ... |
php/config.php
... | ... | @@ -384,9 +384,8 @@ $API = array( |
384 | 384 | 'isSharedObjectNameAlreadyUsed' => array( |
385 | 385 | 'len'=>1 |
386 | 386 | ), |
387 | - 'epnTapGetGranules' => array('len'=>5), | |
388 | - 'epnTapGetNbRows' => array('len'=>3), | |
389 | - 'epnTapGetServices' => array('len'=>0) | |
387 | + 'epnTapGetNbResults' => array('len' => 6), | |
388 | + 'epnTapGetGranules' => array('len' => 8) | |
390 | 389 | ) |
391 | 390 | ) |
392 | 391 | ); |
... | ... |
php/my_config.php
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | */ |
8 | 8 | |
9 | 9 | //AKKA - Path to AMDA_Integration base dir |
10 | -define('INTEGRATION_BASE_PATH', '/home/benjamin/AMDA-GIT/AMDA_Integration/'); | |
10 | +define('INTEGRATION_BASE_PATH', '/home/nathanael/CDPP/AMDA_CLIENT/AMDA_Integration/'); | |
11 | 11 | |
12 | 12 | require_once(INTEGRATION_BASE_PATH.'config/AMDAIntegrationConfig.php'); |
13 | 13 | // |
... | ... | @@ -19,12 +19,14 @@ define('ROOT_PATH', '/usr/local/AMDA/DDHTML/'); |
19 | 19 | |
20 | 20 | //AKKA - For compatibility with IHM |
21 | 21 | define('DDHOME', NEWKERNEL_BASE_PATH.'/build/Debug/'); |
22 | - | |
22 | + | |
23 | 23 | define('CEFLIB', '/usr/local/cef/lib'); |
24 | 24 | define('CDFLIB', '/opt/local/lib'); |
25 | 25 | define('SYS_LIBS', '/lib:/usr/lib:/usr/local/lib64'); |
26 | 26 | define('SYS_BIN','/bin:/usr/bin/:/usr/local/bin/'); |
27 | 27 | |
28 | +define('LOG_DIR', '/home/nathanael/CDPP/AMDA_CLIENT/AMDA_IHM/logs'); | |
29 | + | |
28 | 30 | //DD WebServices |
29 | 31 | define('INFOSITE', 'http://cdpp1.cesr.fr/BASE/'); |
30 | 32 | //log for AmdaUpdate/AmdaInstall |
... | ... | @@ -32,9 +34,9 @@ define('log', IHM_SRC_DIR.'LOG'); |
32 | 34 | // User apache |
33 | 35 | define('APACHE_USER', 'apache'); |
34 | 36 | // Alias for name of AMDA |
35 | -define('APACHE_ALIAS', '/NEWAMDA-BENJAMIN/'); | |
37 | +define('APACHE_ALIAS', '/AMDA_JOURDANE/'); | |
36 | 38 | //email to send errors from AmdaUpdate/AmdaInstall |
37 | -define('email','brenard@irap.omp.eu'); | |
39 | +define('email','nathanael.jourdane@irap.omp.eu'); | |
38 | 40 | |
39 | 41 | //DDPATH |
40 | 42 | define('DDBIN','/opt/local/bin/'); |
... | ... |
php/router.php
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * router.php |
4 | - * http://www.ibm.com/developerworks/opensource/library/wa-aj-streamline/ | |
4 | + * http://www.ibm.com/developerworks/opensource/library/wa-aj-streamline/ | |
5 | 5 | * @version $Id: router.php 687 2011-12-24 14:36:27Z elena $ |
6 | 6 | */ |
7 | - | |
7 | + | |
8 | 8 | require('config.php'); |
9 | 9 | |
10 | 10 | class ExtAction { |
... | ... | @@ -13,17 +13,17 @@ |
13 | 13 | public $data; |
14 | 14 | public $tid; |
15 | 15 | } |
16 | - | |
16 | + | |
17 | 17 | function doRpc($cdata){ |
18 | 18 | global $API; |
19 | - | |
19 | + | |
20 | 20 | try { |
21 | 21 | if(!isset($API[$cdata->action])) { |
22 | 22 | throw new Exception('Call to undefined action: ' . $cdata->action); |
23 | 23 | } |
24 | 24 | $action = $cdata->action; |
25 | 25 | $a = $API[$action]; |
26 | - | |
26 | + | |
27 | 27 | doAroundCalls($a['before'], $cdata); |
28 | 28 | |
29 | 29 | $method = $cdata->method; |
... | ... | @@ -41,12 +41,12 @@ |
41 | 41 | ); |
42 | 42 | |
43 | 43 | $o = new $action(); |
44 | - | |
45 | - $params = isset($cdata->data) && is_array($cdata->data) ? | |
46 | - $cdata->data : array(); | |
47 | - | |
44 | + | |
45 | + $params = isset($cdata->data) && is_array($cdata->data) ? | |
46 | + $cdata->data : array(); | |
47 | + | |
48 | 48 | $r['result'] = call_user_func_array(array($o, $method), $params); |
49 | - | |
49 | + | |
50 | 50 | doAroundCalls($mdef['after'], $cdata, $r); |
51 | 51 | doAroundCalls($a['after'], $cdata, $r); |
52 | 52 | } catch(Exception $e) { |
... | ... | @@ -54,7 +54,7 @@ |
54 | 54 | $r['message'] = $e->getMessage(); |
55 | 55 | $r['where'] = $e->getTraceAsString(); |
56 | 56 | } |
57 | - | |
57 | + | |
58 | 58 | return $r; |
59 | 59 | } |
60 | 60 | |
... | ... | @@ -72,20 +72,20 @@ |
72 | 72 | } |
73 | 73 | |
74 | 74 | |
75 | -/** | |
75 | +/** | |
76 | 76 | * Main |
77 | 77 | */ |
78 | 78 | |
79 | - define('log',fopen('log','w')); | |
79 | + // define('log',fopen('log','w')); | |
80 | 80 | $isForm = false; |
81 | 81 | $isUpload = false; |
82 | - | |
83 | - | |
82 | + | |
83 | + | |
84 | 84 | /* |
85 | 85 | * artificial truc to get $HTTP_RAW_POST_DATA from POST AJAX |
86 | 86 | */ |
87 | - if ($_SERVER['REQUEST_METHOD'] === 'POST' && !isset($_POST['extAction'])) { | |
88 | -// Read the input from stdin | |
87 | + if ($_SERVER['REQUEST_METHOD'] === 'POST' && !isset($_POST['extAction'])) { | |
88 | +// Read the input from stdin | |
89 | 89 | $HTTP_RAW_POST_DATA = trim(file_get_contents('php://input')); |
90 | 90 | } |
91 | 91 | |
... | ... | @@ -93,7 +93,7 @@ |
93 | 93 | |
94 | 94 | $usrMgr = new UserMgr(); |
95 | 95 | $usrMgr->setPath(); |
96 | - | |
96 | + | |
97 | 97 | if (isset($HTTP_RAW_POST_DATA)) { |
98 | 98 | header('Content-Type: text/javascript'); |
99 | 99 | $data = json_decode($HTTP_RAW_POST_DATA); |
... | ... | @@ -103,18 +103,18 @@ |
103 | 103 | $data = new ExtAction(); |
104 | 104 | $data->action = $_POST['extAction']; |
105 | 105 | $data->method = $_POST['extMethod']; |
106 | - $data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null; | |
106 | + $data->tid = isset($_POST['extTID']) ? $_POST['extTID'] : null; | |
107 | 107 | $data->data = array($_POST, $_FILES); |
108 | - | |
109 | - } | |
110 | - else { | |
108 | + | |
109 | + } | |
110 | + else { | |
111 | 111 | die('INVALID REQUEST'); |
112 | 112 | } |
113 | - | |
114 | - // $RRR = print_r($data->data, true); | |
115 | - // $RRR = print_r($data, true); | |
116 | -// fwrite(log,$RRR.PHP_EOL); | |
117 | - | |
113 | + | |
114 | + // $RRR = print_r($data->data, true); | |
115 | + // $RRR = print_r($data, true); | |
116 | +// fwrite(log,$RRR.PHP_EOL); | |
117 | + | |
118 | 118 | |
119 | 119 | $response = null; |
120 | 120 | if(is_array($data)) { |
... | ... | @@ -123,7 +123,7 @@ |
123 | 123 | $response[] = doRpc($d); |
124 | 124 | } |
125 | 125 | } else { |
126 | - | |
126 | + | |
127 | 127 | $response = doRpc($data); |
128 | 128 | } |
129 | 129 | |
... | ... | @@ -132,8 +132,8 @@ |
132 | 132 | echo json_encode($response); |
133 | 133 | echo '</textarea></body></html>'; |
134 | 134 | } else { |
135 | - echo json_encode($response); | |
135 | + echo json_encode($response); | |
136 | 136 | } |
137 | 137 | |
138 | - fclose(log); | |
139 | -?> | |
140 | 138 | \ No newline at end of file |
139 | + // fclose(log); | |
140 | +?> | |
... | ... |