Blame view

js/app/views/DownloadUI.js 22.9 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/**
 * Project   : AMDA-NG
 * Name      : DownloadUI.js
 * @class 	 amdaUI.DownloadUI
 * @extends  Ext.container.Container 
 * @brief    Download Module UI definition (View)
 * @author 	 Myriam
 * @version $Id: DownloadUI.js 2622 2014-11-07 14:50:09Z elena $  
 */
 
 
Ext.define('amdaUI.DownloadUI', {
	extend: 'Ext.container.Container',
	alias: 'widget.panelDownload',

	requires: [
		'amdaUI.TimeSelectorUI',
7ac3ce50   Benjamin Renard   First implementat...
18
		'amdaUI.ParamArgumentsPlug',
e516c132   Benjamin Renard   Add SAMP export i...
19
		'amdaUI.SendToSampButtonUI',
7ac3ce50   Benjamin Renard   First implementat...
20
		'amdaModel.DownloadParam'
16035364   Benjamin Renard   First commit
21
22
	],   
	
9cb1f3cd   Benjamin Renard   Update download i...
23
24
25
26
	//Old kernel time formats
	//timeformatData    : [['Y-m-dTH:i:s', 'YYYY-MM-DDThh:mm:ss'], ['Y m d H i s', 'YYYY MM DD hh mm ss'], ['d m Y H i s', 'DD MM YYYY hh mm ss'], ['Y z H i s', 'YYYY DDD hh mm ss']],
	//New kernel time formats
	timeformatData    : [['Y-m-dTH:i:s', 'YYYY-MM-DDThh:mm:ss'], ['DD Time', 'DD Time'], ['Timestamp', 'Timestamp']],
fdf1413b   Elena.Budnik   TT download
27
	timeformatTTData    : [['Y-m-dTH:i:s', 'YYYY-MM-DDThh:mm:ss']],
9cb1f3cd   Benjamin Renard   Update download i...
28
	fileformatData    : [['ASCII', 'ASCII'],['vot', 'VOTable'],['cdf', 'CDF'],['json', 'JSON']],
16035364   Benjamin Renard   First commit
29
30
	fileformatTTData  : [['text', 'plain text'], ['vot','VOTable']],
	filecompressData  : [['zip', 'zip'], ['tar+gzip', 'tar+gzip']],
fdf1413b   Elena.Budnik   TT download
31
	filecompressTT    : [['zip', 'zip'], ['tar+gzip', 'tar+gzip'], ['none', 'none']],
16035364   Benjamin Renard   First commit
32
	filestructureData : [['0','All In One File'], ['1','One File Per Time Interval'], ['2','One File Per Param/Interval']],
16035364   Benjamin Renard   First commit
33
34
35
36

	constructor: function(config) {	  
		this.init(config);
		this.callParent(arguments);		
fdf1413b   Elena.Budnik   TT download
37
38
39
40
41
42
		// load object into view		 
		if (this.object) this.loadObject();
		//
		var paramArgsPlug = this.getPlugin('download-param-arguments-plugin');
		if (paramArgsPlug)
			paramArgsPlug.onApply = this.onApplyParameterArgs;
16035364   Benjamin Renard   First commit
43
44
45
	},

	addTT : function(newTTName,newTTid)
fdf1413b   Elena.Budnik   TT download
46
	{ 
16035364   Benjamin Renard   First commit
47
48
49
50
		var tabPanel = this.formPanel.down();
		var downloadSrc = tabPanel.items.indexOf(tabPanel.getActiveTab());
		 
		if (downloadSrc === 0) {
fdf1413b   Elena.Budnik   TT download
51
			this.timeSelector.addTT(newTTName,newTTid);
16035364   Benjamin Renard   First commit
52
53
		}
		else {
fdf1413b   Elena.Budnik   TT download
54
55
56
57
58
59
60
61
			// search for an existing record in store with this unique name
			var existingIndex = this.TTGrid.store.findExact( 'name', newTTName);
			// if no corresponding TT found
			if (existingIndex == -1){
				// adding the time table to the TTGrid of TT download 
				var r = Ext.create('amdaModel.TTobject', { id: newTTid, name: newTTName });
				this.TTGrid.store.insert(this.TTGrid.store.getCount(),r);   
			}        
16035364   Benjamin Renard   First commit
62
63
64
65
66
		}
	},

	addTTs : function(TTarray) {
	// set TTTab	    
fdf1413b   Elena.Budnik   TT download
67
		this.timeSelector.setTTTab(TTarray);
16035364   Benjamin Renard   First commit
68
69
70
71
72
73
74
75
76
77
	},
	
	// Add TT in download TT module
	addTTdownload : function(newTTName,newTTid){
		var tabPanel = this.formPanel.down();
		tabPanel.setActiveTab(1);
		this.addTT(newTTName,newTTid);
		
	},	
        
fdf1413b   Elena.Budnik   TT download
78
79
80
81
	/**
	* Set Start-Stop from parameter info (Local & MyData)
	*/ 
	setTimeFromData : function(obj) {
8f85fbfa   Benjamin Renard   Remove deprecated...
82
83
		if (!obj.start || !obj.stop)
			return;
fdf1413b   Elena.Budnik   TT download
84
85
86
87
88
89
		var dateStart = new Date(obj.start.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 
		var dateStop = new Date(obj.stop.replace(/[T|Z]/g,' ').replace(/\-/g,'\/')); 
		
		this.down('form').getForm().setValues({ startDate : dateStart, stopDate : dateStop });
		this.timeSelector.intervalSel.updateDuration();
	},
16035364   Benjamin Renard   First commit
90
        
fdf1413b   Elena.Budnik   TT download
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
	addParam : function(paramId, isLeaf, needArgs, components) 
	{
		// adding the parameter to the  paramGrid	
		var paramObj = {
			paramid: paramId,
			type: 0,
			'dim1-is-range': false,
			'dim1-min-range': 0.,
			'dim1-max-range': 0.,
			'dim1-index': '*',
			'dim2-is-range': false,
			'dim2-min-range': 0.,
			'dim2-max-range': 0.,
			'dim2-index': '*',
			template_args: {}
		};
63ac7745   Benjamin Renard   Support component...
107
        	
fdf1413b   Elena.Budnik   TT download
108
109
110
111
112
113
114
115
116
117
118
		if (components) {
			if (components['index1']) {
				paramObj['dim1-index'] = components['index1'];
				++paramObj['type'];
			}
			
			if (components['index2']) {
				paramObj['dim2-index'] = components['index2'];
				++paramObj['type'];
			}
		}
63ac7745   Benjamin Renard   Support component...
119
        	
fdf1413b   Elena.Budnik   TT download
120
121
122
123
124
125
126
		var r = Ext.create('amdaModel.DownloadParam', paramObj);
		var pos = this.paramGrid.store.getCount();
		this.paramGrid.store.insert(pos,r); 
		this.paramGrid.getView().refresh();
		if (!isLeaf || needArgs)
			this.editParameterArgs(r);
	},
16035364   Benjamin Renard   First commit
127

fdf1413b   Elena.Budnik   TT download
128
129
130
131
132
133
134
135
136
	addParams: function(arrayParams) 
	{
		var arrayRec = new Array();
		var index = 1;		 
		if (arrayParams)
		{
			index = 0;            
			Ext.Array.each(arrayParams,function(item){		
				if (Ext.isObject(item)) {
27504b3e   Elena.Budnik   redmine 5080
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
					if (typeof paramId !== 'undefined')
					{
						// for Parameter Name in Download Module
						var paramObj = {
							paramid: paramId,
							type: 0,
							'dim1-is-range': false,
							'dim1-min-range': 0.,
							'dim1-max-range': 0.,
							'dim1-index': item.get('dim1'),
							'dim2-is-range': false,
							'dim2-min-range': 0.,
							'dim2-max-range': 0.,
							'dim2-index': item.get('dim2'),
							template_args: {}
						};		
						
						var r = Ext.create('amdaModel.DownloadParam', paramObj);	
					}
					else
					{
						//for download from get Data in Plot module
						var r = Ext.create('amdaModel.DownloadParam', item);	 
					}
						 				 
fdf1413b   Elena.Budnik   TT download
162
163
164
165
166
167
168
169
170
171
172
				}
				else {
				// for Download By Request in Operations menu
				//TODO BRE - Components selection
					var r = Ext.create('amdaModel.DownloadParam', { paramid: item });
				}
				arrayRec.push(r);
			});
		} 	     
		this.paramGrid.getStore().loadData(arrayRec);
	},
16035364   Benjamin Renard   First commit
173
174
175
176
177
178
179
	
	// parameter name -> alias
	updateConstruct : function(oldval,newval) {
		var index = this.paramGrid.store.findExact('name', oldval);
		if (index != -1) {
			this.paramGrid.getStore().getAt(index).set('name',newval);
			this.paramGrid.getStore().getAt(index).set('text',newval);	
fdf1413b   Elena.Budnik   TT download
180
		}
16035364   Benjamin Renard   First commit
181
182
183
184
185
186
187
188
189
190
	},
	
	setObject : function(obj) {
		this.object = obj;  
		this.loadObject();
	},

	/**
	 * update this.object from form
	 */
fdf1413b   Elena.Budnik   TT download
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
	updateObject : function()
	{    
		// get the basic form
		var tabPanel = this.formPanel.down();
		var downloadSrc = tabPanel.items.indexOf(tabPanel.getActiveTab());
		var basicForm = this.formPanel.getForm();
		var updateStatus = true;
		var values = basicForm.getValues();
		
		// data download
		if (downloadSrc === 0) 
		{            
			var timeformat =  basicForm.findField('timeformat').getRawValue();         
			var timeSource = this.timeSelector.getActiveTimeSource();     
			var structure = values.filestructure;
			var sampling = values.sampling ? values.sampling : 600;
			var refparamSampling = values.refparamsampling == 'on';
			var fileprefix = values.fileprefix ? values.fileprefix : '';
			var fileformat = values.fileformat;
			var compression = values.compression;
16035364   Benjamin Renard   First commit
211

fdf1413b   Elena.Budnik   TT download
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
			var fieldsWithoutName = basicForm.getFields().items;
			Ext.Array.each(fieldsWithoutName, function(item, index,allItems){		     
				if (!item.isValid()) {
					if ((timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0]) &&
						((item.name == 'startDate') || (item.name == 'stopDate') || (item.name == 'duration'))) {
						updateStatus = true;
					}
					else {
						// set update isn't allowed
						updateStatus = false;
						return false;
					}       
				}
			}, this);
			
			if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0] // timeSource  'TimeTable'
				&& this.timeSelector.TTGrid.getStore().count() == 0) {
				myDesktopApp.warningMsg('You\'ve chosen Time Selection `by TimeTable` but no timeTable was added!'
				+'<br>You must add one or choose Time Selection `by Interval`'); 
				updateStatus = false;    
			}
16035364   Benjamin Renard   First commit
233
                                
fdf1413b   Elena.Budnik   TT download
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
			if (updateStatus) 
			{
				/// real object update
				// update TimeTable object with the content of form
				basicForm.updateRecord(this.object);
				this.object.set('timesrc', timeSource);
				// set valid intervals into TimeTable object
				if (timeSource === amdaModel.AmdaTimeObject.inputTimeSrc[0])
						this.object.set('timeTables',this.timeSelector.TTGrid.getStore().data.items);
				// set parameters			    
				this.object.set('list',this.paramGrid.getStore().data.items);
				this.object.set('structure', structure);
				this.object.set('refparamSampling', refparamSampling);
				this.object.set('sampling', sampling);
				this.object.set('fileprefix',fileprefix);
				this.object.set('timeformat',timeformat);
				this.object.set('fileformat',fileformat);
				this.object.set('compression',compression);
			}    
		}
		//TT download
		else 
		{
			var timeformat =  values.timeformatTT;
			var compression = values.compressionTT;
			var fileformat = values.fileformatTT;
			if (compression === 'none'  
				&& this.TTGrid.getStore().count() > 1) {
				myDesktopApp.warningMsg('You are going to download several time tables -  select the Compression please'); 
				updateStatus = false;    
			}			
			this.object.set('timeTables',this.TTGrid.getStore().data.items);
			this.object.set('timeformatTT',timeformat);
			this.object.set('fileformatTT',fileformat);
			this.object.set('compressionTT',compression);
		}
16035364   Benjamin Renard   First commit
270
            
fdf1413b   Elena.Budnik   TT download
271
272
273
		this.object.set('downloadSrc',downloadSrc);
		// return the update status
		return updateStatus;	    
16035364   Benjamin Renard   First commit
274
275
276
277
278
279
280
	},

	/**
	 * load this.object into form
	 */
	loadObject : function(){	
	
fdf1413b   Elena.Budnik   TT download
281
282
283
284
285
286
287
288
289
290
291
292
293
294
		if (!this.object.get('timeformat'))
			this.object.set('timeformat', this.timeformatData[0][0]);
		
		if (!this.object.get('timeformatTT'))
			this.object.set('timeformatTT', this.timeformatTTData[0][0]);
		
		if (!this.object.get('fileformat'))
			this.object.set('fileformat', this.fileformatData[0][0]);
		
		if (!this.object.get('fileformatTT'))
			this.object.set('fileformatTT', this.fileformatTTData[0][0]);
		
		if (!this.object.get('compression'))
			this.object.set('compression', this.filecompressData[1][0]);
16035364   Benjamin Renard   First commit
295

fdf1413b   Elena.Budnik   TT download
296
297
298
299
300
301
302
303
304
		if (!this.object.get('compressionTT'))
		this.object.set('compressionTT', this.filecompressData[1][0]);
		
		// load object into form	
		this.formPanel.getForm().loadRecord(this.object);
		// set object's TTs into the timeselector
		this.addTTs(this.object.get('timeTables'));	 
		// set parameters 	
		this.addParams(this.object.get('list'));	     
16035364   Benjamin Renard   First commit
305
306
	},

