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 | 128 | 'serviceId': record.data['id'], |
129 | 129 | 'url': record.data['access_url'], |
130 | 130 | 'tableName': record.data['table_name'], |
131 | - 'targetName': targetName, | |
131 | + 'targetNames': targetName, | |
132 | 132 | 'productTypes': productTypes, |
133 | 133 | 'timeMin': timeMin, |
134 | 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 | 62 | */ |
63 | 63 | Ext.create('Ext.data.Store', { |
64 | 64 | storeId: 'targetNamesStore', |
65 | - fields: ['id', 'name', 'type', 'parent', 'aliases'], | |
65 | + fields: ['id', 'text', 'name', 'type', 'parent', 'aliases'], | |
66 | 66 | proxy: { |
67 | 67 | type: 'ajax', |
68 | 68 | url: 'php/epntap.php', |
... | ... | @@ -171,7 +171,7 @@ Ext.create('Ext.data.Store', { |
171 | 171 | 'action': 'getGranules', |
172 | 172 | 'url': service['access_url'], |
173 | 173 | 'tableName': service['table_name'], |
174 | - 'targetName': Ext.getCmp('epnTapTargetNameCB').rawValue, | |
174 | + 'targetNames': Ext.getCmp('epnTapTargetNameCB').rawValue, | |
175 | 175 | 'productTypes': Ext.getCmp('epnTapProductTypeCB').value.join(';'), |
176 | 176 | 'timeMin': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStartTime(), 'd/m/Y H:i:s'), |
177 | 177 | 'timeMax': Ext.Date.format(Ext.getCmp('epnTapTimeSelector').getStopTime(), 'd/m/Y H:i:s'), |
... | ... | @@ -463,10 +463,11 @@ Ext.define('amdaUI.EpnTapUI', { |
463 | 463 | id: 'epnTapTargetNameCB', |
464 | 464 | fieldLabel: 'Target name', |
465 | 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 | 467 | store: Ext.data.StoreManager.lookup('targetNamesStore'), |
467 | 468 | queryMode: 'remote', |
468 | 469 | queryParam: 'input', |
469 | - displayField: 'name', | |
470 | + displayField: 'text', | |
470 | 471 | valueField: 'id', |
471 | 472 | margin: '15 0 5 0', |
472 | 473 | labelWidth: 71, |
... | ... | @@ -480,10 +481,7 @@ Ext.define('amdaUI.EpnTapUI', { |
480 | 481 | }, |
481 | 482 | listeners: { |
482 | 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 | 500 | id: 'epnTapProductTypeCB', |
503 | 501 | fieldLabel: 'Product type', |
504 | 502 | emptyText: 'Image, Time series, ...', |
503 | + tooltip: 'Select one or several data product types (required).', | |
505 | 504 | store: Ext.data.StoreManager.lookup('productTypesStore'), |
506 | 505 | queryMode: 'local', |
507 | 506 | valueField: 'id', |
... | ... | @@ -524,10 +523,7 @@ Ext.define('amdaUI.EpnTapUI', { |
524 | 523 | } |
525 | 524 | }, |
526 | 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 | 34 | |
35 | 35 | function resolver() { |
36 | 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 | 43 | $response = ['success' => true, 'metaData' => ['root' => 'data', 'messageProperty' => 'msg']]; |
40 | 44 | try { |
... | ... | @@ -49,7 +53,8 @@ function resolver() { |
49 | 53 | $targets = array(); |
50 | 54 | foreach($result['hits'] as $e) { |
51 | 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 | 58 | array_push($targets, $target); |
54 | 59 | } |
55 | 60 | $response['data'] = $targets; |
... | ... | @@ -119,7 +124,7 @@ function getServices() { |
119 | 124 | } |
120 | 125 | |
121 | 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 | 128 | $response = request(getParam('url'), $query); |
124 | 129 | if($response['success']) { |
125 | 130 | $response['success'] = false; |
... | ... | @@ -147,7 +152,7 @@ function getNbResults() { |
147 | 152 | |
148 | 153 | function getGranules() { |
149 | 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 | 156 | $query = "SELECT TOP " . getParam('limit') . " * FROM " . getParam('tableName') . " $filter ORDER BY $sort OFFSET " . getParam('start'); |
152 | 157 | // error_log('getGranules query: ' . $query); |
153 | 158 | $response = request(getParam('url'), $query); |
... | ... | @@ -183,10 +188,10 @@ function getGranules() { |
183 | 188 | |
184 | 189 | // ----- utils ----- |
185 | 190 | |
186 | -function createFilter($targetName, $productTypes, $timeMin, $timeMax) { | |
191 | +function createFilter($targetNames, $productTypes, $timeMin, $timeMax) { | |
187 | 192 | $filter = array(); |
188 | 193 | if($targetName) { |
189 | - array_push($filter, "target_name = '$targetName'"); | |
194 | + array_push($filter, "target_name IN ('" . join("', '", preg_split("/ ?[;,] ?+/", $targetNames)) . "')"); | |
190 | 195 | } |
191 | 196 | if($productTypes) { |
192 | 197 | array_push($filter, "dataproduct_type IN ('" . join("', '", explode(';', $productTypes)) . "')"); | ... | ... |