Commit 12be2344cd1876befaa4cfd917b29204afc52e6b

Authored by Elena.Budnik
1 parent 7ac3e07e

redmine #5507

Showing 1 changed file with 333 additions and 427 deletions   Show diff stats
js/app/controllers/InteropModule.js
... ... @@ -6,10 +6,6 @@
6 6 * @brief Interop Module controller definition
7 7 * @author Benjamin RENARD
8 8 * $Id: InteropModule.js 1870 2013-11-22 13:43:34Z elena $
9   - *****************************************************************************
10   - * FT Id : Date : Name - Description
11   - *******************************************************************************
12   - * 23/04/2012: BRE - file creation
13 9 */
14 10  
15 11  
... ... @@ -17,17 +13,17 @@ Ext.define('amdaDesktop.InteropModule', {
17 13 extend: 'amdaDesktop.AmdaModule',
18 14  
19 15 requires: [
20   - 'amdaUI.InteropUI',
21   - 'amdaDesktop.SampModule',
  16 + 'amdaUI.InteropUI',
  17 + 'amdaDesktop.SampModule',
22 18 'amdaDesktop.EpnTapModule'
23   - ],
  19 + ],
24 20  
25 21 contentId : 'interopUI',
26 22  
27   - /**
28   - * @cfg {String} window definitions
29   - * @required
30   - */
  23 + /**
  24 + * @cfg {String} window definitions
  25 + * @required
  26 + */
31 27 // height: 650,
32 28 // width: 1050,
33 29 uiType : 'panelInterop',
... ... @@ -38,206 +34,201 @@ Ext.define('amdaDesktop.InteropModule', {
38 34  
39 35 sampclientsStore : new Ext.data.SimpleStore({
40 36 idProperty: 'id',
41   - fields: [
42   - {name: 'id'},
43   - {name: 'name'},
44   - {name: 'descriptionText'},
45   - {name: 'iconUrl'},
46   - {name: 'acceptVOTable', type : 'boolean'},
47   - {name: 'acceptFITS', type : 'boolean'}
48   - ]
49   - }),
  37 + fields: [
  38 + {name: 'id'},
  39 + {name: 'name'},
  40 + {name: 'descriptionText'},
  41 + {name: 'iconUrl'},
  42 + {name: 'acceptVOTable', type : 'boolean'},
  43 + {name: 'acceptFITS', type : 'boolean'}
  44 + ]
  45 + }),
50 46  
51 47 init : function() {
52   - this.launcher = {
53   - text : this.title,
54   - iconCls : this.icon,
55   - handler : this.createWindow,
56   - scope : this
  48 + this.launcher = {
  49 + text : this.title,
  50 + iconCls : this.icon,
  51 + handler : this.createWindow,
  52 + scope : this
57 53 };
58   - },
59   -
60   - initSampConnector : function(successfn)
61   - {
62   - var me = this;
63   - if (!this.samp)
64   - {
65   - this.samp = Ext.create('amdaDesktop.SampModule',{
66   - listeners : {
67   - connected : function(o,success)
68   - {
69   - if (!success)
70   - Ext.Msg.show( {
71   - title : 'SAMP',
72   - msg : 'Cannot connect AMDA to a hub',
73   - modal : false,
74   - icon : Ext.Msg.ERROR,
75   - buttons : Ext.Msg.OK
76   - });
77   - me.updateStatus();
78   - me.updateClients();
79   - },
80   - disconnected : function(o,success)
81   - {
82   - me.updateStatus();
83   - me.sampclientsStore.removeAll();
84   - me.updateClients();
85   - },
86   - clientregister : function(o,id)
87   - {
88   - me.updateClients();
89   - },
90   - clientunregister : function(o,id)
91   - {
92   - var record = me.sampclientsStore.getById(id);
93   - if (record)
94   - {
95   - me.sampclientsStore.remove(record);
96   - me.updateClients();
97   - }
98   - },
99   - clientmetachange : function(o,id,data,subs)
100   - {
101   - var record = me.sampclientsStore.getById(id);
102   -
103   - if (!record)
104   - {
105   - me.sampclientsStore.add({id : id});
106   - record = me.sampclientsStore.getById(id);
107   - }
108   -
109   - if (record)
110   - {
111   - record.set('descriptionText',data['samp.description.text']);
112   - record.set('iconUrl',data['samp.icon.url']);
113   - record.set('name',data['samp.name']);
114   - if (subs)
115   - {
116   - record.set('acceptVOTable',
117   - me.samp.isSubscribed(subs,"table.load.votable"));
118   - record.set('acceptFITS',
119   - me.samp.isSubscribed(subs,"image.load.fits"));
120   - }
121   - }
122   -
123   - me.updateClients();
124   - },
125   - clientsubs : function(o,id,data)
126   - {
127   - var record = me.sampclientsStore.getById(id);
128   -
129   - if (!record)
130   - return;
131   -
132   - if (record)
133   - {
134   - record.set('acceptVOTable',
135   - me.samp.isSubscribed(data,"table.load.votable"));
136   - record.set('acceptFITS',
137   - me.samp.isSubscribed(data,"image.load.fits"));
138   - }
139   -
140   - me.updateClients();
141   - },
142   - uploadfile : function(o,clientName,url,format)
143   - {
144   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.upload.id, true, function (module) {
145   - module.uploadNotification(url,format);
146   - });
147   - }
148   - }
149   - });
150   - this.samp.loadScript(function (s){
151   - if (successfn)
152   - successfn.call(me.samp);
153   - });
154   - }
155   - else
156   - this.samp.loadScript(function (s){
157   - if (successfn)
158   - successfn.call(me.samp);
159   - });
160   - },
161   -
162   - updateStatus : function()
163   - {
164   - if (this.app && this.samp)
165   - {
166   - var desktop = this.app.getDesktop();
167   -
168   - var isConnected = this.samp.isConnected();
169   -
170   - if (desktop)
171   - {
172   - var win = desktop.getWindow(this.id);
173   - if (win && win.isVisible)
174   - win.items.items[0].updateStatus(isConnected);
175   -
176   - var taskbar = desktop.taskbar;
177   -
178   - if (taskbar)
179   - {
180   - var samptb = taskbar.getComponent('samptb');
181   - if (samptb)
182   - samptb.updateStatus(isConnected);
183   - }
184   - }
185   - }
186   - },
187   -
188   - updateClients : function()
189   - {
190   - if (this.app && this.samp)
191   - {
192   - var desktop = this.app.getDesktop();
193   -
194   - var isConnected = this.samp.isConnected();
195   -
196   - if (desktop)
197   - {
198   - var win = desktop.getWindow(this.id);
199   -
200   - var taskbar = desktop.taskbar;
201   -
202   - if (taskbar)
203   - {
204   - var samptb = taskbar.getComponent('samptb');
205   - if (samptb)
206   - samptb.updateClients(this.sampclientsStore);
207   - }
208   - }
209   - }
210   - },
211   -
212   - sampConnected : function()
213   - {
214   - if (!this.samp)
215   - return false;
216   - return this.samp.isConnected();
217   - },
218   -
219   - sendVOTable : function(file,clientId)
220   - {
221   - if (!this.samp)
222   - return false;
223   - var href = window.location.href;
224   - var baseurl = href.replace('desktop.php','');
225   - this.samp.sendVOTable(baseurl+file,clientId);
226   - },
227   -
228   - sendAladinScript : function(script)
229   - {
230   - if (!this.samp)
231   - return false;
232   - this.samp.sendAladinScript(script);
233   - },
234   -
235   - sendFITS : function(url,name)
236   - {
237   - if (!this.samp)
238   - return false;
239   - this.samp.sendFITS(url,name);
240   - },
  54 + },
  55 +
  56 + initSampConnector : function(successfn){
  57 + var me = this;
  58 +
  59 + if (!this.samp)
  60 + {
  61 + this.samp = Ext.create('amdaDesktop.SampModule',{
  62 + listeners : {
  63 + connected : function(o,success)
  64 + {
  65 + if (!success)
  66 + Ext.Msg.show( {
  67 + title : 'SAMP',
  68 + msg : 'Cannot connect AMDA to a hub',
  69 + modal : false,
  70 + icon : Ext.Msg.ERROR,
  71 + buttons : Ext.Msg.OK
  72 + });
  73 + me.updateStatus();
  74 + me.updateClients();
  75 + },
  76 + disconnected : function(o,success)
  77 + {
  78 + me.updateStatus();
  79 + me.sampclientsStore.removeAll();
  80 + me.updateClients();
  81 + },
  82 + clientregister : function(o,id)
  83 + {
  84 + me.updateClients();
  85 + },
  86 + clientunregister : function(o,id)
  87 + {
  88 + var record = me.sampclientsStore.getById(id);
  89 + if (record)
  90 + {
  91 + me.sampclientsStore.remove(record);
  92 + me.updateClients();
  93 + }
  94 + },
  95 + clientmetachange : function(o,id,data,subs)
  96 + {
  97 + var record = me.sampclientsStore.getById(id);
  98 +
  99 + if (!record){
  100 + me.sampclientsStore.add({id : id});
  101 + record = me.sampclientsStore.getById(id);
  102 + }
  103 +
  104 + if (record){
  105 + record.set('descriptionText',data['samp.description.text']);
  106 + record.set('iconUrl',data['samp.icon.url']);
  107 + record.set('name',data['samp.name']);
  108 +
  109 + if (subs){
  110 + record.set('acceptVOTable',
  111 + me.samp.isSubscribed(subs,"table.load.votable"));
  112 + record.set('acceptFITS',
  113 + me.samp.isSubscribed(subs,"image.load.fits"));
  114 + }
  115 + }
  116 +
  117 + me.updateClients();
  118 + },
  119 + clientsubs : function(o,id,data)
  120 + {
  121 + var record = me.sampclientsStore.getById(id);
  122 +
  123 + if (!record)
  124 + return;
  125 +
  126 + if (record){
  127 + record.set('acceptVOTable',
  128 + me.samp.isSubscribed(data,"table.load.votable"));
  129 + record.set('acceptFITS',
  130 + me.samp.isSubscribed(data,"image.load.fits"));
  131 + }
  132 +
  133 + me.updateClients();
  134 + },
  135 + uploadfile : function(o,clientName,url,format)
  136 + {
  137 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.upload.id, true, function (module) {
  138 + module.uploadNotification(url,format);
  139 + });
  140 + }
  141 + }
  142 + });
  143 + this.samp.loadScript(function (s){
  144 + if (successfn)
  145 + successfn.call(me.samp);
  146 + });
  147 + }
  148 + else
  149 + this.samp.loadScript(function (s){
  150 + if (successfn)
  151 + successfn.call(me.samp);
  152 + });
  153 + },
  154 +
  155 + updateStatus : function()
  156 + {
  157 + if (this.app && this.samp)
  158 + {
  159 + var desktop = this.app.getDesktop();
  160 +
  161 + var isConnected = this.samp.isConnected();
  162 +
  163 + if (desktop){
  164 + var win = desktop.getWindow(this.id);
  165 + if (win && win.isVisible)
  166 + win.items.items[0].updateStatus(isConnected);
  167 +
  168 + var taskbar = desktop.taskbar;
  169 +
  170 + if (taskbar){
  171 + var samptb = taskbar.getComponent('samptb');
  172 + if (samptb)
  173 + samptb.updateStatus(isConnected);
  174 + }
  175 + }
  176 + }
  177 + },
  178 +
  179 + updateClients : function()
  180 + {
  181 + if (this.app && this.samp)
  182 + {
  183 + var desktop = this.app.getDesktop();
  184 +
  185 + var isConnected = this.samp.isConnected();
  186 +
  187 + if (desktop)
  188 + {
  189 + var win = desktop.getWindow(this.id);
  190 +
  191 + var taskbar = desktop.taskbar;
  192 +
  193 + if (taskbar)
  194 + {
  195 + var samptb = taskbar.getComponent('samptb');
  196 + if (samptb)
  197 + samptb.updateClients(this.sampclientsStore);
  198 + }
  199 + }
  200 + }
  201 + },
  202 +
  203 + sampConnected : function()
  204 + {
  205 + if (!this.samp)
  206 + return false;
  207 + return this.samp.isConnected();
  208 + },
  209 +
  210 + sendVOTable : function(file,clientId)
  211 + {
  212 + if (!this.samp)
  213 + return false;
  214 + var href = window.location.href;
  215 + var baseurl = href.replace('desktop.php','');
  216 + this.samp.sendVOTable(baseurl+file,clientId);
  217 + },
  218 +
  219 + sendAladinScript : function(script)
  220 + {
  221 + if (!this.samp)
  222 + return false;
  223 + this.samp.sendAladinScript(script);
  224 + },
  225 +
  226 + sendFITS : function(url,name)
  227 + {
  228 + if (!this.samp)
  229 + return false;
  230 + this.samp.sendFITS(url,name);
  231 + },
