Commit b034ce890709d59bcc06e2e38c3359ee387e4327

Authored by Nathanael Jourdane
1 parent d05bf0bb

Move EPN-TAP module to InteropUI (draft).

js/app/AmdaApp.js
... ... @@ -99,10 +99,10 @@ Ext.define('amdaApp.AmdaApp', {
99 99 },
100 100 epntap : {
101 101 id : 'epntap-win',
102   - icon : 'icon-epntap',
  102 + icon : 'icon-interop',
103 103 title : 'EPN-TAP data',
104 104 source : 'amdaDesktop.EpnTapModule',
105   - useLauncher : true
  105 + useLauncher : false
106 106 },
107 107 info : {
108 108 id : 'info-win',
... ...
js/app/controllers/InteropModule.js
1   -/**
  1 +/**
2 2 * Project  : AMDA-NG
3 3 * Name : InteropModule.js
4 4 * @class amdaDesktop.InteropModule
5 5 * @extends amdaDesktop.AmdaModule
6   - * @brief Interop Module controller definition
  6 + * @brief Interop Module controller definition
  7 + * @extends amdaDesktop.InteractiveModule
  8 + * @brief Interop Module controller definition
7 9 * @author Benjamin RENARD
8 10 * $Id: InteropModule.js 1870 2013-11-22 13:43:34Z elena $
9 11 *****************************************************************************
... ... @@ -15,14 +17,15 @@
15 17  
16 18 Ext.define('amdaDesktop.InteropModule', {
17 19 extend: 'amdaDesktop.AmdaModule',
18   -
  20 +
19 21 requires: [
20 22 'amdaUI.InteropUI',
21   - 'amdaDesktop.SampModule'
  23 + 'amdaDesktop.SampModule',
  24 + 'amdaDesktop.EpnTapModule'
22 25 ],
23   -
  26 +
24 27 contentId : 'interopUI',
25   -
  28 +
26 29 /**
27 30 * @cfg {String} window definitions
28 31 * @required
... ... @@ -31,9 +34,9 @@ Ext.define('amdaDesktop.InteropModule', {
31 34 width: 850,
32 35 uiType : 'panelInterop',
33 36 helpTitle :'Help on Interop Module',
34   -
  37 +
35 38 samp : null,
36   -
  39 +
37 40 sampclientsStore : new Ext.data.SimpleStore({
38 41 idProperty: 'id',
39 42 fields: [
... ... @@ -45,8 +48,8 @@ Ext.define('amdaDesktop.InteropModule', {
45 48 {name: 'acceptFITS', type : 'boolean'}
46 49 ]
47 50 }),
48   -
49   - init : function() {
  51 +
  52 + init : function() {
50 53 this.launcher = {
51 54 text : this.title,
52 55 iconCls : this.icon,
... ... @@ -54,7 +57,7 @@ Ext.define('amdaDesktop.InteropModule', {
54 57 scope : this
55 58 };
56 59 },
57   -
  60 +
58 61 initSampConnector : function(successfn)
59 62 {
60 63 var me = this;
... ... @@ -97,13 +100,13 @@ Ext.define('amdaDesktop.InteropModule', {
97 100 clientmetachange : function(o,id,data,subs)
98 101 {
99 102 var record = me.sampclientsStore.getById(id);
100   -
  103 +
101 104 if (!record)
102 105 {
103 106 me.sampclientsStore.add({id : id});
104 107 record = me.sampclientsStore.getById(id);
105 108 }
106   -
  109 +
107 110 if (record)
108 111 {
109 112 record.set('descriptionText',data['samp.description.text']);
... ... @@ -117,16 +120,16 @@ Ext.define('amdaDesktop.InteropModule', {
117 120 me.samp.isSubscribed(subs,"image.load.fits"));
118 121 }
119 122 }
120   -
  123 +
121 124 me.updateClients();
122 125 },
123 126 clientsubs : function(o,id,data)
124 127 {
125 128 var record = me.sampclientsStore.getById(id);
126   -
  129 +
127 130 if (!record)
128 131 return;
129   -
  132 +
130 133 if (record)
131 134 {
132 135 record.set('acceptVOTable',
... ... @@ -134,7 +137,7 @@ Ext.define('amdaDesktop.InteropModule', {
134 137 record.set('acceptFITS',
135 138 me.samp.isSubscribed(data,"image.load.fits"));
136 139 }
137   -
  140 +
138 141 me.updateClients();
139 142 },
140 143 uploadfile : function(o,clientName,url,format)
... ... @@ -148,31 +151,31 @@ Ext.define('amdaDesktop.InteropModule', {
148 151 this.samp.loadScript(function (s){
149 152 if (successfn)
150 153 successfn.call(me.samp);
151   - });
  154 + });
152 155 }
153 156 else
154 157 this.samp.loadScript(function (s){
155 158 if (successfn)
156 159 successfn.call(me.samp);
157   - });
  160 + });
158 161 },
159   -
  162 +
160 163 updateStatus : function()
161 164 {
162 165 if (this.app && this.samp)
163 166 {
164 167 var desktop = this.app.getDesktop();
165   -
  168 +
166 169 var isConnected = this.samp.isConnected();
167   -
  170 +
168 171 if (desktop)
169 172 {
170 173 var win = desktop.getWindow(this.id);
171 174 if (win && win.isVisible)
172 175 win.items.items[0].updateStatus(isConnected);
173   -
  176 +
174 177 var taskbar = desktop.taskbar;
175   -
  178 +
176 179 if (taskbar)
177 180 {
178 181 var samptb = taskbar.getComponent('samptb');
... ... @@ -182,21 +185,21 @@ Ext.define('amdaDesktop.InteropModule', {
182 185 }
183 186 }
184 187 },
185   -
  188 +
186 189 updateClients : function()
187 190 {
188 191 if (this.app && this.samp)
189 192 {
190 193 var desktop = this.app.getDesktop();
191   -
  194 +
192 195 var isConnected = this.samp.isConnected();
193   -
  196 +
194 197 if (desktop)
195 198 {
196 199 var win = desktop.getWindow(this.id);
197   -
  200 +
198 201 var taskbar = desktop.taskbar;
199   -
  202 +
200 203 if (taskbar)
201 204 {
202 205 var samptb = taskbar.getComponent('samptb');
... ... @@ -206,14 +209,14 @@ Ext.define('amdaDesktop.InteropModule', {
206 209 }
207 210 }
208 211 },
209   -
  212 +
210 213 sampConnected : function()
211 214 {
212 215 if (!this.samp)
213 216 return false;
214 217 return this.samp.isConnected();
215 218 },
216   -
  219 +
217 220 sendVOTable : function(file,clientId)
218 221 {
219 222 if (!this.samp)
... ... @@ -222,25 +225,25 @@ Ext.define('amdaDesktop.InteropModule', {
222 225 var baseurl = href.replace('desktop.php','');
223 226 this.samp.sendVOTable(baseurl+file,clientId);
224 227 },
225   -
  228 +
226 229 sendAladinScript : function(script)
227 230 {
228 231 if (!this.samp)
229 232 return false;
230 233 this.samp.sendAladinScript(script);
231 234 },
232   -
  235 +
233 236 sendFITS : function(url,name)
234 237 {
235 238 if (!this.samp)
236 239 return false;
237 240 this.samp.sendFITS(url,name);
238 241 },
239   -
  242 +
240 243 generateAladinScript : function(urlList, scriptType)
241 244 {
242 245 /*var script="reset;"; //reset all views & all planes
243   - // first get files
  246 + // first get files
244 247 var scriptHead='';
245 248 //var script="#AJS;\n";
246 249 //scriptHead+="trace 3;"; //
... ... @@ -263,7 +266,7 @@ Ext.define('amdaDesktop.InteropModule', {
263 266 }*/
264 267  
265 268 //scriptHead += 'sync;';
266   -
  269 +
267 270 // add som method specific lines
268 271 /*switch( scriptType )
269 272 {
... ... @@ -310,18 +313,18 @@ Ext.define('amdaDesktop.InteropModule', {
310 313 break;
311 314 }
312 315 //script += 'sync;';*/
313   -
  316 +
314 317 var script = 'reset;';
315   -
  318 +
316 319 for( var i=0; i < urlList.length; i++)
317 320 {
318 321 var url = urlList[i].url;
319 322 var name = urlList[i].name;
320   - script += 'get File(' + url +','+name+');';
  323 + script += 'get File(' + url +','+name+');';
321 324 }
322   -
  325 +
323 326 script += 'sync;';
324   -
  327 +
325 328 /*for( var i=0; i < urlList.length; i++)
326 329 {
327 330 //then modify some fits values
... ... @@ -329,12 +332,12 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
329 332 script += 'set '+name+' FITS:CRPIX1=100;';
330 333 script += 'set '+name+' FITS:CRPIX2=0;';
331 334 }*/
332   -
  335 +
333 336 switch( scriptType )
334 337 {
335 338 case('mosaic'):
336 339 {
337   -
  340 +
338 341 script += 'sync;mview 16';
339 342 }
340 343 break;
... ... @@ -348,12 +351,12 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
348 351 }
349 352 break;
350 353 }
351   -
352   -
353   -
354   - return script;
  354 +
  355 +
  356 +
  357 + return script;
355 358 },
356   -
  359 +
