Blame view

js/app/views/UploadPanelUI.js 16.9 KB
16035364   Benjamin Renard   First commit
1
2
3
4
/**
 * Project   : AMDA-NG
 * Name      : UploadUI.js
 * @class    amdaUI.UploadUI
901ba3f3   Elena.Budnik   upload catalog
5
 * @extends  Ext.form.Panel 
16035364   Benjamin Renard   First commit
6
7
8
9
10
11
 * @brief    Upload Panel UI definition (View)
 * @author 	 Elena
 * @version  $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $            
 */

Ext.define('amdaUI.UploadPanelUI', {
901ba3f3   Elena.Budnik   upload catalog
12
13
14
15
16
17
	extend: 'Ext.form.Panel',
	alias: 'widget.panelUpload',
	
	requires : [
		'amdaUI.RemoteSearchPlugin'
	],
d5088c34   Elena.Budnik   correct info on T...
18

73625886   Elena.Budnik   added auto, manua...
19
20
21
22
23
	tmpNode : null,
	specialItems : null,
	formats : null,
	localName : null,
	
901ba3f3   Elena.Budnik   upload catalog
24
25
26
	constructor: function(config) 
	{  
		this.init(config);
73625886   Elena.Budnik   added auto, manua...
27
		this.callParent(arguments);
901ba3f3   Elena.Budnik   upload catalog
28
	},
16035364   Benjamin Renard   First commit
29

901ba3f3   Elena.Budnik   upload catalog
30
31
32
33
34
35
36
37
38
39
40
41
42
	/*
	* create MyData linked node and edit in module MyData
	* update myDataParams info if needed
	*/
	getObjectCallback : function(result,remoteEvent)
	{                    
		var t = remoteEvent.getTransaction();
		if (result && !result.error) 
		{
			// set parameter into node
			var me = this;
			myDesktopApp.getLoadedModule(this.tmpNode.get('moduleId'), true, function (module){
				// myData
73625886   Elena.Budnik   added auto, manua...
43
				if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType) {		       
901ba3f3   Elena.Budnik   upload catalog
44
45
46
47
48
49
50
51
52
53
54
55
					var linkedFile = Ext.create('amdaModel.MyDataNode', {leaf : true, text : me.tmpNode.get('text')});
							
					linkedFile.create(result.mask, result.description, result.maskDesc);
					linkedFile.updateMyDataParam(result.mask,result.maskDesc); 
					
					if (!linkedFile.get('id')) 
						linkedFile.set('id',me.tmpNode.get('text'));   
		
					var paramObj = Ext.create(linkedFile.get('objectDataModel'), result);
					linkedFile.set('object',paramObj);
					me.tmpNode.set('fileObject',paramObj);
				}
73625886   Elena.Budnik   added auto, manua...
56
				else {
901ba3f3   Elena.Budnik   upload catalog
57
58
59
60
					// Time Table or Catalog
					var paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result);
					
					paramObj.set('fromPlugin',true);
73625886   Elena.Budnik   added auto, manua...
61
					if (result.intervals) {
901ba3f3   Elena.Budnik   upload catalog
62
63
64
65
66
						paramObj.set('intervals',result.intervals);
						paramObj.set('nbIntervals',result.intervals.length);
					}
					me.tmpNode.set('object',paramObj);
				}	
73625886   Elena.Budnik   added auto, manua...
67
				if (module) {
901ba3f3   Elena.Budnik   upload catalog
68
69
70
71
72
					module.setLinkedNode(me.tmpNode); 	      
					module.linkedNode.editInModule();  
				}
			}); 
		} 
73625886   Elena.Budnik   added auto, manua...
73
		else {   
901ba3f3   Elena.Budnik   upload catalog
74
75
76
			// EXCEPTION : parameter not found !
			myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"+this.tmpNode.get('text')+"' found!");	     
		}
73625886   Elena.Budnik   added auto, manua...
77
		
901ba3f3   Elena.Budnik   upload catalog
78
79
		loadMask.hide();
	},
