From 8a0f1e9e436de4eb0de3f23c05acaeb38c85bae8 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Wed, 23 Aug 2017 18:45:13 +0200 Subject: [PATCH] Add autocompletion to targetname --- js/app/controllers/EpnTapModule.js | 48 ++++++++---------------------------------------- js/app/controllers/InteropModule.js | 18 +++++++++--------- js/app/views/EpnTapUI.js | 59 +++++++++++++++++++++++++++++++++++++++++------------------ php/epntap_resolver.php | 13 +++++++++++++ 4 files changed, 71 insertions(+), 67 deletions(-) create mode 100644 php/epntap_resolver.php diff --git a/js/app/controllers/EpnTapModule.js b/js/app/controllers/EpnTapModule.js index ad3e444..f921a89 100644 --- a/js/app/controllers/EpnTapModule.js +++ b/js/app/controllers/EpnTapModule.js @@ -92,30 +92,6 @@ Ext.define('amdaDesktop.EpnTapModule', { }, scope: this }); - // Fill productTypeCB if epntap is lauched from InteropUI - // this.metadataStore.on('load', function(store) { - // if(!this.target) { - // var dataproductTypes = store.collect('dataproduct_type'); - // - // // Update productTypeCB - // this.productTypesStore.add({'id': 'all', 'name': 'All dataproduct types'}); - // for (var i = 0; i < dataproductTypes.length; i++) { - // if (dataproductTypes[i] in this.productTypeDict) { - // this.productTypesStore.add({'id': dataproductTypes[i], 'name': this.productTypeDict[dataproductTypes[i]]}); - // } else { - // var vals = new Array(); - // for (var key in this.productTypeDict) { - // vals.push(this.productTypeDict[key]); - // } - // if(vals.indexOf(dataproductTypes[i]) <= -1) { - // console.log('Unknown data product type "' + dataproductTypes[i] + '".'); - // } - // this.productTypesStore.add({'id': dataproductTypes[i], 'name': dataproductTypes[i]}); - // } - // } - // this.productTypeCB.select('all'); - // } - // }, this); }, addUIListeners: function() { @@ -191,7 +167,7 @@ Ext.define('amdaDesktop.EpnTapModule', { /** Called each time the epntap module is loaded. - - `target`: an array of 3 values: [dataproduct_type, target_class, target_name]; or null. + - `target`: an array of 3 values: [target_name, dataproduct_type]; or null. */ loadTarget: function(target) { this.target = target; @@ -202,24 +178,16 @@ Ext.define('amdaDesktop.EpnTapModule', { this.metadataStore.clearFilter(); this.granulesStore.removeAll(); - // If the EPN-TAP module is launched from the AMDA tree - if(target) { - var name = target[0] in this.productTypeDict ? this.productTypeDict[target[0]] : target[0]; - this.productTypeCB.getStore().add({'id': target[0], 'name': this.prettify(name)}); - this.productTypeCB.select(target[0]); - this.productTypeCB.enable(); - - this.targetNameCB.getStore().add({'id': target[2], 'name': this.prettify(target[2])}); - this.targetNameCB.select(target[2]); + this.productTypeCB.getStore().add({'id': 'all', 'name': 'All dataproduct types'}); + if(target) { + this.targetNameCB.getStore().add({'id': target[0], 'name': this.prettify(target[0])}); + this.targetNameCB.select(target[0]); + this.productTypeCB.select(target[1]); this.updateNbResults(); - // If the EPN-TAP module is launched from the Interop window } else { - this.productTypeCB.select('all'); - - // Update targetNameCB - this.targetNameCB.getStore().add({'id': 'all', 'name': 'All target names'}); this.targetNameCB.select('all'); + this.productTypeCB.select('all'); this.servicesStore.each(function(record, idx) { record.set('nb_results', this.metadataStore.sum('nb_results')); @@ -350,8 +318,8 @@ Ext.define('amdaDesktop.EpnTapModule', { } this.filter = Array( - this.productTypeCB.value === 'all' ? null : this.productTypeCB.value, // product type this.targetNameCB.value === 'all' ? null : this.targetNameCB.value, // target name + this.productTypeCB.value === 'all' ? null : this.productTypeCB.value, // product type Ext.Date.format(this.timeSelector.getStartTime(), 'd/m/Y H:i:s'), // start time Ext.Date.format(this.timeSelector.getStopTime(), 'd/m/Y H:i:s') // stop time ); diff --git a/js/app/controllers/InteropModule.js b/js/app/controllers/InteropModule.js index 4180ecc..d8aa463 100644 --- a/js/app/controllers/InteropModule.js +++ b/js/app/controllers/InteropModule.js @@ -63,15 +63,15 @@ Ext.define('amdaDesktop.InteropModule', { this.epntap = Ext.create('amdaDesktop.EpnTapModule'); } var icons_dic = { - 'icon-mercury': ['ts', 'planet', 'mercury'], - 'icon-venus': ['ts', 'planet', 'venus'], - 'icon-earth': ['ts', 'planet', 'earth'], - 'icon-mars': ['ts', 'planet', 'mars'], - 'icon-jupiter': ['ts', 'planet', 'jupiter'], - 'icon-saturn': ['ts', 'planet', 'saturn'], - 'icon-comet': ['ts', 'comet', 'comet'], - 'icon-sw': ['ts', 'interplanetary_medium', 'all'], - 'icon-solarsystem': ['ts', 'interplanetary_medium', 'all'] + 'icon-mercury': ['mercury', 'ts'], + 'icon-venus': ['venus', 'ts'], + 'icon-earth': ['earth', 'ts'], + 'icon-mars': ['mars', 'ts'], + 'icon-jupiter': ['jupiter', 'ts'], + 'icon-saturn': ['saturn', 'ts'], + 'icon-comet': ['comet', 'ts'], + 'icon-sw': ['all', 'ts'], + 'icon-solarsystem': ['all', 'ts'] } this.epntap.loadTarget(icon_id ? icons_dic[icon_id]: false); }, diff --git a/js/app/views/EpnTapUI.js b/js/app/views/EpnTapUI.js index cf6f061..2f732b5 100644 --- a/js/app/views/EpnTapUI.js +++ b/js/app/views/EpnTapUI.js @@ -57,9 +57,17 @@ This list is used to fill the `targetNameCB` combo box, which is updated by `Epn - `id`: the target name in lowercase, with the underscore between each word; - `name`: the target name, capitalized with spaces between each word (done `EpnTapModule.prettify()`). */ -Ext.create('Ext.data.Store', { +Ext.create('Ext.data.Store', { // TODO: ArrayStore storeId: 'targetNamesStore', - fields: ['id', 'name'] + fields: ['id', 'name', 'type', 'parent', 'aliases'], + proxy: { + type: 'ajax', + url: 'php/epntap_resolver.php', + reader: { + type: 'json', + root: 'hits' + } + } }); /** @@ -267,34 +275,49 @@ Ext.define('amdaUI.EpnTapUI', { xtype: 'combobox', id: 'epnTapTargetNameCB', fieldLabel: 'Target name', + emptyText: 'Earth, Saturn, 67P, ...', store: Ext.data.StoreManager.lookup('targetNamesStore'), queryMode: 'remote', + queryParam: 'input', displayField: 'name', valueField: 'id', maxWidth: 100, minChars: 2, - - // triggerAction: 'all', - // mode: 'remote', - // forceSelection: true - - emptyText: 'Earth, Saturn, 67P, ...', - editable: true, - autoSelect: false, - forceSelection: false, hideTrigger: true, - selectOnFocus: false, + listConfig: { + getInnerTpl: function() { + return '
{name}
'; + } + }, listeners: { - specialkey: function(field, e){ - if (e.getKey() == e.ENTER) { - console.log('yolo'); - } + render: function(c) { + new Ext.ToolTip({ + target: c.getEl(), + html: 'Type a text then select the correct target.' + }); } } - }; }, - +/* +name "Jujo" +parent "Sun" +type "Asteroid" +system "sys-Sun" +classes "MB>OMB" +@id 104747 +id "Jujo" +aliases +0 "4747" +1 "1989 WB" +2 "J89W00B" +3 "1976 GK6" +4 "J76G06K" +5 "1978 PJ" +6 "J78P00J" +7 "1978 SW" +8 "J78S00W" +*/ /** Create `epnTapTimeSelector`, an IntervalUI object, allowing the user to select a time interval (by filling two diff --git a/php/epntap_resolver.php b/php/epntap_resolver.php new file mode 100644 index 0000000..a7e8068 --- /dev/null +++ b/php/epntap_resolver.php @@ -0,0 +1,13 @@ +' . join('
  • ', $e['aliases']) . '
  • '; + $target = array('name' => $e['name'], 'type' => $e['type'], 'parent' => $e['parent'], 'aliases' => $aliases); + array_push($response, $target); +} +echo json_encode($response); +?> -- libgit2 0.21.2