Commit 7211d9b512b9c832be9a8681bbcc48ce25e7c75b
1 parent
cadbea27
Exists in
master
and in
112 other branches
Move util.Format outside the gridpanels
Showing
1 changed file
with
96 additions
and
97 deletions
Show diff stats
js/app/views/EpnTapUI.js
... | ... | @@ -157,6 +157,101 @@ Ext.create('Ext.data.Store', { |
157 | 157 | } |
158 | 158 | }); |
159 | 159 | |
160 | +Ext.define('App.util.Format', { | |
161 | + override: 'Ext.util.Format', | |
162 | + 'text': function(data) { | |
163 | + return '<p style="white-space: normal;">' + data + '</p>'; | |
164 | + }, | |
165 | + 'link': function(data) { | |
166 | + return '<a href="' + data + '">data</a>'; | |
167 | + }, | |
168 | + 'img': function(data) { | |
169 | + return '<img width="40px height="40px" src="' + data + '">'; | |
170 | + }, | |
171 | + 'type': function(data) { | |
172 | + var productTypeDict = Ext.data.StoreManager.lookup('productTypesStore').data.map; | |
173 | + return '<p>' + productTypeDict[data].data.name + '</p>'; | |
174 | + }, | |
175 | + 'size': function(data) { | |
176 | + var size = parseInt(data); | |
177 | + var txt = ''; | |
178 | + if (isNaN(size)) { | |
179 | + } else if (size >= 1024*1024) { | |
180 | + txt = (size/(1024*1024)).toPrecision(3) + 'Go'; | |
181 | + } else if (size >= 1024) { | |
182 | + txt = (size/1024).toPrecision(3) + 'Mo'; | |
183 | + } else { | |
184 | + txt = size + 'Ko'; | |
185 | + } | |
186 | + return '<p>' + txt + '</p>' | |
187 | + }, | |
188 | + 'date': function(data) { | |
189 | + return data; // TODO | |
190 | + }, | |
191 | + 'number': function(val) { | |
192 | + if(val < 0) { | |
193 | + return '-'; | |
194 | + } else if(val >= 1000*1000) { | |
195 | + return (val/(1000*1000)).toPrecision(3) + 'm'; | |
196 | + } else if(val >= 1000) { | |
197 | + return (val/1000).toPrecision(3) + 'k'; | |
198 | + } else { | |
199 | + return val; | |
200 | + } | |
201 | + }, | |
202 | + 'format': function(data) { | |
203 | + var mimetypeDict = { | |
204 | + 'application/fits': 'fits', | |
205 | + 'application/x-pds': 'pds', | |
206 | + 'image/x-pds': 'pds', | |
207 | + 'application/gml+xml': 'gml', | |
208 | + 'application/json': 'json', | |
209 | + 'application/octet-stream': 'bin, idl, envi or matlab', | |
210 | + 'application/pdf': 'pdf', | |
211 | + 'application/postscript': 'ps', | |
212 | + 'application/vnd.geo+json': 'geojson', | |
213 | + 'application/vnd.google-earth.kml+xml': 'kml', | |
214 | + 'application/vnd.google-earth.kmz': 'kmz', | |
215 | + 'application/vnd.ms-excel': 'xls', | |
216 | + 'application/x-asdm': 'asdm', | |
217 | + 'application/x-cdf': 'cdf', | |
218 | + 'application/x-cdf-istp': 'cdf', | |
219 | + 'application/x-cdf-pds4': 'cdf', | |
220 | + 'application/x-cef1': 'cef1', | |
221 | + 'application/x-cef2': 'cef2', | |
222 | + 'application/x-directory': 'dir', | |
223 | + 'application/x-fits-bintable': 'bintable', | |
224 | + 'application/x-fits-euro3d': 'euro3d', | |
225 | + 'application/x-fits-mef': 'mef', | |
226 | + 'application/x-geotiff': 'geotiff', | |
227 | + 'application/x-hdf': 'hdf', | |
228 | + 'application/x-netcdf': 'nc', | |
229 | + 'application/x-netcdf4': 'nc', | |
230 | + 'application/x-tar': 'tar', | |
231 | + 'application/x-tar-gzip': 'gtar', | |
232 | + 'application/x-votable+xml': 'votable', | |
233 | + 'application/x-votable+xml;content=datalink': 'votable', | |
234 | + 'application/zip': 'zip', | |
235 | + 'image/fits': 'fits', | |
236 | + 'image/gif': 'gif', | |
237 | + 'image/jpeg': 'jpeg', | |
238 | + 'image/png': 'png', | |
239 | + 'image/tiff': 'tiff', | |
240 | + 'image/x-fits-gzip': 'fits', | |
241 | + 'image/x-fits-hcompress': 'fits', | |
242 | + 'text/csv': 'csv', | |
243 | + 'text/html': 'html', | |
244 | + 'text/plain': 'txt', | |
245 | + 'text/tab-separated-values': 'tsv', | |
246 | + 'text/xml': 'xml', | |
247 | + 'video/mpeg': 'mpeg', | |
248 | + 'video/quicktime': 'mov', | |
249 | + 'video/x-msvideo': 'avi' | |
250 | + }; | |
251 | + return (data in mimetypeDict) ? '<p>' + mimetypeDict[data] + '</p>' : '<em>' + data + '</em>'; | |
252 | + } | |
253 | +}); | |
254 | + | |
160 | 255 | /** |
161 | 256 | `EpnTapUI`: The view of the AMDA EPN-TAP module, allowing the user to query and display granules information from |
162 | 257 | EPN-TAP services. |
... | ... | @@ -406,18 +501,6 @@ Ext.define('amdaUI.EpnTapUI', { |
406 | 501 | service granules. |
407 | 502 | */ |
408 | 503 | createServicesGrid: function() { |
409 | - var nbResRender = function(val) { | |
410 | - if(val < 0) { | |
411 | - return '-'; | |
412 | - } else if(val >= 1000*1000) { | |
413 | - return (val/(1000*1000)).toPrecision(3) + 'm'; | |
414 | - } else if(val >= 1000) { | |
415 | - return (val/1000).toPrecision(3) + 'k'; | |
416 | - } else { | |
417 | - return val; | |
418 | - } | |
419 | - }; | |
420 | - | |
421 | 504 | var epnTapServicesGrid = new Ext.grid.Panel({ |
422 | 505 | id: 'epnTapServicesGrid', |
423 | 506 | title: 'Services', |
... | ... | @@ -425,7 +508,7 @@ Ext.define('amdaUI.EpnTapUI', { |
425 | 508 | flex: 1, |
426 | 509 | columns: [ |
427 | 510 | {text: 'Name', dataIndex: 'short_name', flex: 1}, |
428 | - {text: 'Nb res.', dataIndex: 'nb_results', width: 50, renderer: nbResRender} | |
511 | + {text: 'Nb res.', dataIndex: 'nb_results', width: 50, renderer: 'number'} | |
429 | 512 | ], |
430 | 513 | viewConfig: { |
431 | 514 | getRowClass: function(record, index) { |
... | ... | @@ -503,90 +586,6 @@ Ext.define('amdaUI.EpnTapUI', { |
503 | 586 | TODO: infinite scroll! http://docs.sencha.com/extjs/4.2.3/extjs-build/examples/grid/infinite-scroll-with-filter.html |
504 | 587 | */ |
505 | 588 | createGranulesGrid: function() { |
506 | - Ext.define('App.util.Format', { | |
507 | - override: 'Ext.util.Format', | |
508 | - 'text': function(data) { | |
509 | - return '<p style="white-space: normal;">' + data + '</p>'; | |
510 | - }, | |
511 | - 'link': function(data) { | |
512 | - return '<a href="' + data + '">data</a>'; | |
513 | - }, | |
514 | - 'img': function(data) { | |
515 | - return '<img width="40px height="40px" src="' + data + '">'; | |
516 | - }, | |
517 | - 'type': function(data) { | |
518 | - var productTypeDict = Ext.data.StoreManager.lookup('productTypesStore').data.map; | |
519 | - return '<p>' + productTypeDict[data].data.name + '</p>'; | |
520 | - }, | |
521 | - 'format': function(data) { | |
522 | - var mimetypeDict = { | |
523 | - 'application/fits': 'fits', | |
524 | - 'application/x-pds': 'pds', | |
525 | - 'image/x-pds': 'pds', | |
526 | - 'application/gml+xml': 'gml', | |
527 | - 'application/json': 'json', | |
528 | - 'application/octet-stream': 'bin, idl, envi or matlab', | |
529 | - 'application/pdf': 'pdf', | |
530 | - 'application/postscript': 'ps', | |
531 | - 'application/vnd.geo+json': 'geojson', | |
532 | - 'application/vnd.google-earth.kml+xml': 'kml', | |
533 | - 'application/vnd.google-earth.kmz': 'kmz', | |
534 | - 'application/vnd.ms-excel': 'xls', | |
535 | - 'application/x-asdm': 'asdm', | |
536 | - 'application/x-cdf': 'cdf', | |
537 | - 'application/x-cdf-istp': 'cdf', | |
538 | - 'application/x-cdf-pds4': 'cdf', | |
539 | - 'application/x-cef1': 'cef1', | |
540 | - 'application/x-cef2': 'cef2', | |
541 | - 'application/x-directory': 'dir', | |
542 | - 'application/x-fits-bintable': 'bintable', | |
543 | - 'application/x-fits-euro3d': 'euro3d', | |
544 | - 'application/x-fits-mef': 'mef', | |
545 | - 'application/x-geotiff': 'geotiff', | |
546 | - 'application/x-hdf': 'hdf', | |
547 | - 'application/x-netcdf': 'nc', | |
548 | - 'application/x-netcdf4': 'nc', | |
549 | - 'application/x-tar': 'tar', | |
550 | - 'application/x-tar-gzip': 'gtar', | |
551 | - 'application/x-votable+xml': 'votable', | |
552 | - 'application/x-votable+xml;content=datalink': 'votable', | |
553 | - 'application/zip': 'zip', | |
554 | - 'image/fits': 'fits', | |
555 | - 'image/gif': 'gif', | |
556 | - 'image/jpeg': 'jpeg', | |
557 | - 'image/png': 'png', | |
558 | - 'image/tiff': 'tiff', | |
559 | - 'image/x-fits-gzip': 'fits', | |
560 | - 'image/x-fits-hcompress': 'fits', | |
561 | - 'text/csv': 'csv', | |
562 | - 'text/html': 'html', | |
563 | - 'text/plain': 'txt', | |
564 | - 'text/tab-separated-values': 'tsv', | |
565 | - 'text/xml': 'xml', | |
566 | - 'video/mpeg': 'mpeg', | |
567 | - 'video/quicktime': 'mov', | |
568 | - 'video/x-msvideo': 'avi' | |
569 | - }; | |
570 | - return (data in mimetypeDict) ? '<p>' + mimetypeDict[data] + '</p>' : '<em>' + data + '</em>'; | |
571 | - }, | |
572 | - 'size': function(data) { | |
573 | - var size = parseInt(data); | |
574 | - var txt = ''; | |
575 | - if (isNaN(size)) { | |
576 | - } else if (size >= 1024*1024) { | |
577 | - txt = (size/(1024*1024)).toPrecision(3) + 'Go'; | |
578 | - } else if (size >= 1024) { | |
579 | - txt = (size/1024).toPrecision(3) + 'Mo'; | |
580 | - } else { | |
581 | - txt = size + 'Ko'; | |
582 | - } | |
583 | - return '<p>' + txt + '</p>' | |
584 | - }, | |
585 | - 'date': function(data) { | |
586 | - | |
587 | - } | |
588 | - }); | |
589 | - | |
590 | 589 | var epnTapGranulesGrid = new Ext.grid.Panel({ |
591 | 590 | id: 'epnTapGranulesGrid', |
592 | 591 | title: 'Granules', |
... | ... |