16035364   Benjamin Renard   First commit
80
        
901ba3f3   Elena.Budnik   upload catalog
81
82
/*
*  form validation
901ba3f3   Elena.Budnik   upload catalog
83
84
85
86
*/
	validate : function() 
	{
		var values = this.getForm().getValues();
16035364   Benjamin Renard   First commit
87

901ba3f3   Elena.Budnik   upload catalog
88
89
		if (values['filesrc'] == 'LOCAL') 
		{
73625886   Elena.Budnik   added auto, manua...
90
91
92
			var locFile = this.getForm().findField(this.localName).getValue();

			if (!locFile) {
901ba3f3   Elena.Budnik   upload catalog
93
94
95
96
97
98
				myDesktopApp.warningMsg("Select File to Upload");
				return false;
			}
		}
		else 
		{
73625886   Elena.Budnik   added auto, manua...
99
			if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat']) {
901ba3f3   Elena.Budnik   upload catalog
100
101
102
				myDesktopApp.warningMsg("Select File to Upload");
				return false;
			}
73625886   Elena.Budnik   added auto, manua...
103
104
		}
		
901ba3f3   Elena.Budnik   upload catalog
105
106
		return true;
	},
16035364   Benjamin Renard   First commit
107
108

        
73625886   Elena.Budnik   added auto, manua...
109
110
111
/*
 *  Upadte format if user didn't do this himself
 */
901ba3f3   Elena.Budnik   upload catalog
112
113
114
	updateFormat: function(value) 
	{    
		var arrayOfStr = value.split('.');
73625886   Elena.Budnik   added auto, manua...
115
116
117
118
119

		var radios = Ext.getCmp(this.radioId);
		var user_format_obj = radios.getValue();

		var user_format = user_format_obj[this.radioId];
901ba3f3   Elena.Budnik   upload catalog
120
121
122
		
		//  auto define format in some special cases 
		//TODO name without extention => ASCII?
73625886   Elena.Budnik   added auto, manua...
123
124
125
126
		if (arrayOfStr.length == 1) {
			auto_format = 'ASCII'; 
		}
		else  {
901ba3f3   Elena.Budnik   upload catalog
127
128
129
			var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase();
			if (suffix == 'gz') 
				suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz';
16035364   Benjamin Renard   First commit
130

901ba3f3   Elena.Budnik   upload catalog
131
132
133
134
135
136
137
			switch (suffix)
			{
				case 'cdf' :  auto_format = 'CDF'; break;
				case 'cef.gz' :
				case 'cef' :  auto_format = 'CEF'; break;
				case 'xml' :  auto_format = 'VOT';
				case 'vot' :  auto_format = 'VOT'; break;
73625886   Elena.Budnik   added auto, manua...
138
				case 'nc'  :  auto_format = 'NC';  break;
901ba3f3   Elena.Budnik   upload catalog
139
140
141
142
143
144
				case 'asc' :
				case 'txt' :			 
				default : auto_format = 'ASCII'; 			   
			}
		} 
		// set auto format : case when format was not set by user before   
73625886   Elena.Budnik   added auto, manua...
145
146
147
148
		if (user_format !== auto_format) {
			user_format_obj[this.radioId] = auto_format;    
		} 

901ba3f3   Elena.Budnik   upload catalog
149
150
		radios.setValue(user_format_obj);
	},
16035364   Benjamin Renard   First commit
151
 
73625886   Elena.Budnik   added auto, manua...
152
153
154
/*
* 
*/
f60f0bd9   Benjamin Renard   Fix upload from s...
155
	forceUpload : function (url,format,onFinish)
