Commit 736258860a4f283187d754e5513acbaa129e0a8a
1 parent
a5c6d5eb
Exists in
master
and in
109 other branches
added auto, manual sampling definition for all formats, cleaned up code extjs
Showing
3 changed files
with
303 additions
and
291 deletions
Show diff stats
js/app/controllers/UploadModule.js
... | ... | @@ -20,8 +20,8 @@ Ext.define('amdaDesktop.UploadModule', { |
20 | 20 | * @cfg {String} window definitions |
21 | 21 | * @required |
22 | 22 | */ |
23 | - width: 320, | |
24 | - height: 510, | |
23 | + width: 330, | |
24 | + height: 520, | |
25 | 25 | uiType : 'panelTabUpload', |
26 | 26 | helpTitle : 'Help on Upload Module', |
27 | 27 | helpFile : 'uploadHelp', | ... | ... |
js/app/views/UploadPanelUI.js
... | ... | @@ -15,15 +15,16 @@ Ext.define('amdaUI.UploadPanelUI', { |
15 | 15 | requires : [ |
16 | 16 | 'amdaUI.RemoteSearchPlugin' |
17 | 17 | ], |
18 | - | |
19 | - isFile : true, | |
20 | - isTimeTable : false, | |
21 | - tmpNode : null, | |
22 | 18 | |
19 | + tmpNode : null, | |
20 | + specialItems : null, | |
21 | + formats : null, | |
22 | + localName : null, | |
23 | + | |
23 | 24 | constructor: function(config) |
24 | 25 | { |
25 | 26 | this.init(config); |
26 | - this.callParent(arguments); | |
27 | + this.callParent(arguments); | |
27 | 28 | }, |
28 | 29 | |
29 | 30 | /* |
... | ... | @@ -39,8 +40,7 @@ Ext.define('amdaUI.UploadPanelUI', { |
39 | 40 | var me = this; |
40 | 41 | myDesktopApp.getLoadedModule(this.tmpNode.get('moduleId'), true, function (module){ |
41 | 42 | // myData |
42 | - if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType) | |
43 | - { | |
43 | + if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType) { | |
44 | 44 | var linkedFile = Ext.create('amdaModel.MyDataNode', {leaf : true, text : me.tmpNode.get('text')}); |
45 | 45 | |
46 | 46 | linkedFile.create(result.mask, result.description, result.maskDesc); |
... | ... | @@ -53,37 +53,33 @@ Ext.define('amdaUI.UploadPanelUI', { |
53 | 53 | linkedFile.set('object',paramObj); |
54 | 54 | me.tmpNode.set('fileObject',paramObj); |
55 | 55 | } |
56 | - else | |
57 | - { | |
56 | + else { | |
58 | 57 | // Time Table or Catalog |
59 | 58 | var paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result); |
60 | 59 | |
61 | 60 | paramObj.set('fromPlugin',true); |
62 | - if (result.intervals) | |
63 | - { | |
61 | + if (result.intervals) { | |
64 | 62 | paramObj.set('intervals',result.intervals); |
65 | 63 | paramObj.set('nbIntervals',result.intervals.length); |
66 | 64 | } |
67 | 65 | me.tmpNode.set('object',paramObj); |
68 | 66 | } |
69 | - if (module) | |
70 | - { | |
67 | + if (module) { | |
71 | 68 | module.setLinkedNode(me.tmpNode); |
72 | 69 | module.linkedNode.editInModule(); |
73 | 70 | } |
74 | 71 | }); |
75 | 72 | } |
76 | - else | |
77 | - { | |
73 | + else { | |
78 | 74 | // EXCEPTION : parameter not found ! |
79 | 75 | myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"+this.tmpNode.get('text')+"' found!"); |
80 | 76 | } |
77 | + | |
81 | 78 | loadMask.hide(); |
82 | 79 | }, |
83 | 80 | |
84 | 81 | /* |
85 | 82 | * form validation |
86 | -* TODO markInvalid()? | |
87 | 83 | */ |
88 | 84 | validate : function() |
89 | 85 | { |
... | ... | @@ -91,59 +87,43 @@ Ext.define('amdaUI.UploadPanelUI', { |
91 | 87 | |
92 | 88 | if (values['filesrc'] == 'LOCAL') |
93 | 89 | { |
94 | - if (this.isFile) var locFile = this.getForm().findField('localFileName').getValue(); | |
95 | - else if (this.isTimeTable) var locFile = this.getForm().findField('localTTName').getValue(); | |
96 | - else var locFile = this.getForm().findField('localCatName').getValue(); | |
97 | - | |
98 | - if (!locFile) | |
99 | - { | |
90 | + var locFile = this.getForm().findField(this.localName).getValue(); | |
91 | + | |
92 | + if (!locFile) { | |
100 | 93 | myDesktopApp.warningMsg("Select File to Upload"); |
101 | 94 | return false; |
102 | 95 | } |
103 | 96 | } |
104 | 97 | else |
105 | 98 | { |
106 | - if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat']) | |
107 | - { | |
99 | + if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat']) { | |
108 | 100 | myDesktopApp.warningMsg("Select File to Upload"); |
109 | 101 | return false; |
110 | 102 | } |
111 | - } | |
103 | + } | |
104 | + | |
112 | 105 | return true; |
113 | 106 | }, |
114 | 107 | |
115 | 108 | |
116 | - //TODO proper parsing | |
109 | +/* | |
110 | + * Upadte format if user didn't do this himself | |
111 | + */ | |
117 | 112 | updateFormat: function(value) |
118 | 113 | { |
119 | 114 | var arrayOfStr = value.split('.'); |
120 | - //TODO use down method? | |
121 | - if (this.isFile) | |
122 | - { | |
123 | - var radios = Ext.getCmp('filefrmt'); | |
124 | - var user_format_obj = radios.getValue(); | |
125 | - var user_format = user_format_obj.filefrmt; | |
126 | - } | |
127 | - else if (this.isTimeTable) | |
128 | - { | |
129 | - var radios = Ext.getCmp('ttfrmt'); | |
130 | - var user_format_obj = radios.getValue(); | |
131 | - var user_format = user_format_obj.ttfrmt; | |
132 | - } | |
133 | - else | |
134 | - { | |
135 | - var radios = Ext.getCmp('catfrmt'); | |
136 | - var user_format_obj = radios.getValue(); | |
137 | - var user_format = user_format_obj.catfrmt; | |
138 | - } | |
139 | - | |
140 | - var auto_format = user_format; | |
115 | + | |
116 | + var radios = Ext.getCmp(this.radioId); | |
117 | + var user_format_obj = radios.getValue(); | |
118 | + | |
119 | + var user_format = user_format_obj[this.radioId]; | |
141 | 120 | |
142 | 121 | // auto define format in some special cases |
143 | 122 | //TODO name without extention => ASCII? |
144 | - if (arrayOfStr.length == 1) auto_format = 'ASCII'; | |
145 | - else | |
146 | - { | |
123 | + if (arrayOfStr.length == 1) { | |
124 | + auto_format = 'ASCII'; | |
125 | + } | |
126 | + else { | |
147 | 127 | var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase(); |
148 | 128 | if (suffix == 'gz') |
149 | 129 | suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz'; |
... | ... | @@ -155,35 +135,30 @@ Ext.define('amdaUI.UploadPanelUI', { |
155 | 135 | case 'cef' : auto_format = 'CEF'; break; |
156 | 136 | case 'xml' : auto_format = 'VOT'; |
157 | 137 | case 'vot' : auto_format = 'VOT'; break; |
158 | - case 'nc' : auto_format = 'NC'; break; | |
138 | + case 'nc' : auto_format = 'NC'; break; | |
159 | 139 | case 'asc' : |
160 | 140 | case 'txt' : |
161 | 141 | default : auto_format = 'ASCII'; |
162 | 142 | } |
163 | 143 | } |
164 | 144 | // set auto format : case when format was not set by user before |
165 | - if (this.isFile && user_format !== auto_format) { | |
166 | - user_format_obj.filefrmt = auto_format; | |
167 | - } else if (this.isTimeTable && user_format !== auto_format) { | |
168 | - user_format_obj.ttfrmt = auto_format; | |
169 | - } else if (!this.isFile && !this.isTimeTable && user_format !== auto_format) { | |
170 | - user_format_obj.catfrmt = auto_format; | |
171 | - } | |
172 | - | |
145 | + if (user_format !== auto_format) { | |
146 | + user_format_obj[this.radioId] = auto_format; | |
147 | + } | |
148 | + | |
173 | 149 | radios.setValue(user_format_obj); |
174 | 150 | }, |
175 | 151 | |
176 | - /* | |
177 | - * | |
178 | - */ | |
152 | +/* | |
153 | +* | |
154 | +*/ | |
179 | 155 | forceUpload : function (url,format,onFinish) |
180 | 156 | { |
181 | 157 | var me = this; |
182 | 158 | var re = /http:\/\/127.0.0.1:/; |
183 | 159 | var isRemoteUrl = !re.test(url); |
184 | 160 | |
185 | - switch (format) | |
186 | - { | |
161 | + switch (format) { | |
187 | 162 | case 'votable' : |
188 | 163 | this.getForm().findField('filefrmt').setValue('VOT'); |
189 | 164 | break; |
... | ... | @@ -230,14 +205,14 @@ Ext.define('amdaUI.UploadPanelUI', { |
230 | 205 | this.postUpload(onFinish); |
231 | 206 | }, |
232 | 207 | |
233 | - /* | |
234 | - * | |
235 | - */ | |
208 | +/* | |
209 | +* | |
210 | +*/ | |
236 | 211 | postUpload : function(onFinish) |
237 | 212 | { |
238 | 213 | // 'global' form containing 'partial' forms |
239 | 214 | var form = this.getForm(); |
240 | - | |
215 | + | |
241 | 216 | // special validation |
242 | 217 | if(this.validate()) |
243 | 218 | { |
... | ... | @@ -246,16 +221,14 @@ Ext.define('amdaUI.UploadPanelUI', { |
246 | 221 | scope: this, |
247 | 222 | url: 'php/uploadFile.php', |
248 | 223 | waitMsg: 'Uploading your file...', |
249 | - success: function(form, o) | |
250 | - { | |
224 | + success: function(form, o) { | |
251 | 225 | if (onFinish) |
252 | 226 | onFinish(); |
253 | 227 | this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file}); |
254 | 228 | AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this); |
255 | 229 | loadMask.hide(); |
256 | 230 | }, |
257 | - failure: function(form, o) | |
258 | - { | |
231 | + failure: function(form, o) { | |
259 | 232 | if (onFinish) |
260 | 233 | onFinish(); |
261 | 234 | loadMask.hide(); |
... | ... | @@ -265,25 +238,19 @@ Ext.define('amdaUI.UploadPanelUI', { |
265 | 238 | } |
266 | 239 | }, |
267 | 240 | |
268 | - /* | |
269 | - * panel config | |
270 | - */ | |
271 | - init : function(config) | |
272 | - { | |
273 | - this.isFile = config.panelType == 'file'? true : false; | |
274 | - this.isTimeTable = config.panelType == 'timetable'? true : false; | |
275 | - | |
276 | - // file / time table / catalog settings | |
277 | - if (this.isFile) | |
278 | - { | |
279 | - var title = 'File'; | |
280 | - var items = [ | |
241 | + initFileUpload : function() | |
242 | + { | |
243 | + this.formats = [ | |
281 | 244 | { boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true, |
282 | - listeners: | |
283 | - { | |
245 | + listeners: { | |
284 | 246 | change: function (cb, nv, ov) { |
285 | - if (nv) Ext.getCmp('tf').show(); | |
286 | - else Ext.getCmp('tf').hide(); | |
247 | + if (nv) { | |
248 | + Ext.getCmp('tf').show(); | |
249 | + } | |
250 | + else { | |
251 | + Ext.getCmp('tf').hide(); | |
252 | + Ext.getCmp('nfs').hide(); | |
253 | + } | |
287 | 254 | } |
288 | 255 | } |
289 | 256 | }, |
... | ... | @@ -291,143 +258,88 @@ Ext.define('amdaUI.UploadPanelUI', { |
291 | 258 | { boxLabel: 'CDF <img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'CDF' }, |
292 | 259 | // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' }, |
293 | 260 | { boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT' }]; |
294 | - var timeFormatId = 'tf'; | |
295 | - this.formatId = 'nsf'; | |
261 | + | |
296 | 262 | this.localUploadId = 'form-uploadfile'; |
297 | - var localUploadName ='localFileName'; | |
298 | - var remoteUploadName ='remoteFile'; | |
299 | 263 | this.remoteUploadId = 'form-uploadurl'; |
300 | 264 | this.nodeType = 'amdaModel.MyDataParamNode'; |
301 | 265 | //TODO load XML |
302 | - var store = Ext.create('Ext.data.Store', { | |
266 | + this.store = Ext.create('Ext.data.Store', { | |
303 | 267 | fields: ['value', 'name'], |
304 | 268 | data : [ |
305 | 269 | {"value":"ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name":"CDAWEB/FTP"}/*, |
306 | 270 | {"value":"ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/", "name":"Solar Data"}*/] |
307 | - }); | |
308 | - } | |
309 | - else if (this.isTimeTable) | |
310 | - { | |
311 | - var title = 'Time Table'; | |
312 | - var items = [ | |
313 | - { boxLabel: 'ASCII <img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'ttfrmt', inputValue: 'ASCII', checked: true}, | |
314 | - { boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'} | |
315 | - ]; | |
316 | - var timeFormatId = 'tf_tt'; | |
317 | - this.formatId = 'nsf_tt'; | |
318 | - this.localUploadId = 'form-uploadtt'; | |
319 | - var localUploadName ='localTTName'; | |
320 | - var remoteUploadName ='remoteTT'; | |
321 | - this.remoteUploadId = 'form-uploadtturl'; | |
322 | - this.nodeType = 'amdaModel.TimeTableNode'; | |
323 | - //TODO load XML | |
324 | - var store = Ext.create('Ext.data.Store', { | |
325 | - fields: ['value', 'name'], | |
326 | - data : [] | |
327 | 271 | }); |
328 | - } | |
329 | - else | |
330 | - { | |
331 | - var title = 'Catalog'; | |
332 | - var items = [ | |
333 | - { boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true }]; | |
334 | - | |
335 | - var timeFormatId = 'tf_cat'; | |
336 | - this.formatId = 'nsf_cat'; | |
337 | - this.localUploadId = 'form-uploadcat'; | |
338 | - var localUploadName ='localCatName'; | |
339 | - var remoteUploadName ='remoteCat'; | |
340 | 272 | |
341 | - this.remoteUploadId = 'form-uploadcaturl'; | |
342 | - this.nodeType = 'amdaModel.CatalogNode'; | |
343 | - //TODO load XML | |
344 | - var store = Ext.create('Ext.data.Store', { | |
345 | - fields: ['value', 'name'], | |
346 | - data : [] | |
347 | - }); | |
348 | - } | |
349 | - | |
350 | - var combo = Ext.create('Ext.form.ComboBox', { | |
351 | - flex : 4, | |
352 | - store: store, | |
353 | - emptyText: 'Enter Remote Site URL (ftp)', | |
354 | - queryMode: 'local', | |
355 | - displayField: 'name', | |
356 | - valueField: 'value' | |
357 | - }); | |
358 | - | |
359 | - var fieldcontainer = | |
360 | - { | |
361 | - xtype: 'fieldcontainer', | |
362 | - fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0, | |
363 | - layout: 'hbox', | |
273 | + this.radioId = 'filefrmt'; | |
274 | + | |
275 | +/* | |
276 | + * Sampling : TimeFormat Fieldset | |
277 | + */ | |
278 | + this.autoSampling = Ext.create('Ext.form.RadioGroup', { | |
279 | + // fieldLabel : 'Constant or Variable ?', | |
280 | + // labelWidth: 90, | |
281 | + defaults : {name : 'timesmpl'}, | |
364 | 282 | items: [ |
365 | - combo, | |
366 | - { | |
367 | - xtype : 'button', | |
368 | - flex : 1, | |
369 | - text: 'Browse It', | |
370 | - handler: function() | |
371 | - { | |
372 | - var form = this.up('form').getForm(); | |
373 | - var site = form.getFields().getAt(0).getValue(); | |
374 | - if (site) | |
375 | - this.up('form').ownerCt.fireEvent('open', site); | |
376 | - else | |
377 | - myDesktopApp.warningMsg("Please Enter Remote Site URL"); | |
378 | - } | |
379 | - }] | |
380 | - }; | |
381 | - | |
382 | - if (this.isFile) var radioId = 'filefrmt'; | |
383 | - else if (this.isTimeTable) var radioId = 'ttfrmt'; | |
384 | - else var radioId = 'catfrmt'; | |
283 | + {boxLabel: 'constant sampling', inputValue: 'constant', checked: true}, | |
284 | + {boxLabel: 'variable sampling <img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'} | |
285 | + ] | |
286 | + }); | |
385 | 287 | |
386 | - var fileFormat = Ext.create('Ext.form.FieldSet', { | |
387 | - title: 'File Format', | |
388 | - items : [{ | |
389 | - xtype: 'radiogroup', | |
390 | - id : radioId, | |
391 | - columns: 3, | |
392 | - cls: 'x-check-group-alt', | |
393 | - items: items | |
288 | + this.manualSampling = Ext.create('Ext.form.FieldContainer', { | |
289 | + defaultType: 'textfield', | |
290 | + layout: 'anchor', | |
291 | + defaults: { | |
292 | + layout: '100%', | |
293 | + labelWidth : 150 | |
294 | + }, | |
295 | + hidden : true, | |
296 | + items: [ | |
297 | + { | |
298 | + fieldLabel : 'min sampling', | |
299 | + name : 'min_manual_sampling' | |
300 | + }, | |
301 | + { | |
302 | + fieldLabel : 'max sampling', | |
303 | + name : 'max_manual_sampling' | |
394 | 304 | }] |
305 | + }); | |
306 | + | |
307 | + var Sampling = Ext.create('Ext.form.RadioGroup', { | |
308 | + fieldLabel: 'Time Sampling', | |
309 | + labelWidth: 90, | |
310 | + cls: 'x-check-group-alt', | |
311 | + defaults : {name : 'smpl'}, | |
312 | + items: [ | |
313 | + {boxLabel: 'auto-defined', inputValue: 'auto', checked: true}, | |
314 | + {boxLabel: 'manual', inputValue: 'manual'} | |
315 | + ], | |
316 | + listeners: { | |
317 | + scope : this, | |
318 | + change: function (cb, nv, ov) { | |
319 | + if (nv.smpl == 'manual') { | |
320 | + this.autoSampling.setVisible(false); | |
321 | + this.manualSampling.setVisible(true); | |
322 | + } | |
323 | + else { | |
324 | + this.autoSampling.setVisible(true); | |
325 | + this.manualSampling.setVisible(false); | |
326 | + } | |
327 | + } | |
328 | + } | |
395 | 329 | }); |
396 | - | |
397 | - var Sampling = | |
398 | - { | |
399 | - xtype: 'radiogroup', | |
400 | - fieldLabel: 'Time Sampling', | |
401 | - labelWidth: 90, | |
402 | - cls: 'x-check-group-alt', | |
403 | - hidden : !this.isFile, | |
404 | - defaults : {name : 'timesmpl'}, | |
405 | - items: [ | |
406 | - {boxLabel: 'constant', inputValue: 'constant', checked: true}, | |
407 | - {boxLabel: 'variable <img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'} | |
408 | - ] | |
409 | - }; | |
410 | - | |
411 | - var dayStart = | |
412 | - { | |
413 | - xtype: 'checkbox', | |
414 | - name : 'doy', | |
415 | - hidden : true, | |
416 | - fieldLabel: 'DOY starts from 1', | |
417 | - inputValue: '1' | |
418 | - }; | |
419 | - | |
420 | - var nonStandardFormat = | |
421 | - { | |
330 | + | |
331 | +/* | |
332 | + * NonStandardFormat : TimeFormat Fieldset | |
333 | + */ | |
334 | + var nonStandardFormat = { | |
422 | 335 | xtype: 'fieldcontainer', |
423 | 336 | defaultType: 'textfield', |
424 | 337 | layout: 'anchor', |
425 | - defaults: | |
426 | - { | |
427 | - layout: '100%', | |
428 | - labelWidth : 150 | |
338 | + defaults: { | |
339 | + layout: '100%', | |
340 | + labelWidth : 150 | |
429 | 341 | }, |
430 | - id : this.formatId, | |
342 | + id : 'nfs', | |
431 | 343 | hidden : true, |
432 | 344 | items: [ |
433 | 345 | { |
... | ... | @@ -435,8 +347,7 @@ Ext.define('amdaUI.UploadPanelUI', { |
435 | 347 | name : 'nonstd', |
436 | 348 | value: 'Y-m-d H:i:s', |
437 | 349 | enableKeyEvents: true, |
438 | - listeners : | |
439 | - { | |
350 | + listeners : { | |
440 | 351 | keyUp : function() { |
441 | 352 | if (this.getValue().indexOf('z') > 0) { |
442 | 353 | this.nextSibling().show(); |
... | ... | @@ -446,65 +357,147 @@ Ext.define('amdaUI.UploadPanelUI', { |
446 | 357 | } |
447 | 358 | } |
448 | 359 | } |
449 | - }, | |
450 | - dayStart, | |
451 | - { | |
452 | - fieldLabel : 'define max time length', | |
453 | - name : 'timelength', | |
454 | - value: 'auto' | |
360 | + },{ | |
361 | + xtype: 'checkbox', | |
362 | + name : 'doy', | |
363 | + fieldLabel: 'DOY starts from 1', | |
364 | + hidden : true, | |
365 | + inputValue: '1' | |
366 | + },{ | |
367 | + fieldLabel : 'define max time length', | |
368 | + name : 'timelength', | |
369 | + value: 'auto' | |
455 | 370 | }], |
456 | - listeners : | |
457 | - { | |
371 | + listeners : { | |
458 | 372 | hide : function() { |
459 | 373 | this.items.getAt(1).hide(); |
374 | + }, | |
375 | + show : function() { | |
376 | + if (this.items.getAt(0).getValue().indexOf('z') > 0) | |
377 | + this.items.getAt(1).show(); | |
460 | 378 | } |
461 | 379 | } |
462 | - }; | |
463 | - | |
464 | - var timeFormat = Ext.create('Ext.form.FieldSet', { | |
465 | - id: timeFormatId, | |
380 | + }; | |
381 | + | |
382 | +/* | |
383 | + * TimeFormat Fieldset : Global form | |
384 | + */ | |
385 | + var timeFormat = Ext.create('Ext.form.FieldSet', { | |
466 | 386 | title: 'Time Settings', |
467 | - hidden : !this.isFile, | |
468 | - items : [ | |
469 | - { | |
387 | + items : [{ | |
388 | + id: 'tf', | |
470 | 389 | xtype: 'radiogroup', |
471 | 390 | fieldLabel: 'Time Format', |
472 | 391 | labelWidth: 90, |
473 | 392 | cls: 'x-check-group-alt', |
474 | 393 | defaults : { name : 'timefrmt'}, |
475 | 394 | items: [ |
476 | - { boxLabel: 'standard <img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true}, | |
477 | - { boxLabel: 'no <img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user', | |
478 | - listeners: | |
479 | - { | |
480 | - scope : this, | |
481 | - change: function (cb, nv, ov) { | |
482 | - if (nv) | |
483 | - Ext.getCmp(this.formatId).show(); | |
484 | - else | |
485 | - Ext.getCmp(this.formatId).hide(); | |
486 | - } | |
487 | - } | |
488 | - }] | |
489 | - }, | |
490 | - nonStandardFormat, | |
491 | - Sampling ] | |
395 | + { boxLabel: 'standard <img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true}, | |
396 | + { boxLabel: 'no <img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user', | |
397 | + listeners: { | |
398 | + change: function (cb, nv, ov) { | |
399 | + if (nv) | |
400 | + Ext.getCmp('nfs').show(); | |
401 | + else | |
402 | + Ext.getCmp('nfs').hide(); | |
403 | + } | |
404 | + } | |
405 | + }] | |
406 | + }, | |
407 | + nonStandardFormat, | |
408 | + Sampling, | |
409 | + this.autoSampling, | |
410 | + this.manualSampling | |
411 | + ] | |
492 | 412 | }); |
413 | + | |
414 | + this.specialItems = [ timeFormat, | |
415 | + { | |
416 | + xtype: 'hidden', | |
417 | + name: 'sampData', | |
418 | + value: null | |
419 | + }, | |
420 | + { | |
421 | + xtype: 'hidden', | |
422 | + name: 'sampFileName', | |
423 | + value: null | |
424 | + }] | |
425 | + }, | |
493 | 426 | |
427 | + initTTUpload : function(isTT) | |
428 | + { | |
429 | + if (isTT) { | |
430 | + this.formats = [ | |
431 | + { boxLabel: 'ASCII <img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'ttfrmt', inputValue: 'ASCII', checked: true}, | |
432 | + { boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'} | |
433 | + ]; | |
434 | + this.localUploadId = 'form-uploadtt'; | |
435 | + this.remoteUploadId = 'form-uploadtturl'; | |
436 | + this.nodeType = 'amdaModel.TimeTableNode'; | |
437 | + //TODO load XML | |
438 | + this.store = Ext.create('Ext.data.Store', { | |
439 | + fields: ['value', 'name'], | |
440 | + data : [] | |
441 | + }); | |
442 | + this.radioId = 'ttfrmt'; | |
443 | + } | |
444 | + else { | |
445 | + this.formats = [ | |
446 | + { boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true }]; | |
447 | + | |
448 | + this.localUploadId = 'form-uploadcat'; | |
449 | + this.remoteUploadId = 'form-uploadcaturl'; | |
450 | + this.nodeType = 'amdaModel.CatalogNode'; | |
451 | + //TODO load XML | |
452 | + this.store = Ext.create('Ext.data.Store', { | |
453 | + fields: ['value', 'name'], | |
454 | + data : [] | |
455 | + }); | |
456 | + | |
457 | + this.radioId = 'catfrmt'; | |
458 | + } | |
459 | + }, | |
460 | +/* | |
461 | +* panel config | |
462 | +*/ | |
463 | + init : function(config) | |
464 | + { | |
465 | + | |
466 | + if ( config.panelType == 'file' ) | |
467 | + this.initFileUpload(); | |
468 | + else | |
469 | + this.initTTUpload(config.panelType == 'timetable'); | |
470 | + | |
471 | + this.localName = config.localUploadName; | |
472 | + /* | |
473 | + * FileFormat Fieldset | |
474 | + */ | |
475 | + var fileFormat = Ext.create('Ext.form.FieldSet', { | |
476 | + title: 'File Format', | |
477 | + items : [{ | |
478 | + xtype: 'radiogroup', | |
479 | + id : this.radioId, | |
480 | + columns: 3, | |
481 | + cls: 'x-check-group-alt', | |
482 | + items: this.formats | |
483 | + }] | |
484 | + }); | |
485 | + | |
486 | +/* | |
487 | + * FileSource Fieldset : Local File Upload | |
488 | + */ | |
494 | 489 | var localFile = Ext.create('Ext.form.Panel', { |
495 | 490 | id: this.localUploadId, |
496 | 491 | fileUpload: true, |
497 | 492 | hideLabels: true, |
498 | 493 | frame: true, |
499 | - items: [ | |
500 | - { | |
494 | + items: [{ | |
501 | 495 | xtype: 'fileuploadfield', |
502 | 496 | emptyText: 'Select Your File', |
503 | 497 | width: 300, |
504 | - name: localUploadName, | |
498 | + name: this.localName, | |
505 | 499 | buttonText: 'Browse', |
506 | - listeners: | |
507 | - { | |
500 | + listeners: { | |
508 | 501 | scope : this, |
509 | 502 | change: function (field, value, e) { |
510 | 503 | this.updateFormat(value); |
... | ... | @@ -517,8 +510,41 @@ Ext.define('amdaUI.UploadPanelUI', { |
517 | 510 | name: 'MAX_FILE_SIZE', |
518 | 511 | value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB |
519 | 512 | }] |
520 | - }); | |
521 | - | |
513 | + }); | |
514 | + | |
515 | +/* | |
516 | + * FileSource Fieldset : Remote File Upload | |
517 | + */ | |
518 | + var combo = Ext.create('Ext.form.ComboBox', { | |
519 | + flex : 4, | |
520 | + store: this.store, | |
521 | + emptyText: 'Enter Remote Site URL (ftp)', | |
522 | + queryMode: 'local', | |
523 | + displayField: 'name', | |
524 | + valueField: 'value' | |
525 | + }); | |
526 | + | |
527 | + var fieldcontainer = { | |
528 | + xtype: 'fieldcontainer', | |
529 | + fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0, | |
530 | + layout: 'hbox', | |
531 | + items: [ | |
532 | + combo, | |
533 | + { | |
534 | + xtype : 'button', | |
535 | + flex : 1, | |
536 | + text: 'Browse It', | |
537 | + handler: function() { | |
538 | + var form = this.up('form').getForm(); | |
539 | + var site = form.getFields().getAt(0).getValue(); | |
540 | + if (site) | |
541 | + this.up('form').ownerCt.fireEvent('open', site); | |
542 | + else | |
543 | + myDesktopApp.warningMsg("Please Enter Remote Site URL"); | |
544 | + } | |
545 | + }] | |
546 | + }; | |
547 | + | |
522 | 548 | var remoteFile = Ext.create('Ext.form.Panel', { |
523 | 549 | id: this.remoteUploadId, |
524 | 550 | hideLabels: true, |
... | ... | @@ -529,7 +555,7 @@ Ext.define('amdaUI.UploadPanelUI', { |
529 | 555 | fieldcontainer, |
530 | 556 | { |
531 | 557 | xtype : 'textfield', |
532 | - name : remoteUploadName, | |
558 | + name : config.remoteUploadName, | |
533 | 559 | emptyText: 'Enter Remote File URL (http or ftp)', |
534 | 560 | width: 310, |
535 | 561 | listeners: |
... | ... | @@ -541,17 +567,18 @@ Ext.define('amdaUI.UploadPanelUI', { |
541 | 567 | } |
542 | 568 | }] |
543 | 569 | }); |
544 | - | |
570 | + | |
571 | + /* | |
572 | + * FileSource Fieldset : global form | |
573 | + */ | |
545 | 574 | var uploadForm = Ext.create('Ext.form.FieldSet',{ |
546 | 575 | title: 'File Source', |
547 | - items : [ | |
548 | - { | |
576 | + items : [{ | |
549 | 577 | xtype: 'radiogroup', |
550 | 578 | cls: 'x-check-group-alt', |
551 | 579 | items: [ |
552 | 580 | { boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true, |
553 | - listeners: | |
554 | - { | |
581 | + listeners: { | |
555 | 582 | scope : this, |
556 | 583 | change: function (cb, nv, ov) { |
557 | 584 | if (nv == ov) return; |
... | ... | @@ -568,58 +595,43 @@ Ext.define('amdaUI.UploadPanelUI', { |
568 | 595 | } |
569 | 596 | } |
570 | 597 | }, |
571 | - { boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'} ] | |
598 | + { boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}] | |
572 | 599 | }] |
573 | 600 | }); |
574 | - | |
601 | + | |
602 | +/* | |
603 | + * Panel Config | |
604 | + */ | |
575 | 605 | var myConf = |
576 | 606 | { |
577 | - title : title, | |
607 | + title : config.title, | |
578 | 608 | layout: {type: 'vbox', align: 'stretch'}, |
609 | + autoScroll : true, | |
579 | 610 | bodyStyle: { background : '#dfe8f6'}, |
580 | - items : [ | |
581 | - uploadForm, | |
582 | - localFile, | |
583 | - remoteFile, | |
584 | - fileFormat, | |
585 | - timeFormat, | |
586 | - { | |
587 | - xtype: 'hidden', | |
588 | - name: 'sampData', | |
589 | - value: null | |
590 | - }, | |
591 | - { | |
592 | - xtype: 'hidden', | |
593 | - name: 'sampFileName', | |
594 | - value: null, | |
595 | - } | |
596 | - ], | |
597 | - buttons: [ | |
598 | - { | |
611 | + items : Ext.Array.merge( | |
612 | + [ uploadForm, localFile, remoteFile, fileFormat ], | |
613 | + this.specialItems ), | |
614 | + buttons: [{ | |
599 | 615 | text: 'Upload', |
600 | - handler: function() | |
601 | - { | |
616 | + handler: function() { | |
602 | 617 | this.postUpload(); |
603 | 618 | }, |
604 | 619 | scope : this |
605 | 620 | }, |
606 | 621 | { |
607 | 622 | text: 'Reset', |
608 | - handler: function(){ | |
623 | + handler: function() { | |
609 | 624 | this.up('form').getForm().reset(); |
610 | 625 | } |
611 | 626 | }], |
612 | 627 | plugins: [{ptype: 'remoteSearchPlugin'}], |
613 | - listeners: | |
614 | - { | |
615 | - click: | |
616 | - { | |
628 | + listeners:{ | |
629 | + click: { | |
617 | 630 | element: 'el', |
618 | - fn: function(e,t) { | |
631 | + fn: function(e,t) { | |
619 | 632 | var me = t, |
620 | 633 | text = me.getAttribute('amda_clicktip'); |
621 | - if (text) | |
622 | - { | |
634 | + if (text) { | |
623 | 635 | e.preventDefault(); |
624 | 636 | AmdaAction.getInfo({name : text}, function(res,e) { |
625 | 637 | if (res.success) myDesktopApp.infoMsg(res.result); | ... | ... |
js/app/views/UploadUI.js
... | ... | @@ -33,9 +33,9 @@ Ext.define('amdaUI.UploadUI', { |
33 | 33 | region: 'center', |
34 | 34 | activeTab : 0, |
35 | 35 | items : [ |
36 | - { xtype: 'panelUpload', panelType : 'file'}, | |
37 | - { xtype: 'panelUpload', panelType : 'timetable'}, | |
38 | - { xtype: 'panelUpload', panelType : 'catalog'}] | |
36 | + { xtype: 'panelUpload', panelType : 'file', title : 'File', localUploadName : 'localFileName', remoteUploadName : 'remoteFile'}, | |
37 | + { xtype: 'panelUpload', panelType : 'timetable', title : 'Time Table', localUploadName : 'localTTName', remoteUploadName : 'remoteTT'}, | |
38 | + { xtype: 'panelUpload', panelType : 'catalog', title : 'Catalog', localUploadName : 'localCatName', remoteUploadName :'remoteCat'}] | |
39 | 39 | }, |
40 | 40 | { |
41 | 41 | xtype: 'panel', | ... | ... |