Blame view

js/app/views/UploadPanelUI.js 16.8 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();  
				}
			}); 
		} 
278185de   Benjamin Renard   Upload catalog fr...
73
		else { 
901ba3f3   Elena.Budnik   upload catalog
74
			// EXCEPTION : parameter not found !
278185de   Benjamin Renard   Upload catalog fr...
75
76
77
78
79
80
			if (result.error) {
				myDesktopApp.errorMsg(result.error);
			}
			else {
				myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"+this.tmpNode.get('text')+"' found!");	     
			}
901ba3f3   Elena.Budnik   upload catalog
81
		}
73625886   Elena.Budnik   added auto, manua...
82
		
901ba3f3   Elena.Budnik   upload catalog
83
84
		loadMask.hide();
	},
16035364   Benjamin Renard   First commit
85
        
901ba3f3   Elena.Budnik   upload catalog
86
87
/*
*  form validation
901ba3f3   Elena.Budnik   upload catalog
88
89
90
91
*/
	validate : function() 
	{
		var values = this.getForm().getValues();
16035364   Benjamin Renard   First commit
92

901ba3f3   Elena.Budnik   upload catalog
93
94
		if (values['filesrc'] == 'LOCAL') 
		{
73625886   Elena.Budnik   added auto, manua...
95
96
97
			var locFile = this.getForm().findField(this.localName).getValue();

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

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

		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
125
126
127
		
		//  auto define format in some special cases 
		//TODO name without extention => ASCII?
73625886   Elena.Budnik   added auto, manua...
128
129
130
131
		if (arrayOfStr.length == 1) {
			auto_format = 'ASCII'; 
		}
		else  {
901ba3f3   Elena.Budnik   upload catalog
132
133
134
			var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase();
			if (suffix == 'gz') 
				suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz';
16035364   Benjamin Renard   First commit
135

901ba3f3   Elena.Budnik   upload catalog
136
137
138
139
140
141
142
			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...
143
				case 'nc'  :  auto_format = 'NC';  break;
901ba3f3   Elena.Budnik   upload catalog
144
145
146
147
148
149
				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...
150
151
152
153
		if (user_format !== auto_format) {
			user_format_obj[this.radioId] = auto_format;    
		} 

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

73625886   Elena.Budnik   added auto, manua...
166
		switch (format) {
6de48c3d   Benjamin Renard   Implement data up...
167
168
169
170
171
172
173
174
175
176
177
			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...
178
		if (!isRemoteUrl) {
6de48c3d   Benjamin Renard   Implement data up...
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
			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...
205
206
			return;
		}
901ba3f3   Elena.Budnik   upload catalog
207
		
f60f0bd9   Benjamin Renard   Fix upload from s...
208
209
		this.getForm().findField('filesrc').setValue('URL');
		this.getForm().findField('remoteFile').setValue(url);
f60f0bd9   Benjamin Renard   Fix upload from s...
210
		this.postUpload(onFinish);
901ba3f3   Elena.Budnik   upload catalog
211
	},
16035364   Benjamin Renard   First commit
212
        
73625886   Elena.Budnik   added auto, manua...
213
214
215
/*
* 
*/
f60f0bd9   Benjamin Renard   Fix upload from s...
216
	postUpload : function(onFinish)
901ba3f3   Elena.Budnik   upload catalog
217
218
219
	{
		// 'global' form containing 'partial' forms				      
		var form = this.getForm();
73625886   Elena.Budnik   added auto, manua...
220

901ba3f3   Elena.Budnik   upload catalog
221
222
		// special validation 	            
		if(this.validate())
f60f0bd9   Benjamin Renard   Fix upload from s...
223
224
		{
			loadMask.show();					
901ba3f3   Elena.Budnik   upload catalog
225
226
227
228
			form.submit({
				scope: this,
				url: 'php/uploadFile.php',
				waitMsg: 'Uploading your file...',
73625886   Elena.Budnik   added auto, manua...
229
				success: function(form, o) {
f60f0bd9   Benjamin Renard   Fix upload from s...
230
231
					if (onFinish)
						onFinish();
901ba3f3   Elena.Budnik   upload catalog
232
					this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file});
901ba3f3   Elena.Budnik   upload catalog
233
					AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this);
f60f0bd9   Benjamin Renard   Fix upload from s...
234
					loadMask.hide();
901ba3f3   Elena.Budnik   upload catalog
235
				},
73625886   Elena.Budnik   added auto, manua...
236
				failure: function(form, o) {
f60f0bd9   Benjamin Renard   Fix upload from s...
237
238
239
					if (onFinish)
						onFinish();
					loadMask.hide();
901ba3f3   Elena.Budnik   upload catalog
240
241
242
243
244
					myDesktopApp.errorMsg('Error '+o.result.error); 
				}
			});
		}		
	},