901ba3f3   Elena.Budnik   upload catalog
156
	{
6de48c3d   Benjamin Renard   Implement data up...
157
		var me = this;
f60f0bd9   Benjamin Renard   Fix upload from s...
158
159
160
		var re = /http:\/\/127.0.0.1:/;
		var isRemoteUrl = !re.test(url);

73625886   Elena.Budnik   added auto, manua...
161
		switch (format) {
6de48c3d   Benjamin Renard   Implement data up...
162
163
164
165
166
167
168
169
170
171
172
			case 'votable' :
				this.getForm().findField('filefrmt').setValue('VOT');
				break;
			case 'cdf' :
				this.getForm().findField('filefrmt').setValue('CDF');
				break;
			default :
				myDesktopApp.errorMsg('Not supported data receive from SAMP');
				return;
		}

f60f0bd9   Benjamin Renard   Fix upload from s...
173
		if (!isRemoteUrl) {
6de48c3d   Benjamin Renard   Implement data up...
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
			myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
				var onError = function(error) {
					if (error)
						myDesktopApp.errorMsg(error);
					else
						myDesktopApp.errorMsg("Cannot load data from this SAMP notification");
					if (onFinish)
						onFinish();
				};
				var onLoad = function(data) {
					//Fake value for validation
					Ext.form.field.File.superclass.setValue.call(me.getForm().findField('localFileName'), 'samp.vot');
					me.getForm().findField('filesrc').setValue('LOCAL');
					//Add data related to the samp notification
					me.getForm().findField('sampFileName').setValue('samp.vot');
					me.getForm().findField('sampData').setValue(data);
					var onFinishAll = function() {
						me.getForm().findField('sampFileName').reset();
						me.getForm().findField('sampData').reset();
						if (onFinish)
							onFinish();
					}
					me.postUpload(onFinishAll);
				};
				module.loadFile(url,onLoad,onError);
			});
f60f0bd9   Benjamin Renard   Fix upload from s...
200
201
			return;
		}
901ba3f3   Elena.Budnik   upload catalog
202
		
f60f0bd9   Benjamin Renard   Fix upload from s...
203
204
		this.getForm().findField('filesrc').setValue('URL');
		this.getForm().findField('remoteFile').setValue(url);
f60f0bd9   Benjamin Renard   Fix upload from s...
205
		this.postUpload(onFinish);
901ba3f3   Elena.Budnik   upload catalog
206
	},
16035364   Benjamin Renard   First commit
207
        
73625886   Elena.Budnik   added auto, manua...
208
209
210
/*
* 
*/
f60f0bd9   Benjamin Renard   Fix upload from s...
211
	postUpload : function(onFinish)
901ba3f3   Elena.Budnik   upload catalog
212
213
214
	{
		// 'global' form containing 'partial' forms				      
		var form = this.getForm();
73625886   Elena.Budnik   added auto, manua...
215

901ba3f3   Elena.Budnik   upload catalog
216
217
		// special validation 	            
		if(this.validate())
f60f0bd9   Benjamin Renard   Fix upload from s...
218
219
		{
			loadMask.show();					
901ba3f3   Elena.Budnik   upload catalog
220
221
222
223
			form.submit({
				scope: this,
				url: 'php/uploadFile.php',
				waitMsg: 'Uploading your file...',
73625886   Elena.Budnik   added auto, manua...
224
				success: function(form, o) {
f60f0bd9   Benjamin Renard   Fix upload from s...
225
226
					if (onFinish)
						onFinish();
901ba3f3   Elena.Budnik   upload catalog
227
					this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file});
901ba3f3   Elena.Budnik   upload catalog
228
					AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this);
f60f0bd9   Benjamin Renard   Fix upload from s...
229
					loadMask.hide();
901ba3f3   Elena.Budnik   upload catalog
230
				},
73625886   Elena.Budnik   added auto, manua...
231
				failure: function(form, o) {
f60f0bd9   Benjamin Renard   Fix upload from s...
232
233
234
					if (onFinish)
						onFinish();
					loadMask.hide();
901ba3f3   Elena.Budnik   upload catalog
235
236
237
238
239
					myDesktopApp.errorMsg('Error '+o.result.error); 
				}
			});
		}		
	},