fdf1413b   Elena.Budnik   TT download
307
308
309
/**
* download method called by 'Download' button to launch the download process
*/
e516c132   Benjamin Renard   Add SAMP export i...
310
	doDownload : function(sendToSamp, clientId){	 
16035364   Benjamin Renard   First commit
311
312
		var downloadModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id);
		if (downloadModule)
e516c132   Benjamin Renard   Add SAMP export i...
313
			downloadModule.linkedNode.execute(sendToSamp, clientId);		  
16035364   Benjamin Renard   First commit
314
	},
fdf1413b   Elena.Budnik   TT download
315
	 	
7ac3ce50   Benjamin Renard   First implementat...
316
	actionItem: function(grid, cell, cellIndex, record, row, recordIndex, e){
fdf1413b   Elena.Budnik   TT download
317
318
319
320
		
		var isTimeTable  = record instanceof amdaModel.TTobject; 
		 
		if ( cellIndex == 3 || ( cellIndex == 2 && isTimeTable ))
16035364   Benjamin Renard   First commit
321
			grid.getStore().remove(record);
fdf1413b   Elena.Budnik   TT download
322
		else if ( cellIndex == 2 ) {
cefdf537   Benjamin Renard   Remove restrictio...
323
			this.paramGrid.getView().select(row);
bb6e93d9   Benjamin Renard   Implement templat...
324
			this.editParameterArgs(record);
cefdf537   Benjamin Renard   Remove restrictio...
325
		}
7ac3ce50   Benjamin Renard   First implementat...
326
327
	},
	
