Commit b083bc63210d851c61bfe28efe474b64b273df14
1 parent
141fcf73
Exists in
master
and in
112 other branches
Update productType combobox when loading services store.
Showing
2 changed files
with
110 additions
and
106 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
... | ... | @@ -7,72 +7,6 @@ |
7 | 7 | * @author Nathanael Jourdane |
8 | 8 | */ |
9 | 9 | |
10 | -// A dictionnary used to associate the productType id (i.e "im") to its value (i.e "Image"). | |
11 | -productTypeDict = { | |
12 | - 'im': 'Image', | |
13 | - 'ma': 'Map', | |
14 | - 'sp': 'Spectrum', | |
15 | - 'ds': 'Dynamic spectrum', | |
16 | - 'sc': 'Spectral cube', | |
17 | - 'pr': 'Profile', | |
18 | - 'vo': 'Volume', | |
19 | - 'mo': 'Movie', | |
20 | - 'cu': 'Cube', | |
21 | - 'ts': 'Time series', | |
22 | - 'ca': 'Catalogue', | |
23 | - 'ci': 'Catalogue item' | |
24 | -}; | |
25 | - | |
26 | -// A dictionnary used to associate the mimetype (i.e "application/fits") to a pretty printed word (i.e "fits"). | |
27 | -mimetypeDict = { | |
28 | - 'application/fits': 'fits', | |
29 | - 'application/x-pds': 'pds', | |
30 | - 'image/x-pds': 'pds', | |
31 | - 'application/gml+xml': 'gml', | |
32 | - 'application/json': 'json', | |
33 | - 'application/octet-stream': 'bin, idl, envi or matlab', | |
34 | - 'application/pdf': 'pdf', | |
35 | - 'application/postscript': 'ps', | |
36 | - 'application/vnd.geo+json': 'geojson', | |
37 | - 'application/vnd.google-earth.kml+xml': 'kml', | |
38 | - 'application/vnd.google-earth.kmz': 'kmz', | |
39 | - 'application/vnd.ms-excel': 'xls', | |
40 | - 'application/x-asdm': 'asdm', | |
41 | - 'application/x-cdf': 'cdf', | |
42 | - 'application/x-cdf-istp': 'cdf', | |
43 | - 'application/x-cdf-pds4': 'cdf', | |
44 | - 'application/x-cef1': 'cef1', | |
45 | - 'application/x-cef2': 'cef2', | |
46 | - 'application/x-directory': 'dir', | |
47 | - 'application/x-fits-bintable': 'bintable', | |
48 | - 'application/x-fits-euro3d': 'euro3d', | |
49 | - 'application/x-fits-mef': 'mef', | |
50 | - 'application/x-geotiff': 'geotiff', | |
51 | - 'application/x-hdf': 'hdf', | |
52 | - 'application/x-netcdf': 'nc', | |
53 | - 'application/x-netcdf4': 'nc', | |
54 | - 'application/x-tar': 'tar', | |
55 | - 'application/x-tar-gzip': 'gtar', | |
56 | - 'application/x-votable+xml': 'votable', | |
57 | - 'application/x-votable+xml;content=datalink': 'votable', | |
58 | - 'application/zip': 'zip', | |
59 | - 'image/fits': 'fits', | |
60 | - 'image/gif': 'gif', | |
61 | - 'image/jpeg': 'jpeg', | |
62 | - 'image/png': 'png', | |
63 | - 'image/tiff': 'tiff', | |
64 | - 'image/x-fits-gzip': 'fits', | |
65 | - 'image/x-fits-hcompress': 'fits', | |
66 | - 'text/csv': 'csv', | |
67 | - 'text/html': 'html', | |
68 | - 'text/plain': 'txt', | |
69 | - 'text/tab-separated-values': 'tsv', | |
70 | - 'text/xml': 'xml', | |
71 | - 'video/mpeg': 'mpeg', | |
72 | - 'video/quicktime': 'mov', | |
73 | - 'video/x-msvideo': 'avi' | |
74 | -}; | |
75 | - | |
76 | 10 | Ext.define('amdaDesktop.EpnTapModule', { |
77 | 11 | |
78 | 12 | extend: 'amdaDesktop.AmdaModule', |
... | ... | @@ -92,12 +26,8 @@ Ext.define('amdaDesktop.EpnTapModule', { |
92 | 26 | Module initialisation. |
93 | 27 | */ |
94 | 28 | init: function() { |
95 | - this.metadataStore = Ext.data.StoreManager.lookup('metadataStore'); | |
96 | - this.metadataStore.load(); | |
97 | - | |
98 | 29 | this.select = Array(); |
99 | 30 | this.filter = Array(); |
100 | - | |
101 | 31 | this.selectedServiceId = null; |
102 | 32 | |
103 | 33 | this.launcher = { |
... | ... | @@ -166,6 +96,9 @@ Ext.define('amdaDesktop.EpnTapModule', { |
166 | 96 | - `target`: an array of 3 values: [dataproduct_type, target_class, target_name]; or null. |
167 | 97 | */ |
168 | 98 | initWindow: function(target) { |
99 | + Ext.data.StoreManager.lookup('servicesStore').load(); | |
100 | + Ext.data.StoreManager.lookup('metadataStore').load(); | |
101 | + | |
169 | 102 | this.productTypeCB = Ext.getCmp('epnTapProductTypeCB'); |
170 | 103 | this.targetClassCB = Ext.getCmp('epnTapTargetClassCB'); |
171 | 104 | this.targetNameCB = Ext.getCmp('epnTapTargetNameCB'); |
... | ... | @@ -181,23 +114,11 @@ Ext.define('amdaDesktop.EpnTapModule', { |
181 | 114 | this.lastPageBtn = Ext.getCmp('epnTapLastPageBtn'); |
182 | 115 | this.epnTapPanel = this.productTypeCB.findParentByType('panelEpnTap'); |
183 | 116 | |
184 | - this.servicesGrid.getStore().load(); | |
185 | - // Update productTypeCB | |
186 | - this.productTypeCB.getStore().add({'id': 'all', 'name': 'All data product types'}); | |
187 | - var dataproductType = this.metadataStore.collect('dataproduct_type'); | |
188 | - for (var i = 0; i < dataproductType.length; i++) { | |
189 | - if (dataproductType[i] in productTypeDict) { | |
190 | - this.productTypeCB.getStore().add({'id': dataproductType[i], 'name': this.prettify(productTypeDict[dataproductType[i]])}); | |
191 | - } else { | |
192 | - console.log('Unknown data product type "' + dataproductType[i] + '"'); | |
193 | - } | |
194 | - } | |
195 | - | |
196 | 117 | // If the EPN-TAP module is launched from the AMDA tree |
197 | 118 | if(target) { |
198 | 119 | // --- Select product types --- |
199 | 120 | if (! target[0] in this.productTypeCB.getStore()) { |
200 | - alert("Sorry, product type " + productTypeDict[target[0]] + " is not found in available services."); | |
121 | + alert("Sorry, product type " + target[0] + " is not found in available services."); | |
201 | 122 | return; |
202 | 123 | } |
203 | 124 | this.productTypeCB.select(target[0]); |
... | ... | @@ -250,8 +171,8 @@ Ext.define('amdaDesktop.EpnTapModule', { |
250 | 171 | if (this.productTypeCB.value == 'all') { |
251 | 172 | this.targetClassCB.disable(); |
252 | 173 | } else { |
253 | - this.metadataStore.filter('dataproduct_type', this.productTypeCB.value) | |
254 | - var targetClasses = this.metadataStore.collect('target_class'); | |
174 | + Ext.data.StoreManager.lookup('metadataStore').filter('dataproduct_type', this.productTypeCB.value) | |
175 | + var targetClasses = Ext.data.StoreManager.lookup('metadataStore').collect('target_class'); | |
255 | 176 | |
256 | 177 | if (targetClasses.length == 1) { |
257 | 178 | this.targetClassCB.getStore().add({'id': targetClasses[0], 'name': this.prettify(targetClasses[0])}); |
... | ... | @@ -284,8 +205,8 @@ Ext.define('amdaDesktop.EpnTapModule', { |
284 | 205 | this.targetNameCB.select('all'); |
285 | 206 | this.targetNameCB.disable(); |
286 | 207 | } else { |
287 | - this.metadataStore.filter('target_class', this.targetClassCB.value); | |
288 | - var targetNames = this.metadataStore.collect('target_name'); | |
208 | + Ext.data.StoreManager.lookup('metadataStore').filter('target_class', this.targetClassCB.value); | |
209 | + var targetNames = Ext.data.StoreManager.lookup('metadataStore').collect('target_name'); | |
289 | 210 | if (targetNames.length == 1) { |
290 | 211 | this.targetNameCB.getStore().add({'id': targetNames[0], 'name': this.prettify(targetNames[0])}); |
291 | 212 | this.targetNameCB.select(this.targetNameCB.getStore().getAt(0)['internalId']); |
... | ... | @@ -341,7 +262,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
341 | 262 | var newPageNumber = 1; |
342 | 263 | var limit = Number(this.rowsPerPageNf.value); |
343 | 264 | var offset = 0; |
344 | - var selectedServiceURL = this.servicesGrid.getStore().getById(this.selectedServiceId)['accessurl']; | |
265 | + var selectedServiceURL = Ext.data.StoreManager.lookup('servicesStore').getById(this.selectedServiceId)['accessurl']; | |
345 | 266 | |
346 | 267 | this.wait(); |
347 | 268 | this.disableNavBtns(true, true, false, false); |
... | ... | @@ -357,7 +278,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
357 | 278 | var newPageNumber = Number(this.currentPageLb.text) - 1; |
358 | 279 | var limit = Number(this.rowsPerPageNf.value); |
359 | 280 | var offset = (newPageNumber-1) * limit; |
360 | - var selectedServiceURL = this.servicesGrid.getStore().getById(this.selectedServiceId)['accessurl']; | |
281 | + var selectedServiceURL = Ext.data.StoreManager.lookup('servicesStore').getById(this.selectedServiceId)['accessurl']; | |
361 | 282 | |
362 | 283 | this.wait(); |
363 | 284 | this.currentPageLb.setText('' + newPageNumber); |
... | ... | @@ -374,7 +295,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
374 | 295 | var newPageNumber = Number(this.currentPageLb.text) + 1; |
375 | 296 | var limit = Number(this.rowsPerPageNf.value); |
376 | 297 | var offset = (newPageNumber-1) * limit; |
377 | - var selectedServiceURL = this.servicesGrid.getStore().getById(this.selectedServiceId)['accessurl']; | |
298 | + var selectedServiceURL = Ext.data.StoreManager.lookup('servicesStore').getById(this.selectedServiceId)['accessurl']; | |
378 | 299 | |
379 | 300 | this.wait(); |
380 | 301 | this.currentPageLb.setText('' + newPageNumber); |
... | ... | @@ -391,7 +312,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
391 | 312 | var newPageNumber = Number(this.totalPagesLb.text); |
392 | 313 | var limit = Number(this.rowsPerPageNf.value); |
393 | 314 | var offset = (newPageNumber-1) * limit; |
394 | - var selectedServiceURL = this.servicesGrid.getStore().getById(this.selectedServiceId)['accessurl']; | |
315 | + var selectedServiceURL = Ext.data.StoreManager.lookup('servicesStore').getById(this.selectedServiceId)['accessurl']; | |
395 | 316 | |
396 | 317 | this.wait(); |
397 | 318 | this.currentPageLb.setText('' + newPageNumber); |
... | ... | @@ -413,7 +334,7 @@ Ext.define('amdaDesktop.EpnTapModule', { |
413 | 334 | this.selectedServiceId = selectedServiceId; |
414 | 335 | this.select = Array(); |
415 | 336 | |
416 | - var selectedService = this.servicesGrid.getStore().findRecord('id', selectedServiceId).data; | |
337 | + var selectedService = Ext.data.StoreManager.lookup('servicesStore').findRecord('id', selectedServiceId).data; | |
417 | 338 | if (selectedService == null) { |
418 | 339 | throw this.selectedServiceId + ' not found in the list of services.'; |
419 | 340 | return; |
... | ... | @@ -454,33 +375,34 @@ Ext.define('amdaDesktop.EpnTapModule', { |
454 | 375 | */ |
455 | 376 | updateNbResults: function(ui) { |
456 | 377 | if(this.productTypeCB.value === 'all' && !this.launchedFromTree ) { |
457 | - filter = []; | |
378 | + var filter = []; | |
458 | 379 | } else if(this.targetClassCB.value === 'all') { |
459 | - filter = [ | |
380 | + var filter = [ | |
460 | 381 | {property: "dataproduct_type", value: this.productTypeCB.value} |
461 | 382 | ]; |
462 | 383 | } else if(this.targetNameCB.value === 'all') { |
463 | - filter = [ | |
384 | + var filter = [ | |
464 | 385 | {property: "dataproduct_type", value: this.productTypeCB.value}, |
465 | 386 | {property: "target_class", value: this.targetClassCB.value} |
466 | 387 | ]; |
467 | 388 | } else { |
468 | - filter = [ | |
389 | + var filter = [ | |
469 | 390 | {property: "dataproduct_type", value: this.productTypeCB.value}, |
470 | 391 | {property: "target_class", value: this.targetClassCB.value}, |
471 | 392 | {property: "target_name", value: this.targetNameCB.value} |
472 | 393 | ]; |
473 | 394 | } |
395 | + var metadataStore = Ext.data.StoreManager.lookup('metadataStore'); | |
474 | 396 | |
475 | - this.servicesGrid.getStore().each(function(record, idx) { | |
476 | - this.metadataStore.filter(filter.concat({property: 'service_id', value: record['id']})); | |
477 | - record.set('nb_results', this.metadataStore.sum('nb_results')); | |
478 | - this.metadataStore.clearFilter(); | |
397 | + Ext.data.StoreManager.lookup('servicesStore').each(function(record, idx) { | |
398 | + metadataStore.filter(filter.concat({property: 'service_id', value: record.get('id')})); | |
399 | + record.set('nb_results', metadataStore.sum('nb_results')); | |
400 | + metadataStore.clearFilter(); | |
479 | 401 | }); |
480 | - this.servicesGrid.getStore().sort('nb_results', 'DESC'); | |
402 | + Ext.data.StoreManager.lookup('servicesStore').sort('nb_results', 'DESC'); | |
481 | 403 | |
482 | - var timeMin = this.metadataStore.min('time_min'); | |
483 | - var timeMax = this.metadataStore.max('time_max'); | |
404 | + var timeMin = metadataStore.min('time_min'); | |
405 | + var timeMax = metadataStore.max('time_max'); | |
484 | 406 | this.timeSelector.setLimits(timeMin, timeMax); |
485 | 407 | this.timeSelector.setInterval(timeMin, timeMax); |
486 | 408 | }, |
... | ... |
js/app/views/EpnTapUI.js
... | ... | @@ -26,7 +26,7 @@ in this store and an information message is displayed on the JavaScript console |
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 | 28 | */ |
29 | -Ext.create('Ext.data.Store', { | |
29 | +Ext.create('Ext.data.ArrayStore', { | |
30 | 30 | storeId:'productTypesStore', |
31 | 31 | fields: ['id', 'name'] |
32 | 32 | }); |
... | ... | @@ -123,6 +123,39 @@ Ext.create('Ext.data.ArrayStore', { |
123 | 123 | proxy: { |
124 | 124 | type: 'ajax', |
125 | 125 | url : '../../../generic_data/EpnTapData/metadata.json' |
126 | + }, | |
127 | + listeners: { | |
128 | + load: function(store) { | |
129 | + // A dictionnary used to associate the productType id (i.e "im") to its value (i.e "Image"). | |
130 | + productTypeDict = { | |
131 | + 'im': 'Image', | |
132 | + 'ma': 'Map', | |
133 | + 'sp': 'Spectrum', | |
134 | + 'ds': 'Dynamic spectrum', | |
135 | + 'sc': 'Spectral cube', | |
136 | + 'pr': 'Profile', | |
137 | + 'vo': 'Volume', | |
138 | + 'mo': 'Movie', | |
139 | + 'cu': 'Cube', | |
140 | + 'ts': 'Time series', | |
141 | + 'ca': 'Catalogue', | |
142 | + 'ci': 'Catalogue item' | |
143 | + }; | |
144 | + | |
145 | + // Update productTypeCB | |
146 | + var productTypeCBStore = Ext.data.StoreManager.lookup('productTypesStore'); | |
147 | + var dataproductTypes = store.collect('dataproduct_type'); | |
148 | + productTypeCBStore.add({'id': 'all', 'name': 'All dataproduct types'}); | |
149 | + for (var i = 0; i < dataproductTypes.length; i++) { | |
150 | + if (dataproductTypes[i] in productTypeDict) { | |
151 | + productTypeCBStore.add({'id': dataproductTypes[i], 'name': productTypeDict[dataproductTypes[i]]}); | |
152 | + } else { | |
153 | + productTypeCBStore.add({'id': dataproductTypes[i], 'name': dataproductTypes[i]}); | |
154 | + console.log('Unknown data product type "' + dataproductTypes[i] + '".'); | |
155 | + } | |
156 | + } | |
157 | + Ext.getCmp('epnTapProductTypeCB').select('all'); | |
158 | + } | |
126 | 159 | } |
127 | 160 | }); |
128 | 161 | |
... | ... | @@ -298,7 +331,56 @@ Ext.define('amdaUI.EpnTapUI', { |
298 | 331 | return (val in mod.productTypeDict) ? '<p style="white-space: normal;">' + mod.productTypeDict[val] + '</p>' : '<em>' + val + '</em>'; |
299 | 332 | }; |
300 | 333 | var formatRender = function(val) { |
301 | - return (val in mod.mimetypeDict) ? mod.mimetypeDict[val] : '<em style="white-space: normal;">' + val + '</em>'; | |
334 | + // A dictionnary used to associate the mimetype (i.e "application/fits") to a pretty printed word (i.e "fits"). | |
335 | + mimetypeDict = { | |
336 | + 'application/fits': 'fits', | |
337 | + 'application/x-pds': 'pds', | |
338 | + 'image/x-pds': 'pds', | |
339 | + 'application/gml+xml': 'gml', | |
340 | + 'application/json': 'json', | |
341 | + 'application/octet-stream': 'bin, idl, envi or matlab', | |
342 | + 'application/pdf': 'pdf', | |
343 | + 'application/postscript': 'ps', | |
344 | + 'application/vnd.geo+json': 'geojson', | |
345 | + 'application/vnd.google-earth.kml+xml': 'kml', | |
346 | + 'application/vnd.google-earth.kmz': 'kmz', | |
347 | + 'application/vnd.ms-excel': 'xls', | |
348 | + 'application/x-asdm': 'asdm', | |
349 | + 'application/x-cdf': 'cdf', | |
350 | + 'application/x-cdf-istp': 'cdf', | |
351 | + 'application/x-cdf-pds4': 'cdf', | |
352 | + 'application/x-cef1': 'cef1', | |
353 | + 'application/x-cef2': 'cef2', | |
354 | + 'application/x-directory': 'dir', | |
355 | + 'application/x-fits-bintable': 'bintable', | |
356 | + 'application/x-fits-euro3d': 'euro3d', | |
357 | + 'application/x-fits-mef': 'mef', | |
358 | + 'application/x-geotiff': 'geotiff', | |
359 | + 'application/x-hdf': 'hdf', | |
360 | + 'application/x-netcdf': 'nc', | |
361 | + 'application/x-netcdf4': 'nc', | |
362 | + 'application/x-tar': 'tar', | |
363 | + 'application/x-tar-gzip': 'gtar', | |
364 | + 'application/x-votable+xml': 'votable', | |
365 | + 'application/x-votable+xml;content=datalink': 'votable', | |
366 | + 'application/zip': 'zip', | |
367 | + 'image/fits': 'fits', | |
368 | + 'image/gif': 'gif', | |
369 | + 'image/jpeg': 'jpeg', | |
370 | + 'image/png': 'png', | |
371 | + 'image/tiff': 'tiff', | |
372 | + 'image/x-fits-gzip': 'fits', | |
373 | + 'image/x-fits-hcompress': 'fits', | |
374 | + 'text/csv': 'csv', | |
375 | + 'text/html': 'html', | |
376 | + 'text/plain': 'txt', | |
377 | + 'text/tab-separated-values': 'tsv', | |
378 | + 'text/xml': 'xml', | |
379 | + 'video/mpeg': 'mpeg', | |
380 | + 'video/quicktime': 'mov', | |
381 | + 'video/x-msvideo': 'avi' | |
382 | + }; | |
383 | + return (val in mod.mimetypeDict) ? mimetypeDict[val] : '<em style="white-space: normal;">' + val + '</em>'; | |
302 | 384 | }; |
303 | 385 | var sizeRender = function(val) { |
304 | 386 | var size = parseInt(val); |
... | ... | @@ -393,8 +475,8 @@ Ext.define('amdaUI.EpnTapUI', { |
393 | 475 | fieldLabel: 'Product type', |
394 | 476 | store: Ext.data.StoreManager.lookup('productTypesStore'), |
395 | 477 | queryMode: 'local', |
396 | - displayField: 'name', | |
397 | 478 | valueField: 'id', |
479 | + displayField: 'name', | |
398 | 480 | name: 'productType', |
399 | 481 | editable: false, |
400 | 482 | listeners: { |
... | ... |