16035364   Benjamin Renard   First commit
240
	
73625886   Elena.Budnik   added auto, manua...
241
242
243
	initFileUpload : function()
	{
		this.formats = [
901ba3f3   Elena.Budnik   upload catalog
244
				{ boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true,
73625886   Elena.Budnik   added auto, manua...
245
					listeners: {
901ba3f3   Elena.Budnik   upload catalog
246
						change: function (cb, nv, ov) {
73625886   Elena.Budnik   added auto, manua...
247
248
249
250
251
252
253
							if (nv) { 
								Ext.getCmp('tf').show();
							}
							else {
								Ext.getCmp('tf').hide();
								Ext.getCmp('nfs').hide();
							}
901ba3f3   Elena.Budnik   upload catalog
254
255
256
						}
					} 
				}, 
bec49ccf   Benjamin Renard   Uncomment netCDF ...
257
				{ boxLabel: 'netCDF&nbsp;<img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'NC' },
901ba3f3   Elena.Budnik   upload catalog
258
259
260
				{ boxLabel: 'CDF&nbsp;<img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'CDF' },
			// { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' },
				{ boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT' }];
73625886   Elena.Budnik   added auto, manua...
261

901ba3f3   Elena.Budnik   upload catalog
262
			this.localUploadId = 'form-uploadfile';
901ba3f3   Elena.Budnik   upload catalog
263
			this.remoteUploadId = 'form-uploadurl'; 	 
b530f31f   Elena.Budnik   remote sites from...
264
			this.nodeType = 'amdaModel.MyDataParamNode';	   
73625886   Elena.Budnik   added auto, manua...
265
			this.store = Ext.create('Ext.data.Store', {
901ba3f3   Elena.Budnik   upload catalog
266
				fields: ['value', 'name'],
b530f31f   Elena.Budnik   remote sites from...
267
268
269
270
271
272
273
274
275
				proxy: {
					type: 'ajax',
					url : 'generic_data/remote_sites.json',
					reader: {
						type: 'json',
						root: 'remote_sites'
					}
				},
				autoLoad: true
901ba3f3   Elena.Budnik   upload catalog
276
			});
901ba3f3   Elena.Budnik   upload catalog
277
			
73625886   Elena.Budnik   added auto, manua...
278
279
280
281
282
283
284
285
286
			this.radioId = 'filefrmt';

/*
 *  Sampling : TimeFormat Fieldset  
 */    
		this.autoSampling = Ext.create('Ext.form.RadioGroup', {
		//	fieldLabel : 'Constant or Variable ?',
		//	labelWidth: 90,
			defaults : {name : 'timesmpl'},
901ba3f3   Elena.Budnik   upload catalog
287
			items: [
73625886   Elena.Budnik   added auto, manua...
288
289
290
291
				{boxLabel: 'constant sampling', inputValue: 'constant', checked: true},
				{boxLabel: 'variable sampling&nbsp;<img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'}	  
			]
		});
901ba3f3   Elena.Budnik   upload catalog
292
		
73625886   Elena.Budnik   added auto, manua...
293
		this.manualSampling = Ext.create('Ext.form.FieldContainer', { 
905a78e2   Elena.Budnik   numberfield for s...
294
			defaultType: 'numberfield',
73625886   Elena.Budnik   added auto, manua...
295
296
297
			layout: 'anchor',
			defaults: {
				layout: '100%',
905a78e2   Elena.Budnik   numberfield for s...
298
299
300
				labelWidth : 150,
				minValue : 0.001,
				hideTrigger: true
73625886   Elena.Budnik   added auto, manua...
301
302
303
304
305
			}, 
			hidden : true,
			items: [  
			{ 
				fieldLabel : 'min sampling',	
905a78e2   Elena.Budnik   numberfield for s...
306
				name : 'min_manual_sampling'
73625886   Elena.Budnik   added auto, manua...
307
308
309
310
			},  
			{ 
				fieldLabel : 'max sampling',	
				name : 'max_manual_sampling'				   
901ba3f3   Elena.Budnik   upload catalog
311
			}]
73625886   Elena.Budnik   added auto, manua...
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
		}); 
	
		var Sampling = Ext.create('Ext.form.RadioGroup', {
			fieldLabel: 'Time Sampling',
			labelWidth: 90,   
			cls: 'x-check-group-alt',	
			defaults : {name : 'smpl'},
			items: [
				{boxLabel: 'auto-defined', inputValue: 'auto', checked: true},
				{boxLabel: 'manual', inputValue: 'manual'}
			],
			listeners: {
				scope : this,
				change: function (cb, nv, ov) {
					if (nv.smpl == 'manual') {
							this.autoSampling.setVisible(false);
							this.manualSampling.setVisible(true);
					}
					else {   
							this.autoSampling.setVisible(true);
							this.manualSampling.setVisible(false);
					}
				}
			}
901ba3f3   Elena.Budnik   upload catalog
336
		});
73625886   Elena.Budnik   added auto, manua...
337
338
339
340
341
		
/*
 *  NonStandardFormat : TimeFormat Fieldset  
 */
		var nonStandardFormat = { 
901ba3f3   Elena.Budnik   upload catalog
342
343
344
			xtype: 'fieldcontainer',
			defaultType: 'textfield',
			layout: 'anchor',
73625886   Elena.Budnik   added auto, manua...
345
346
347
			defaults: {
				layout: '100%',
				labelWidth : 150 
901ba3f3   Elena.Budnik   upload catalog
348
			}, 
73625886   Elena.Budnik   added auto, manua...
349
			id : 'nfs', 
901ba3f3   Elena.Budnik   upload catalog
350
351
352
353
354
355
356
			hidden : true,
			items: [  
			{ 
				fieldLabel : 'define time format',	
				name : 'nonstd',				   
				value: 'Y-m-d H:i:s',
				enableKeyEvents: true,
73625886   Elena.Budnik   added auto, manua...
357
				listeners : {
901ba3f3   Elena.Budnik   upload catalog
358
359
360
361
362
363
364
365
366
					keyUp : function() {
						if (this.getValue().indexOf('z') > 0) {
							this.nextSibling().show();
						}                                                 
						if (this.getValue().indexOf('d') > 0) {
							this.nextSibling().hide();
						}                                                 
					}
				}
73625886   Elena.Budnik   added auto, manua...
367
368
369
370
371
372
373
374
375
376
			},{ 
				xtype: 'checkbox',  
				name : 'doy',
				fieldLabel: 'DOY starts from 1',
				hidden : true,
				inputValue: '1'
			},{ 
				fieldLabel : 'define max time length',
				name : 'timelength',
				value: 'auto'    
901ba3f3   Elena.Budnik   upload catalog
377
			}],
73625886   Elena.Budnik   added auto, manua...
378
			listeners : {
901ba3f3   Elena.Budnik   upload catalog
379
380
				hide : function() {
						this.items.getAt(1).hide();                                                
73625886   Elena.Budnik   added auto, manua...
381
382
383
384
				},
				show : function() {
					if (this.items.getAt(0).getValue().indexOf('z') > 0)
						this.items.getAt(1).show();                                                
901ba3f3   Elena.Budnik   upload catalog
385
386
				}
			}
73625886   Elena.Budnik   added auto, manua...
387
388
389
390
391
392
		};
		
/*
 *  TimeFormat Fieldset :  Global form
 */
		var timeFormat = Ext.create('Ext.form.FieldSet', {
655e355f   Elena.Budnik   disable "predefin...
393
			title: 'Time Settings',
73625886   Elena.Budnik   added auto, manua...
394
395
			items : [{
				id: 'tf',
901ba3f3   Elena.Budnik   upload catalog
396
397
				xtype: 'radiogroup',
				fieldLabel: 'Time Format',
655e355f   Elena.Budnik   disable "predefin...
398
				labelWidth: 90,   
901ba3f3   Elena.Budnik   upload catalog
399
400
				cls: 'x-check-group-alt',
				defaults : { name : 'timefrmt'},
655e355f   Elena.Budnik   disable "predefin...
401
				items: [ 
73625886   Elena.Budnik   added auto, manua...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
					{ boxLabel: 'standard&nbsp;<img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true},     			
					{ boxLabel: 'no&nbsp;<img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user', 
						listeners: {
							change: function (cb, nv, ov) {
								if (nv) 
										Ext.getCmp('nfs').show();
								else    
										Ext.getCmp('nfs').hide();	
							}
						}      
					}]
				},
				nonStandardFormat,
				Sampling,
				this.autoSampling,
				this.manualSampling
			]
901ba3f3   Elena.Budnik   upload catalog
419
		});
73625886   Elena.Budnik   added auto, manua...
420
421
422
423
424
425
426
427
428
429
430
431
432
		
		this.specialItems = [ timeFormat,
					{
						xtype: 'hidden',
						name: 'sampData',
						value: null
					},
					{
						xtype: 'hidden',
						name: 'sampFileName',
						value: null
					}]
	},
901ba3f3   Elena.Budnik   upload catalog
433
	
73625886   Elena.Budnik   added auto, manua...
434
435
436
437
438
439
440
441
442
443
	initTTUpload : function(isTT)
	{
		if (isTT) {
			this.formats = [
				{ boxLabel: 'ASCII&nbsp;<img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'ttfrmt',  inputValue: 'ASCII', checked: true},
				{ boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'}
			];
			this.localUploadId = 'form-uploadtt';
			this.remoteUploadId = 'form-uploadtturl'; 
			this.nodeType = 'amdaModel.TimeTableNode';
b530f31f   Elena.Budnik   remote sites from...
444
		    
73625886   Elena.Budnik   added auto, manua...
445
			this.store = Ext.create('Ext.data.Store', {
b530f31f   Elena.Budnik   remote sites from...
446
447
448
449
450
451
452
453
454
455
				fields: ['value', 'name']/*,
				proxy: {
					type: 'ajax',
					url : 'generic_data/remote_sites.json',
					reader: {
						type: 'json',
						root: 'remote_sites'
					}
				},
				autoLoad: true*/
73625886   Elena.Budnik   added auto, manua...
456
			});
b530f31f   Elena.Budnik   remote sites from...
457
			
73625886   Elena.Budnik   added auto, manua...
458
459
460
461
462
463
464
465
466
			this.radioId =	'ttfrmt';
		}
		else {
			this.formats = [
				{ boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true }];
						
			this.localUploadId = 'form-uploadcat';
			this.remoteUploadId = 'form-uploadcaturl'; 
			this.nodeType = 'amdaModel.CatalogNode';
73625886   Elena.Budnik   added auto, manua...
467
			this.store = Ext.create('Ext.data.Store', {
b530f31f   Elena.Budnik   remote sites from...
468
469
470
471
472
473
474
475
476
477
478
				fields: ['value', 'name']/*,
				proxy: {
					type: 'ajax',
					url : 'generic_data/remote_sites.json',
					reader: {
						type: 'json',
						root: 'remote_sites'
					}
				},
				autoLoad: true*/
			}); 
73625886   Elena.Budnik   added auto, manua...
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
			
			this.radioId = 'catfrmt';
		}
	},
/*
*  panel config
*/
	init : function(config) 
	{       
		 
		if ( config.panelType == 'file' )
				this.initFileUpload();
		else 
				this.initTTUpload(config.panelType == 'timetable');

		this.localName = config.localUploadName;
 /*
 *  FileFormat Fieldset 
 */ 
		var fileFormat =  Ext.create('Ext.form.FieldSet', { 			      
			title: 'File Format',			     		     
			items : [{ 
				xtype: 'radiogroup',
				id : this.radioId, 
				columns: 3,
				cls: 'x-check-group-alt',
				items: this.formats
			}]
		}); 

/*
 * FileSource Fieldset : Local File Upload
 */
655e355f   Elena.Budnik   disable "predefin...
512
		var localFile = Ext.create('Ext.form.Panel', {      
901ba3f3   Elena.Budnik   upload catalog
513
514
515
516
			id: this.localUploadId,
			fileUpload: true,
			hideLabels: true,
			frame: true,			      
73625886   Elena.Budnik   added auto, manua...
517
			items: [{
655e355f   Elena.Budnik   disable "predefin...
518
				xtype: 'fileuploadfield',     
901ba3f3   Elena.Budnik   upload catalog
519
520
				emptyText: 'Select Your File',
				width: 300,
73625886   Elena.Budnik   added auto, manua...
521
				name: this.localName,  
901ba3f3   Elena.Budnik   upload catalog
522
				buttonText: 'Browse',
73625886   Elena.Budnik   added auto, manua...
523
				listeners: {
901ba3f3   Elena.Budnik   upload catalog
524
					scope : this,
655e355f   Elena.Budnik   disable "predefin...
525
					change: function (field, value, e) {
901ba3f3   Elena.Budnik   upload catalog
526
527
528
529
530
531
532
533
534
535
							this.updateFormat(value);	
					} 
				}
			},
			{  
				// it is common setting for Local and Remote files
				xtype : 'hiddenfield',
				name: 'MAX_FILE_SIZE',
				value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB	 			      
			}] 
73625886   Elena.Budnik   added auto, manua...
536
537
538
539
540
541
542
543
		});
		
/*
 * FileSource Fieldset : Remote File Upload
 */
		var combo = Ext.create('Ext.form.ComboBox', {
				flex : 4, 
				store: this.store,
a2409f36   Elena.Budnik   no https for url ...
544
				emptyText: 'Enter Remote Site URL (ftp/http)',
73625886   Elena.Budnik   added auto, manua...
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
				queryMode: 'local',
				displayField: 'name',
				valueField: 'value' 
		});
	    	  
		var fieldcontainer = { 
			xtype: 'fieldcontainer', 
			fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0,
			layout: 'hbox',		
			items: [
				combo,
				{
					xtype : 'button',
					flex : 1,
					text: 'Browse It',								   
					handler: function() {					      
						var form = this.up('form').getForm(); 
						var site = form.getFields().getAt(0).getValue(); 					    
						if (site) 						   
							this.up('form').ownerCt.fireEvent('open', site);
						else 
							myDesktopApp.warningMsg("Please Enter Remote Site URL");				 
					} 
				}]
		};
		
655e355f   Elena.Budnik   disable "predefin...
571
572
		var remoteFile = Ext.create('Ext.form.Panel', { 
			id: this.remoteUploadId, 
901ba3f3   Elena.Budnik   upload catalog
573
			hideLabels: true,
655e355f   Elena.Budnik   disable "predefin...
574
			autoHeight: true, 
901ba3f3   Elena.Budnik   upload catalog
575
576
577
578
579
580
			frame: true,
			hidden : true,
			items: [  
				fieldcontainer,
				{ 
					xtype : 'textfield',
73625886   Elena.Budnik   added auto, manua...
581
					name : config.remoteUploadName, 
a2409f36   Elena.Budnik   no https for url ...
582
					emptyText: 'Enter Remote File URL (ftp/http)',
901ba3f3   Elena.Budnik   upload catalog
583
584
585
586
					width: 310,
					listeners: 
					{
						scope : this,
655e355f   Elena.Budnik   disable "predefin...
587
588
						change: function (field, value, e) {
									this.updateFormat(value);
901ba3f3   Elena.Budnik   upload catalog
589
590
591
592
						} 
					}
				}]
		});
73625886   Elena.Budnik   added auto, manua...
593
594
595
596
		
 /*
 * FileSource Fieldset  :  global form
 */                                       
655e355f   Elena.Budnik   disable "predefin...
597
598
		var uploadForm = Ext.create('Ext.form.FieldSet',{    
			title: 'File Source',     
73625886   Elena.Budnik   added auto, manua...
599
			items : [{ 
655e355f   Elena.Budnik   disable "predefin...
600
				xtype: 'radiogroup', 
901ba3f3   Elena.Budnik   upload catalog
601
602
603
				cls: 'x-check-group-alt',
				items: [
					{ boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true,
73625886   Elena.Budnik   added auto, manua...
604
						listeners: {
901ba3f3   Elena.Budnik   upload catalog
605
606
607
608
609
610
611
							scope : this,
							change: function (cb, nv, ov) {
								if (nv == ov) return;
								var local = Ext.getCmp(this.localUploadId);
								var remote = Ext.getCmp(this.remoteUploadId);
								if (nv) {
										remote.hide();
655e355f   Elena.Budnik   disable "predefin...
612
										local.show();
901ba3f3   Elena.Budnik   upload catalog
613
614
615
								}
								else  {
										local.hide();
655e355f   Elena.Budnik   disable "predefin...
616
										remote.show();    
901ba3f3   Elena.Budnik   upload catalog
617
618
619
620
								}   
							}
						} 
					},
73625886   Elena.Budnik   added auto, manua...
621
					{ boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}]
901ba3f3   Elena.Budnik   upload catalog
622
623
			}]
		});		      
73625886   Elena.Budnik   added auto, manua...
624
625
626
627

/*
 * Panel Config
 */
901ba3f3   Elena.Budnik   upload catalog
628
629
		var myConf = 
		{
73625886   Elena.Budnik   added auto, manua...
630
			title : config.title,  
901ba3f3   Elena.Budnik   upload catalog
631
			layout: {type: 'vbox', align: 'stretch'},
73625886   Elena.Budnik   added auto, manua...
632
			autoScroll : true,
901ba3f3   Elena.Budnik   upload catalog
633
			bodyStyle: { background : '#dfe8f6'},
73625886   Elena.Budnik   added auto, manua...
634
635
636
637
			items : Ext.Array.merge(
					[ uploadForm, localFile, remoteFile, fileFormat ],
					this.specialItems ), 
			buttons: [{
901ba3f3   Elena.Budnik   upload catalog
638
				text: 'Upload',
73625886   Elena.Budnik   added auto, manua...
639
				handler: function() {
901ba3f3   Elena.Budnik   upload catalog
640
641
642
643
644
645
					this.postUpload();
				},
				scope : this
			},
			{
				text: 'Reset',
73625886   Elena.Budnik   added auto, manua...
646
				handler: function() {      
901ba3f3   Elena.Budnik   upload catalog
647
648
649
650
					this.up('form').getForm().reset();  
				}
			}], 
			plugins: [{ptype: 'remoteSearchPlugin'}],
73625886   Elena.Budnik   added auto, manua...
651
652
			listeners:{
				click: {
901ba3f3   Elena.Budnik   upload catalog
653
					element: 'el',
73625886   Elena.Budnik   added auto, manua...
654
					fn: function(e,t) { 
901ba3f3   Elena.Budnik   upload catalog
655
656
						var me = t,
						text = me.getAttribute('amda_clicktip');
73625886   Elena.Budnik   added auto, manua...
657
						if (text) {
901ba3f3   Elena.Budnik   upload catalog
658
659
660
661
662
663
664
665
666
667
668
669
							e.preventDefault();
							AmdaAction.getInfo({name : text}, function(res,e) {					    					   
								if (res.success) myDesktopApp.infoMsg(res.result);
							}); 
						}
					}
				}
			}
		};

		Ext.apply (this, Ext.apply(arguments, myConf));	 	  
	}		 
16035364   Benjamin Renard   First commit
670
});