Commit ebdc15a7316247dcf40bf952dc67f20f063f3381

Authored by Nathanael Jourdane
1 parent 5deeade0

remove targetclass cb (WIP)

Showing 2 changed files with 79 additions and 182 deletions   Show diff stats
js/app/controllers/EpnTapModule.js
... ... @@ -42,6 +42,7 @@ Ext.define('amdaDesktop.EpnTapModule', {
42 42  
43 43 this.servicesStore.load();
44 44 this.metadataStore.load();
  45 + this.productTypesStore.load();
45 46 },
46 47  
47 48 aquireElements: function() {
... ... @@ -49,7 +50,6 @@ Ext.define('amdaDesktop.EpnTapModule', {
49 50 this.servicesGrid = Ext.getCmp('epnTapServicesGrid');
50 51 this.granulesGrid = Ext.getCmp('epnTapGranulesGrid');
51 52 this.productTypeCB = Ext.getCmp('epnTapProductTypeCB');
52   - this.targetClassCB = Ext.getCmp('epnTapTargetClassCB');
53 53 this.targetNameCB = Ext.getCmp('epnTapTargetNameCB');
54 54 this.timeSelector = Ext.getCmp('epnTapTimeSelector');
55 55 this.rowsPerPageNf = Ext.getCmp('epnTapRowsPerPageNf');
... ... @@ -65,20 +65,7 @@ Ext.define('amdaDesktop.EpnTapModule', {
65 65 this.granulesStore = Ext.data.StoreManager.lookup('granulesStore');
66 66 this.metadataStore = Ext.data.StoreManager.lookup('metadataStore')
67 67 this.productTypesStore = Ext.data.StoreManager.lookup('productTypesStore');
68   - this.targetClassesStore = Ext.data.StoreManager.lookup('targetClassesStore');
69 68 this.targetNamesStore = Ext.data.StoreManager.lookup('targetNamesStore');
70   - this.productTypeDict = { 'im': 'Image',
71   - 'ma': 'Map',
72   - 'sp': 'Spectrum',
73   - 'ds': 'Dynamic spectrum',
74   - 'sc': 'Spectral cube',
75   - 'pr': 'Profile',
76   - 'vo': 'Volume',
77   - 'mo': 'Movie',
78   - 'cu': 'Cube',
79   - 'ts': 'Time series',
80   - 'ca': 'Catalogue',
81   - 'ci': 'Catalogue item'};
82 69 },
83 70  
84 71 addStoreListeners: function() {
... ... @@ -96,30 +83,39 @@ Ext.define('amdaDesktop.EpnTapModule', {
96 83 scope: this
97 84 });
98 85  
99   - // Fill productTypeCB if epntap is lauched from InteropUI
100   - this.metadataStore.on('load', function(store) {
101   - if(!this.target) {
102   - var dataproductTypes = store.collect('dataproduct_type');
103   -
104   - // Update productTypeCB
105   - this.productTypesStore.add({'id': 'all', 'name': 'All dataproduct types'});
106   - for (var i = 0; i < dataproductTypes.length; i++) {
107   - if (dataproductTypes[i] in this.productTypeDict) {
108   - this.productTypesStore.add({'id': dataproductTypes[i], 'name': this.productTypeDict[dataproductTypes[i]]});
109   - } else {
110   - var vals = new Array();
111   - for (var key in this.productTypeDict) {
112   - vals.push(this.productTypeDict[key]);
113   - }
114   - if(vals.indexOf(dataproductTypes[i]) <= -1) {
115   - console.log('Unknown data product type "' + dataproductTypes[i] + '".');
116   - }
117   - this.productTypesStore.add({'id': dataproductTypes[i], 'name': dataproductTypes[i]});
118   - }
  86 + this.productTypesStore.on({
  87 + load: function(store) {
  88 + this.productTypeDict = {};
  89 + for (var key in store.data.map) {
  90 + this.productTypeDict[key] = store.data.map[key].data.name;
119 91 }
120   - this.productTypeCB.select('all');
121   - }
122   - }, this);
  92 + },
  93 + scope: this
  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);
123 119 },
124 120  
125 121 addUIListeners: function() {
... ... @@ -136,11 +132,6 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
136 132 this.updateNbResults();
137 133 }, this);
138 134  
139   - this.targetClassCB.on('select', function(cb) {
140   - this.onTargetClassCBChanged(cb.value);
141   - this.updateNbResults();
142   - }, this);
143   -
144 135 this.targetNameCB.on('select', function(cb) {
145 136 this.onTargetNameCBChanged(cb.value);
146 137 this.updateNbResults();
... ... @@ -218,28 +209,17 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
218 209 this.productTypeCB.select(target[0]);
219 210 this.productTypeCB.enable();
220 211  
221   - this.targetClassCB.getStore().add({'id': target[1], 'name': this.prettify(target[1])});
222   - this.targetClassCB.select(target[1]);
223   - this.targetClassCB.enable();
224   -
225 212 this.targetNameCB.getStore().add({'id': target[2], 'name': this.prettify(target[2])});
226 213 this.targetNameCB.select(target[2]);
227   - this.targetNameCB.enable();
228 214  
229 215 this.updateNbResults();
230 216 // If the EPN-TAP module is launched from the Interop window
231 217 } else {
232 218 this.productTypeCB.select('all');
233 219  
234   - // Update targetClassCB
235   - this.targetClassCB.getStore().add({'id': 'all', 'name': 'All target classes'});
236   - this.targetClassCB.select('all');
237   - this.targetClassCB.disable();
238   -
239 220 // Update targetNameCB
240 221 this.targetNameCB.getStore().add({'id': 'all', 'name': 'All target names'});
241 222 this.targetNameCB.select('all');
242   - this.targetNameCB.disable();
243 223  
244 224 this.servicesStore.each(function(record, idx) {
245 225 record.set('nb_results', this.metadataStore.sum('nb_results'));
... ... @@ -250,73 +230,13 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
250 230 /**
251 231 Trigerred when *the user* (not `productTypeCB.select()`) select a new item in `productTypeCB`
252 232 (see `EpnTapUI.createProductTypeCB()`).
253   - Among other things, updates the `targetClassCB` combobox and the `servicesGrid` table.
  233 + Among other things, updates the `servicesGrid` table.
254 234 */
255 235 onProductTypeCBChanged: function() {
256   - this.granulesStore.removeAll();
257   - this.targetClassCB.getStore().removeAll();
258   - this.targetNameCB.getStore().removeAll();
259   - this.targetNameCB.disable();
260   -
261   - if (this.productTypeCB.value == 'all') {
262   - this.targetClassCB.disable();
263   - } else {
264   - this.metadataStore.filter('dataproduct_type', this.productTypeCB.value)
265   - var targetClasses = this.metadataStore.collect('target_class');
266   -
267   - if (targetClasses.length == 1) {
268   - this.targetClassCB.getStore().add({'id': targetClasses[0], 'name': this.prettify(targetClasses[0])});
269   - this.targetClassCB.disable();
270   - this.targetClassCB.select(this.targetClassCB.getStore().getAt(0)['internalId']);
271   - } else {
272   - var name = this.productTypeCB.value in this.productTypeDict ? this.productTypeDict[this.productTypeCB.value] : this.productTypeCB.value;
273   - this.targetClassCB.getStore().add({'id': 'all', 'name': this.allPrettify(name)});
274   - // this.targetClassCB.getStore().add({'id': 'all', 'name': 'All'});
275   - for (var i = 0; i < targetClasses.length; i++) {
276   - this.targetClassCB.getStore().add({'id': targetClasses[i], 'name': this.prettify(targetClasses[i])});
277   - }
278   - this.targetClassCB.select('all');
279   - this.targetClassCB.enable();
280   - }
281   - }
282   - this.targetNameCB.getStore().add({'id': 'all', 'name': 'All target names'});
283   - this.targetNameCB.select('all');
284 236 },
285 237  
286 238 /**
287   - Trigerred when *the user* (not `targetClassCB.select()`) select a new item in `targetClassCB` (see
288   - `EpnTapUI.createTargetClassCB()`).
289   - Among other things, updates the `targetNameCB` combobox and the `servicesGrid` table.
290   - */
291   - onTargetClassCBChanged: function() {
292   - this.granulesStore.removeAll();
293   - this.targetNameCB.getStore().removeAll();
294   -
295   - if (this.targetClassCB.value == 'all') {
296   - this.targetNameCB.getStore().add({'id': 'all', 'name': 'All target names'});
297   - this.targetNameCB.select('all');
298   - this.targetNameCB.disable();
299   - } else {
300   - this.metadataStore.filter('target_class', this.targetClassCB.value);
301   - var targetNames = this.metadataStore.collect('target_name');
302   - if (targetNames.length == 1) {
303   - this.targetNameCB.getStore().add({'id': targetNames[0], 'name': this.prettify(targetNames[0])});
304   - this.targetNameCB.select(this.targetNameCB.getStore().getAt(0)['internalId']);
305   - this.targetNameCB.disable();
306   - } else {
307   - this.targetNameCB.getStore().add({'id': 'all', 'name': this.allPrettify(this.targetClassCB.value)});
308   - for (var i = 0; i < targetNames.length; i++) {
309   - this.targetNameCB.getStore().add({'id': targetNames[i], 'name': this.prettify(targetNames[i])});
310   - }
311   - this.targetNameCB.select('all');
312   - this.targetNameCB.enable();
313   - }
314   - }
315   - },
316   -
317   - /**
318   - Trigerred when *the user* (not `targetClassCB.select()`) select a new item in `targetNameCB`
319   - (see `EpnTapUI.createTargetNameCB()`).
  239 + Trigerred when the user select a new item in `targetNameCB` (see `EpnTapUI.createTargetNameCB()`).
320 240 Updates the `servicesGrid` table.
321 241 */
322 242 onTargetNameCBChanged: function() {
... ... @@ -458,20 +378,16 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
458 378 */
459 379 updateNbResults: function() {
460 380 if(this.productTypeCB.value === 'all' && !this.launchedFromTree ) {
461   - var filter = [];
462   - } else if(this.targetClassCB.value === 'all') {
463 381 var filter = [
464 382 {property: "dataproduct_type", value: this.productTypeCB.value}
465 383 ];
466 384 } else if(this.targetNameCB.value === 'all') {
467 385 var filter = [
468   - {property: "dataproduct_type", value: this.productTypeCB.value},
469   - {property: "target_class", value: this.targetClassCB.value}
  386 + {property: "dataproduct_type", value: this.productTypeCB.value}
470 387 ];
471 388 } else {
472 389 var filter = [
473 390 {property: "dataproduct_type", value: this.productTypeCB.value},
474   - {property: "target_class", value: this.targetClassCB.value},
475 391 {property: "target_name", value: this.targetNameCB.value}
476 392 ];
477 393 }
... ...
js/app/views/EpnTapUI.js
... ... @@ -25,26 +25,25 @@ Notes:
25 25 in this store and an information message is displayed on the JavaScript console during the panel creation.
26 26 - if a data product type is not present in any of the granules from the EPN-TAP services, it is not present in this
27 27 store.
28   -*/
29   -Ext.create('Ext.data.ArrayStore', {
30   - storeId:'productTypesStore',
31   - fields: ['id', 'name']
32   -});
33   -
34   -/**
35   -`targetClassesStore`: An ExtJS Store containing the list of the different target classes defined on all granules, on
36   -all available EPN-TAP services (defined in `generic_data/EpnTapData/metadata.json`, updated periodically with a cron
37   -script), which match with the selected data product type.
38   -
39   -This list is used to fill the `targetClassCB` combo box, which is updated by `EpnTapModule` each time a new product type
40   -is selected.
41   -
42   -- `id`: the target class in lowercase, with the underscore between each word;
43   -- `name`: the target class, capitalized with spaces between each word (done `EpnTapModule.prettify()`).
  28 +TODO: try "var arrayStore = Ext.create(...);"
44 29 */
45 30 Ext.create('Ext.data.Store', {
46   - storeId:'targetClassesStore',
47   - fields: ['id', 'name']
  31 + storeId:'productTypesStore',
  32 + fields: ['id', 'name'],
  33 + data: [
  34 + {'id': 'im', 'name': 'Image'},
  35 + {'id': 'ma', 'name': 'Map'},
  36 + {'id': 'sp', 'name': 'Spectrum'},
  37 + {'id': 'ds', 'name': 'Dynamic spectrum'},
  38 + {'id': 'sc', 'name': 'Spectral cube'},
  39 + {'id': 'pr', 'name': 'Profile'},
  40 + {'id': 'vo', 'name': 'Volume'},
  41 + {'id': 'mo', 'name': 'Movie'},
  42 + {'id': 'cu', 'name': 'Cube'},
  43 + {'id': 'ts', 'name': 'Time series'},
  44 + {'id': 'ca', 'name': 'Catalogue'},
  45 + {'id': 'ci', 'name': 'Catalogue item'}
  46 + ]
48 47 });
49 48  
50 49 /**
... ... @@ -210,9 +209,8 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
210 209 xtype : 'container',
211 210 flex: 3,
212 211 items: [
213   - this.createProductTypeCB(),
214   - this.createTargetClassCB(),
215 212 this.createTargetNameCB(),
  213 + this.createProductTypeCB(),
216 214 {
217 215 xtype: 'panel',
218 216 layout: { type: 'hbox', pack: 'start', align: 'stretch' },
... ... @@ -241,7 +239,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
241 239 `epnTapProductTypesStore`, which is initilized by `EpnTapModule`.
242 240  
243 241 The selection of a produt type triggers `EpnTapModule.onProductTypeCBChanged()`, which basically update
244   - `epnTapTargetClassCB` and `epnTapGranulesGrid`.
  242 + `epnTapGranulesGrid`.
245 243 */
246 244 createProductTypeCB: function() {
247 245 return {
... ... @@ -251,28 +249,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
251 249 store: Ext.data.StoreManager.lookup('productTypesStore'),
252 250 queryMode: 'local',
253 251 valueField: 'id',
254   - maxWidth: 100,
255 252 displayField: 'name',
256   - editable: false
257   - };
258   - },
259   -
260   - /**
261   - Create `epnTapTargetClassCB`, an ExtJS ComboBox, containing a list of target classes corresponding to the
262   - selected product type, as defined in `targetClassesStore`, which is initilized by `EpnTapModule`.
263   -
264   - The selection of a target class triggers the `EpnTapModule.onTargetClassCBChanged()`, which basically updates
265   - `targetNameCB` and `granulesGrid`.
266   - */
267   - createTargetClassCB: function() {
268   - return {
269   - xtype: 'combobox',
270   - id: 'epnTapTargetClassCB',
271   - fieldLabel: 'Target class',
272   - store: Ext.data.StoreManager.lookup('targetClassesStore'),
273   - queryMode: 'local',
274   - displayField: 'name',
275   - valueField: 'id',
276 253 maxWidth: 100,
277 254 editable: false
278 255 };
... ... @@ -291,18 +268,34 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
291 268 id: 'epnTapTargetNameCB',
292 269 fieldLabel: 'Target name',
293 270 store: Ext.data.StoreManager.lookup('targetNamesStore'),
294   - queryMode: 'local',
  271 + queryMode: 'remote',
295 272 displayField: 'name',
296 273 valueField: 'id',
297   - triggerAction: 'all',
298   - typeAhead: true,
299 274 maxWidth: 100,
300   - mode: 'remote',
301 275 minChars: 2,
302   - forceSelection: true
  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 + hideTrigger: true,
  286 + selectOnFocus: false,
  287 + listeners: {
  288 + specialkey: function(field, e){
  289 + if (e.getKey() == e.ENTER) {
  290 + console.log('yolo');
  291 + }
  292 + }
  293 + }
  294 +
303 295 };
304 296 },
305 297  
  298 +
306 299 /**
307 300 Create `epnTapTimeSelector`, an IntervalUI object, allowing the user to select a time interval (by filling two
308 301 dates and/or a duration).
... ... @@ -537,21 +530,9 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
537 530 return '<img width="40px height="40px" src="' + val + '">';
538 531 };
539 532 var dptRender = function(val) {
540   - productTypeDict = {
541   - 'im': 'Image',
542   - 'ma': 'Map',
543   - 'sp': 'Spectrum',
544   - 'ds': 'Dynamic spectrum',
545   - 'sc': 'Spectral cube',
546   - 'pr': 'Profile',
547   - 'vo': 'Volume',
548   - 'mo': 'Movie',
549   - 'cu': 'Cube',
550   - 'ts': 'Time series',
551   - 'ca': 'Catalogue',
552   - 'ci': 'Catalogue item'
553   - };
554   - return (val in productTypeDict) ? '<p style="white-space: normal;">' + productTypeDict[val] + '</p>' : '<em>' + val + '</em>';
  533 + console.log(Ext.data.StoreManager.lookup('productTypesStore'));
  534 + return val;
  535 + // (val in productTypeDict) ? '<p style="white-space: normal;">' + productTypeDict[val] + '</p>' : '<em>' + val + '</em>';
555 536 };
556 537 var formatRender = function(val) {
557 538 // A dictionnary used to associate the mimetype (i.e "application/fits") to a pretty printed word (i.e "fits").
... ...