Commit 574171f0df8caf76d37b15146896ef8bf1408387

Authored by Nathanael Jourdane
1 parent 210a3164

Display granules thumbnails and other UI improvments.

js/app/controllers/EpnTapModule.js
@@ -7,26 +7,6 @@ @@ -7,26 +7,6 @@
7 * @author Nathanael Jourdane 7 * @author Nathanael Jourdane
8 */ 8 */
9 9
10 -// for(let service of Ext.getCmp('servicesPanel').getStore().getRange()) {  
11 -// var filter = Array(service.data.schema, service.data.accessurl, targetName, productType, startTime, stopTime);  
12 -// AmdaAction.epnTapMgr('getServiceNbResults', filter, function(epnTapServices) {  
13 -// service.set('nb_responses', epnTapServices===null ? "-" : epnTapServices);  
14 -// console.log(epnTapServices);  
15 -// });  
16 -// }  
17 -  
18 -// var grid = Ext.getCmp('servicesPanel');  
19 -// var selection = grid.getSelectionModel();  
20 -// access_url = [];  
21 -// table_name = [];  
22 -// for(i=0 ; i<grid.store.getCount() ; i++) {  
23 -// if(selection.isSelected(i)) {  
24 -// table_name.push(grid.store.getAt(i).data.table_name);  
25 -// access_url.push(grid.store.getAt(i).data.access_url);  
26 -// }  
27 -//  
28 -// }  
29 -  
30 // Load text with Ajax synchronously: takes path to file and optional MIME type 10 // Load text with Ajax synchronously: takes path to file and optional MIME type
31 function loadTextFileAjaxSync(filePath, mimeType) { 11 function loadTextFileAjaxSync(filePath, mimeType) {
32 var xmlhttp=new XMLHttpRequest(); 12 var xmlhttp=new XMLHttpRequest();
@@ -61,11 +41,11 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -61,11 +41,11 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
61 /** The name of the documentation file related to the module. */ 41 /** The name of the documentation file related to the module. */
62 helpFile : 'epnTapHelp', 42 helpFile : 'epnTapHelp',
63 43
64 - width : 600, 44 + width : 800,
65 height: 550, 45 height: 550,
66 46
67 dpt_dic: { "im": "Image", "ma": "Map", "sp": "Spectrum", "ds": "Dynamic spectrum", "sc": "Spectral cube", "pr": "Profile", 47 dpt_dic: { "im": "Image", "ma": "Map", "sp": "Spectrum", "ds": "Dynamic spectrum", "sc": "Spectral cube", "pr": "Profile",
68 - "vo": "Volume", "mo": "Movie", "cu": "Cube", "ts": "Time series", "ca": "Catalogue", "ci": "Catalogue item" }, 48 + "vo": "Volume", "mo": "Movie", "cu": "Cube", "ts": "Time series", "ca": "Catalogue", "ci": "Catalogue item" },
69 49
70 prettify: function(name) { 50 prettify: function(name) {
71 return name.charAt(0).toUpperCase() + name.replace(/_/g, ' ').substr(1).toLowerCase(); 51 return name.charAt(0).toUpperCase() + name.replace(/_/g, ' ').substr(1).toLowerCase();
@@ -81,32 +61,32 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -81,32 +61,32 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
81 61
82 var filter_dic = new Array(); 62 var filter_dic = new Array();
83 if(this.dpt_cb.value == 'all') { 63 if(this.dpt_cb.value == 'all') {
84 - for (var dpt in this.services) {  
85 - for (var tc in this.services[dpt]) {  
86 - for (tn in this.services[dpt][tc]) {  
87 - for (serv in this.services[dpt][tc][tn]) {  
88 - filter_dic[serv] = this.services[dpt][tc][tn][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0); 64 + for (var dpt in this.metadata) {
  65 + for (var tc in this.metadata[dpt]) {
  66 + for (tn in this.metadata[dpt][tc]) {
  67 + for (serv in this.metadata[dpt][tc][tn]) {
  68 + filter_dic[serv] = this.metadata[dpt][tc][tn][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0);
89 } 69 }
90 } 70 }
91 } 71 }
92 } 72 }
93 } else if (this.tc_cb.value == 'all') { 73 } else if (this.tc_cb.value == 'all') {
94 - for (var tc in this.services[this.dpt_cb.value]) {  
95 - for (tn in this.services[this.dpt_cb.value][tc]) {  
96 - for (serv in this.services[this.dpt_cb.value][tc][tn]) {  
97 - filter_dic[serv] = this.services[this.dpt_cb.value][tc][tn][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0); 74 + for (var tc in this.metadata[this.dpt_cb.value]) {
  75 + for (tn in this.metadata[this.dpt_cb.value][tc]) {
  76 + for (serv in this.metadata[this.dpt_cb.value][tc][tn]) {
  77 + filter_dic[serv] = this.metadata[this.dpt_cb.value][tc][tn][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0);
98 } 78 }
99 } 79 }
100 } 80 }
101 } else if (this.tn_cb.value == 'all') { 81 } else if (this.tn_cb.value == 'all') {
102 - for (tn in this.services[this.dpt_cb.value][this.tc_cb.value]) {  
103 - for (serv in this.services[this.dpt_cb.value][this.tc_cb.value][tn]) {  
104 - filter_dic[serv] = this.services[this.dpt_cb.value][this.tc_cb.value][tn][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0); 82 + for (tn in this.metadata[this.dpt_cb.value][this.tc_cb.value]) {
  83 + for (serv in this.metadata[this.dpt_cb.value][this.tc_cb.value][tn]) {
  84 + filter_dic[serv] = this.metadata[this.dpt_cb.value][this.tc_cb.value][tn][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0);
105 } 85 }
106 } 86 }
107 } else { 87 } else {
108 - for (serv in this.services[this.dpt_cb.value][this.tc_cb.value][this.tn_cb.value]) {  
109 - filter_dic[serv] = this.services[this.dpt_cb.value][this.tc_cb.value][this.tn_cb.value][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0); 88 + for (serv in this.metadata[this.dpt_cb.value][this.tc_cb.value][this.tn_cb.value]) {
  89 + filter_dic[serv] = this.metadata[this.dpt_cb.value][this.tc_cb.value][this.tn_cb.value][serv][0] + (serv in filter_dic ? filter_dic[serv] : 0);
110 } 90 }
111 } 91 }
112 92
@@ -122,7 +102,9 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -122,7 +102,9 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
122 }, 102 },
123 103
124 onWindowLoaded: function(services) { 104 onWindowLoaded: function(services) {
125 - this.services = JSON.parse(loadTextFileAjaxSync('../../generic_data/EpnTapData/services.json', "application/json")); 105 + this.metadata = JSON.parse(loadTextFileAjaxSync('../../generic_data/EpnTapData/metadata.json', "application/json"));
  106 + this.services = JSON.parse(loadTextFileAjaxSync('../../generic_data/EpnTapData/EpnTapServices.json', "application/json"));
  107 + console.log(Object.keys(this.metadata).length + " dataproduct_type rรฉpertoriรฉs.");
126 108
127 this.dpt_cb = Ext.getCmp('productTypeCB'); 109 this.dpt_cb = Ext.getCmp('productTypeCB');
128 this.tc_cb = Ext.getCmp('targetClassCB'); 110 this.tc_cb = Ext.getCmp('targetClassCB');
@@ -137,8 +119,10 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -137,8 +119,10 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
137 this.tn_cb.disable(); 119 this.tn_cb.disable();
138 120
139 this.dpt_cb.getStore().add({'id': 'all', 'name': 'All data product types'}); 121 this.dpt_cb.getStore().add({'id': 'all', 'name': 'All data product types'});
  122 + this.tc_cb.getStore().add({'id': 'all', 'name': 'All target names'});
  123 + this.tn_cb.getStore().add({'id': 'all', 'name': 'All target classes'});
140 124
141 - for (var dpt_id in this.services) { 125 + for (var dpt_id in this.metadata) {
142 if (dpt_id in this.dpt_dic) { 126 if (dpt_id in this.dpt_dic) {
143 this.dpt_cb.getStore().add({'id': dpt_id, 'name': this.prettify(this.dpt_dic[dpt_id])}); 127 this.dpt_cb.getStore().add({'id': dpt_id, 'name': this.prettify(this.dpt_dic[dpt_id])});
144 } else { 128 } else {
@@ -146,6 +130,8 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -146,6 +130,8 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
146 } 130 }
147 } 131 }
148 this.dpt_cb.select('all'); 132 this.dpt_cb.select('all');
  133 + this.tc_cb.select('all');
  134 + this.tn_cb.select('all');
149 this.update_services(); 135 this.update_services();
150 }, 136 },
151 137
@@ -157,7 +143,7 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -157,7 +143,7 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
157 if (this.dpt_cb.value == 'all') { 143 if (this.dpt_cb.value == 'all') {
158 this.tc_cb.disable(); 144 this.tc_cb.disable();
159 } else { 145 } else {
160 - var target_classes = this.services[this.dpt_cb.value]; 146 + var target_classes = this.metadata[this.dpt_cb.value];
161 147
162 if (Object.keys(target_classes).length == 1) { 148 if (Object.keys(target_classes).length == 1) {
163 this.tc_cb.getStore().add({'id': Object.keys(target_classes)[0], 'name': this.prettify(Object.keys(target_classes)[0])}); 149 this.tc_cb.getStore().add({'id': Object.keys(target_classes)[0], 'name': this.prettify(Object.keys(target_classes)[0])});
@@ -173,6 +159,8 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -173,6 +159,8 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
173 this.tc_cb.enable(); 159 this.tc_cb.enable();
174 } 160 }
175 } 161 }
  162 + this.tn_cb.getStore().add({'id': 'all', 'name': 'All target names'});
  163 + this.tn_cb.select('all');
176 this.update_services(); 164 this.update_services();
177 }, 165 },
178 166
@@ -180,9 +168,11 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -180,9 +168,11 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
180 this.tn_cb.getStore().removeAll(); 168 this.tn_cb.getStore().removeAll();
181 169
182 if (this.tc_cb.value == 'all') { 170 if (this.tc_cb.value == 'all') {
  171 + this.tn_cb.getStore().add({'id': 'all', 'name': 'All target names'});
  172 + this.tn_cb.select('all');
183 this.tn_cb.disable(); 173 this.tn_cb.disable();
184 } else { 174 } else {
185 - var target_names = this.services[this.dpt_cb.value][this.tc_cb.value]; 175 + var target_names = this.metadata[this.dpt_cb.value][this.tc_cb.value];
186 176
187 if (Object.keys(target_names).length == 1) { 177 if (Object.keys(target_names).length == 1) {
188 this.tn_cb.getStore().add({'id': Object.keys(target_names)[0], 'name': this.prettify(Object.keys(target_names)[0])}); 178 this.tn_cb.getStore().add({'id': Object.keys(target_names)[0], 'name': this.prettify(Object.keys(target_names)[0])});
@@ -205,20 +195,39 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, { @@ -205,20 +195,39 @@ Ext.define(&#39;amdaDesktop.EpnTapModule&#39;, {
205 }, 195 },
206 196
207 onSearchBtnClicked: function() { 197 onSearchBtnClicked: function() {
208 - console.log("onSearchBtnClicked"); 198 + // console.log("onSearchBtnClicked");
209 }, 199 },
210 200
211 - onServiceSelected: function(service) {  
212 - var filter = Array(service['schema'], service['accessurl'], Ext.getCmp('targetNameCB').value,  
213 - this.dpt_cb.value, Ext.getCmp('startTimeDF').rawValue, Ext.getCmp('stopTimeDF').rawValue); 201 + fillGranules: function(granules) {
  202 + console.log(granules);
214 203
215 - AmdaAction.epnTapMgr('getGranules', filter, function(granules) {  
216 - console.log(granules);  
217 - }); 204 + Ext.getCmp('granulesPanel').getStore().removeAll();
  205 + Ext.getCmp('granulesPanel').getStore().add(granules);
  206 + },
  207 +
  208 + onServiceSelected: function(service) {
  209 + var select = Array();
  210 + for (var i_s = 0 ; i_s < this.services.length ; i_s++) {
  211 + if (this.services[i_s]['schema'] === service['id']) {
  212 + var columns = this.services[i_s]['columns'].split(',');
  213 + for (var i_c=0 ; i_c<this.gp_grid.columns.length ; i_c++) {
  214 + if (columns.indexOf(this.gp_grid.columns[i_c].dataIndex) != -1)
  215 + select.push(this.gp_grid.columns[i_c].dataIndex)
  216 + }
  217 + var filter = Array(
  218 + this.dpt_cb.value !== 'all' ? this.dpt_cb.value : null,
  219 + this.tn_cb.value !== 'all' ? this.dpt_cb.value : null,
  220 + Ext.getCmp('startTimeDF').rawValue !== '' ? this.dpt_cb.value : null,
  221 + Ext.getCmp('stopTimeDF').rawValue !== '' ? this.dpt_cb.value : null);
  222 + break;
  223 + }
  224 + }
  225 + console.log("Getting granules of " + service['id'] + "...");
  226 + AmdaAction.epnTapGetGranules(service['id'], this.services[i_s]['accessurl'], filter, select, this.fillGranules);
218 }, 227 },
219 228
220 onGranuleSelected: function(granule) { 229 onGranuleSelected: function(granule) {
221 - console.log('selected granule: ' + granule.target_name); 230 + // console.log('selected granule: ' + granule.target_name);
222 }, 231 },
223 232
224 /** @class Module initialisation. */ 233 /** @class Module initialisation. */
js/app/views/EpnTapUI.js
@@ -30,7 +30,7 @@ Ext.create(&#39;Ext.data.Store&#39;, { @@ -30,7 +30,7 @@ Ext.create(&#39;Ext.data.Store&#39;, {
30 30
31 Ext.create('Ext.data.Store', { 31 Ext.create('Ext.data.Store', {
32 storeId:'granules_store', 32 storeId:'granules_store',
33 - fields:['type', 'target_name', 'time_min', 'time_max'] 33 + fields:['dataproduct_type', 'target_name', 'time_min', 'time_max', 'access_format', 'granule_uid', 'access_estsize', 'access_url', 'thumbnail_url']
34 }); 34 });
35 35
36 var serviceFilterPanel = { 36 var serviceFilterPanel = {
@@ -144,24 +144,47 @@ var servicesPanel = { @@ -144,24 +144,47 @@ var servicesPanel = {
144 } 144 }
145 } 145 }
146 146
147 -var granulesPanel = { 147 +var txt_render = function(val) { return '<p style="white-space: normal;">' + val + '</p>'; };
  148 +var link_render = function(val) { return '<a href="' + val + '">get</a>'; };
  149 +var img_render = function(val) { return '<img src="' + val + '">' };
  150 +
  151 +var granulesPanel = Ext.create('Ext.grid.Panel', {
148 id: 'granulesPanel', 152 id: 'granulesPanel',
149 - xtype : 'grid',  
150 title: 'Granules', 153 title: 'Granules',
151 - store: Ext.data.StoreManager.lookup('granulesStore'), 154 + store: Ext.data.StoreManager.lookup('granules_store'),
152 flex: 3, 155 flex: 3,
  156 + cls: 'epntap_granules',
153 columns: [ 157 columns: [
154 - { text: 'Type', dataIndex: 'type', flex: 1 },  
155 - { text: 'Target', dataIndex: 'target_name', flex: 1 },  
156 - { text: 'Time min', dataIndex: 'time_min', flex: 2 },  
157 - { text: 'Time max', dataIndex: 'time_max', flex: 2 } 158 + { text: 'Type', dataIndex: 'dataproduct_type', flex: 1, renderer: txt_render },
  159 + { text: 'Target', dataIndex: 'target_name', flex: 2, renderer: txt_render },
  160 + { text: 'Time min', dataIndex: 'time_min', flex: 2, renderer: txt_render },
  161 + { text: 'Time max', dataIndex: 'time_max', flex: 2, renderer: txt_render },
  162 + { text: 'Format', dataIndex: 'access_format', flex: 2, renderer: txt_render },
  163 + { text: 'uid', dataIndex: 'granule_uid', flex: 2, renderer: txt_render },
  164 + { text: 'Size', dataIndex: 'access_estsize', flex: 2, renderer: txt_render },
  165 + { text: 'URL', dataIndex: 'access_url', flex: 1, renderer: link_render },
  166 + { text: 'Thumbnail', dataIndex: 'thumbnail_url', flex: 2, renderer: img_render}
158 ], 167 ],
159 listeners: { 168 listeners: {
160 'cellclick': function(grid, td, cellIndex, record, tr, rowIndex, e, eOpts) { 169 'cellclick': function(grid, td, cellIndex, record, tr, rowIndex, e, eOpts) {
161 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.epntap.id).onGranuleSelected(record.data); 170 myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.epntap.id).onGranuleSelected(record.data);
162 } 171 }
  172 + },
  173 + renderTo: Ext.getBody()
  174 +});
  175 +
  176 +var tooltip = Ext.create('Ext.tip.ToolTip', {
  177 + target: granulesPanel.getView().el,
  178 + delegate: granulesPanel.getView().itemSelector,
  179 + trackMouse: true,
  180 + renderTo: Ext.getBody(),
  181 + listeners: {
  182 + beforeshow: function updateTipBody(tip) {
  183 + var thumb = granulesPanel.getView().getRecord(tooltip.triggerElement).get('thumbnail_url');
  184 + tooltip.update('<img src="' + thumb + '">');
  185 + }
163 } 186 }
164 -} 187 +});
165 188
166 var mainPanel = { 189 var mainPanel = {
167 id: 'mainPanel', 190 id: 'mainPanel',
@@ -202,7 +225,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, { @@ -202,7 +225,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
202 225
203 init : function(config) { 226 init : function(config) {
204 var myConf = { 227 var myConf = {
205 - width: 600, 228 + width: 800,
206 height: 550, 229 height: 550,
207 layout: 'border', 230 layout: 'border',
208 items: [ 231 items: [
js/resources/css/amda.css
@@ -487,3 +487,16 @@ p + p { @@ -487,3 +487,16 @@ p + p {
487 filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100) !important; 487 filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=100) !important;
488 opacity: 1.0 !important; 488 opacity: 1.0 !important;
489 } 489 }
  490 +
  491 +.epntap_granules img {
  492 + max-width: 40px;
  493 + max-height: 40px;
  494 +}
  495 +
  496 +#granule_tooltip {
  497 + /*position:absolute;*/
  498 + margin:5px;
  499 + width:200px;
  500 + height:50px;
  501 + border:1px solid black;
  502 +}