Commit bb3d4334d78887940c728f5663ca384984e7c2a4

Authored by Nathanaël Jourdane
1 parent f178b4df

auto code cleanup (fix indents)

Showing 1 changed file with 627 additions and 625 deletions   Show diff stats
js/app/views/UploadPanelUI.js
... ... @@ -2,634 +2,636 @@
2 2 * Project  : AMDA-NG
3 3 * Name : UploadUI.js
4 4 * @class amdaUI.UploadUI
5   - * @extends Ext.form.Panel
  5 + * @extends Ext.form.Panel
6 6 * @brief Upload Panel UI definition (View)
7   - * @author Elena
8   - * @version $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $
  7 + * @author Elena
  8 + * @version $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $
9 9 */
10 10  
11 11 Ext.define('amdaUI.UploadPanelUI', {
12   - extend: 'Ext.form.Panel',
13   - alias: 'widget.panelUpload',
14   -
15   - requires : [
16   - 'amdaUI.RemoteSearchPlugin'
17   - ],
18   -
19   - isFile : true,
20   - isTimeTable : false,
21   - tmpNode : null,
22   -
23   - constructor: function(config)
24   - {
25   - this.init(config);
26   - this.callParent(arguments);
27   - },
28   -
29   - /*
30   - * create MyData linked node and edit in module MyData
31   - * update myDataParams info if needed
32   - */
33   - getObjectCallback : function(result,remoteEvent)
34   - {
35   - var t = remoteEvent.getTransaction();
36   - if (result && !result.error)
37   - {
38   - // set parameter into node
39   - var me = this;
40   - myDesktopApp.getLoadedModule(this.tmpNode.get('moduleId'), true, function (module){
41   - // myData
42   - if (me.tmpNode.get('nodeType') == amdaModel.MyDataParamNode.nodeType)
43   - {
44   - var linkedFile = Ext.create('amdaModel.MyDataNode', {leaf : true, text : me.tmpNode.get('text')});
45   -
46   - linkedFile.create(result.mask, result.description, result.maskDesc);
47   - linkedFile.updateMyDataParam(result.mask,result.maskDesc);
48   -
49   - if (!linkedFile.get('id'))
50   - linkedFile.set('id',me.tmpNode.get('text'));
51   -
52   - var paramObj = Ext.create(linkedFile.get('objectDataModel'), result);
53   - linkedFile.set('object',paramObj);
54   - me.tmpNode.set('fileObject',paramObj);
55   - }
56   - else
57   - {
58   - // Time Table or Catalog
59   - var paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result);
60   -
61   - paramObj.set('fromPlugin',true);
62   - if (result.intervals)
63   - {
64   - paramObj.set('intervals',result.intervals);
65   - paramObj.set('nbIntervals',result.intervals.length);
66   - }
67   - me.tmpNode.set('object',paramObj);
68   - }
69   - if (module)
70   - {
71   - module.setLinkedNode(me.tmpNode);
72   - module.linkedNode.editInModule();
73   - }
74   - });
75   - }
76   - else
77   - {
78   - // EXCEPTION : parameter not found !
79   - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '"+this.tmpNode.get('text')+"' found!");
80   - }
81   - loadMask.hide();
82   - },
83   -
84   -/*
85   -* form validation
86   -* TODO markInvalid()?
87   -*/
88   - validate : function()
89   - {
90   - var values = this.getForm().getValues();
91   -
92   - if (values['filesrc'] == 'LOCAL')
93   - {
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   - {
100   - myDesktopApp.warningMsg("Select File to Upload");
101   - return false;
102   - }
103   - }
104   - else
105   - {
106   - if (!values['remoteFile'] && !values['remoteTT'] && !values['remoteCat'])
107   - {
108   - myDesktopApp.warningMsg("Select File to Upload");
109   - return false;
110   - }
111   - }
112   - return true;
113   - },
114   -
115   -
116   - //TODO proper parsing
117   - updateFormat: function(value)
118   - {
119   - 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;
141   -
142   - // auto define format in some special cases
143   - //TODO name without extention => ASCII?
144   - if (arrayOfStr.length == 1) auto_format = 'ASCII';
145   - else
146   - {
147   - var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase();
148   - if (suffix == 'gz')
149   - suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz';
150   -
151   - switch (suffix)
152   - {
153   - case 'cdf' : auto_format = 'CDF'; break;
154   - case 'cef.gz' :
155   - case 'cef' : auto_format = 'CEF'; break;
156   - case 'xml' : auto_format = 'VOT';
157   - case 'vot' : auto_format = 'VOT'; break;
158   - case 'nc' : auto_format = 'NC'; break;
159   - case 'asc' :
160   - case 'txt' :
161   - default : auto_format = 'ASCII';
162   - }
163   - }
164   - // 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   -
173   - radios.setValue(user_format_obj);
174   - },
175   -
176   - /*
177   - *
178   - */
179   - forceUpload : function (url,format,onFinish)
180   - {
181   - var me = this;
182   - var re = /http:\/\/127.0.0.1:/;
183   - var isRemoteUrl = !re.test(url);
184   -
185   - switch (format)
186   - {
187   - case 'votable' :
188   - this.getForm().findField('filefrmt').setValue('VOT');
189   - break;
190   - case 'cdf' :
191   - this.getForm().findField('filefrmt').setValue('CDF');
192   - break;
193   - default :
194   - myDesktopApp.errorMsg('Not supported data receive from SAMP');
195   - return;
196   - }
197   -
198   - if (!isRemoteUrl) {
199   - myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
200   - var onError = function(error) {
201   - if (error)
202   - myDesktopApp.errorMsg(error);
203   - else
204   - myDesktopApp.errorMsg("Cannot load data from this SAMP notification");
205   - if (onFinish)
206   - onFinish();
207   - };
208   - var onLoad = function(data) {
209   - //Fake value for validation
210   - Ext.form.field.File.superclass.setValue.call(me.getForm().findField('localFileName'), 'samp.vot');
211   - me.getForm().findField('filesrc').setValue('LOCAL');
212   - //Add data related to the samp notification
213   - me.getForm().findField('sampFileName').setValue('samp.vot');
214   - me.getForm().findField('sampData').setValue(data);
215   - var onFinishAll = function() {
216   - me.getForm().findField('sampFileName').reset();
217   - me.getForm().findField('sampData').reset();
218   - if (onFinish)
219   - onFinish();
220   - }
221   - me.postUpload(onFinishAll);
222   - };
223   - module.loadFile(url,onLoad,onError);
224   - });
225   - return;
226   - }
227   -
228   - this.getForm().findField('filesrc').setValue('URL');
229   - this.getForm().findField('remoteFile').setValue(url);
230   - this.postUpload(onFinish);
231   - },
232   -
233   - /*
234   - *
235   - */
236   - postUpload : function(onFinish)
237   - {
238   - // 'global' form containing 'partial' forms
239   - var form = this.getForm();
240   -
241   - // special validation
242   - if(this.validate())
243   - {
244   - loadMask.show();
245   - form.submit({
246   - scope: this,
247   - url: 'php/uploadFile.php',
248   - waitMsg: 'Uploading your file...',
249   - success: function(form, o)
250   - {
251   - if (onFinish)
252   - onFinish();
253   - this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file});
254   - AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this);
255   - loadMask.hide();
256   - },
257   - failure: function(form, o)
258   - {
259   - if (onFinish)
260   - onFinish();
261   - loadMask.hide();
262   - myDesktopApp.errorMsg('Error '+o.result.error);
263   - }
264   - });
265   - }
266   - },
267   -
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 = [
281   - { boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true,
282   - listeners:
283   - {
284   - change: function (cb, nv, ov) {
285   - if (nv) Ext.getCmp('tf').show();
286   - else Ext.getCmp('tf').hide();
287   - }
288   - }
289   - },
290   - { boxLabel: 'netCDF&nbsp;<img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'NC' },
291   - { boxLabel: 'CDF&nbsp;<img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'CDF' },
292   - // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' },
293   - { boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT' }];
294   - var timeFormatId = 'tf';
295   - this.formatId = 'nsf';
296   - this.localUploadId = 'form-uploadfile';
297   - var localUploadName ='localFileName';
298   - var remoteUploadName ='remoteFile';
299   - this.remoteUploadId = 'form-uploadurl';
300   - this.nodeType = 'amdaModel.MyDataParamNode';
301   - //TODO load XML
302   - var store = Ext.create('Ext.data.Store', {
303   - fields: ['value', 'name'],
304   - data : [
305   - {"value":"ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name":"CDAWEB/FTP"}/*,
  12 + extend: 'Ext.form.Panel',
  13 + alias: 'widget.panelUpload',
  14 +
  15 + requires: [
  16 + 'amdaUI.RemoteSearchPlugin'
  17 + ],
  18 +
  19 + isFile: true,
  20 + isTimeTable: false,
  21 + tmpNode: null,
  22 +
  23 + constructor: function (config) {
  24 + this.init(config);
  25 + this.callParent(arguments);
  26 + },
  27 +
  28 + /*
  29 + * create MyData linked node and edit in module MyData
  30 + * update myDataParams info if needed
  31 + */
  32 + getObjectCallback: function (result, remoteEvent) {
  33 + var t = remoteEvent.getTransaction();
  34 + if (result && !result.error) {
  35 + // set parameter into node
  36 + var me = this;
  37 + 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 +
  42 + linkedFile.create(result.mask, result.description, result.maskDesc);
  43 + linkedFile.updateMyDataParam(result.mask, result.maskDesc);
  44 +
  45 + if (!linkedFile.get('id'))
  46 + linkedFile.set('id', me.tmpNode.get('text'));
  47 +
  48 + var paramObj = Ext.create(linkedFile.get('objectDataModel'), result);
  49 + linkedFile.set('object', paramObj);
  50 + me.tmpNode.set('fileObject', paramObj);
  51 + }
  52 + else {
  53 + // Time Table or Catalog
  54 + var paramObj = Ext.create(me.tmpNode.get('objectDataModel'), result);
  55 +
  56 + paramObj.set('fromPlugin', true);
  57 + if (result.intervals) {
  58 + paramObj.set('intervals', result.intervals);
  59 + paramObj.set('nbIntervals', result.intervals.length);
  60 + }
  61 + me.tmpNode.set('object', paramObj);
  62 + }
  63 + if (module) {
  64 + module.setLinkedNode(me.tmpNode);
  65 + module.linkedNode.editInModule();
  66 + }
  67 + });
  68 + }
  69 + else {
  70 + // EXCEPTION : parameter not found !
  71 + myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" + this.tmpNode.get('text') + "' found!");
  72 + }
  73 + loadMask.hide();
  74 + },
  75 +
  76 + /*
  77 + * form validation
  78 + * TODO markInvalid()?
  79 + */
  80 + 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();
  87 +
  88 + 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");
  96 + return false;
  97 + }
  98 + }
  99 + return true;
  100 + },
  101 +
  102 +
  103 + //TODO proper parsing
  104 + updateFormat: function (value) {
  105 + var arrayOfStr = value.split('.');
  106 + //TODO use down method?
  107 + 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;
  121 + }
  122 +
  123 + var auto_format = user_format;
  124 +
  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')
  131 + suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz';
  132 +
  133 + switch (suffix) {
  134 + case 'cdf' :
  135 + auto_format = 'CDF';
  136 + break;
  137 + case 'cef.gz' :
  138 + case 'cef' :
  139 + auto_format = 'CEF';
  140 + break;
  141 + case 'xml' :
  142 + auto_format = 'VOT';
  143 + case 'vot' :
  144 + auto_format = 'VOT';
  145 + break;
  146 + case 'nc' :
  147 + auto_format = 'NC';
  148 + break;
  149 + case 'asc' :
  150 + case 'txt' :
  151 + default :
  152 + auto_format = 'ASCII';
  153 + }
  154 + }
  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;
  162 + }
  163 +
  164 + radios.setValue(user_format_obj);
  165 + },
  166 +
  167 + /*
  168 + *
  169 + */
  170 + forceUpload: function (url, format, onFinish) {
  171 + var me = this;
  172 + var re = /http:\/\/127.0.0.1:/;
  173 + var isRemoteUrl = !re.test(url);
  174 +
  175 + switch (format) {
  176 + case 'votable' :
  177 + this.getForm().findField('filefrmt').setValue('VOT');
  178 + break;
  179 + case 'cdf' :
  180 + this.getForm().findField('filefrmt').setValue('CDF');
  181 + break;
  182 + default :
  183 + myDesktopApp.errorMsg('Not supported data receive from SAMP');
  184 + return;
  185 + }
  186 +
  187 + if (!isRemoteUrl) {
  188 + myDesktopApp.getLoadedModule(myDesktopApp.dynamicModules.interop.id, true, function (module) {
  189 + var onError = function (error) {
  190 + if (error)
  191 + myDesktopApp.errorMsg(error);
  192 + else
  193 + myDesktopApp.errorMsg("Cannot load data from this SAMP notification");
  194 + if (onFinish)
  195 + onFinish();
  196 + };
  197 + var onLoad = function (data) {
  198 + //Fake value for validation
  199 + Ext.form.field.File.superclass.setValue.call(me.getForm().findField('localFileName'), 'samp.vot');
  200 + me.getForm().findField('filesrc').setValue('LOCAL');
  201 + //Add data related to the samp notification
  202 + me.getForm().findField('sampFileName').setValue('samp.vot');
  203 + me.getForm().findField('sampData').setValue(data);
  204 + var onFinishAll = function () {
  205 + me.getForm().findField('sampFileName').reset();
  206 + me.getForm().findField('sampData').reset();
  207 + if (onFinish)
  208 + onFinish();
  209 + };
  210 + me.postUpload(onFinishAll);
  211 + };
  212 + module.loadFile(url, onLoad, onError);
  213 + });
  214 + return;
  215 + }
  216 +
  217 + this.getForm().findField('filesrc').setValue('URL');
  218 + this.getForm().findField('remoteFile').setValue(url);
  219 + this.postUpload(onFinish);
  220 + },
  221 +
  222 + /*
  223 + *
  224 + */
  225 + postUpload: function (onFinish) {
  226 + // 'global' form containing 'partial' forms
  227 + var form = this.getForm();
  228 +
  229 + // special validation
  230 + if (this.validate()) {
  231 + loadMask.show();
  232 + form.submit({
  233 + scope: this,
  234 + url: 'php/uploadFile.php',
  235 + waitMsg: 'Uploading your file...',
  236 + success: function (form, o) {
  237 + if (onFinish)
  238 + 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);
  241 + loadMask.hide();
  242 + },
  243 + failure: function (form, o) {
  244 + if (onFinish)
  245 + onFinish();
  246 + loadMask.hide();
  247 + myDesktopApp.errorMsg('Error ' + o.result.error);
  248 + }
  249 + });
  250 + }
  251 + },
  252 +
  253 + /*
  254 + * panel config
  255 + */
  256 + init: function (config) {
  257 + this.isFile = config.panelType == 'file' ? true : false;
  258 + this.isTimeTable = config.panelType == 'timetable' ? true : false;
  259 +
  260 + // file / time table / catalog settings
  261 + if (this.isFile) {
  262 + var title = 'File';
  263 + var items = [
  264 + {
  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();
  271 + }
  272 + }
  273 + },
  274 + {
  275 + boxLabel: 'netCDF&nbsp;<img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
  276 + name: 'filefrmt',
  277 + inputValue: 'NC'
  278 + },
  279 + {
  280 + boxLabel: 'CDF&nbsp;<img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
  281 + name: 'filefrmt',
  282 + inputValue: 'CDF'
  283 + },
  284 + // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' },
  285 + {boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT'}];
  286 + var timeFormatId = 'tf';
  287 + this.formatId = 'nsf';
  288 + this.localUploadId = 'form-uploadfile';
  289 + var localUploadName = 'localFileName';
  290 + var remoteUploadName = 'remoteFile';
  291 + this.remoteUploadId = 'form-uploadurl';
  292 + this.nodeType = 'amdaModel.MyDataParamNode';
  293 + //TODO load XML
  294 + var store = Ext.create('Ext.data.Store', {
  295 + fields: ['value', 'name'],
  296 + data: [
  297 + {"value": "ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name": "CDAWEB/FTP"}/*,
306 298 {"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&nbsp;<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   - });
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   -
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',
364   - 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';
385   -
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
394   - }]
395   - });
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&nbsp;<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   - {
422   - xtype: 'fieldcontainer',
423   - defaultType: 'textfield',
424   - layout: 'anchor',
425   - defaults:
426   - {
427   - layout: '100%',
428   - labelWidth : 150
429   - },
430   - id : this.formatId,
431   - hidden : true,
432   - items: [
433   - {
434   - fieldLabel : 'define time format',
435   - name : 'nonstd',
436   - value: 'Y-m-d H:i:s',
437   - enableKeyEvents: true,
438   - listeners :
439   - {
440   - keyUp : function() {
441   - if (this.getValue().indexOf('z') > 0) {
442   - this.nextSibling().show();
443   - }
444   - if (this.getValue().indexOf('d') > 0) {
445   - this.nextSibling().hide();
446   - }
447   - }
448   - }
449   - },
450   - dayStart,
451   - {
452   - fieldLabel : 'define max time length',
453   - name : 'timelength',
454   - value: 'auto'
455   - }],
456   - listeners :
457   - {
458   - hide : function() {
459   - this.items.getAt(1).hide();
460   - }
461   - }
462   - };
463   -
464   - var timeFormat = Ext.create('Ext.form.FieldSet', {
465   - id: timeFormatId,
466   - title: 'Time Settings',
467   - hidden : !this.isFile,
468   - items : [
469   - {
470   - xtype: 'radiogroup',
471   - fieldLabel: 'Time Format',
472   - labelWidth: 90,
473   - cls: 'x-check-group-alt',
474   - defaults : { name : 'timefrmt'},
475   - items: [
476   - { boxLabel: 'standard&nbsp;<img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true},
477   - { boxLabel: 'no&nbsp;<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 ]
492   - });
493   -
494   - var localFile = Ext.create('Ext.form.Panel', {
495   - id: this.localUploadId,
496   - fileUpload: true,
497   - hideLabels: true,
498   - frame: true,
499   - items: [
500   - {
501   - xtype: 'fileuploadfield',
502   - emptyText: 'Select Your File',
503   - width: 300,
504   - name: localUploadName,
505   - buttonText: 'Browse',
506   - listeners:
507   - {
508   - scope : this,
509   - change: function (field, value, e) {
510   - this.updateFormat(value);
511   - }
512   - }
513   - },
514   - {
515   - // it is common setting for Local and Remote files
516   - xtype : 'hiddenfield',
517   - name: 'MAX_FILE_SIZE',
518   - value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB
519   - }]
520   - });
521   -
522   - var remoteFile = Ext.create('Ext.form.Panel', {
523   - id: this.remoteUploadId,
524   - hideLabels: true,
525   - autoHeight: true,
526   - frame: true,
527   - hidden : true,
528   - items: [
529   - fieldcontainer,
530   - {
531   - xtype : 'textfield',
532   - name : remoteUploadName,
533   - emptyText: 'Enter Remote File URL (http or ftp)',
534   - width: 310,
535   - listeners:
536   - {
537   - scope : this,
538   - change: function (field, value, e) {
539   - this.updateFormat(value);
540   - }
541   - }
542   - }]
543   - });
544   -
545   - var uploadForm = Ext.create('Ext.form.FieldSet',{
546   - title: 'File Source',
547   - items : [
548   - {
549   - xtype: 'radiogroup',
550   - cls: 'x-check-group-alt',
551   - items: [
552   - { boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true,
553   - listeners:
554   - {
555   - scope : this,
556   - change: function (cb, nv, ov) {
557   - if (nv == ov) return;
558   - var local = Ext.getCmp(this.localUploadId);
559   - var remote = Ext.getCmp(this.remoteUploadId);
560   - if (nv) {
561   - remote.hide();
562   - local.show();
563   - }
564   - else {
565   - local.hide();
566   - remote.show();
567   - }
568   - }
569   - }
570   - },
571   - { boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'} ]
572   - }]
573   - });
574   -
575   - var myConf =
576   - {
577   - title : title,
578   - layout: {type: 'vbox', align: 'stretch'},
579   - 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   - {
599   - text: 'Upload',
600   - handler: function()
601   - {
602   - this.postUpload();
603   - },
604   - scope : this
605   - },
606   - {
607   - text: 'Reset',
608   - handler: function(){
609   - this.up('form').getForm().reset();
610   - }
611   - }],
612   - plugins: [{ptype: 'remoteSearchPlugin'}],
613   - listeners:
614   - {
615   - click:
616   - {
617   - element: 'el',
618   - fn: function(e,t) {
619   - var me = t,
620   - text = me.getAttribute('amda_clicktip');
621   - if (text)
622   - {
623   - e.preventDefault();
624   - AmdaAction.getInfo({name : text}, function(res,e) {
625   - if (res.success) myDesktopApp.infoMsg(res.result);
626   - });
627   - }
628   - }
629   - }
630   - }
631   - };
632   -
633   - Ext.apply (this, Ext.apply(arguments, myConf));
634   - }
  299 + });
  300 + }
  301 + else if (this.isTimeTable) {
  302 + var title = 'Time Table';
  303 + var items = [
  304 + {
  305 + boxLabel: 'ASCII&nbsp;<img amda_clicktip="ttTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
  306 + name: 'ttfrmt',
  307 + inputValue: 'ASCII',
  308 + checked: true
  309 + },
  310 + {boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'}
  311 + ];
  312 + var timeFormatId = 'tf_tt';
  313 + this.formatId = 'nsf_tt';
  314 + this.localUploadId = 'form-uploadtt';
  315 + var localUploadName = 'localTTName';
  316 + var remoteUploadName = 'remoteTT';
  317 + this.remoteUploadId = 'form-uploadtturl';
  318 + this.nodeType = 'amdaModel.TimeTableNode';
  319 + //TODO load XML
  320 + var store = Ext.create('Ext.data.Store', {
  321 + fields: ['value', 'name'],
  322 + data: []
  323 + });
  324 + }
  325 + else {
  326 + var title = 'Catalog';
  327 + var items = [
  328 + {boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true}];
  329 +
  330 + var timeFormatId = 'tf_cat';
  331 + this.formatId = 'nsf_cat';
  332 + this.localUploadId = 'form-uploadcat';
  333 + var localUploadName = 'localCatName';
  334 + var remoteUploadName = 'remoteCat';
  335 +
  336 + this.remoteUploadId = 'form-uploadcaturl';
  337 + this.nodeType = 'amdaModel.CatalogNode';
  338 + //TODO load XML
  339 + var store = Ext.create('Ext.data.Store', {
  340 + fields: ['value', 'name'],
  341 + data: []
  342 + });
  343 + }
  344 +
  345 + var combo = Ext.create('Ext.form.ComboBox', {
  346 + flex: 4,
  347 + store: store,
  348 + emptyText: 'Enter Remote Site URL (ftp)',
  349 + queryMode: 'local',
  350 + displayField: 'name',
  351 + valueField: 'value'
  352 + });
  353 +
  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");
  372 + }
  373 + }]
  374 + };
  375 +
  376 + if (this.isFile) var radioId = 'filefrmt';
  377 + else if (this.isTimeTable) var radioId = 'ttfrmt';
  378 + else var radioId = 'catfrmt';
  379 +
  380 + var fileFormat = Ext.create('Ext.form.FieldSet', {
  381 + title: 'File Format',
  382 + items: [{
  383 + xtype: 'radiogroup',
  384 + id: radioId,
  385 + columns: 3,
  386 + cls: 'x-check-group-alt',
  387 + items: items
  388 + }]
  389 + });
  390 +
  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&nbsp;<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 + }
  445 + }
  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 + }
  458 + }
  459 + };
  460 +
  461 + var timeFormat = Ext.create('Ext.form.FieldSet', {
  462 + id: timeFormatId,
  463 + title: 'Time Settings',
  464 + hidden: !this.isFile,
  465 + items: [
  466 + {
  467 + xtype: 'radiogroup',
  468 + fieldLabel: 'Time Format',
  469 + labelWidth: 90,
  470 + cls: 'x-check-group-alt',
  471 + defaults: {name: 'timefrmt'},
  472 + items: [
  473 + {
  474 + boxLabel: 'standard&nbsp;<img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
  475 + inputValue: 'standard',
  476 + checked: true
  477 + },
  478 + {
  479 + boxLabel: 'no&nbsp;<img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"',
  480 + 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();
  489 + }
  490 + }
  491 + }]
  492 + },
  493 + nonStandardFormat,
  494 + Sampling]
  495 + });
  496 +
  497 + var localFile = Ext.create('Ext.form.Panel', {
  498 + id: this.localUploadId,
  499 + fileUpload: true,
  500 + hideLabels: true,
  501 + frame: true,
  502 + items: [
  503 + {
  504 + xtype: 'fileuploadfield',
  505 + emptyText: 'Select Your File',
  506 + width: 300,
  507 + name: localUploadName,
  508 + buttonText: 'Browse',
  509 + listeners:
  510 + {
  511 + scope: this,
  512 + change: function (field, value, e) {
  513 + this.updateFormat(value);
  514 + }
  515 + }
  516 + },
  517 + {
  518 + // it is common setting for Local and Remote files
  519 + xtype: 'hiddenfield',
  520 + name: 'MAX_FILE_SIZE',
  521 + value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB
  522 + }]
  523 + });
  524 +
  525 + var remoteFile = Ext.create('Ext.form.Panel', {
  526 + id: this.remoteUploadId,
  527 + hideLabels: true,
  528 + autoHeight: true,
  529 + frame: true,
  530 + hidden: true,
  531 + items: [
  532 + fieldcontainer,
  533 + {
  534 + xtype: 'textfield',
  535 + name: remoteUploadName,
  536 + emptyText: 'Enter Remote File URL (http or ftp)',
  537 + width: 310,
  538 + listeners:
  539 + {
  540 + scope: this,
  541 + change: function (field, value, e) {
  542 + this.updateFormat(value);
  543 + }
  544 + }
  545 + }]
  546 + });
  547 +
  548 + var uploadForm = Ext.create('Ext.form.FieldSet', {
  549 + title: 'File Source',
  550 + items: [
  551 + {
  552 + xtype: 'radiogroup',
  553 + cls: 'x-check-group-alt',
  554 + items: [
  555 + {
  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 + }
  572 + }
  573 + }
  574 + },
  575 + {boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}]
  576 + }]
  577 + });
  578 +
  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
  594 + },
  595 + {
  596 + xtype: 'hidden',
  597 + name: 'sampFileName',
  598 + value: null,
  599 + }
  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 + }
  630 + }
  631 + }
  632 + }
  633 + };
  634 +
  635 + Ext.apply(this, Ext.apply(arguments, myConf));
  636 + }
635 637 });
... ...