bb6e93d9   Benjamin Renard   Implement templat...
328
	editParameterArgs: function(record) {
7ac3ce50   Benjamin Renard   First implementat...
329
330
		var paramArgsPlug = this.getPlugin('download-param-arguments-plugin');
		if (paramArgsPlug)
bb6e93d9   Benjamin Renard   Implement templat...
331
			paramArgsPlug.show('download-param-arguments-plugin', record);
7ac3ce50   Benjamin Renard   First implementat...
332
333
	},
	
bb6e93d9   Benjamin Renard   Implement templat...
334
	onApplyParameterArgs : function(parentUI, paramObject) {
7ac3ce50   Benjamin Renard   First implementat...
335
		parentUI.paramGrid.getView().refresh();
16035364   Benjamin Renard   First commit
336
337
	},
	 
9cb1f3cd   Benjamin Renard   Update download i...
338
339
340
341
342
343
	onFileStructureChange : function(combo, newValue, oldValue){
		if (!this.formPanel)
			return;

		var refParamCheck = this.formPanel.getForm().findField('refparamsampling');
		var samplingField = this.formPanel.getForm().findField('sampling');
16035364   Benjamin Renard   First commit
344

9cb1f3cd   Benjamin Renard   Update download i...
345
346
347
		if (samplingField &&  newValue !== oldValue) {
		     refParamCheck.setDisabled(newValue == 2);
		     samplingField.setDisabled((newValue == 2) || refParamCheck.getValue());
16035364   Benjamin Renard   First commit
348
349
		}
	},