357 360 switchSampConnect : function()
358 361 {
359 362 var me = this;
... ... @@ -369,20 +372,20 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
369 372 // loadMask.hide();
370 373 }
371 374 });
372   -
  375 +
373 376 },
374 377  
375 378 forceSampDisconnect : function()
376 379 {
377 380 if (!this.samp)
378 381 return;
379   -
  382 +
380 383 if (!this.samp.isConnected())
381 384 return;
382   -
  385 +
383 386 this.samp.disconnect();
384 387 },
385   -
  388 +
386 389 getVOTableClients : function ()
387 390 {
388 391 //return list of all clients that can receive a VOTable
... ... @@ -392,11 +395,11 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
392 395 this.sampclientsStore.each(function (client){
393 396 if (client.get('acceptVOTable'))
394 397 result.push({id : client.get('id'), name : client.get('name'), icon : client.get('iconUrl')});
395   -
  398 +
396 399 },this);
397 400 return result;
398 401 },
399   -
  402 +
400 403 getFITSClients : function ()
401 404 {
402 405 //return list of all clients that can receive a FITS image
... ... @@ -406,32 +409,32 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
406 409 this.sampclientsStore.each(function (client){
407 410 if (client.get('acceptFITS'))
408 411 result.push({id : client.get('id'), name : client.get('name'), icon : client.get('iconUrl')});
409   -
  412 +
410 413 },this);
411 414 return result;
412   -
  415 +
413 416 },
414   - // arguments from launcher : CONFIG (OBJECT!!!)
415   - createWindow : function(config){
  417 + // arguments from launcher : CONFIG (OBJECT!!!)
  418 + createWindow : function(config){
416 419 var me = this;
417 420 var baseId = null;
418   -
  421 +
419 422 if (!Ext.isObject(config)) {
420 423 baseId = config;
421 424 }
422 425 var desktop = this.app.getDesktop();
423 426 var win = desktop.getWindow(this.id);
424   -
  427 +
425 428 activeTab = 1;
426   -
  429 +
427 430 if(!win)
428 431 {
429   - win = desktop.createWindow({
  432 + win = desktop.createWindow({
430 433 id: this.id,
431   - title:this.title,
  434 + title:this.title,
432 435 layout: 'anchor',
433 436 width:600,
434   - height:550,
  437 + height:550,
435 438 modal: true,
436 439 minimizable: false,
437 440 iconCls: this.icon,
... ... @@ -445,7 +448,7 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
445 448 {
446 449 xtype: 'panelInterop',
447 450 clientsStore : this.sampclientsStore,
448   - activeTab : activeTab,
  451 + activeTab : activeTab,
449 452 baseId : baseId,
450 453 onSwitchConnect : function ()
451 454 {
... ... @@ -454,13 +457,13 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
454 457 }
455 458 ]
456 459 });
457   - }
458   -
  460 + }
  461 +
459 462 if (me.samp && me.samp.ready)
460 463 this.updateStatus();
461   -
  464 +
462 465 win.show();
463 466 return win;
464 467 }
465 468  
466   -});
467 469 \ No newline at end of file
  470 +});
