Commit 34d41fb32ce568bd3574c78e395de17a7420a4a4
1 parent
bb3d4334
Exists in
master
and in
109 other branches
Fix eslint warnings
Showing
2 changed files
with
453 additions
and
367 deletions
Show diff stats
js/.eslintrc.yml
... | ... | @@ -7,18 +7,17 @@ plugins: |
7 | 7 | - extjs |
8 | 8 | rules: |
9 | 9 | indent: [error, 2, SwitchCase: 1] |
10 | - semi: [warn, never] | |
10 | + semi: [error, always] | |
11 | 11 | max-len: [error, code: 120] |
12 | - max-lines: [error, 600] | |
12 | + max-lines: [warn, 600] | |
13 | 13 | linebreak-style: [error, unix] |
14 | 14 | quotes: [error, single] |
15 | 15 | strict: [error, global] |
16 | 16 | quote-props: [error, as-needed] |
17 | 17 | max-statements: [warn, 20] |
18 | - array-bracket-newline: [warn, consistent] | |
19 | 18 | consistent-this: [error, me] |
20 | 19 | padded-blocks: off |
21 | - no-tabs: off | |
20 | + newline-per-chained-call: [error, ignoreChainWithDepth: 3] | |
22 | 21 | no-warning-comments: off |
23 | 22 | func-names: off |
24 | 23 | function-paren-newline: off | ... | ... |
js/app/views/UploadPanelUI.js
1 | 1 | /** |
2 | - * Project : AMDA-NG | |
3 | - * Name : UploadUI.js | |
4 | - * @class amdaUI.UploadUI | |
5 | - * @extends Ext.form.Panel | |
6 | - * @brief Upload Panel UI definition (View) | |
7 | - * @author Elena | |
8 | - * @version $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $ | |
2 | + * Project: AMDA-NG | |
3 | + * Name: UploadUI.js | |
4 | + * @class amdaUI.UploadUI | |
5 | + * @extends Ext.form.panel | |
6 | + * @brief Upload Panel UI definition (View) | |
7 | + * @author Elena | |
8 | + * @version $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $ | |
9 | 9 | */ |
10 | 10 | |
11 | +/* global AmdaAction, myDesktopApp, amdaModel, loadMask */ | |
12 | + | |
13 | +/** | |
14 | + * @typedef {AmdaApp} myDesktopApp | |
15 | + * @typedef {Object} AmdaAction | |
16 | + * @typedef {Object} Ext | |
17 | + */ | |
18 | + | |
19 | +'use strict'; | |
11 | 20 | Ext.define('amdaUI.UploadPanelUI', { |
12 | 21 | extend: 'Ext.form.Panel', |
13 | 22 | alias: 'widget.panelUpload', |
14 | 23 | |
15 | - requires: [ | |
16 | - 'amdaUI.RemoteSearchPlugin' | |
17 | - ], | |
24 | + requires: ['amdaUI.RemoteSearchPlugin'], | |
18 | 25 | |
19 | 26 | isFile: true, |
20 | 27 | isTimeTable: false, |
... | ... | @@ -22,36 +29,40 @@ Ext.define('amdaUI.UploadPanelUI', { |
22 | 29 | |
23 | 30 | constructor: function (config) { |
24 | 31 | this.init(config); |
25 | - this.callParent(arguments); | |
32 | + this.superclass.constructor.apply(this, arguments); | |
26 | 33 | }, |
27 | 34 | |
28 | 35 | /* |
29 | - * create MyData linked node and edit in module MyData | |
30 | - * update myDataParams info if needed | |
31 | - */ | |
36 | + * Create MyData linked node and edit in module MyData | |
37 | + * Update myDataParams info if needed | |
38 | + */ | |
32 | 39 | getObjectCallback: function (result, remoteEvent) { |
33 | - var t = remoteEvent.getTransaction(); | |
40 | + var linkedFile, me, paramObj, t; | |
41 | + | |
42 | + t = remoteEvent.getTransaction(); | |
34 | 43 | if (result && !result.error) { |
35 | - // set parameter into node | |
36 | - var me = this; | |
44 | + // Set parameter into node | |
45 | + me = this; | |
37 | 46 | myDesktopApp.getLoadedModule(this.tmpNode.get('moduleId'), true, function (module) { |
38 | - // myData | |
39 | - if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType) { | |
40 | - var linkedFile = Ext.create('amdaModel.MyDataNode', {leaf: true, text: me.tmpNode.get('text')}); | |
41 | - | |
47 | + // MyData | |
48 | + if (me.tmpNode.get('nodeType') === amdaModel.MyDataParamNode.nodeType) { | |
49 | + linkedFile = Ext.create('amdaModel.MyDataNode', { | |
50 | + leaf: true, | |
51 | + text: me.tmpNode.get('text') | |
52 | + }); | |
42 | 53 | linkedFile.create(result.mask, result.description, result.maskDesc); |
43 | 54 | linkedFile.updateMyDataParam(result.mask, result.maskDesc); |
44 | 55 | |
45 | - if (!linkedFile.get('id')) | |
56 | + if (!linkedFile.get('id')) { | |
46 | 57 | linkedFile.set('id', me.tmpNode.get('text')); |
58 | + } | |
47 | 59 | |
48 | - var paramObj = Ext.create(linkedFile.get('objectDataModel'), result); | |
60 | + paramObj = Ext.create(linkedFile.get('objectDataModel'), result); | |
49 | 61 | linkedFile.set('object', paramObj); |
50 | 62 | me.tmpNode.set('fileObject', paramObj); |
51 | - } | |
52 | - else { | |
63 | + } else { | |
53 | 64 | // Time Table or Catalog |
54 | - var paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result); | |
65 | + paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result); | |
55 | 66 | |
56 | 67 | paramObj.set('fromPlugin', true); |
57 | 68 | if (result.intervals) { |
... | ... | @@ -65,121 +76,125 @@ Ext.define('amdaUI.UploadPanelUI', { |
65 | 76 | module.linkedNode.editInModule(); |
66 | 77 | } |
67 | 78 | }); |
68 | - } | |
69 | - else { | |
79 | + } else { | |
70 | 80 | // EXCEPTION : parameter not found ! |
71 | - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" + this.tmpNode.get('text') + "' found!"); | |
81 | + myDesktopApp.errorMsg(t.action + '.' + t.method + ' : No parameter "' + this.tmpNode.get('text') + '" found!'); | |
72 | 82 | } |
73 | 83 | loadMask.hide(); |
74 | 84 | }, |
75 | 85 | |
76 | 86 | /* |
77 | - * form validation | |
78 | - * TODO markInvalid()? | |
79 | - */ | |
87 | + * Form validation | |
88 | + * TODO markInvalid()? | |
89 | + */ | |
80 | 90 | validate: function () { |
81 | - var values = this.getForm().getValues(); | |
82 | - | |
83 | - if (values['filesrc'] == 'LOCAL') { | |
84 | - if (this.isFile) var locFile = this.getForm().findField('localFileName').getValue(); | |
85 | - else if (this.isTimeTable) var locFile = this.getForm().findField('localTTName').getValue(); | |
86 | - else var locFile = this.getForm().findField('localCatName').getValue(); | |
91 | + var locFile, values; | |
92 | + values = this.getForm().getValues(); | |
93 | + | |
94 | + if (values.filesrc === 'LOCAL') { | |
95 | + if (this.isFile) { | |
96 | + locFile = this.getForm().findField('localFileName').getValue(); | |
97 | + } else if (this.isTimeTable) { | |
98 | + locFile = this.getForm().findField('localTTName').getValue(); | |
99 | + } else { | |
100 | + locFile = this.getForm().findField('localCatName').getValue(); | |
101 | + } | |
87 | 102 | |
88 | 103 | if (!locFile) { |
89 | - myDesktopApp.warningMsg("Select File to Upload"); | |
90 | - return false; | |
91 | - } | |
92 | - } | |
93 | - else { | |
94 | - if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat']) { | |
95 | - myDesktopApp.warningMsg("Select File to Upload"); | |
104 | + myDesktopApp.warningMsg('Select File to Upload'); | |
96 | 105 | return false; |
97 | 106 | } |
107 | + } else if (!values.remoteFile && !values.remoteTT && !values.remoteCat) { | |
108 | + myDesktopApp.warningMsg('Select File to Upload'); | |
109 | + return false; | |
98 | 110 | } |
99 | 111 | return true; |
100 | 112 | }, |
101 | 113 | |
102 | 114 | |
103 | - //TODO proper parsing | |
115 | + // TODO proper parsing | |
104 | 116 | updateFormat: function (value) { |
105 | - var arrayOfStr = value.split('.'); | |
106 | - //TODO use down method? | |
117 | + var arrayOfStr, autoFormat, radios, suffix, userFormat, userFormatObj; | |
118 | + | |
119 | + arrayOfStr = value.split('.'); | |
120 | + // TODO use down method? | |
107 | 121 | if (this.isFile) { |
108 | - var radios = Ext.getCmp('filefrmt'); | |
109 | - var user_format_obj = radios.getValue(); | |
110 | - var user_format = user_format_obj.filefrmt; | |
111 | - } | |
112 | - else if (this.isTimeTable) { | |
113 | - var radios = Ext.getCmp('ttfrmt'); | |
114 | - var user_format_obj = radios.getValue(); | |
115 | - var user_format = user_format_obj.ttfrmt; | |
116 | - } | |
117 | - else { | |
118 | - var radios = Ext.getCmp('catfrmt'); | |
119 | - var user_format_obj = radios.getValue(); | |
120 | - var user_format = user_format_obj.catfrmt; | |
122 | + radios = Ext.getCmp('filefrmt'); | |
123 | + userFormatObj = radios.getValue(); | |
124 | + userFormat = userFormatObj.filefrmt; | |
125 | + } else if (this.isTimeTable) { | |
126 | + radios = Ext.getCmp('ttfrmt'); | |
127 | + userFormatObj = radios.getValue(); | |
128 | + userFormat = userFormatObj.ttfrmt; | |
129 | + } else { | |
130 | + radios = Ext.getCmp('catfrmt'); | |
131 | + userFormatObj = radios.getValue(); | |
132 | + userFormat = userFormatObj.catfrmt; | |
121 | 133 | } |
122 | 134 | |
123 | - var auto_format = user_format; | |
135 | + autoFormat = userFormat; | |
124 | 136 | |
125 | - // auto define format in some special cases | |
126 | - //TODO name without extention => ASCII? | |
127 | - if (arrayOfStr.length == 1) auto_format = 'ASCII'; | |
128 | - else { | |
129 | - var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase(); | |
130 | - if (suffix == 'gz') | |
137 | + // Auto define format in some special cases TODO: name without extention => ASCII? | |
138 | + if (arrayOfStr.length === 1) { | |
139 | + autoFormat = 'ASCII'; | |
140 | + } else { | |
141 | + suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase(); | |
142 | + if (suffix === 'gz') { | |
131 | 143 | suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz'; |
144 | + } | |
132 | 145 | |
133 | 146 | switch (suffix) { |
134 | - case 'cdf' : | |
135 | - auto_format = 'CDF'; | |
147 | + case 'cdf': | |
148 | + autoFormat = 'CDF'; | |
136 | 149 | break; |
137 | - case 'cef.gz' : | |
138 | - case 'cef' : | |
139 | - auto_format = 'CEF'; | |
150 | + case 'cef.gz': | |
151 | + case 'cef': | |
152 | + autoFormat = 'CEF'; | |
140 | 153 | break; |
141 | - case 'xml' : | |
142 | - auto_format = 'VOT'; | |
143 | - case 'vot' : | |
144 | - auto_format = 'VOT'; | |
154 | + case 'xml': | |
155 | + autoFormat = 'VOT'; | |
145 | 156 | break; |
146 | - case 'nc' : | |
147 | - auto_format = 'NC'; | |
157 | + case 'vot': | |
158 | + autoFormat = 'VOT'; | |
148 | 159 | break; |
149 | - case 'asc' : | |
150 | - case 'txt' : | |
151 | - default : | |
152 | - auto_format = 'ASCII'; | |
160 | + case 'nc': | |
161 | + autoFormat = 'NC'; | |
162 | + break; | |
163 | + case 'asc': | |
164 | + case 'txt': | |
165 | + default: | |
166 | + autoFormat = 'ASCII'; | |
153 | 167 | } |
154 | 168 | } |
155 | - // set auto format : case when format was not set by user before | |
156 | - if (this.isFile && user_format !== auto_format) { | |
157 | - user_format_obj.filefrmt = auto_format; | |
158 | - } else if (this.isTimeTable && user_format !== auto_format) { | |
159 | - user_format_obj.ttfrmt = auto_format; | |
160 | - } else if (!this.isFile && !this.isTimeTable && user_format !== auto_format) { | |
161 | - user_format_obj.catfrmt = auto_format; | |
169 | + // Set auto format : case when format was not set by user before | |
170 | + if (this.isFile && userFormat !== autoFormat) { | |
171 | + userFormatObj.filefrmt = autoFormat; | |
172 | + } else if (this.isTimeTable && userFormat !== autoFormat) { | |
173 | + userFormatObj.ttfrmt = autoFormat; | |
174 | + } else if (!this.isFile && !this.isTimeTable && userFormat !== autoFormat) { | |
175 | + userFormatObj.catfrmt = autoFormat; | |
162 | 176 | } |
163 | 177 | |
164 | - radios.setValue(user_format_obj); | |
178 | + radios.setValue(userFormatObj); | |
165 | 179 | }, |
166 | 180 | |
167 | 181 | /* |
168 | - * | |
169 | - */ | |
182 | + * Force upload | |
183 | + */ | |
170 | 184 | forceUpload: function (url, format, onFinish) { |
171 | - var me = this; | |
172 | - var re = /http:\/\/127.0.0.1:/; | |
173 | - var isRemoteUrl = !re.test(url); | |
185 | + var isRemoteUrl, me, onFinishAll, onLoad, re; | |
186 | + me = this; | |
187 | + re = /http:\/\/127.0.0.1:/; | |
188 | + isRemoteUrl = !re.test(url); | |
174 | 189 | |
175 | 190 | switch (format) { |
176 | - case 'votable' : | |
191 | + case 'votable': | |
177 | 192 | this.getForm().findField('filefrmt').setValue('VOT'); |
178 | 193 | break; |
179 | - case 'cdf' : | |
194 | + case 'cdf': | |
180 | 195 | this.getForm().findField('filefrmt').setValue('CDF'); |
181 | 196 | break; |
182 | - default : | |
197 | + default: | |
183 | 198 | myDesktopApp.errorMsg('Not supported data receive from SAMP'); |
184 | 199 | return; |
185 | 200 | } |
... | ... | @@ -187,25 +202,28 @@ Ext.define('amdaUI.UploadPanelUI', { |
187 | 202 | if (!isRemoteUrl) { |
188 | 203 | myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) { |
189 | 204 | var onError = function (error) { |
190 | - if (error) | |
205 | + if (error) { | |
191 | 206 | myDesktopApp.errorMsg(error); |
192 | - else | |
193 | - myDesktopApp.errorMsg("Cannot load data from this SAMP notification"); | |
194 | - if (onFinish) | |
207 | + } else { | |
208 | + myDesktopApp.errorMsg('Cannot load data from this SAMP notification'); | |
209 | + } | |
210 | + if (onFinish) { | |
195 | 211 | onFinish(); |
212 | + } | |
196 | 213 | }; |
197 | - var onLoad = function (data) { | |
198 | - //Fake value for validation | |
214 | + onLoad = function (data) { | |
215 | + // Fake value for validation | |
199 | 216 | Ext.form.field.File.superclass.setValue.call(me.getForm().findField('localFileName'), 'samp.vot'); |
200 | 217 | me.getForm().findField('filesrc').setValue('LOCAL'); |
201 | - //Add data related to the samp notification | |
218 | + // Add data related to the samp notification | |
202 | 219 | me.getForm().findField('sampFileName').setValue('samp.vot'); |
203 | 220 | me.getForm().findField('sampData').setValue(data); |
204 | - var onFinishAll = function () { | |
221 | + onFinishAll = function () { | |
205 | 222 | me.getForm().findField('sampFileName').reset(); |
206 | 223 | me.getForm().findField('sampData').reset(); |
207 | - if (onFinish) | |
224 | + if (onFinish) { | |
208 | 225 | onFinish(); |
226 | + } | |
209 | 227 | }; |
210 | 228 | me.postUpload(onFinishAll); |
211 | 229 | }; |
... | ... | @@ -220,29 +238,35 @@ Ext.define('amdaUI.UploadPanelUI', { |
220 | 238 | }, |
221 | 239 | |
222 | 240 | /* |
223 | - * | |
224 | - */ | |
241 | + * Post upload | |
242 | + */ | |
225 | 243 | postUpload: function (onFinish) { |
226 | 244 | // 'global' form containing 'partial' forms |
227 | 245 | var form = this.getForm(); |
228 | 246 | |
229 | - // special validation | |
247 | + // Special validation | |
230 | 248 | if (this.validate()) { |
231 | 249 | loadMask.show(); |
232 | 250 | form.submit({ |
233 | 251 | scope: this, |
234 | 252 | url: 'php/uploadFile.php', |
235 | 253 | waitMsg: 'Uploading your file...', |
236 | - success: function (form, o) { | |
237 | - if (onFinish) | |
254 | + success: function (onSuccessForm, o) { | |
255 | + if (onFinish) { | |
238 | 256 | onFinish(); |
239 | - this.tmpNode = Ext.create(this.nodeType, {leaf: true, text: o.result.file}); | |
240 | - AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this); | |
257 | + } | |
258 | + this.tmpNode = Ext.create(this.nodeType, { | |
259 | + leaf: true, | |
260 | + text: o.result.file | |
261 | + }); | |
262 | + AmdaAction.getUploadedObject(o.result.file, o.result.format, | |
263 | + this.tmpNode.get('nodeType'), this.getObjectCallback, this); | |
241 | 264 | loadMask.hide(); |
242 | 265 | }, |
243 | - failure: function (form, o) { | |
244 | - if (onFinish) | |
266 | + failure: function (onFailureForm, o) { | |
267 | + if (onFinish) { | |
245 | 268 | onFinish(); |
269 | + } | |
246 | 270 | loadMask.hide(); |
247 | 271 | myDesktopApp.errorMsg('Error ' + o.result.error); |
248 | 272 | } |
... | ... | @@ -251,98 +275,135 @@ Ext.define('amdaUI.UploadPanelUI', { |
251 | 275 | }, |
252 | 276 | |
253 | 277 | /* |
254 | - * panel config | |
255 | - */ | |
278 | + * Panel config | |
279 | + */ | |
256 | 280 | init: function (config) { |
257 | - this.isFile = config.panelType == 'file' ? true : false; | |
258 | - this.isTimeTable = config.panelType == 'timetable' ? true : false; | |
281 | + var combo, dayStart, fieldcontainer, fileFormat, form, items, local, localFile, localUploadName, myConf, | |
282 | + nonStandardFormat, radioId, remote, remoteFile, remoteUploadName, sampling, site, store, timeFormat, timeFormatId, | |
283 | + title, uploadForm; | |
284 | + this.isFile = config.panelType === 'file'; | |
285 | + this.isTimeTable = config.panelType === 'timetable'; | |
259 | 286 | |
260 | - // file / time table / catalog settings | |
287 | + // File / time table / catalog settings | |
261 | 288 | if (this.isFile) { |
262 | - var title = 'File'; | |
263 | - var items = [ | |
289 | + title = 'File'; | |
290 | + items = [ | |
264 | 291 | { |
265 | - boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true, | |
266 | - listeners: | |
267 | - { | |
268 | - change: function (cb, nv, ov) { | |
269 | - if (nv) Ext.getCmp('tf').show(); | |
270 | - else Ext.getCmp('tf').hide(); | |
292 | + boxLabel: 'ASCII', | |
293 | + name: 'filefrmt', | |
294 | + inputValue: 'ASCII', | |
295 | + checked: true, | |
296 | + listeners: { | |
297 | + change: function (cb, nv) { | |
298 | + if (nv) { | |
299 | + Ext.getCmp('tf').show(); | |
300 | + } else { | |
301 | + Ext.getCmp('tf').hide(); | |
271 | 302 | } |
272 | 303 | } |
304 | + } | |
273 | 305 | }, |
274 | 306 | { |
275 | - boxLabel: 'netCDF <img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', | |
307 | + boxLabel: 'netCDF <img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" ' + | |
308 | + 'src="js/resources/images/16x16/info_mini.png"', | |
276 | 309 | name: 'filefrmt', |
277 | 310 | inputValue: 'NC' |
278 | 311 | }, |
279 | 312 | { |
280 | - boxLabel: 'CDF <img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', | |
313 | + boxLabel: 'CDF <img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" ' + | |
314 | + 'src="js/resources/images/16x16/info_mini.png"', | |
281 | 315 | name: 'filefrmt', |
282 | 316 | inputValue: 'CDF' |
283 | 317 | }, |
284 | 318 | // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' }, |
285 | - {boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT'}]; | |
286 | - var timeFormatId = 'tf'; | |
319 | + { | |
320 | + boxLabel: 'VOTable', | |
321 | + name: 'filefrmt', | |
322 | + inputValue: 'VOT' | |
323 | + } | |
324 | + ]; | |
325 | + timeFormatId = 'tf'; | |
287 | 326 | this.formatId = 'nsf'; |
288 | 327 | this.localUploadId = 'form-uploadfile'; |
289 | - var localUploadName = 'localFileName'; | |
290 | - var remoteUploadName = 'remoteFile'; | |
328 | + localUploadName = 'localFileName'; | |
329 | + remoteUploadName = 'remoteFile'; | |
291 | 330 | this.remoteUploadId = 'form-uploadurl'; |
292 | 331 | this.nodeType = 'amdaModel.MyDataParamNode'; |
293 | - //TODO load XML | |
294 | - var store = Ext.create('Ext.data.Store', { | |
295 | - fields: ['value', 'name'], | |
332 | + // TODO load XML | |
333 | + store = Ext.create('Ext.data.Store', { | |
334 | + fields: [ | |
335 | + 'value', | |
336 | + 'name' | |
337 | + ], | |
296 | 338 | data: [ |
297 | - {"value": "ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name": "CDAWEB/FTP"}/*, | |
298 | - {"value":"ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/", "name":"Solar Data"}*/] | |
339 | + { | |
340 | + value: 'ftp://cdaweb.gsfc.nasa.gov/pub/data/', | |
341 | + name: 'CDAWEB/FTP' | |
342 | + } | |
343 | + ] | |
344 | + // {'value': 'ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/', 'name': 'Solar Data'} | |
299 | 345 | }); |
300 | - } | |
301 | - else if (this.isTimeTable) { | |
302 | - var title = 'Time Table'; | |
303 | - var items = [ | |
346 | + } else if (this.isTimeTable) { | |
347 | + title = 'Time Table'; | |
348 | + items = [ | |
304 | 349 | { |
305 | - boxLabel: 'ASCII <img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', | |
350 | + boxLabel: 'ASCII <img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" ' + | |
351 | + 'src="js/resources/images/16x16/info_mini.png"', | |
306 | 352 | name: 'ttfrmt', |
307 | 353 | inputValue: 'ASCII', |
308 | 354 | checked: true |
309 | 355 | }, |
310 | - {boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'} | |
356 | + { | |
357 | + boxLabel: 'VOTable', | |
358 | + name: 'ttfrmt', | |
359 | + inputValue: 'VOT' | |
360 | + } | |
311 | 361 | ]; |
312 | - var timeFormatId = 'tf_tt'; | |
362 | + timeFormatId = 'tf_tt'; | |
313 | 363 | this.formatId = 'nsf_tt'; |
314 | 364 | this.localUploadId = 'form-uploadtt'; |
315 | - var localUploadName = 'localTTName'; | |
316 | - var remoteUploadName = 'remoteTT'; | |
365 | + localUploadName = 'localTTName'; | |
366 | + remoteUploadName = 'remoteTT'; | |
317 | 367 | this.remoteUploadId = 'form-uploadtturl'; |
318 | 368 | this.nodeType = 'amdaModel.TimeTableNode'; |
319 | - //TODO load XML | |
320 | - var store = Ext.create('Ext.data.Store', { | |
321 | - fields: ['value', 'name'], | |
369 | + // TODO load XML | |
370 | + store = Ext.create('Ext.data.Store', { | |
371 | + fields: [ | |
372 | + 'value', | |
373 | + 'name' | |
374 | + ], | |
322 | 375 | data: [] |
323 | 376 | }); |
324 | - } | |
325 | - else { | |
326 | - var title = 'Catalog'; | |
327 | - var items = [ | |
328 | - {boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true}]; | |
377 | + } else { | |
378 | + title = 'Catalog'; | |
379 | + items = [ | |
380 | + { | |
381 | + boxLabel: 'VOTable', | |
382 | + name: 'catfrmt', | |
383 | + inputValue: 'VOT', | |
384 | + checked: true | |
385 | + } | |
386 | + ]; | |
329 | 387 | |
330 | - var timeFormatId = 'tf_cat'; | |
388 | + timeFormatId = 'tf_cat'; | |
331 | 389 | this.formatId = 'nsf_cat'; |
332 | 390 | this.localUploadId = 'form-uploadcat'; |
333 | - var localUploadName = 'localCatName'; | |
334 | - var remoteUploadName = 'remoteCat'; | |
391 | + localUploadName = 'localCatName'; | |
392 | + remoteUploadName = 'remoteCat'; | |
335 | 393 | |
336 | 394 | this.remoteUploadId = 'form-uploadcaturl'; |
337 | 395 | this.nodeType = 'amdaModel.CatalogNode'; |
338 | - //TODO load XML | |
339 | - var store = Ext.create('Ext.data.Store', { | |
340 | - fields: ['value', 'name'], | |
396 | + // TODO load XML | |
397 | + store = Ext.create('Ext.data.Store', { | |
398 | + fields: [ | |
399 | + 'value', | |
400 | + 'name' | |
401 | + ], | |
341 | 402 | data: [] |
342 | 403 | }); |
343 | 404 | } |
344 | 405 | |
345 | - var combo = Ext.create('Ext.form.ComboBox', { | |
406 | + combo = Ext.create('Ext.form.ComboBox', { | |
346 | 407 | flex: 4, |
347 | 408 | store: store, |
348 | 409 | emptyText: 'Enter Remote Site URL (ftp)', |
... | ... | @@ -351,114 +412,124 @@ Ext.define('amdaUI.UploadPanelUI', { |
351 | 412 | valueField: 'value' |
352 | 413 | }); |
353 | 414 | |
354 | - var fieldcontainer = | |
355 | - { | |
356 | - xtype: 'fieldcontainer', | |
357 | - fieldLabel: ' ', labelWidth: 0, labelSeparator: '', labelPad: 0, | |
358 | - layout: 'hbox', | |
359 | - items: [ | |
360 | - combo, | |
361 | - { | |
362 | - xtype: 'button', | |
363 | - flex: 1, | |
364 | - text: 'Browse It', | |
365 | - handler: function () { | |
366 | - var form = this.up('form').getForm(); | |
367 | - var site = form.getFields().getAt(0).getValue(); | |
368 | - if (site) | |
369 | - this.up('form').ownerCt.fireEvent('open', site); | |
370 | - else | |
371 | - myDesktopApp.warningMsg("Please Enter Remote Site URL"); | |
415 | + fieldcontainer = { | |
416 | + xtype: 'fieldcontainer', | |
417 | + fieldLabel: ' ', | |
418 | + labelWidth: 0, | |
419 | + labelSeparator: '', | |
420 | + labelPad: 0, | |
421 | + layout: 'hbox', | |
422 | + items: [ | |
423 | + combo, | |
424 | + { | |
425 | + xtype: 'button', | |
426 | + flex: 1, | |
427 | + text: 'Browse It', | |
428 | + handler: function () { | |
429 | + form = this.up('form').getForm(); | |
430 | + site = form.getFields().getAt(0).getValue(); | |
431 | + if (site) { | |
432 | + this.up('form').ownerCt.fireEvent('open', site); | |
433 | + } else { | |
434 | + myDesktopApp.warningMsg('Please Enter Remote Site URL'); | |
372 | 435 | } |
373 | - }] | |
374 | - }; | |
436 | + } | |
437 | + } | |
438 | + ] | |
439 | + }; | |
375 | 440 | |
376 | - if (this.isFile) var radioId = 'filefrmt'; | |
377 | - else if (this.isTimeTable) var radioId = 'ttfrmt'; | |
378 | - else var radioId = 'catfrmt'; | |
441 | + if (this.isFile) { | |
442 | + radioId = 'filefrmt'; | |
443 | + } else if (this.isTimeTable) { | |
444 | + radioId = 'ttfrmt'; | |
445 | + } else { | |
446 | + radioId = 'catfrmt'; | |
447 | + } | |
379 | 448 | |
380 | - var fileFormat = Ext.create('Ext.form.FieldSet', { | |
449 | + fileFormat = Ext.create('Ext.form.FieldSet', { | |
381 | 450 | title: 'File Format', |
382 | - items: [{ | |
383 | - xtype: 'radiogroup', | |
384 | - id: radioId, | |
385 | - columns: 3, | |
386 | - cls: 'x-check-group-alt', | |
387 | - items: items | |
388 | - }] | |
451 | + items: [ | |
452 | + { | |
453 | + xtype: 'radiogroup', | |
454 | + id: radioId, | |
455 | + columns: 3, | |
456 | + cls: 'x-check-group-alt', | |
457 | + items: items | |
458 | + } | |
459 | + ] | |
389 | 460 | }); |
390 | 461 | |
391 | - var Sampling = | |
392 | - { | |
393 | - xtype: 'radiogroup', | |
394 | - fieldLabel: 'Time Sampling', | |
395 | - labelWidth: 90, | |
396 | - cls: 'x-check-group-alt', | |
397 | - hidden: !this.isFile, | |
398 | - defaults: {name: 'timesmpl'}, | |
399 | - items: [ | |
400 | - {boxLabel: 'constant', inputValue: 'constant', checked: true}, | |
401 | - { | |
402 | - boxLabel: 'variable <img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', | |
403 | - inputValue: 'variable' | |
404 | - } | |
405 | - ] | |
406 | - }; | |
407 | - | |
408 | - var dayStart = | |
409 | - { | |
410 | - xtype: 'checkbox', | |
411 | - name: 'doy', | |
412 | - hidden: true, | |
413 | - fieldLabel: 'DOY starts from 1', | |
414 | - inputValue: '1' | |
415 | - }; | |
416 | - | |
417 | - var nonStandardFormat = | |
418 | - { | |
419 | - xtype: 'fieldcontainer', | |
420 | - defaultType: 'textfield', | |
421 | - layout: 'anchor', | |
422 | - defaults: | |
423 | - { | |
424 | - layout: '100%', | |
425 | - labelWidth: 150 | |
426 | - }, | |
427 | - id: this.formatId, | |
428 | - hidden: true, | |
429 | - items: [ | |
430 | - { | |
431 | - fieldLabel: 'define time format', | |
432 | - name: 'nonstd', | |
433 | - value: 'Y-m-d H:i:s', | |
434 | - enableKeyEvents: true, | |
435 | - listeners: | |
436 | - { | |
437 | - keyUp: function () { | |
438 | - if (this.getValue().indexOf('z') > 0) { | |
439 | - this.nextSibling().show(); | |
440 | - } | |
441 | - if (this.getValue().indexOf('d') > 0) { | |
442 | - this.nextSibling().hide(); | |
443 | - } | |
444 | - } | |
462 | + sampling = { | |
463 | + xtype: 'radiogroup', | |
464 | + fieldLabel: 'Time Sampling', | |
465 | + labelWidth: 90, | |
466 | + cls: 'x-check-group-alt', | |
467 | + hidden: !this.isFile, | |
468 | + defaults: {name: 'timesmpl'}, | |
469 | + items: [ | |
470 | + { | |
471 | + boxLabel: 'constant', | |
472 | + inputValue: 'constant', | |
473 | + checked: true | |
474 | + }, | |
475 | + { | |
476 | + boxLabel: 'variable <img amda_clicktip="variableSampling" style="vertical-align:bottom" ' + | |
477 | + 'src="js/resources/images/16x16/info_mini.png"', | |
478 | + inputValue: 'variable' | |
479 | + } | |
480 | + ] | |
481 | + }; | |
482 | + | |
483 | + dayStart = { | |
484 | + xtype: 'checkbox', | |
485 | + name: 'doy', | |
486 | + hidden: true, | |
487 | + fieldLabel: 'DOY starts from 1', | |
488 | + inputValue: '1' | |
489 | + }; | |
490 | + | |
491 | + nonStandardFormat = { | |
492 | + xtype: 'fieldcontainer', | |
493 | + defaultType: 'textfield', | |
494 | + layout: 'anchor', | |
495 | + defaults: { | |
496 | + layout: '100%', | |
497 | + labelWidth: 150 | |
498 | + }, | |
499 | + id: this.formatId, | |
500 | + hidden: true, | |
501 | + items: [ | |
502 | + { | |
503 | + fieldLabel: 'define time format', | |
504 | + name: 'nonstd', | |
505 | + value: 'Y-m-d H:i:s', | |
506 | + enableKeyEvents: true, | |
507 | + listeners: { | |
508 | + keyUp: function () { | |
509 | + if (this.getValue().indexOf('z') > 0) { | |
510 | + this.nextSibling().show(); | |
511 | + } | |
512 | + if (this.getValue().indexOf('d') > 0) { | |
513 | + this.nextSibling().hide(); | |
445 | 514 | } |
446 | - }, | |
447 | - dayStart, | |
448 | - { | |
449 | - fieldLabel: 'define max time length', | |
450 | - name: 'timelength', | |
451 | - value: 'auto' | |
452 | - }], | |
453 | - listeners: | |
454 | - { | |
455 | - hide: function () { | |
456 | - this.items.getAt(1).hide(); | |
457 | 515 | } |
458 | 516 | } |
459 | - }; | |
517 | + }, | |
518 | + dayStart, | |
519 | + { | |
520 | + fieldLabel: 'define max time length', | |
521 | + name: 'timelength', | |
522 | + value: 'auto' | |
523 | + } | |
524 | + ], | |
525 | + listeners: { | |
526 | + hide: function () { | |
527 | + this.items.getAt(1).hide(); | |
528 | + } | |
529 | + } | |
530 | + }; | |
460 | 531 | |
461 | - var timeFormat = Ext.create('Ext.form.FieldSet', { | |
532 | + timeFormat = Ext.create('Ext.form.FieldSet', { | |
462 | 533 | id: timeFormatId, |
463 | 534 | title: 'Time Settings', |
464 | 535 | hidden: !this.isFile, |
... | ... | @@ -471,30 +542,34 @@ Ext.define('amdaUI.UploadPanelUI', { |
471 | 542 | defaults: {name: 'timefrmt'}, |
472 | 543 | items: [ |
473 | 544 | { |
474 | - boxLabel: 'standard <img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', | |
545 | + boxLabel: 'standard <img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" ' + | |
546 | + 'src="js/resources/images/16x16/info_mini.png"', | |
475 | 547 | inputValue: 'standard', |
476 | 548 | checked: true |
477 | 549 | }, |
478 | 550 | { |
479 | - boxLabel: 'no <img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', | |
551 | + boxLabel: 'no <img amda_clicktip="userTimeFormat" style="vertical-align:bottom" ' + | |
552 | + 'src="js/resources/images/16x16/info_mini.png"', | |
480 | 553 | inputValue: 'user', |
481 | - listeners: | |
482 | - { | |
483 | - scope: this, | |
484 | - change: function (cb, nv, ov) { | |
485 | - if (nv) | |
486 | - Ext.getCmp(this.formatId).show(); | |
487 | - else | |
488 | - Ext.getCmp(this.formatId).hide(); | |
554 | + listeners: { | |
555 | + scope: this, | |
556 | + change: function (cb, nv) { | |
557 | + if (nv) { | |
558 | + Ext.getCmp(this.formatId).show(); | |
559 | + } else { | |
560 | + Ext.getCmp(this.formatId).hide(); | |
489 | 561 | } |
490 | 562 | } |
491 | - }] | |
563 | + } | |
564 | + } | |
565 | + ] | |
492 | 566 | }, |
493 | 567 | nonStandardFormat, |
494 | - Sampling] | |
568 | + sampling | |
569 | + ] | |
495 | 570 | }); |
496 | 571 | |
497 | - var localFile = Ext.create('Ext.form.Panel', { | |
572 | + localFile = Ext.create('Ext.form.Panel', { | |
498 | 573 | id: this.localUploadId, |
499 | 574 | fileUpload: true, |
500 | 575 | hideLabels: true, |
... | ... | @@ -506,23 +581,24 @@ Ext.define('amdaUI.UploadPanelUI', { |
506 | 581 | width: 300, |
507 | 582 | name: localUploadName, |
508 | 583 | buttonText: 'Browse', |
509 | - listeners: | |
510 | - { | |
511 | - scope: this, | |
512 | - change: function (field, value, e) { | |
513 | - this.updateFormat(value); | |
514 | - } | |
584 | + listeners: { | |
585 | + scope: this, | |
586 | + change: function (field, value) { | |
587 | + this.updateFormat(value); | |
515 | 588 | } |
589 | + } | |
516 | 590 | }, |
517 | 591 | { |
518 | - // it is common setting for Local and Remote files | |
592 | + // It is common setting for Local and Remote files | |
519 | 593 | xtype: 'hiddenfield', |
520 | 594 | name: 'MAX_FILE_SIZE', |
521 | - value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB | |
522 | - }] | |
595 | + // Max uploaded file size: 30MB | |
596 | + value: myDesktopApp.MAX_UPLOADED_FILE_SIZE | |
597 | + } | |
598 | + ] | |
523 | 599 | }); |
524 | 600 | |
525 | - var remoteFile = Ext.create('Ext.form.Panel', { | |
601 | + remoteFile = Ext.create('Ext.form.Panel', { | |
526 | 602 | id: this.remoteUploadId, |
527 | 603 | hideLabels: true, |
528 | 604 | autoHeight: true, |
... | ... | @@ -535,17 +611,17 @@ Ext.define('amdaUI.UploadPanelUI', { |
535 | 611 | name: remoteUploadName, |
536 | 612 | emptyText: 'Enter Remote File URL (http or ftp)', |
537 | 613 | width: 310, |
538 | - listeners: | |
539 | - { | |
540 | - scope: this, | |
541 | - change: function (field, value, e) { | |
542 | - this.updateFormat(value); | |
543 | - } | |
614 | + listeners: { | |
615 | + scope: this, | |
616 | + change: function (field, value) { | |
617 | + this.updateFormat(value); | |
544 | 618 | } |
545 | - }] | |
619 | + } | |
620 | + } | |
621 | + ] | |
546 | 622 | }); |
547 | 623 | |
548 | - var uploadForm = Ext.create('Ext.form.FieldSet', { | |
624 | + uploadForm = Ext.create('Ext.form.FieldSet', { | |
549 | 625 | title: 'File Source', |
550 | 626 | items: [ |
551 | 627 | { |
... | ... | @@ -553,84 +629,95 @@ Ext.define('amdaUI.UploadPanelUI', { |
553 | 629 | cls: 'x-check-group-alt', |
554 | 630 | items: [ |
555 | 631 | { |
556 | - boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true, | |
557 | - listeners: | |
558 | - { | |
559 | - scope: this, | |
560 | - change: function (cb, nv, ov) { | |
561 | - if (nv == ov) return; | |
562 | - var local = Ext.getCmp(this.localUploadId); | |
563 | - var remote = Ext.getCmp(this.remoteUploadId); | |
564 | - if (nv) { | |
565 | - remote.hide(); | |
566 | - local.show(); | |
567 | - } | |
568 | - else { | |
569 | - local.hide(); | |
570 | - remote.show(); | |
571 | - } | |
632 | + boxLabel: 'Local', | |
633 | + name: 'filesrc', | |
634 | + inputValue: 'LOCAL', | |
635 | + checked: true, | |
636 | + listeners: { | |
637 | + scope: this, | |
638 | + change: function (cb, nv, ov) { | |
639 | + if (nv === ov) { | |
640 | + return; | |
641 | + } | |
642 | + local = Ext.getCmp(this.localUploadId); | |
643 | + remote = Ext.getCmp(this.remoteUploadId); | |
644 | + if (nv) { | |
645 | + remote.hide(); | |
646 | + local.show(); | |
647 | + } else { | |
648 | + local.hide(); | |
649 | + remote.show(); | |
572 | 650 | } |
573 | 651 | } |
652 | + } | |
574 | 653 | }, |
575 | - {boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}] | |
576 | - }] | |
654 | + { | |
655 | + boxLabel: 'URL', | |
656 | + name: 'filesrc', | |
657 | + inputValue: 'URL' | |
658 | + } | |
659 | + ] | |
660 | + } | |
661 | + ] | |
577 | 662 | }); |
578 | 663 | |
579 | - var myConf = | |
580 | - { | |
581 | - title: title, | |
582 | - layout: {type: 'vbox', align: 'stretch'}, | |
583 | - bodyStyle: {background: '#dfe8f6'}, | |
584 | - items: [ | |
585 | - uploadForm, | |
586 | - localFile, | |
587 | - remoteFile, | |
588 | - fileFormat, | |
589 | - timeFormat, | |
590 | - { | |
591 | - xtype: 'hidden', | |
592 | - name: 'sampData', | |
593 | - value: null | |
664 | + myConf = { | |
665 | + title: title, | |
666 | + layout: { | |
667 | + type: 'vbox', | |
668 | + align: 'stretch' | |
669 | + }, | |
670 | + bodyStyle: {background: '#dfe8f6'}, | |
671 | + items: [ | |
672 | + uploadForm, | |
673 | + localFile, | |
674 | + remoteFile, | |
675 | + fileFormat, | |
676 | + timeFormat, | |
677 | + { | |
678 | + xtype: 'hidden', | |
679 | + name: 'sampData', | |
680 | + value: null | |
681 | + }, | |
682 | + { | |
683 | + xtype: 'hidden', | |
684 | + name: 'sampFileName', | |
685 | + value: null | |
686 | + } | |
687 | + ], | |
688 | + buttons: [ | |
689 | + { | |
690 | + text: 'Upload', | |
691 | + handler: function () { | |
692 | + this.postUpload(); | |
594 | 693 | }, |
595 | - { | |
596 | - xtype: 'hidden', | |
597 | - name: 'sampFileName', | |
598 | - value: null, | |
694 | + scope: this | |
695 | + }, | |
696 | + { | |
697 | + text: 'Reset', | |
698 | + handler: function () { | |
699 | + this.up('form').getForm().reset(); | |
599 | 700 | } |
600 | - ], | |
601 | - buttons: [ | |
602 | - { | |
603 | - text: 'Upload', | |
604 | - handler: function () { | |
605 | - this.postUpload(); | |
606 | - }, | |
607 | - scope: this | |
608 | - }, | |
609 | - { | |
610 | - text: 'Reset', | |
611 | - handler: function () { | |
612 | - this.up('form').getForm().reset(); | |
613 | - } | |
614 | - }], | |
615 | - plugins: [{ptype: 'remoteSearchPlugin'}], | |
616 | - listeners: | |
617 | - { | |
618 | - click: | |
619 | - { | |
620 | - element: 'el', | |
621 | - fn: function (e, t) { | |
622 | - var me = t, | |
623 | - text = me.getAttribute('amda_clicktip'); | |
624 | - if (text) { | |
625 | - e.preventDefault(); | |
626 | - AmdaAction.getInfo({name: text}, function (res, e) { | |
627 | - if (res.success) myDesktopApp.infoMsg(res.result); | |
628 | - }); | |
629 | - } | |
701 | + } | |
702 | + ], | |
703 | + plugins: [{ptype: 'remoteSearchPlugin'}], | |
704 | + listeners: { | |
705 | + click: { | |
706 | + element: 'el', | |
707 | + fn: function (e, t) { | |
708 | + var text = t.getAttribute('amda_clicktip'); | |
709 | + if (text) { | |
710 | + e.preventDefault(); | |
711 | + AmdaAction.getInfo({name: text}, function (res) { | |
712 | + if (res.success) { | |
713 | + myDesktopApp.infoMsg(res.result); | |
630 | 714 | } |
631 | - } | |
715 | + }); | |
716 | + } | |
632 | 717 | } |
633 | - }; | |
718 | + } | |
719 | + } | |
720 | + }; | |
634 | 721 | |
635 | 722 | Ext.apply(this, Ext.apply(arguments, myConf)); |
636 | 723 | } | ... | ... |