9cb1f3cd   Benjamin Renard   Update download i...
350
351
352
353
354
355
356
357
358
359
360

	onRefParamSamplingChange : function(check, newValue, oldValue){
		if (!this.formPanel)
                        return;

		var samplingField = this.formPanel.getForm().findField('sampling');
		var structureCombo = this.formPanel.getForm().findField('filestructure');

		if (samplingField &&  newValue !== oldValue)
			samplingField.setDisabled((structureCombo.getValue() == 2) || check.getValue());
	},
e516c132   Benjamin Renard   Add SAMP export i...
361
362
363
364
365
366
367

        onSendVOTableToSamp : function (clientId, sendOpt){
                var me = sendOpt.scope;
		if(me.updateObject()){
			me.doDownload(true, clientId);
		}
        },
16035364   Benjamin Renard   First commit
368
369
370
371
372
373
374
375
376
377
	
	/**
	 * Check if changes were made before closing window 
	 * @return false
	 */	
	fclose : function() {
		return false;
	},
	
	init : function (config){
0bda97f3   Benjamin Renard   Fix SAMP export f...
378
		var me = this;
16035364   Benjamin Renard   First commit
379
380
381
382
		
		this.timeSelector = new amdaUI.TimeSelectorUI({id: 'downloadTimeSelector',flex: 1});
		
		this.paramGrid = Ext.create('Ext.grid.Panel', {
fdf1413b   Elena.Budnik   TT download
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
			flex: 2,
			store : Ext.create('Ext.data.Store', { model: 'amdaModel.DownloadParam'} ),  
			columns: [ 
				{ xtype: 'rownumberer', width: 20 },
				{ 
					header: "Parameter Name", 
					dataIndex: 'name', 
					flex:1, 
					sortable: false, 
					menuDisabled : true ,
					renderer: function (val, meta, rec) {
						return rec.getParamFullName();
					}
				},
				{
					menuDisabled : true, width: 30, renderer: function(){
						return'<div class="icon-parameters" style="width: 15px; height: 15px;"></div>';
					}
				},
				{ 
					menuDisabled : true, width: 30, renderer: function(){
						return'<div class="icon-remover" style="width: 15px; height: 15px;"></div>';
					}
				}
			],
16035364   Benjamin Renard   First commit
408
			//TODO - BRE - Wait the fix for drag&drop issue
fdf1413b   Elena.Budnik   TT download
409
			listeners :
16035364   Benjamin Renard   First commit
410
			{
fdf1413b   Elena.Budnik   TT download
411
412
413
414
415
416
				render : function(o,op)
				{
					var me = this;
					var el = me.body.dom;
					var dropTarget = Ext.create('Ext.dd.DropTarget', el, {
						ddGroup: 'explorerTree',
3ab0bee9   Elena.Budnik   aprams with args ...
417
						notifyEnter : function(ddSource, e, data) { },
fdf1413b   Elena.Budnik   TT download
418
419
						notifyOver  : function(ddSource, e, data)
						{                                    
3ab0bee9   Elena.Budnik   aprams with args ...
420
421
							if (data.records[0].data.nodeType == 'localParam' && data.records[0].get('notyet')) 
							{
fdf1413b   Elena.Budnik   TT download
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
								this.valid = false;
								return this.dropNotAllowed;   
							}	
							if (((data.records[0].data.nodeType == 'localParam')   ||
								(data.records[0].data.nodeType == 'remoteParam') || 
								(data.records[0].data.nodeType == 'remoteSimuParam') ||
								(data.records[0].data.nodeType == 'derivedParam') || 
								(data.records[0].data.nodeType == 'myDataParam') ||
								(data.records[0].data.nodeType == 'alias'))&&
								(data.records[0].isLeaf() || data.records[0].data.isParameter) &&
								!data.records[0].data.disable)
							{
								this.valid = true;
								return this.dropAllowed;
							}
							
							this.valid = false;
							return this.dropNotAllowed;
						},
						notifyDrop  : function(ddSource, e, data)
						{
							if (!this.valid)
								return false;
							var idToSent;
							var components = null;
							switch (data.records[0].data.nodeType)
							{
								case 'localParam' :
								case 'remoteParam':
								case 'remoteSimuParam':                                           
									idToSent = data.records[0].get('id');
									if (data.records[0].get('alias')!= "" )
										idToSent = "#"+data.records[0].get('alias');
3ab0bee9   Elena.Budnik   aprams with args ...
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
									var component_info = data.records[0].get('component_info');
									if (component_info && component_info.parentId) 
									{													
										if ( component_info.index1 && component_info.index2 )
										{															 
											idToSent = component_info.parentId;
											components = [];												
											if (component_info.index1)
												components['index1'] = component_info.index1;
											if (component_info.index2)
												components['index2'] = component_info.index2;
										}	
										if ( data.records[0].get('needsArgs') )
										{															
											idToSent = component_info.parentId;	
											if (component_info.index1)
											{
												components = [];	
												components['index1'] = component_info.index1;
											}
										}													
									}
fdf1413b   Elena.Budnik   TT download
477
478
479
480
481
482
483
484
485
486
487
488
489
									break;
								case 'alias' :
									idToSent = "#"+data.records[0].get('text');
									break;
								case 'derivedParam' :
									idToSent = "ws_"+data.records[0].get('text');
									break;
								case 'myDataParam' :
									idToSent = "wsd_"+data.records[0].get('text');
									break;
								default :
								return false;
							}
9fad5834   Elena.Budnik   redmine #4795
490
							var downModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id);							
fdf1413b   Elena.Budnik   TT download
491
492
493
494
495
496
497
							if (downModule)
								downModule.addParam(idToSent,data.records[0].get('leaf'), data.records[0].get('needsArgs'), components);	
							return true;
						}
					});
				}
			}			
16035364   Benjamin Renard   First commit
498
499
		});      
						
