Commit 24fcdbc7a43cfb0f257759891333df96fb7614d9
1 parent
3345b95b
Exists in
master
and in
112 other branches
Fix crash when epntap panel reloads, move service tooltip in utils.Format render…
…ers, autoload services/granules stores
Showing
3 changed files
with
61 additions
and
79 deletions
Show diff stats
js/app/controllers/EpnTapModule.js
@@ -35,10 +35,27 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -35,10 +35,27 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
35 | handler: this.createWindow, | 35 | handler: this.createWindow, |
36 | scope: this | 36 | scope: this |
37 | }; | 37 | }; |
38 | + }, | ||
38 | 39 | ||
40 | + /** | ||
41 | + Called each time the epntap module is loaded. | ||
42 | + - `target`: an array of 3 values: [target_name, dataproduct_type]; or null. | ||
43 | + */ | ||
44 | + loadTarget: function(target) { | ||
45 | + this.target = target; | ||
39 | this.aquireElements(); | 46 | this.aquireElements(); |
40 | - this.servicesStore.load(); | ||
41 | - this.productTypesStore.load(); | 47 | + this.addListeners(); |
48 | + | ||
49 | + // this.servicesStore.clearFilter(); | ||
50 | + this.granulesStore.removeAll(); | ||
51 | + | ||
52 | + if(target) { | ||
53 | + var name = target[0].charAt(0).toUpperCase() + target[0].replace(/_/g, ' ').substr(1).toLowerCase(); | ||
54 | + this.targetNameCB.getStore().add({'id': target[0], 'name': name}); | ||
55 | + this.targetNameCB.select(target[0]); | ||
56 | + this.productTypeCB.select(target[1]); | ||
57 | + this.updateNbResults(); | ||
58 | + } | ||
42 | }, | 59 | }, |
43 | 60 | ||
44 | aquireElements: function() { | 61 | aquireElements: function() { |
@@ -91,28 +108,6 @@ Ext.define('amdaDesktop.EpnTapModule', { | @@ -91,28 +108,6 @@ Ext.define('amdaDesktop.EpnTapModule', { | ||
91 | } else { | 108 | } else { |
92 | this.getBtn.disable(); | 109 | this.getBtn.disable(); |
93 | } | 110 | } |
94 | - | ||
95 | - }, | ||
96 | - | ||
97 | - /** | ||
98 | - Called each time the epntap module is loaded. | ||
99 | - - `target`: an array of 3 values: [target_name, dataproduct_type]; or null. | ||
100 | - */ | ||
101 | - loadTarget: function(target) { | ||
102 | - this.target = target; | ||
103 | - this.aquireElements(); | ||
104 | - this.addListeners(); | ||
105 | - | ||
106 | - // this.servicesStore.clearFilter(); | ||
107 | - this.granulesStore.removeAll(); | ||
108 | - | ||
109 | - if(target) { | ||
110 | - var name = target[0].charAt(0).toUpperCase() + target[0].replace(/_/g, ' ').substr(1).toLowerCase(); | ||
111 | - this.targetNameCB.getStore().add({'id': target[0], 'name': name}); | ||
112 | - this.targetNameCB.select(target[0]); | ||
113 | - this.productTypeCB.select(target[1]); | ||
114 | - this.updateNbResults(); | ||
115 | - } | ||
116 | }, | 111 | }, |
117 | 112 | ||
118 | /************* | 113 | /************* |
js/app/controllers/InteropModule.js
@@ -423,7 +423,7 @@ Ext.define('amdaDesktop.InteropModule', { | @@ -423,7 +423,7 @@ Ext.define('amdaDesktop.InteropModule', { | ||
423 | activeTab: activeTab, | 423 | activeTab: activeTab, |
424 | baseId: baseId, | 424 | baseId: baseId, |
425 | loadTab: function(tab) { | 425 | loadTab: function(tab) { |
426 | - if(tab['id'] == 'epntapTab') { | 426 | + if(tab['id'] === 'epntapTab') { |
427 | me.loadEpnTap(config && 'epntapTarget' in config ? config['epntapTarget']: false); | 427 | me.loadEpnTap(config && 'epntapTarget' in config ? config['epntapTarget']: false); |
428 | } | 428 | } |
429 | }, | 429 | }, |
js/app/views/EpnTapUI.js
@@ -28,7 +28,8 @@ store. | @@ -28,7 +28,8 @@ store. | ||
28 | TODO: try "var arrayStore = Ext.create(...);" | 28 | TODO: try "var arrayStore = Ext.create(...);" |
29 | */ | 29 | */ |
30 | Ext.create('Ext.data.Store', { | 30 | Ext.create('Ext.data.Store', { |
31 | - storeId:'productTypesStore', | 31 | + storeId: 'productTypesStore', |
32 | + autoLoad: true, | ||
32 | fields: ['id', 'name', 'desc'], | 33 | fields: ['id', 'name', 'desc'], |
33 | data: [ | 34 | data: [ |
34 | {'id': 'all', 'name': '--All--', 'desc': 'Select all produt types.'}, | 35 | {'id': 'all', 'name': '--All--', 'desc': 'Select all produt types.'}, |
@@ -95,6 +96,7 @@ This list is used to fill the `servicesGrid` table, which is updated by `EpnTapM | @@ -95,6 +96,7 @@ This list is used to fill the `servicesGrid` table, which is updated by `EpnTapM | ||
95 | */ | 96 | */ |
96 | Ext.create('Ext.data.Store', { | 97 | Ext.create('Ext.data.Store', { |
97 | storeId: 'servicesStore', | 98 | storeId: 'servicesStore', |
99 | + autoLoad: true, | ||
98 | fields: [ | 100 | fields: [ |
99 | {name: 'id', type: 'string'}, | 101 | {name: 'id', type: 'string'}, |
100 | {name: 'short_name', type: 'string'}, | 102 | {name: 'short_name', type: 'string'}, |
@@ -146,7 +148,7 @@ selected. | @@ -146,7 +148,7 @@ selected. | ||
146 | - `thumbnail_url`: the thumbnail_url EPN-TAP parameter (ibid). | 148 | - `thumbnail_url`: the thumbnail_url EPN-TAP parameter (ibid). |
147 | */ | 149 | */ |
148 | Ext.create('Ext.data.Store', { | 150 | Ext.create('Ext.data.Store', { |
149 | - id: 'granulesStore', | 151 | + storeId: 'granulesStore', |
150 | model: 'granulesModel', // Created dynamically | 152 | model: 'granulesModel', // Created dynamically |
151 | autoload: false, | 153 | autoload: false, |
152 | pageSize: 25, | 154 | pageSize: 25, |
@@ -166,6 +168,38 @@ Ext.create('Ext.data.Store', { | @@ -166,6 +168,38 @@ Ext.create('Ext.data.Store', { | ||
166 | 168 | ||
167 | Ext.define('App.util.Format', { | 169 | Ext.define('App.util.Format', { |
168 | override: 'Ext.util.Format', | 170 | override: 'Ext.util.Format', |
171 | + 'prettify': function(data) { | ||
172 | + return data.charAt(0).toUpperCase() + data.replace(/_/g, ' ').substr(1).toLowerCase(); | ||
173 | + }, | ||
174 | + 'serviceTooltip': function(value, data) { | ||
175 | + var infoColor = data.nb_results == -2 ? 'IndianRed' : 'green'; | ||
176 | + var info = data.info.length > 0 ? "<p style='color:" + infoColor + "'>" + data.info + '</p>' : ''; | ||
177 | + | ||
178 | + var colums = ['res_title', 'ivoid', 'access_url', 'table_name', 'content_type', 'creator_seq', 'content_level', 'reference_url', 'created', 'updated']; | ||
179 | + var details = ''; | ||
180 | + for (var i=0 ; i < colums.length ; i++) { | ||
181 | + if(data[colums[i]] !== '') { | ||
182 | + key = Ext.util.Format.prettify(colums[i]); | ||
183 | + var val = key === 'Content level' ? data[colums[i]].replace(/#/g, ', ') : data[colums[i]]; | ||
184 | + details += '<li><b>' + key + '</b>: ' + val + '</li>'; | ||
185 | + } | ||
186 | + } | ||
187 | + return Ext.String.format('<div data-qtitle="{0}" data-qtip="{1}<ul>{2}</ul>">{0}</div>', value, info, details); | ||
188 | + }, | ||
189 | + 'service.text': function(data, metadata, record) { | ||
190 | + return Ext.util.Format.serviceTooltip(data, record.data); | ||
191 | + }, | ||
192 | + 'service.number': function(data, metadata, record) { | ||
193 | + value = '' + data; | ||
194 | + if(data < 0) { | ||
195 | + value = '-'; | ||
196 | + } else if(data >= 1000*1000) { | ||
197 | + value = (data/(1000*1000)).toPrecision(3) + 'm'; | ||
198 | + } else if(data >= 1000) { | ||
199 | + value = (data/1000).toPrecision(3) + 'k'; | ||
200 | + } | ||
201 | + return Ext.util.Format.serviceTooltip(value, record.data); | ||
202 | + }, | ||
169 | 'text': function(data) { | 203 | 'text': function(data) { |
170 | return '<p style="white-space: normal;">' + data + '</p>'; | 204 | return '<p style="white-space: normal;">' + data + '</p>'; |
171 | }, | 205 | }, |
@@ -209,17 +243,6 @@ Ext.define('App.util.Format', { | @@ -209,17 +243,6 @@ Ext.define('App.util.Format', { | ||
209 | var Y = Math.floor(e / 1461) - 4716 + Math.floor((12 + 2 - M) / 12); | 243 | var Y = Math.floor(e / 1461) - 4716 + Math.floor((12 + 2 - M) / 12); |
210 | return Ext.Date.format(new Date(Y, M-1, D), 'Y/m/d'); | 244 | return Ext.Date.format(new Date(Y, M-1, D), 'Y/m/d'); |
211 | }, | 245 | }, |
212 | - 'number': function(val) { | ||
213 | - if(val < 0) { | ||
214 | - return '-'; | ||
215 | - } else if(val >= 1000*1000) { | ||
216 | - return (val/(1000*1000)).toPrecision(3) + 'm'; | ||
217 | - } else if(val >= 1000) { | ||
218 | - return (val/1000).toPrecision(3) + 'k'; | ||
219 | - } else { | ||
220 | - return val; | ||
221 | - } | ||
222 | - }, | ||
223 | 'format': function(data) { | 246 | 'format': function(data) { |
224 | var mimetypeDict = { | 247 | var mimetypeDict = { |
225 | 'application/fits': 'fits', | 248 | 'application/fits': 'fits', |
@@ -518,14 +541,15 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -518,14 +541,15 @@ Ext.define('amdaUI.EpnTapUI', { | ||
518 | service granules. | 541 | service granules. |
519 | */ | 542 | */ |
520 | createServicesGrid: function() { | 543 | createServicesGrid: function() { |
521 | - var epnTapServicesGrid = new Ext.grid.Panel({ | 544 | + return { |
545 | + xtype: 'grid', | ||
522 | id: 'epnTapServicesGrid', | 546 | id: 'epnTapServicesGrid', |
523 | title: 'Services', | 547 | title: 'Services', |
524 | store: Ext.data.StoreManager.lookup('servicesStore'), | 548 | store: Ext.data.StoreManager.lookup('servicesStore'), |
525 | flex: 1, | 549 | flex: 1, |
526 | columns: [ | 550 | columns: [ |
527 | - {text: 'Name', dataIndex: 'short_name', flex: 1}, | ||
528 | - {text: 'Nb res.', dataIndex: 'nb_results', width: 50, renderer: 'number'} | 551 | + {text: 'Name', dataIndex: 'short_name', flex: 1, renderer: 'service.text'}, |
552 | + {text: 'Nb res.', dataIndex: 'nb_results', width: 50, renderer: 'service.number'} | ||
529 | ], | 553 | ], |
530 | viewConfig: { | 554 | viewConfig: { |
531 | getRowClass: function(record, index) { | 555 | getRowClass: function(record, index) { |
@@ -536,45 +560,8 @@ Ext.define('amdaUI.EpnTapUI', { | @@ -536,45 +560,8 @@ Ext.define('amdaUI.EpnTapUI', { | ||
536 | return 'error_row'; | 560 | return 'error_row'; |
537 | } | 561 | } |
538 | } | 562 | } |
539 | - }, | ||
540 | - renderTo: Ext.getBody() | ||
541 | - }); | ||
542 | - | ||
543 | - Ext.create('Ext.tip.ToolTip', { | ||
544 | - target: epnTapServicesGrid.getView().el, | ||
545 | - delegate: epnTapServicesGrid.getView().itemSelector, | ||
546 | - trackMouse: true, | ||
547 | - listeners: { | ||
548 | - beforeshow: function updateTipBody(tooltip) { | ||
549 | - var column_titles = { | ||
550 | - 'res_title': 'Title', | ||
551 | - 'ivoid': 'ivoid', | ||
552 | - 'access_url': 'Access URL', | ||
553 | - 'table_name': 'Table name', | ||
554 | - 'content_type': 'content type', | ||
555 | - 'creator_seq': 'Creator', | ||
556 | - 'content_level': 'Content level', | ||
557 | - 'reference_url': 'reference URL', | ||
558 | - 'created': 'Created on', | ||
559 | - 'updated': 'Updated on'}; | ||
560 | - var record = epnTapServicesGrid.getView().getRecord(tooltip.triggerElement); | ||
561 | - var ttContent = '<h3>' + record.get('short_name') + '</h3><ul>'; | ||
562 | - if(record.get('info').length > 0) { | ||
563 | - var infoColor = record.get('nb_results') == -2 ? 'IndianRed' : 'green'; | ||
564 | - ttContent += '<p style="color:' + infoColor + '">' + record.get('info') + '</p><br/>'; | ||
565 | - } | ||
566 | - for (var column in column_titles) { | ||
567 | - var col_content = record.get(column); | ||
568 | - if(column === 'content_level' && col_content!=='') { | ||
569 | - col_content = col_content.replace(/#/g, ", "); | ||
570 | - } | ||
571 | - ttContent += '<li><b>' + column_titles[column] + '</b>: ' + col_content + '</li>'; | ||
572 | - } | ||
573 | - tooltip.update(ttContent + '</ul>'); | ||
574 | - } | ||
575 | } | 563 | } |
576 | - }); | ||
577 | - return epnTapServicesGrid; | 564 | + }; |
578 | }, | 565 | }, |
579 | 566 | ||
580 | /** | 567 | /** |