... ...
js/app/views/EpnTapUI.js
... ... @@ -126,6 +126,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
126 126 Method constructor, which basically call the `init()` method to create the EpnTap panel.
127 127 */
128 128 constructor: function(config) {
  129 + console.log("EpnTAPUI constructor");
129 130 this.init(config);
130 131 this.callParent(arguments);
131 132 },
... ... @@ -140,6 +141,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
140 141 */
141 142 init: function(config) {
142 143 var mod = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.epntap.id);
  144 + console.log("init: module =", mod);
143 145  
144 146 /************
145 147 *** Grids ***
... ... @@ -193,7 +195,7 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
193 195 trackMouse: true,
194 196 listeners: {
195 197 beforeshow: function updateTipBody(tooltip) {
196   - var service = Ext.getCmp('servicesGrid').getView().getRecord(tooltip.triggerElement);
  198 + var service = Ext.getCmp('epnTapServicesGrid').getView().getRecord(tooltip.triggerElement);
197 199 var ttContent = '<h3>' + service.get('shortName') + '</h3>';
198 200 ttContent += '<p>' + service.get('title') + '</p>';
199 201 ttContent += '<p>' + service.get('accessURL') + '</p>';
... ... @@ -285,12 +287,12 @@ Ext.define(&#39;amdaUI.EpnTapUI&#39;, {
285 287 var createGranuleTooltip = function() {
286 288 return new Ext.tip.ToolTip({
287 289 id: 'epnTapGranuleTooltip',
288   - target: Ext.getCmp('granulesGrid').getView().el,
289   - delegate: Ext.getCmp('granulesGrid').getView().itemSelector,
  290 + target: Ext.getCmp('epnTapGranulesGrid').getView().el,
  291 + delegate: Ext.getCmp('epnTapGranulesGrid').getView().itemSelector,
290 292 trackMouse: true,
291 293 listeners: {
292 294 beforeshow: function updateTipBody(tooltip) {
293   - var thumb = Ext.getCmp('granulesGrid').getView().getRecord(tooltip.triggerElement).get('thumbnail_url');
  295 + var thumb = Ext.getCmp('epnTapGranulesGrid').getView().getRecord(tooltip.triggerElement).get('thumbnail_url');
294 296 tooltip.update('<img src="' + thumb + '">');
295 297 }
296 298 },
... ...
js/app/views/InteropUI.js
... ... @@ -16,35 +16,35 @@
16 16 Ext.define('amdaUI.InteropUI', {
17 17 extend: 'Ext.tab.Panel',
18 18 alias: 'widget.panelInterop',
19   -
  19 +
20 20 requires: [
21   - 'amdaUI.ParamsMgrUI'
22   - ],
23   -
  21 + 'amdaUI.ParamsMgrUI', 'amdaUI.EpnTapUI'
  22 + ],
  23 +
24 24 constructor: function(config) {
25 25 this.init(config);
26 26 this.callParent(arguments);
27 27 },
28   -
  28 +
29 29 onSwitchConnect : Ext.emptyFn,
30   -
  30 +
31 31 updateStatus : function(isConnected)
32 32 {
33 33 var sampTab = this.getComponent('samp_tab_panel');
34   -
  34 +
35 35 var sampButton = sampTab.dockedItems.items[0].items.items[1];
36 36 sampButton.setIconCls(isConnected ? 'icon-connected' : 'icon-disconnected');
37 37 },
38   -
  38 +
39 39 /*updateClients : function(clients)
40 40 {
41 41 var sampTab = this.getComponent('samp_tab_panel');
42   -
  42 +
43 43 var sampDataView = sampTab.query('dataview')[0];
44 44  
45   - sampDataView.store.loadData(clients);
  45 + sampDataView.store.loadData(clients);
46 46 },*/
47   -
  47 +