7ac3ce50   Benjamin Renard   First implementat...
500
		this.paramGrid.on('cellclick', this.actionItem, this);
16035364   Benjamin Renard   First commit
501
502

		this.TTGrid = Ext.create('Ext.grid.Panel', {
fdf1413b   Elena.Budnik   TT download
503
504
505
506
			flex: 2,
			store : Ext.create('Ext.data.Store', {model: 'amdaModel.TTobject'}),  
			columns: [ 
				{ xtype: 'rownumberer', width: 20 },
6a058338   Elena.Budnik   redmine #5241
507
				{ header: "TimeTable/Catalog Name", dataIndex: 'name', flex:1, sortable: false, menuDisabled: true},
fdf1413b   Elena.Budnik   TT download
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
				{ 
					menuDisabled : true, width: 30, renderer: function(){
						return '<div class="icon-remover" style="width: 15px; height: 15px;"></div>';
					}
				}
			],
			listeners :
			{
				render : function(o,op)
				{
					var me = this;
					var el = me.body.dom;
					var dropTarget = Ext.create('Ext.dd.DropTarget', el, {
						ddGroup: 'explorerTree',
						notifyEnter : function(ddSource, e, data) 
						{
						
						},
						notifyOver  : function(ddSource, e, data)
						{
							var nodeType = data.records[0].get('nodeType');
							
							if ((nodeType == 'timeTable' || nodeType == 'sharedtimeTable') ||
							(nodeType == 'catalog' || nodeType == 'sharedCatalog') &&
							(data.records[0].get('leaf')))
							{
								this.valid = true;
								return this.dropAllowed;
							}
							this.valid = false;
							return this.dropNotAllowed;
						},
						notifyDrop  : function(ddSource, e, data)
						{
							if (!this.valid)
								return false;
							var downModule = myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.download.id);
							if (downModule)
								downModule.getUiContent().addTTdownload(data.records[0].get('text'),data.records[0].get('id'));
							return true;
						}
					});
				}
16035364   Benjamin Renard   First commit
551
			}
16035364   Benjamin Renard   First commit
552
		});
