Commit b5d477c69a0b2524d470bf27f971dede994ab5b6
1 parent
3f51339d
Exists in
master
and in
111 other branches
Allow multiple values for target names
Showing
3 changed files
with
19 additions
and
18 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
@@ -128,7 +128,7 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -128,7 +128,7 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
128 | 'serviceId': record.data['id'], | 128 | 'serviceId': record.data['id'], |
129 | 'url': record.data['access_url'], | 129 | 'url': record.data['access_url'], |
130 | 'tableName': record.data['table_name'], | 130 | 'tableName': record.data['table_name'], |
131 | - 'targetName': targetName, | 131 | + 'targetNames': targetName, |
132 | 'productTypes': productTypes, | 132 | 'productTypes': productTypes, |
133 | 'timeMin': timeMin, | 133 | 'timeMin': timeMin, |
134 | 'timeMax': timeMax | 134 | 'timeMax': timeMax |
js/app/views/EpnTapUI.js
@@ -62,7 +62,7 @@ This list is used to fill the `targetNameCB` combo box, which is updated by `Epn | @@ -62,7 +62,7 @@ This list is used to fill the `targetNameCB` combo box, which is updated by `Epn | ||
62 | */ | 62 | */ |
63 | Ext.create('Ext.data.Store', { | 63 | Ext.create('Ext.data.Store', { |
64 | storeId: 'targetNamesStore', | 64 | storeId: 'targetNamesStore', |
65 | - fields: ['id', 'name', 'type', 'parent', 'aliases'], | 65 | + fields: ['id', 'text', 'name', 'type', 'parent', 'aliases'], |
66 | proxy: { | 66 | proxy: { |
67 | type: 'ajax', | 67 | type: 'ajax', |
68 | url: 'php/epntap.php', | 68 | url: 'php/epntap.php', |
@@ -171,7 +171,7 @@ Ext.create('Ext.data.Store', { | @@ -171,7 +171,7 @@ Ext.create('Ext.data.Store', { | ||
171 | 'action': 'getGranules', | 171 | 'action': 'getGranules', |
172 | 'url': service['access_url'], | 172 | 'url': service['access_url'], |
173 | 'tableName': service['table_name'], | 173 | 'tableName': service['table_name'], |
174 | - 'targetName': Ext.getCmp('epnTapTargetNameCB').rawValue, | 174 | + 'targetNames': Ext.getCmp('epnTapTargetNameCB').rawValue, |
175 | 'productTypes': Ext.getCmp('epnTapProductTypeCB').value.join(';'), | 175 | 'productTypes': Ext.getCmp('epnTapProductTypeCB').value.join(';'), |
176 | 'timeMin': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStartTime(), 'd/m/Y H:i:s'), | 176 | 'timeMin': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStartTime(), 'd/m/Y H:i:s'), |
177 | 'timeMax': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStopTime(), 'd/m/Y H:i:s'), | 177 | 'timeMax': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStopTime(), 'd/m/Y H:i:s'), |
@@ -463,10 +463,11 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -463,10 +463,11 @@ Ext.define('amdaUI.EpnTapUI', { | ||
463 | id: 'epnTapTargetNameCB', | 463 | id: 'epnTapTargetNameCB', |
464 | fieldLabel: 'Target name', | 464 | fieldLabel: 'Target name', |
465 | emptyText: 'Earth, Saturn, 67P, ...', | 465 | emptyText: 'Earth, Saturn, 67P, ...', |
466 | + tooltip: 'Start to type a text, then select a target name (required). Several values are allowed, separated by a semicolon.', | ||
466 | store: Ext.data.StoreManager.lookup('targetNamesStore'), | 467 | store: Ext.data.StoreManager.lookup('targetNamesStore'), |
467 | queryMode: 'remote', | 468 | queryMode: 'remote', |
468 | queryParam: 'input', | 469 | queryParam: 'input', |
469 | - displayField: 'name', | 470 | + displayField: 'text', |
470 | valueField: 'id', | 471 | valueField: 'id', |
471 | margin: '15 0 5 0', | 472 | margin: '15 0 5 0', |
472 | labelWidth: 71, | 473 | labelWidth: 71, |
@@ -480,10 +481,7 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -480,10 +481,7 @@ Ext.define('amdaUI.EpnTapUI', { | ||
480 | }, | 481 | }, |
481 | listeners: { | 482 | listeners: { |
482 | render: function(cb) { | 483 | render: function(cb) { |
483 | - new Ext.ToolTip({ | ||
484 | - target: cb.getEl(), | ||
485 | - html: 'Start to type a text then select a target name (required).' | ||
486 | - }); | 484 | + new Ext.ToolTip({ target: cb.getEl(), html: '<div style="width:200px">' + cb.tooltip + '</div>'}); |
487 | } | 485 | } |
488 | } | 486 | } |
489 | }; | 487 | }; |
@@ -502,6 +500,7 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -502,6 +500,7 @@ Ext.define('amdaUI.EpnTapUI', { | ||
502 | id: 'epnTapProductTypeCB', | 500 | id: 'epnTapProductTypeCB', |
503 | fieldLabel: 'Product type', | 501 | fieldLabel: 'Product type', |
504 | emptyText: 'Image, Time series, ...', | 502 | emptyText: 'Image, Time series, ...', |
503 | + tooltip: 'Select one or several data product types (required).', | ||
505 | store: Ext.data.StoreManager.lookup('productTypesStore'), | 504 | store: Ext.data.StoreManager.lookup('productTypesStore'), |
506 | queryMode: 'local', | 505 | queryMode: 'local', |
507 | valueField: 'id', | 506 | valueField: 'id', |
@@ -524,10 +523,7 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -524,10 +523,7 @@ Ext.define('amdaUI.EpnTapUI', { | ||
524 | } | 523 | } |
525 | }, | 524 | }, |
526 | render: function(cb) { | 525 | render: function(cb) { |
527 | - new Ext.ToolTip({ | ||
528 | - target: cb.getEl(), | ||
529 | - html: 'Select one or several data product types (required).' | ||
530 | - }); | 526 | + new Ext.ToolTip({ target: cb.getEl(), html: '<div style="width:200px">' + cb.tooltip + '</div>'}); |
531 | } | 527 | } |
532 | } | 528 | } |
533 | }; | 529 | }; |
php/epntap.php
@@ -34,7 +34,11 @@ function getParam($paramName, $default=null) { | @@ -34,7 +34,11 @@ function getParam($paramName, $default=null) { | ||
34 | 34 | ||
35 | function resolver() { | 35 | function resolver() { |
36 | $input = filter_var($_GET['input'], FILTER_SANITIZE_URL); | 36 | $input = filter_var($_GET['input'], FILTER_SANITIZE_URL); |
37 | - $resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$input%22"; | 37 | + $words = preg_split("/ ?[;,] ?+/", $input); |
38 | + $lastWord = trim(array_pop($words)); | ||
39 | + $firstsWords = implode(', ', $words); | ||
40 | + | ||
41 | + $resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$lastWord%22"; | ||
38 | 42 | ||
39 | $response = ['success' => true, 'metaData' => ['root' => 'data', 'messageProperty' => 'msg']]; | 43 | $response = ['success' => true, 'metaData' => ['root' => 'data', 'messageProperty' => 'msg']]; |
40 | try { | 44 | try { |
@@ -49,7 +53,8 @@ function resolver() { | @@ -49,7 +53,8 @@ function resolver() { | ||
49 | $targets = array(); | 53 | $targets = array(); |
50 | foreach($result['hits'] as $e) { | 54 | foreach($result['hits'] as $e) { |
51 | $aliases = '<li>' . join('</li><li>', $e['aliases']) . '</li>'; | 55 | $aliases = '<li>' . join('</li><li>', $e['aliases']) . '</li>'; |
52 | - $target = array('name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases); | 56 | + $text = (!empty($firstsWords) ? "$firstsWords, " : "") . $e['name']; |
57 | + $target = ['text' => $text, 'name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases]; | ||
53 | array_push($targets, $target); | 58 | array_push($targets, $target); |
54 | } | 59 | } |
55 | $response['data'] = $targets; | 60 | $response['data'] = $targets; |
@@ -119,7 +124,7 @@ function getServices() { | @@ -119,7 +124,7 @@ function getServices() { | ||
119 | } | 124 | } |
120 | 125 | ||
121 | function getNbResults() { | 126 | function getNbResults() { |
122 | - $query = "SELECT COUNT(*) AS nb_rows FROM " . getParam('tableName') . createFilter(getParam('targetName'), getParam('productTypes'), getParam('timeMin'), getParam('timeMax')); | 127 | + $query = "SELECT COUNT(*) AS nb_rows FROM " . getParam('tableName') . createFilter(getParam('targetNames'), getParam('productTypes'), getParam('timeMin'), getParam('timeMax')); |
123 | $response = request(getParam('url'), $query); | 128 | $response = request(getParam('url'), $query); |
124 | if($response['success']) { | 129 | if($response['success']) { |
125 | $response['success'] = false; | 130 | $response['success'] = false; |
@@ -147,7 +152,7 @@ function getNbResults() { | @@ -147,7 +152,7 @@ function getNbResults() { | ||
147 | 152 | ||
148 | function getGranules() { | 153 | function getGranules() { |
149 | $sort = is_null(getParam('sort')) ? 'granule_uid ASC' : (getParam('sort') . ' ' . getParam('dir')); | 154 | $sort = is_null(getParam('sort')) ? 'granule_uid ASC' : (getParam('sort') . ' ' . getParam('dir')); |
150 | - $filter = createFilter(getParam('targetName'), getParam('productTypes'), getParam('timeMin'), getParam('timeMax')); | 155 | + $filter = createFilter(getParam('targetNames'), getParam('productTypes'), getParam('timeMin'), getParam('timeMax')); |
151 | $query = "SELECT TOP " . getParam('limit') . " * FROM " . getParam('tableName') . " $filter ORDER BY $sort OFFSET " . getParam('start'); | 156 | $query = "SELECT TOP " . getParam('limit') . " * FROM " . getParam('tableName') . " $filter ORDER BY $sort OFFSET " . getParam('start'); |
152 | // error_log('getGranules query: ' . $query); | 157 | // error_log('getGranules query: ' . $query); |
153 | $response = request(getParam('url'), $query); | 158 | $response = request(getParam('url'), $query); |
@@ -183,10 +188,10 @@ function getGranules() { | @@ -183,10 +188,10 @@ function getGranules() { | ||
183 | 188 | ||
184 | // ----- utils ----- | 189 | // ----- utils ----- |
185 | 190 | ||
186 | -function createFilter($targetName, $productTypes, $timeMin, $timeMax) { | 191 | +function createFilter($targetNames, $productTypes, $timeMin, $timeMax) { |
187 | $filter = array(); | 192 | $filter = array(); |
188 | if($targetName) { | 193 | if($targetName) { |
189 | - array_push($filter, "target_name = '$targetName'"); | 194 | + array_push($filter, "target_name IN ('" . join("', '", preg_split("/ ?[;,] ?+/", $targetNames)) . "')"); |
190 | } | 195 | } |
191 | if($productTypes) { | 196 | if($productTypes) { |
192 | array_push($filter, "dataproduct_type IN ('" . join("', '", explode(';', $productTypes)) . "')"); | 197 | array_push($filter, "dataproduct_type IN ('" . join("', '", explode(';', $productTypes)) . "')"); |