48 48 getSampToolBar : function()
49 49 {
50 50 var me = this;
... ... @@ -59,7 +59,7 @@ Ext.define(&#39;amdaUI.InteropUI&#39;, {
59 59 }
60 60 ];
61 61 },
62   -
  62 +
63 63 getSampClientsDataView : function(clientsStore)
64 64 {
65 65 var tpl = new Ext.XTemplate(
... ... @@ -73,7 +73,7 @@ Ext.define(&#39;amdaUI.InteropUI&#39;, {
73 73 '</div>',
74 74 '</tpl>'
75 75 );
76   -
  76 +
77 77 return {
78 78 xtype : 'dataview',
79 79 store : clientsStore,
... ... @@ -86,11 +86,11 @@ Ext.define(&#39;amdaUI.InteropUI&#39;, {
86 86 height : 300
87 87 };
88 88 },
89   -
  89 +
90 90 getSampTab : function (clientsStore)
91 91 {
92 92 var me = this;
93   -
  93 +
94 94 return {
95 95 xtype : 'panel',
96 96 id : 'samp_tab_panel',
... ... @@ -102,28 +102,38 @@ Ext.define(&#39;amdaUI.InteropUI&#39;, {
102 102 tbar : me.getSampToolBar()
103 103 };
104 104 },
105   -
  105 +
  106 + getEpnTapTab: function() {
  107 + return {
  108 + xtype : 'panelEpnTap',
  109 + id : 'epnTapTab',
  110 + title : 'EPN-TAP',
  111 + layout : 'fit'
  112 + };
  113 + },
  114 +
106 115 init : function(config) {
107   -
  116 +
108 117 var me = this;
109   -
  118 +
110 119 this.onSwitchConnect = config.onSwitchConnect;
111 120 var activeTab = config.activeTab ? config.activeTab : 0;
112   -
113   - var myConf = {
114   - plain : true,
115   - activeTab: activeTab,
116   - defaults: {
117   - autoHeight: true,
118   - layout : 'fit',
119   - bodyStyle: { background : '#dfe8f6' }
120   - },
121   - items: [
122   - this.getSampTab(config.clientsStore),
123   - { xtype : 'paramsMgrPanel', baseId : config.baseId, layout : 'hbox'}
124   - ]
125   - };
126   -
127   - Ext.apply (this , Ext.apply (arguments, myConf));
128   - }
129   -});
130 121 \ No newline at end of file
  122 +
  123 + var myConf = {
  124 + plain : true,
  125 + activeTab: activeTab,
  126 + defaults: {
  127 + autoHeight: true,
  128 + layout : 'fit',
  129 + bodyStyle: { background : '#dfe8f6' }
  130 + },
  131 + items: [
  132 + this.getSampTab(config.clientsStore),
  133 + { xtype: 'paramsMgrPanel', baseId: config.baseId, layout: 'hbox'},
  134 + this.getEpnTapTab()
  135 + ]
  136 + };
  137 +
  138 + Ext.apply (this , Ext.apply (arguments, myConf));
  139 + }
  140 +});