fdf1413b   Elena.Budnik   TT download
553
		
7ac3ce50   Benjamin Renard   First implementat...
554
		this.TTGrid.on('cellclick', this.actionItem, this);
16035364   Benjamin Renard   First commit
555
556
						
		this.paramPanel = { 		 
fdf1413b   Elena.Budnik   TT download
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
			xtype: 'container',	  
			title: 'Parameters',		   
			layout: {
				type: 'hbox',
				align : 'stretch',
				defaultMargins: {top: 10, left:10, bottom: 5, right:10}
			},
			items: [		     
			{
				xtype: 'container',
				flex: 2,
				layout: {
					type: 'vbox',
					align : 'stretch'
					},
				items: [ 				
					{
						xtype: 'textfield',				 				 
						fieldLabel: 'Request Name',
						disabled: true,
						name : 'name'	 
					}, 
					{
						xtype: 'splitter',
						flex: 0.05 
					},  	 			 				 			 	      
					this.paramGrid
				]  
			},			 
			{                 		   
				xtype: 'container',
				flex: 2,
				defaults : {
					xtype : 'combo',
					labelWidth: 90,
					queryMode: 'local',
					editable: false
9cb1f3cd   Benjamin Renard   Update download i...
594
				},
fdf1413b   Elena.Budnik   TT download
595
596
597
				layout: {
					type: 'vbox',
					align: 'stretch'
16035364   Benjamin Renard   First commit
598
				},
fdf1413b   Elena.Budnik   TT download
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
				items: [				
					{				    				  
						fieldLabel: 'Time Format',				  
						name: 'timeformat',				   
						store: this.timeformatData,
						value: this.timeformatData[0]					     
					},
					{				    
						fieldLabel: 'File Structure',
						name: 'filestructure',
						store: this.filestructureData,
						value: this.filestructureData[2],
						listeners : {
							change  : { fn : this.onFileStructureChange },
							scope: this
						} 
					},
					{
						xtype: 'checkbox', boxLabel: 'Use first param. as reference for sampling', 		
						boxLabelAlign: 'before',
						name: 'refparamsampling', checked: false, disabled: true,
						listeners : {
							change : { fn : this.onRefParamSamplingChange },
							scope : this
						}
					},  		 					    						
					{
						xtype: 'numberfield', name: 'sampling',
						fieldLabel: 'Sampling Time', value: 600,
						hideTrigger: true,  editable: true,
						disabled: true
					},
					{
						xtype: 'textfield', name: 'fileprefix',
						fieldLabel: 'File Prefix',				    
						disabled: false,  editable: true
					},
					{				     
						fieldLabel: 'File Format',
						name: 'fileformat',				    
						store: this.fileformatData, 
						value: this.fileformatData[0]                  	        	        	 
					},				
					{
						fieldLabel: 'Compression', 
						name: 'compression',
						store: this.filecompressData, 
						value: this.filecompressData[0]
					},
					this.timeSelector
				]
			} 
		]};

		this.ttPanel =
		{  
			xtype: 'container',	        
			title: 'Time Tables / Catalogs',			 
			layout: {
				type: 'hbox',
				align : 'stretch',
				defaultMargins: { top: 10, left:10, bottom: 5, right:10 }
			},
			items: [ 			 									 			 				 			 	      
				this.TTGrid,			         
				{                 		   
					xtype: 'container',
					flex: 2,
					defaults : {
					xtype : 'combo',
					labelWidth: 90,
					queryMode: 'local',
					editable: false			      
16035364   Benjamin Renard   First commit
672
				},
fdf1413b   Elena.Budnik   TT download
673
674
675
				layout: {
					type: 'vbox',
					align : 'stretch'
16035364   Benjamin Renard   First commit
676
				},
fdf1413b   Elena.Budnik   TT download
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
				items: [{						    				  
						fieldLabel:'Time Format',				  
						name:'timeformatTT',				   
						store: this.timeformatTTData,
						value: this.timeformatTTData[0]					     
					}, 
					{				     
						fieldLabel: 'File Format ',
						name: 'fileformatTT',				    
						store: this.fileformatTTData, 
						value: this.fileformatTTData[0]                  	        	        	 
					},				
					{
						fieldLabel: 'Compression ', 
						name: 'compressionTT',
						store: this.filecompressTT, 
						value: this.filecompressTT[0]
					}	          	        	           
				]}
			]			     
		};       