241 232  
242 233 loadEpnTap: function(filter) {
243 234 if(!this.epntap) {
... ... @@ -246,81 +237,9 @@ Ext.define('amdaDesktop.InteropModule', {
246 237 this.epntap.loadTarget(filter);
247 238 },
248 239  
249   - generateAladinScript : function(urlList, scriptType)
250   - {
251   - /*var script="reset;"; //reset all views & all planes
252   - // first get files
253   - var scriptHead='';
254   - //var script="#AJS;\n";
255   - //scriptHead+="trace 3;"; //
256   - for( var i=0; i < urlList.length; i++)
257   - {
258   - var url = urlList[i].url;
259   - var name = urlList[i].name;
260   - scriptHead += 'get File(' + url +','+name+');';
261   - scriptHead += 'sync;';
262   - }*/
263   -
264   - //scriptHead += 'sync;';
265   -
266   - /*for( var i=0; i < urlList.length; i++)
267   - {
268   - //then modify some fits values
269   - var name = urlList[i].name;
270   - scriptHead += 'set '+name+' FITS:CRVAL1=0;';
271   - scriptHead += 'set '+name+' FITS:CRVAL2=0;';
272   - }*/
273   -
274   - //scriptHead += 'sync;';
275   -
276   - // add som method specific lines
277   - /*switch( scriptType )
278   - {
279   - case( 'mosaic' ):
280   - // first insert the modeview
281   - script += "mview 16;";
282   - // then download the files
283   - script += scriptHead;
284   - //for( var i=0; i < urlList.length; i++){
285   - // // we also shall position each image in the grid
286   - // var gridCols = ["A", "B", "C", "D"];
287   - // var colIndex = i%4;
288   - // var lineIndex = 1+Math.floor(i/4);
289   - // script += "cview "+i+" "+gridCols[colIndex]+lineIndex+";\n";
290   - //}
291   - break;
292   -
293   - case( 'movie' ):
294   - // download first
295   - script += scriptHead;
296   - script += 'blink ';
297   - for( var i=1; i < urlList.length; i++){
298   - script += urlList[i].name+" ";
299   - }
300   - script += ';';
301   - break;
302   -
303   - case( 'diff' ):
304   - // download first
305   - script += scriptHead;
306   - for( var i=1; i < urlList.length; i++){
307   - var diffName = 'diff' + i;
308   - var currRawName = urlList[i].name;
309   - var prevRawNum = i-1;
310   - var prevRawName = urlList[prevRawNum].name;
311   - script += diffName + ' = ' + currRawName + ' - ' + prevRawName + ';\n';
312   - }
313   - script += 'sync;';
314   - script += 'diff_movie = blink ';
315   - for( var i=1; i < urlList.length; i++){
316   - script += 'diff'+i+' ';
317   - }
318   - script += ';';
319   - break;
320   - }
321   - //script += 'sync;';*/
322   -
323   - var script = 'reset;';
  240 + generateAladinScript : function(urlList, scriptType)
  241 + {
  242 + var script = 'reset;';
324 243  
325 244 for( var i=0; i < urlList.length; i++) {
326 245 var url = urlList[i].url;
... ... @@ -328,162 +247,149 @@ Ext.define(&#39;amdaDesktop.InteropModule&#39;, {
328 247 script += 'get File(' + url +','+name+');';
329 248 }
330 249  
331   - script += 'sync;';
332   -
333   - /*for( var i=0; i < urlList.length; i++)
334   - {
335   - //then modify some fits values
336   - var name = urlList[i].name;
337   - script += 'set '+name+' FITS:CRPIX1=100;';
338   - script += 'set '+name+' FITS:CRPIX2=0;';
339   - }*/
340   -
341   - switch( scriptType )
342   - {
343   - case('mosaic'):
344   - {
345   -
346   - script += 'sync;mview 16';
347   - }
348   - break;
349   - case('movie'):
350   - {
351   - script += 'blink ';
352   - for( var i=1; i < urlList.length; i++){
353   - script += urlList[i].name+" ";
354   - }
355   - script += ';';
356   - }
357   - break;
358   - }
359   -
360   -
361   -
362   - return script;
  250 + script += 'sync;';
  251 + switch( scriptType )
  252 + {
  253 + case('mosaic'):
  254 + {
  255 + script += 'sync;mview 16';
  256 + }
  257 + break;
  258 + case('movie'):
  259 + {
  260 + script += 'blink ';
  261 + for( var i=1; i < urlList.length; i++){
  262 + script += urlList[i].name+" ";
  263 + }
  264 + script += ';';
  265 + }
  266 + break;
  267 + }
  268 + return script;
  269 + },
  270 +
  271 + switchSampConnect : function()
  272 + {
  273 + var me = this;
  274 + //loadMask.show();
  275 + this.initSampConnector(function (s){
  276 + if (me.samp.isConnected())
  277 + {
  278 + me.samp.disconnect();
  279 + }
  280 + else
  281 + {
  282 + me.samp.connect();
  283 + // loadMask.hide();
  284 + }
  285 + });
  286 + },
  287 +
  288 + forceSampDisconnect : function()
  289 + {
  290 + if (!this.samp)
  291 + return;
  292 +
  293 + if (!this.samp.isConnected())
  294 + return;
  295 +
  296 + this.samp.disconnect();
363 297 },
364 298  
365   - switchSampConnect : function()
366   - {
367   - var me = this;
368   - //loadMask.show();
369   - this.initSampConnector(function (s){
370   - if (me.samp.isConnected())
371   - {
372   - me.samp.disconnect();
373   - }
374   - else
375   - {
376   - me.samp.connect();
377   - // loadMask.hide();
378   - }
379   - });
380   -
381   - },
382   -
383   - forceSampDisconnect : function()
384   - {
385   - if (!this.samp)
386   - return;
387   -
388   - if (!this.samp.isConnected())
389   - return;
390   -
391   - this.samp.disconnect();
392   - },
393   -
394   - getVOTableClients : function ()
395   - {
396   - //return list of all clients that can receive a VOTable
397   - if (!this.samp)
398   - return [];
399   - var result = new Array();
400   - this.sampclientsStore.each(function (client){
401   - if (client.get('acceptVOTable'))
402   - result.push({id : client.get('id'), name : client.get('name'), icon : client.get('iconUrl')});
403   -
404   - },this);
405   - return result;
406   - },
407   -
408   - getFITSClients : function ()
409   - {
410   - //return list of all clients that can receive a FITS image
411   - if (!this.samp)
412   - return [];
413   - var result = new Array();
414   - this.sampclientsStore.each(function (client){
415   - if (client.get('acceptFITS'))
416   - result.push({id : client.get('id'), name : client.get('name'), icon : client.get('iconUrl')});
417   -
418   - },this);
419   - return result;
420   -
421   - },
  299 + getVOTableClients : function ()
  300 + {
  301 + //return list of all clients that can receive a VOTable
  302 + if (!this.samp)
  303 + return [];
  304 + var result = new Array();
  305 + this.sampclientsStore.each(function (client){
  306 + if (client.get('acceptVOTable'))
  307 + result.push({id : client.get('id'), name : client.get('name'), icon : client.get('iconUrl')});
  308 +
  309 + },this);
  310 + return result;
  311 + },
  312 +
  313 + getFITSClients : function ()
  314 + {
  315 + //return list of all clients that can receive a FITS image
  316 + if (!this.samp)
  317 + return [];
  318 + var result = new Array();
  319 + this.sampclientsStore.each(function (client){
  320 + if (client.get('acceptFITS'))
  321 + result.push({id : client.get('id'), name : client.get('name'), icon : client.get('iconUrl')});
  322 +
  323 + },this);
  324 + return result;
  325 + },
  326 +
422 327 // arguments from launcher : CONFIG (OBJECT!!!)
423 328 createWindow : function(config){
424   - var me = this;
425   - var baseId = null;
  329 + var me = this;
  330 + var baseId = null;
426 331  
427   - if (!Ext.isObject(config)) {
428   - baseId = config;
429   - }
430   - var desktop = this.app.getDesktop();
431   - var win = desktop.getWindow(this.id);
432   - var activeTab = (config && 'activeTab' in config) ? config['activeTab']: 1;
433   -
434   - if(!win)
435   - {
436   - win = desktop.createWindow({
437   - id: this.id,
438   - title:this.title,
  332 + if (!Ext.isObject(config)) {
  333 + baseId = config;
  334 + var activeTab = 1;
  335 + }
  336 + else {
  337 + var activeTab = ('activeTab' in config) ? config['activeTab'] : 1;
  338 + }
  339 + var desktop = this.app.getDesktop();
  340 + var win = desktop.getWindow(this.id);
  341 +
  342 + if(!win)
  343 + {
  344 + win = desktop.createWindow({
  345 + id: this.id,
  346 + title:this.title,
439 347 layout: 'fit',
440 348 minWidth: 650,
441 349 minHeight: 350,
442 350 minimizable: false,
443   - iconCls: this.icon,
444   - animCollapse:false,
445   - constrainHeader:true,
446   - bodyPadding : 5,
447   - stateful : true,
448   - stateId : this.id,
449   - stateEvents: ['move','show','resize'],
450   - tools: [{
451   - type:'help',
452   - qtip: this.helpTitle,
453   - scope:this,
454   - handler: function(event, toolEl, panel) {
455   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
456   - module.createWindow(me.helpFile, me.helpTitle);
457   - });
458   - }
459   - }],
460   - items : [
461   - {
462   - xtype: 'panelInterop',
463   - clientsStore : this.sampclientsStore,
464   - activeTab : activeTab,
465   - baseId : baseId,
466   - loadTab: function(tab) {
467   - if(tab['id'] === 'epntapTab') {
468   - me.loadEpnTap(config && 'epntapFilter' in config ? config['epntapFilter']: false);
469   - }
470   - },
471   - onSwitchConnect : function ()
472   - {
473   - me.switchSampConnect();
474   - }
475   - }
476   - ]
477   - });
478   - } else if(activeTab == 2) {
  351 + iconCls: this.icon,
  352 + animCollapse:false,
  353 + constrainHeader:true,
  354 + bodyPadding : 5,
  355 + stateful : true,
  356 + stateId : this.id,
  357 + stateEvents: ['move','show','resize'],
  358 + tools: [{
  359 + type:'help',
  360 + qtip: this.helpTitle,
  361 + scope:this,
  362 + handler: function(event, toolEl, panel) {
  363 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.info.id, true, function(module) {
  364 + module.createWindow(me.helpFile, me.helpTitle);
  365 + });
  366 + }
  367 + }],
  368 + items : [
  369 + {
  370 + xtype: 'panelInterop',
  371 + clientsStore : this.sampclientsStore,
  372 + activeTab : activeTab,
  373 + baseId : baseId,
  374 + loadTab: function(tab) {
  375 + if(tab['id'] === 'epntapTab') {
  376 + me.loadEpnTap(config && 'epntapFilter' in config ? config['epntapFilter']: false);
  377 + }
  378 + },
  379 + onSwitchConnect : function ()
  380 + {
  381 + me.switchSampConnect();
  382 + }
  383 + }]
  384 + });
  385 + } else if(activeTab == 2) {
479 386 me.loadEpnTap(config && 'epntapFilter' in config ? config['epntapFilter']: false);
480 387 }
481 388  
482   - if (me.samp && me.samp.ready)
483   - this.updateStatus();
  389 + if (me.samp && me.samp.ready)
  390 + this.updateStatus();
484 391  
485   - win.show();
486   - return win;
  392 + win.show();
  393 + return win;
487 394 }
488   -
489 395 });
... ...