... ...
php/classes/EpnTapMgr.php
... ... @@ -35,9 +35,9 @@ class EpnTapMgr {
35 35 if($target_name)
36 36 array_push($filter, "target_name = '$target_name'");
37 37 if($time_min)
38   - array_push($filter, "time_min <= " . $this->dateToJD($time_min));
  38 + array_push($filter, "time_min >= " . $this->dateToJD($time_min));
39 39 if($time_max)
40   - array_push($filter, "time_max >= " . $this->dateToJD($time_max));
  40 + array_push($filter, "time_max <= " . $this->dateToJD($time_max));
41 41 return (count($filter) > 0 ? ' WHERE ' . join(' AND ', $filter) : '');
42 42 }
43 43  
... ... @@ -46,10 +46,10 @@ class EpnTapMgr {
46 46 $params = 'FORMAT=votable&LANG=ADQL&REQUEST=doQuery';
47 47 $url = $access_url . '/sync?' . $params . '&QUERY=' . urlencode($query);
48 48  
  49 + $res = $votMgr->load($url);
49 50 $this->addLog("Query URL: " . $url);
50   - $votMgr->load($url);
51   - $result = $votMgr->isValidSchema() ? $votMgr->parseStream() : NULL;
52   - return $result;
  51 + $result = $votMgr->parseStream();
  52 + return $votMgr->getVotableError() ? array('error' => $votMgr->getVotableError()) : $result;
53 53 }
54 54  
55 55 /* filter order: product type, target name, time min, time max */
... ... @@ -57,10 +57,12 @@ class EpnTapMgr {
57 57 $query = "SELECT TOP {$limit} " . join(', ', $select) . " FROM {$table_name}.epn_core " . $this->createFilter($filter[0], $filter[1], $filter[2], $filter[3]) . " OFFSET {$offset}";
58 58 // return $query;
59 59 $result = $this->request($access_url, $query);
60   - for ($i = 0 ; $i < sizeof($result) ; $i++) {
61   - $result[$i]['num'] = $i + $offset + 1;
62   - $result[$i]['time_min'] = $this->JDTodate($result[$i]['time_min']);
63   - $result[$i]['time_max'] = $this->JDTodate($result[$i]['time_max']);
  60 + if(! array_key_exists("error", $result)) {
  61 + for ($i = 0 ; $i < sizeof($result) ; $i++) {
  62 + $result[$i]['num'] = $i + $offset + 1;
  63 + $result[$i]['time_min'] = $this->JDTodate($result[$i]['time_min']);
  64 + $result[$i]['time_max'] = $this->JDTodate($result[$i]['time_max']);
  65 + }
64 66 }
65 67 return $result;
66 68 }
... ...