16035364   Benjamin Renard   First commit
698
699
 
		this.formPanel = new Ext.form.Panel({
fdf1413b   Elena.Budnik   TT download
700
701
702
703
704
705
			layout: 'fit',
			region: 'center',
			bodyStyle: { background : '#dfe8f6' },  
			buttonAlign: 'left',
			trackResetOnLoad: true,  //reset to the last loaded record
			defaults: {
16035364   Benjamin Renard   First commit
706
			border: false
fdf1413b   Elena.Budnik   TT download
707
708
709
710
711
712
713
714
			},
			items: [{  			   
				xtype: 'tabpanel',
				activeTab : 0,
				bodyStyle: { background : '#dfe8f6' },
				items: [
					this.paramPanel,
					this.ttPanel			      
0bda97f3   Benjamin Renard   Fix SAMP export f...
715
716
717
718
719
720
721
				],
				listeners: {
					'tabchange' : function (tabPanel, tab) {
						var sampAvailable = (tab.title == me.paramPanel.title);
						me.down('sendToSampButton').setDisabled(!sampAvailable);
					}
				}
fdf1413b   Elena.Budnik   TT download
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
			}],
			fbar: [
			{
				text: 'Download',
				scope : this,
				handler: function(button){
					// if the return is true (object had been updated)
					if(this.updateObject()){
						// launch the download process 			        
						this.doDownload();				   				
					}
				} 
			},
			{
				text: 'Reset',
				scope : this,
				handler: function(){
					this.formPanel.getForm().reset();						
					var tabPanel = this.formPanel.down();
					var downloadSrc = tabPanel.items.indexOf(tabPanel.getActiveTab());					 
					if (downloadSrc === 0) {
						// reset parameters and Time Tables in Get Data
						this.paramGrid.store.removeAll();
						this.timeSelector.TTGrid.store.removeAll();
					}
					else {
						// reset Time Tables in Get time Table
						this.TTGrid.store.removeAll();
					}
				}			 
e516c132   Benjamin Renard   Add SAMP export i...
752
753
754
755
756
757
758
759
			},
			'->',
			{
                                xtype        : 'sendToSampButton',
                                type         : 'votable',
                                onSendToSamp : this.onSendVOTableToSamp,
                                sendOpt      : {scope : this}
                        }]  
fdf1413b   Elena.Budnik   TT download
760
		});    	 
16035364   Benjamin Renard   First commit
761
		
fdf1413b   Elena.Budnik   TT download
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
		var myConf = {
			layout: 'border',
			items: [		   
				this.formPanel,   
				{
					xtype: 'panel', 
					region: 'south',
					title: 'Information',
					collapsible: true,
					height: 100,
					autoHide: false,
					bodyStyle: 'padding:5px',
					iconCls: 'icon-information',
					loader: {
						autoLoad: true,
						url: helpDir + 'downloadHOWTO'
					}				
				}				
			],
			plugins: [ {ptype: 'paramArgumentsPlugin', pluginId: 'download-param-arguments-plugin'}]
		}; 
		
		Ext.apply (this, Ext.apply(arguments, myConf));
	}
16035364   Benjamin Renard   First commit
786
});