Commit 8a0f1e9e436de4eb0de3f23c05acaeb38c85bae8

Authored by Nathanael Jourdane
1 parent ebdc15a7

Add autocompletion to targetname

js/app/controllers/EpnTapModule.js
... ... @@ -92,30 +92,6 @@ Ext.define('amdaDesktop.EpnTapModule', {
92 92 },
93 93 scope: this
94 94 });
95   - // Fill productTypeCB if epntap is lauched from InteropUI
96   - // this.metadataStore.on('load', function(store) {
97   - // if(!this.target) {
98   - // var dataproductTypes = store.collect('dataproduct_type');
99   - //
100   - // // Update productTypeCB
101   - // this.productTypesStore.add({'id': 'all', 'name': 'All dataproduct types'});
102   - // for (var i = 0; i < dataproductTypes.length; i++) {
103   - // if (dataproductTypes[i] in this.productTypeDict) {
104   - // this.productTypesStore.add({'id': dataproductTypes[i], 'name': this.productTypeDict[dataproductTypes[i]]});
105   - // } else {
106   - // var vals = new Array();
107   - // for (var key in this.productTypeDict) {
108   - // vals.push(this.productTypeDict[key]);
109   - // }
110   - // if(vals.indexOf(dataproductTypes[i]) <= -1) {
111   - // console.log('Unknown data product type "' + dataproductTypes[i] + '".');
112   - // }
113   - // this.productTypesStore.add({'id': dataproductTypes[i], 'name': dataproductTypes[i]});
114   - // }
115   - // }
116   - // this.productTypeCB.select('all');
117   - // }
118   - // }, this);
119 95 },
120 96  
121 97 addUIListeners: function() {
... ... @@ -191,7 +167,7 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
191 167  
192 168 /**
193 169 Called each time the epntap module is loaded.
194   - - `target`: an array of 3 values: [dataproduct_type, target_class, target_name]; or null.
  170 + - `target`: an array of 3 values: [target_name, dataproduct_type]; or null.
195 171 */
196 172 loadTarget: function(target) {
197 173 this.target = target;
... ... @@ -202,24 +178,16 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
202 178 this.metadataStore.clearFilter();
203 179 this.granulesStore.removeAll();
204 180  
205   - // If the EPN-TAP module is launched from the AMDA tree
206   - if(target) {
207   - var name = target[0] in this.productTypeDict ? this.productTypeDict[target[0]] : target[0];
208   - this.productTypeCB.getStore().add({'id': target[0], 'name': this.prettify(name)});
209   - this.productTypeCB.select(target[0]);
210   - this.productTypeCB.enable();
211   -
212   - this.targetNameCB.getStore().add({'id': target[2], 'name': this.prettify(target[2])});
213   - this.targetNameCB.select(target[2]);
  181 + this.productTypeCB.getStore().add({'id': 'all', 'name': 'All dataproduct types'});
214 182  
  183 + if(target) {
  184 + this.targetNameCB.getStore().add({'id': target[0], 'name': this.prettify(target[0])});
  185 + this.targetNameCB.select(target[0]);
  186 + this.productTypeCB.select(target[1]);
215 187 this.updateNbResults();
216   - // If the EPN-TAP module is launched from the Interop window
217 188 } else {
218   - this.productTypeCB.select('all');
219   -
220   - // Update targetNameCB
221   - this.targetNameCB.getStore().add({'id': 'all', 'name': 'All target names'});
222 189 this.targetNameCB.select('all');
  190 + this.productTypeCB.select('all');
223 191  
224 192 this.servicesStore.each(function(record, idx) {
225 193 record.set('nb_results', this.metadataStore.sum('nb_results'));
... ... @@ -350,8 +318,8 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
350 318 }
351 319  
352 320 this.filter = Array(
353   - this.productTypeCB.value === 'all' ? null : this.productTypeCB.value, // product type
354 321 this.targetNameCB.value === 'all' ? null : this.targetNameCB.value, // target name
  322 + this.productTypeCB.value === 'all' ? null : this.productTypeCB.value, // product type
355 323 Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'), // start time
356 324 Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s') // stop time
357 325 );
... ...
js/app/controllers/InteropModule.js
... ... @@ -63,15 +63,15 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
63 63 this.epntap = Ext.create('amdaDesktop.EpnTapModule');
64 64 }
65 65 var icons_dic = {
66   - 'icon-mercury': ['ts', 'planet', 'mercury'],
67   - 'icon-venus': ['ts', 'planet', 'venus'],
68   - 'icon-earth': ['ts', 'planet', 'earth'],
69   - 'icon-mars': ['ts', 'planet', 'mars'],
70   - 'icon-jupiter': ['ts', 'planet', 'jupiter'],
71   - 'icon-saturn': ['ts', 'planet', 'saturn'],
72   - 'icon-comet': ['ts', 'comet', 'comet'],
73   - 'icon-sw': ['ts', 'interplanetary_medium', 'all'],
74   - 'icon-solarsystem': ['ts', 'interplanetary_medium', 'all']
  66 + 'icon-mercury': ['mercury', 'ts'],
  67 + 'icon-venus': ['venus', 'ts'],
  68 + 'icon-earth': ['earth', 'ts'],
  69 + 'icon-mars': ['mars', 'ts'],
  70 + 'icon-jupiter': ['jupiter', 'ts'],
  71 + 'icon-saturn': ['saturn', 'ts'],
  72 + 'icon-comet': ['comet', 'ts'],
  73 + 'icon-sw': ['all', 'ts'],
  74 + 'icon-solarsystem': ['all', 'ts']
75 75 }
76 76 this.epntap.loadTarget(icon_id ? icons_dic[icon_id]: false);
77 77 },
... ...
js/app/views/EpnTapUI.js
... ... @@ -57,9 +57,17 @@ This list is used to fill the `targetNameCB` combo box, which is updated by `Epn
57 57 - `id`: the target name in lowercase, with the underscore between each word;
58 58 - `name`: the target name, capitalized with spaces between each word (done `EpnTapModule.prettify()`).
59 59 */
60   -Ext.create('Ext.data.Store', {
  60 +Ext.create('Ext.data.Store', { // TODO: ArrayStore
61 61 storeId: 'targetNamesStore',
62   - fields: ['id', 'name']
  62 + fields: ['id', 'name', 'type', 'parent', 'aliases'],
  63 + proxy: {
  64 + type: 'ajax',
  65 + url: 'php/epntap_resolver.php',
  66 + reader: {
  67 + type: 'json',
  68 + root: 'hits'
  69 + }
  70 + }
63 71 });
64 72  
65 73 /**
... ... @@ -267,34 +275,49 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
267 275 xtype: 'combobox',
268 276 id: 'epnTapTargetNameCB',
269 277 fieldLabel: 'Target name',
  278 + emptyText: 'Earth, Saturn, 67P, ...',
270 279 store: Ext.data.StoreManager.lookup('targetNamesStore'),
271 280 queryMode: 'remote',
  281 + queryParam: 'input',
272 282 displayField: 'name',
273 283 valueField: 'id',
274 284 maxWidth: 100,
275 285 minChars: 2,
276   -
277   - // triggerAction: 'all',
278   - // mode: 'remote',
279   - // forceSelection: true
280   -
281   - emptyText: 'Earth, Saturn, 67P, ...',
282   - editable: true,
283   - autoSelect: false,
284   - forceSelection: false,
285 286 hideTrigger: true,
286   - selectOnFocus: false,
  287 + listConfig: {
  288 + getInnerTpl: function() {
  289 + return '<div data-qtip="<p><b>{name}</b></p><p>type: {type}</p><p>parent: {parent}</p><p>aliases:</p><ul>{aliases}</ul>">{name}</div>';
  290 + }
  291 + },
287 292 listeners: {
288   - specialkey: function(field, e){
289   - if (e.getKey() == e.ENTER) {
290   - console.log('yolo');
291   - }
  293 + render: function(c) {
  294 + new Ext.ToolTip({
  295 + target: c.getEl(),
  296 + html: 'Type a text then select the correct target.'
  297 + });
292 298 }
293 299 }
294   -
295 300 };
296 301 },
297   -
  302 +/*
  303 +name "Jujo"
  304 +parent "Sun"
  305 +type "Asteroid"
  306 +system "sys-Sun"
  307 +classes "MB>OMB"
  308 +@id 104747
  309 +id "Jujo"
  310 +aliases
  311 +0 "4747"
  312 +1 "1989 WB"
  313 +2 "J89W00B"
  314 +3 "1976 GK6"
  315 +4 "J76G06K"
  316 +5 "1978 PJ"
  317 +6 "J78P00J"
  318 +7 "1978 SW"
  319 +8 "J78S00W"
  320 +*/
298 321  
299 322 /**
300 323 Create `epnTapTimeSelector`, an IntervalUI object, allowing the user to select a time interval (by filling two
... ...
php/epntap_resolver.php 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +<?php
  2 +$input = filter_var($_REQUEST['input'], FILTER_SANITIZE_URL);
  3 +$resolver_url = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete?q=%22$input%22";
  4 +$result = json_decode(file_get_contents($resolver_url), true);
  5 +
  6 +$response = array();
  7 +foreach($result['hits'] as $e) {
  8 + $aliases = '<li>' . join('</li><li>', $e['aliases']) . '</li>';
  9 + $target = array('name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases);
  10 + array_push($response, $target);
  11 +}
  12 +echo json_encode($response);
  13 +?>
... ...