16035364   Benjamin Renard   First commit
245
	
73625886   Elena.Budnik   added auto, manua...
246
247
248
	initFileUpload : function()
	{
		this.formats = [
901ba3f3   Elena.Budnik   upload catalog
249
				{ boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true,
73625886   Elena.Budnik   added auto, manua...
250
					listeners: {
901ba3f3   Elena.Budnik   upload catalog
251
						change: function (cb, nv, ov) {
73625886   Elena.Budnik   added auto, manua...
252
253
254
255
256
257
258
							if (nv) { 
								Ext.getCmp('tf').show();
							}
							else {
								Ext.getCmp('tf').hide();
								Ext.getCmp('nfs').hide();
							}
901ba3f3   Elena.Budnik   upload catalog
259
260
261
						}
					} 
				}, 
bec49ccf   Benjamin Renard   Uncomment netCDF ...
262
				{ 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
263
264
265
				{ 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...
266

901ba3f3   Elena.Budnik   upload catalog
267
			this.localUploadId = 'form-uploadfile';
901ba3f3   Elena.Budnik   upload catalog
268
			this.remoteUploadId = 'form-uploadurl'; 	 
b530f31f   Elena.Budnik   remote sites from...
269
			this.nodeType = 'amdaModel.MyDataParamNode';	   
73625886   Elena.Budnik   added auto, manua...
270
			this.store = Ext.create('Ext.data.Store', {
901ba3f3   Elena.Budnik   upload catalog
271
				fields: ['value', 'name'],
b530f31f   Elena.Budnik   remote sites from...
272
273
274
275
276
277
278
279
280
				proxy: {
					type: 'ajax',
					url : 'generic_data/remote_sites.json',
					reader: {
						type: 'json',
						root: 'remote_sites'
					}
				},
				autoLoad: true
901ba3f3   Elena.Budnik   upload catalog
281
			});
901ba3f3   Elena.Budnik   upload catalog
282
			
73625886   Elena.Budnik   added auto, manua...
283
284
285
286
287
288
289
290
291
			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
292
			items: [
73625886   Elena.Budnik   added auto, manua...
293
294
295
296
				{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
297
		
73625886   Elena.Budnik   added auto, manua...
298
		this.manualSampling = Ext.create('Ext.form.FieldContainer', { 
905a78e2   Elena.Budnik   numberfield for s...
299
			defaultType: 'numberfield',
73625886   Elena.Budnik   added auto, manua...
300
301
302
			layout: 'anchor',
			defaults: {
				layout: '100%',
905a78e2   Elena.Budnik   numberfield for s...
303
304
305
				labelWidth : 150,
				minValue : 0.001,
				hideTrigger: true
73625886   Elena.Budnik   added auto, manua...
306
307
308
309
310
			}, 
			hidden : true,
			items: [  
			{ 
				fieldLabel : 'min sampling',	
905a78e2   Elena.Budnik   numberfield for s...
311
				name : 'min_manual_sampling'
73625886   Elena.Budnik   added auto, manua...
312
313
314
315
			},  
			{ 
				fieldLabel : 'max sampling',	
				name : 'max_manual_sampling'				   
901ba3f3   Elena.Budnik   upload catalog
316
			}]
73625886   Elena.Budnik   added auto, manua...
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
		}); 
	
		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
341
		});
73625886   Elena.Budnik   added auto, manua...
342
343
344
345
346
		
/*
 *  NonStandardFormat : TimeFormat Fieldset  
 */
		var nonStandardFormat = { 
901ba3f3   Elena.Budnik   upload catalog
347
348
349
			xtype: 'fieldcontainer',
			defaultType: 'textfield',
			layout: 'anchor',
73625886   Elena.Budnik   added auto, manua...
350
351
352
			defaults: {
				layout: '100%',
				labelWidth : 150 
901ba3f3   Elena.Budnik   upload catalog
353
			}, 
73625886   Elena.Budnik   added auto, manua...
354
			id : 'nfs', 
901ba3f3   Elena.Budnik   upload catalog
355
356
357
358
359
360
361
			hidden : true,
			items: [  
			{ 
				fieldLabel : 'define time format',	
				name : 'nonstd',				   
				value: 'Y-m-d H:i:s',
				enableKeyEvents: true,
73625886   Elena.Budnik   added auto, manua...
362
				listeners : {
901ba3f3   Elena.Budnik   upload catalog
363
364
365
366
367
368
369
370
371
					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...
372
373
374
375
376
377
378
379
380
381
			},{ 
				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
382
			}],
73625886   Elena.Budnik   added auto, manua...
383
			listeners : {
901ba3f3   Elena.Budnik   upload catalog
384
385
				hide : function() {
						this.items.getAt(1).hide();                                                
73625886   Elena.Budnik   added auto, manua...
386
387
388
389
				},
				show : function() {
					if (this.items.getAt(0).getValue().indexOf('z') > 0)
						this.items.getAt(1).show();                                                
901ba3f3   Elena.Budnik   upload catalog
390
391
				}
			}
73625886   Elena.Budnik   added auto, manua...
392
393
394
395
396
397
		};
		
/*
 *  TimeFormat Fieldset :  Global form
 */
		var timeFormat = Ext.create('Ext.form.FieldSet', {
655e355f   Elena.Budnik   disable "predefin...
398
			title: 'Time Settings',
73625886   Elena.Budnik   added auto, manua...
399
400
			items : [{
				id: 'tf',
901ba3f3   Elena.Budnik   upload catalog
401
402
				xtype: 'radiogroup',
				fieldLabel: 'Time Format',
655e355f   Elena.Budnik   disable "predefin...
403
				labelWidth: 90,   
901ba3f3   Elena.Budnik   upload catalog
404
405
				cls: 'x-check-group-alt',
				defaults : { name : 'timefrmt'},
655e355f   Elena.Budnik   disable "predefin...
406
				items: [ 
73625886   Elena.Budnik   added auto, manua...
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
					{ 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
424
		});
73625886   Elena.Budnik   added auto, manua...
425
426
427
428
429
430
431
432
433
434
435
436
437
		
		this.specialItems = [ timeFormat,
					{
						xtype: 'hidden',
						name: 'sampData',
						value: null
					},
					{
						xtype: 'hidden',
						name: 'sampFileName',
						value: null
					}]
	},
901ba3f3   Elena.Budnik   upload catalog
438
	
73625886   Elena.Budnik   added auto, manua...
439
440
441
442
443
444
445
446
447
448
	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...
449
		    
73625886   Elena.Budnik   added auto, manua...
450
			this.store = Ext.create('Ext.data.Store', {
278185de   Benjamin Renard   Upload catalog fr...
451
				fields: ['value', 'name']
73625886   Elena.Budnik   added auto, manua...
452
			});
b530f31f   Elena.Budnik   remote sites from...
453
			
73625886   Elena.Budnik   added auto, manua...
454
455
456
457
			this.radioId =	'ttfrmt';
		}
		else {
			this.formats = [
a04c45ea   Elena.Budnik   rm 6503 - ascii c...
458
				{ boxLabel: 'ASCII&nbsp;<img amda_clicktip="catAsciiFormat" style="vertical-align:middle" src="js/resources/images/icons/attention.png"', name: 'catfrmt',  inputValue: 'ASCII', checked: true},
278185de   Benjamin Renard   Upload catalog fr...
459
460
				{ boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT'}
			];
73625886   Elena.Budnik   added auto, manua...
461
462
463
464
						
			this.localUploadId = 'form-uploadcat';
			this.remoteUploadId = 'form-uploadcaturl'; 
			this.nodeType = 'amdaModel.CatalogNode';
73625886   Elena.Budnik   added auto, manua...
465
			this.store = Ext.create('Ext.data.Store', {
278185de   Benjamin Renard   Upload catalog fr...
466
				fields: ['value', 'name']
b530f31f   Elena.Budnik   remote sites from...
467
			}); 
73625886   Elena.Budnik   added auto, manua...
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
			
			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...
501
		var localFile = Ext.create('Ext.form.Panel', {      
901ba3f3   Elena.Budnik   upload catalog
502
503
504
505
			id: this.localUploadId,
			fileUpload: true,
			hideLabels: true,
			frame: true,			      
73625886   Elena.Budnik   added auto, manua...
506
			items: [{
655e355f   Elena.Budnik   disable "predefin...
507
				xtype: 'fileuploadfield',     
901ba3f3   Elena.Budnik   upload catalog
508
509
				emptyText: 'Select Your File',
				width: 300,
73625886   Elena.Budnik   added auto, manua...
510
				name: this.localName,  
901ba3f3   Elena.Budnik   upload catalog
511
				buttonText: 'Browse',
73625886   Elena.Budnik   added auto, manua...
512
				listeners: {
901ba3f3   Elena.Budnik   upload catalog
513
					scope : this,
655e355f   Elena.Budnik   disable "predefin...
514
					change: function (field, value, e) {
901ba3f3   Elena.Budnik   upload catalog
515
516
517
518
519
520
521
522
523
524
							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...
525
526
527
528
529
530
531
532
		});
		
/*
 * FileSource Fieldset : Remote File Upload
 */
		var combo = Ext.create('Ext.form.ComboBox', {
				flex : 4, 
				store: this.store,
a2409f36   Elena.Budnik   no https for url ...
533
				emptyText: 'Enter Remote Site URL (ftp/http)',
73625886   Elena.Budnik   added auto, manua...
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
				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...
560
561
		var remoteFile = Ext.create('Ext.form.Panel', { 
			id: this.remoteUploadId, 
901ba3f3   Elena.Budnik   upload catalog
562
			hideLabels: true,
655e355f   Elena.Budnik   disable "predefin...
563
			autoHeight: true, 
901ba3f3   Elena.Budnik   upload catalog
564
565
566
567
568
569
			frame: true,
			hidden : true,
			items: [  
				fieldcontainer,
				{ 
					xtype : 'textfield',
73625886   Elena.Budnik   added auto, manua...
570
					name : config.remoteUploadName, 
a2409f36   Elena.Budnik   no https for url ...
571
					emptyText: 'Enter Remote File URL (ftp/http)',
901ba3f3   Elena.Budnik   upload catalog
572
573
574
575
					width: 310,
					listeners: 
					{
						scope : this,
655e355f   Elena.Budnik   disable "predefin...
576
577
						change: function (field, value, e) {
									this.updateFormat(value);
901ba3f3   Elena.Budnik   upload catalog
578
579
580
581
						} 
					}
				}]
		});
73625886   Elena.Budnik   added auto, manua...
582
583
584
585
		
 /*
 * FileSource Fieldset  :  global form
 */                                       
655e355f   Elena.Budnik   disable "predefin...
586
587
		var uploadForm = Ext.create('Ext.form.FieldSet',{    
			title: 'File Source',     
73625886   Elena.Budnik   added auto, manua...
588
			items : [{ 
655e355f   Elena.Budnik   disable "predefin...
589
				xtype: 'radiogroup', 
901ba3f3   Elena.Budnik   upload catalog
590
591
592
				cls: 'x-check-group-alt',
				items: [
					{ boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true,
73625886   Elena.Budnik   added auto, manua...
593
						listeners: {
901ba3f3   Elena.Budnik   upload catalog
594
595
596
597
598
599
600
							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...
601
										local.show();
901ba3f3   Elena.Budnik   upload catalog
602
603
604
								}
								else  {
										local.hide();
655e355f   Elena.Budnik   disable "predefin...
605
										remote.show();    
901ba3f3   Elena.Budnik   upload catalog
606
607
608
609
								}   
							}
						} 
					},
73625886   Elena.Budnik   added auto, manua...
610
					{ boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}]
901ba3f3   Elena.Budnik   upload catalog
611
612
			}]
		});		      
73625886   Elena.Budnik   added auto, manua...
613
614
615
616

/*
 * Panel Config
 */
901ba3f3   Elena.Budnik   upload catalog
617
618
		var myConf = 
		{
73625886   Elena.Budnik   added auto, manua...
619
			title : config.title,  
901ba3f3   Elena.Budnik   upload catalog
620
			layout: {type: 'vbox', align: 'stretch'},
73625886   Elena.Budnik   added auto, manua...
621
			autoScroll : true,
901ba3f3   Elena.Budnik   upload catalog
622
			bodyStyle: { background : '#dfe8f6'},
73625886   Elena.Budnik   added auto, manua...
623
624
625
626
			items : Ext.Array.merge(
					[ uploadForm, localFile, remoteFile, fileFormat ],
					this.specialItems ), 
			buttons: [{
901ba3f3   Elena.Budnik   upload catalog
627
				text: 'Upload',
73625886   Elena.Budnik   added auto, manua...
628
				handler: function() {
901ba3f3   Elena.Budnik   upload catalog
629
630
631
632
633
634
					this.postUpload();
				},
				scope : this
			},
			{
				text: 'Reset',
73625886   Elena.Budnik   added auto, manua...
635
				handler: function() {      
901ba3f3   Elena.Budnik   upload catalog
636
637
638
639
					this.up('form').getForm().reset();  
				}
			}], 
			plugins: [{ptype: 'remoteSearchPlugin'}],
73625886   Elena.Budnik   added auto, manua...
640
641
			listeners:{
				click: {
901ba3f3   Elena.Budnik   upload catalog
642
					element: 'el',
73625886   Elena.Budnik   added auto, manua...
643
					fn: function(e,t) { 
901ba3f3   Elena.Budnik   upload catalog
644
645
						var me = t,
						text = me.getAttribute('amda_clicktip');
73625886   Elena.Budnik   added auto, manua...
646
						if (text) {
901ba3f3   Elena.Budnik   upload catalog
647
648
649
650
651
652
653
654
655
656
657
658
							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
659
});