Commit 901ba3f34364b1d8b6be8aff28dccde97220b5a0
1 parent
08eee02f
Exists in
master
and in
112 other branches
upload catalog
Showing
9 changed files
with
1015 additions
and
816 deletions
Show diff stats
js/app/views/CatalogUI.js
@@ -195,11 +195,11 @@ Ext.define('amdaUI.CatalogUI', { | @@ -195,11 +195,11 @@ Ext.define('amdaUI.CatalogUI', { | ||
195 | this.status = null; | 195 | this.status = null; |
196 | 196 | ||
197 | if (this.object.get('fromPlugin')) | 197 | if (this.object.get('fromPlugin')) |
198 | - { | 198 | + { |
199 | if (this.object.get('objFormat') && this.object.get('objFormat') != '') | 199 | if (this.object.get('objFormat') && this.object.get('objFormat') != '') |
200 | { | 200 | { |
201 | //From uploaded file | 201 | //From uploaded file |
202 | - //AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.onAfterInit, this); | 202 | + AmdaAction.initTTCacheFromUploadedFile(this.object.get('objName'), this.object.get('objFormat'), this.isCatalog, this.onAfterInit, this); |
203 | } | 203 | } |
204 | else | 204 | else |
205 | { | 205 | { |
js/app/views/TimeTableUI.js
@@ -47,7 +47,8 @@ Ext.define('amdaUI.TimeTableUI', { | @@ -47,7 +47,8 @@ Ext.define('amdaUI.TimeTableUI', { | ||
47 | this.loadObject(); | 47 | this.loadObject(); |
48 | 48 | ||
49 | // show the default duration column | 49 | // show the default duration column |
50 | - this.TTGrid.headerCt.getGridColumns() | 50 | + this.TTGrid.headerCt.getGridColumns(); |
51 | + | ||
51 | Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){ | 52 | Ext.Array.each(this.TTGrid.headerCt.getGridColumns(), function(item,index,all){ |
52 | // if item is the default duration column | 53 | // if item is the default duration column |
53 | if ( item.id == amdaUI.TimeTableUI.COL_TO_HIDE+'2' ) { | 54 | if ( item.id == amdaUI.TimeTableUI.COL_TO_HIDE+'2' ) { |
js/app/views/UploadPanelUI.js
@@ -2,527 +2,594 @@ | @@ -2,527 +2,594 @@ | ||
2 | * Project : AMDA-NG | 2 | * Project : AMDA-NG |
3 | * Name : UploadUI.js | 3 | * Name : UploadUI.js |
4 | * @class amdaUI.UploadUI | 4 | * @class amdaUI.UploadUI |
5 | - * @extends Ext.panel.Panel | 5 | + * @extends Ext.form.Panel |
6 | * @brief Upload Panel UI definition (View) | 6 | * @brief Upload Panel UI definition (View) |
7 | * @author Elena | 7 | * @author Elena |
8 | * @version $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $ | 8 | * @version $Id: UploadPanelUI.js 2831 2015-03-26 10:33:42Z elena $ |
9 | */ | 9 | */ |
10 | 10 | ||
11 | Ext.define('amdaUI.UploadPanelUI', { | 11 | Ext.define('amdaUI.UploadPanelUI', { |
12 | - extend: 'Ext.form.Panel', | ||
13 | - alias: 'widget.panelUpload', | ||
14 | - | ||
15 | - requires : [ | ||
16 | - 'amdaUI.RemoteSearchPlugin' | ||
17 | - ], | 12 | + extend: 'Ext.form.Panel', |
13 | + alias: 'widget.panelUpload', | ||
14 | + | ||
15 | + requires : [ | ||
16 | + 'amdaUI.RemoteSearchPlugin' | ||
17 | + ], | ||
18 | 18 | ||
19 | - isFile : true, | ||
20 | - tmpNode : null, | ||
21 | - | ||
22 | - constructor: function(config) { | ||
23 | - this.init(config); | ||
24 | - this.callParent(arguments); | ||
25 | - }, | 19 | + isFile : true, |
20 | + isTimeTable : false, | ||
21 | + tmpNode : null, | ||
22 | + | ||
23 | + constructor: function(config) | ||
24 | + { | ||
25 | + this.init(config); | ||
26 | + this.callParent(arguments); | ||
27 | + }, | ||
26 | 28 | ||
27 | - /* | ||
28 | - * create MyData linked node and edit in module MyData | ||
29 | - * update myDataParams info if needed | ||
30 | - */ | ||
31 | - getObjectCallback : function(result,remoteEvent) | ||
32 | - { | ||
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 | ||
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 | - { | ||
65 | - module.setLinkedNode(me.tmpNode); | ||
66 | - module.linkedNode.editInModule(); | ||
67 | - } | ||
68 | - }); | ||
69 | - } | ||
70 | - else { | ||
71 | - // EXCEPTION : parameter not found ! | ||
72 | - myDesktopApp.errorMsg(t.action + "." + t.method + " : No parameter '" | ||
73 | - +this.tmpNode.get('text')+"' found!"); | ||
74 | - } | ||
75 | - loadMask.hide(); | ||
76 | - }, | 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 | + }, | ||
77 | 83 | ||
78 | - /* | ||
79 | - * form validation | ||
80 | - * TODO markInvalid()? | ||
81 | - */ | ||
82 | - validate : function() | ||
83 | - { | ||
84 | - var values = this.getForm().getValues(); | 84 | +/* |
85 | +* form validation | ||
86 | +* TODO markInvalid()? | ||
87 | +*/ | ||
88 | + validate : function() | ||
89 | + { | ||
90 | + var values = this.getForm().getValues(); | ||
85 | 91 | ||
86 | - if (values['filesrc'] == 'LOCAL') { | ||
87 | - var locFile = this.isFile ? this.getForm().findField('localFileName').getValue() : | ||
88 | - this.getForm().findField('localTTName').getValue(); | ||
89 | - | ||
90 | - if (!locFile) { | ||
91 | - myDesktopApp.warningMsg("Select File to Upload"); | ||
92 | - return false; | ||
93 | - } | ||
94 | - } | ||
95 | - else { | ||
96 | - if (!values['remoteFile'] && !values['remoteTT']) { | ||
97 | - myDesktopApp.warningMsg("Select File to Upload"); | ||
98 | - return false; | ||
99 | - } | ||
100 | - } | ||
101 | - return true; | ||
102 | - }, | 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 | + }, | ||
103 | 114 | ||
104 | 115 | ||
105 | - //TODO proper parsing | ||
106 | - updateFormat: function(value) | ||
107 | - { | ||
108 | - var arrayOfStr = value.split('.'); | ||
109 | - //TODO use down method? | ||
110 | - if (this.isFile) { | ||
111 | - var radios = Ext.getCmp('filefrmt'); | ||
112 | - var user_format_obj = radios.getValue(); | ||
113 | - var user_format = user_format_obj.filefrmt; | ||
114 | - } | ||
115 | - else { | ||
116 | - var radios = Ext.getCmp('ttfrmt'); | ||
117 | - var user_format_obj = radios.getValue(); | ||
118 | - var user_format = user_format_obj.ttfrmt; | ||
119 | - } | ||
120 | - | ||
121 | - var auto_format = user_format; | ||
122 | - | ||
123 | - // auto define format in some special cases | ||
124 | - //TODO name without extention => ASCII? | ||
125 | - if (arrayOfStr.length == 1) auto_format = 'ASCII'; | ||
126 | - else { | ||
127 | - var suffix = arrayOfStr[arrayOfStr.length - 1].toLowerCase(); | ||
128 | - if (suffix == 'gz') | ||
129 | - suffix = arrayOfStr[arrayOfStr.length - 2].toLowerCase() + '.gz'; | 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.TimeTable) | ||
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'; | ||
130 | 150 | ||
131 | - switch (suffix) | ||
132 | - { | ||
133 | - case 'cdf' : auto_format = 'CDF'; break; | ||
134 | - case 'cef.gz' : | ||
135 | - case 'cef' : auto_format = 'CEF'; break; | ||
136 | - case 'xml' : auto_format = 'VOT'; | ||
137 | - case 'vot' : auto_format = 'VOT'; break; | ||
138 | - case 'nc' : auto_format = 'NC'; break; | ||
139 | - case 'asc' : | ||
140 | - case 'txt' : | ||
141 | - default : auto_format = 'ASCII'; | ||
142 | - } | ||
143 | - } | 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.File && !this.TimeTable && user_format !== auto_format) { | ||
170 | + user_format_obj.catfrmt = auto_format; | ||
171 | + } | ||
172 | + | ||
173 | + radios.setValue(user_format_obj); | ||
174 | + }, | ||
144 | 175 | ||
145 | - // set auto format : case when format was not set by user before | ||
146 | - if (this.isFile && user_format !== auto_format) { | ||
147 | - user_format_obj.filefrmt = auto_format; | ||
148 | - } else if (!this.isFile && user_format !== auto_format) { | ||
149 | - user_format_obj.ttfrmt = auto_format; | ||
150 | - } | ||
151 | - radios.setValue(user_format_obj); | ||
152 | - }, | ||
153 | - | ||
154 | - /* | ||
155 | - * | ||
156 | - */ | ||
157 | - forceUpload : function (url,format) | ||
158 | - { | ||
159 | - this.getForm().findField('filesrc').setValue('URL'); | ||
160 | - | ||
161 | - switch (format) | ||
162 | - { | ||
163 | - case 'votable' : | ||
164 | - this.getForm().findField('filefrmt').setValue('VOT'); | ||
165 | - break; | ||
166 | - case 'cdf' : | ||
167 | - this.getForm().findField('filefrmt').setValue('CDF'); | ||
168 | - break; | ||
169 | - default : | ||
170 | - //ToDo Error - unknown format | ||
171 | - return; | ||
172 | - } | ||
173 | - this.getForm().findField('remoteFile').setValue(url); | ||
174 | - | ||
175 | - this.postUpload(); | ||
176 | - }, | 176 | + /* |
177 | + * | ||
178 | + */ | ||
179 | + forceUpload : function (url,format) | ||
180 | + { | ||
181 | + this.getForm().findField('filesrc').setValue('URL'); | ||
182 | + | ||
183 | + switch (format) | ||
184 | + { | ||
185 | + case 'votable' : | ||
186 | + this.getForm().findField('filefrmt').setValue('VOT'); | ||
187 | + break; | ||
188 | + case 'cdf' : | ||
189 | + this.getForm().findField('filefrmt').setValue('CDF'); | ||
190 | + break; | ||
191 | + default : | ||
192 | + //ToDo Error - unknown format | ||
193 | + return; | ||
194 | + } | ||
195 | + this.getForm().findField('remoteFile').setValue(url); | ||
196 | + | ||
197 | + this.postUpload(); | ||
198 | + }, | ||
177 | 199 | ||
178 | - /* | ||
179 | - * | ||
180 | - */ | ||
181 | - postUpload : function() | ||
182 | - { | ||
183 | - // 'global' form containing 'partial' forms | ||
184 | - var form = this.getForm(); | ||
185 | - | ||
186 | - // special validation | ||
187 | - if(this.validate()){ | ||
188 | - form.submit({ | ||
189 | - scope: this, | ||
190 | - url: 'php/uploadFile.php', | ||
191 | - waitMsg: 'Uploading your file...', | ||
192 | - success: function(form, o){ | ||
193 | - this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file}); | ||
194 | - loadMask.show(); | ||
195 | - AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this); | ||
196 | - }, | ||
197 | - failure: function(form, o) { | ||
198 | - loadMask.hide(); | ||
199 | - myDesktopApp.errorMsg('Error '+o.result.error); | ||
200 | - } | ||
201 | - }); | ||
202 | - } | ||
203 | - }, | 200 | + /* |
201 | + * | ||
202 | + */ | ||
203 | + postUpload : function() | ||
204 | + { | ||
205 | + // 'global' form containing 'partial' forms | ||
206 | + var form = this.getForm(); | ||
207 | + | ||
208 | + // special validation | ||
209 | + if(this.validate()) | ||
210 | + { | ||
211 | + form.submit({ | ||
212 | + scope: this, | ||
213 | + url: 'php/uploadFile.php', | ||
214 | + waitMsg: 'Uploading your file...', | ||
215 | + success: function(form, o) | ||
216 | + { | ||
217 | + this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file}); | ||
218 | + loadMask.show(); | ||
219 | + AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this); | ||
220 | + }, | ||
221 | + failure: function(form, o) | ||
222 | + { | ||
223 | + loadMask.hide(); | ||
224 | + myDesktopApp.errorMsg('Error '+o.result.error); | ||
225 | + } | ||
226 | + }); | ||
227 | + } | ||
228 | + }, | ||
204 | 229 | ||
205 | - /* | ||
206 | - * panel config | ||
207 | - */ | ||
208 | - init : function(config) | ||
209 | - { | ||
210 | - this.isFile = config.panelType == 'file'? true : false; | ||
211 | - | ||
212 | - // file/time table settings | ||
213 | - if (this.isFile) { | ||
214 | - var title = 'Upload File'; | ||
215 | - var items = [ | ||
216 | - { boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true, | ||
217 | - listeners: { | ||
218 | - change: function (cb, nv, ov) { | ||
219 | - if (nv) Ext.getCmp('tf').show(); | ||
220 | - else Ext.getCmp('tf').hide(); | ||
221 | - } | ||
222 | - } | ||
223 | - }, | ||
224 | - { boxLabel: 'netCDF <img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'NC' }, | ||
225 | - { boxLabel: 'CDF <img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'CDF' }, | ||
226 | - // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' }, | ||
227 | - { boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT' } | ||
228 | - ]; | ||
229 | - var timeFormatId = 'tf'; | ||
230 | - this.formatId = 'nsf'; | ||
231 | - this.localUploadId = 'form-uploadfile'; | ||
232 | - var localUploadName ='localFileName'; | ||
233 | - var remoteUploadName ='remoteFile'; | ||
234 | - this.remoteUploadId = 'form-uploadurl'; | ||
235 | - this.nodeType = 'amdaModel.MyDataParamNode'; | ||
236 | - //TODO load XML | ||
237 | - var store = Ext.create('Ext.data.Store', { | ||
238 | - fields: ['value', 'name'], | ||
239 | - data : [ | ||
240 | - {"value":"ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name":"CDAWEB/FTP"}, | ||
241 | - {"value":"ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/", "name":"Solar Data"} | ||
242 | - ] | ||
243 | - }); | ||
244 | - } | ||
245 | - else { | ||
246 | - | ||
247 | - var title = 'Upload Time Table'; | ||
248 | - var items = [ | ||
249 | - {boxLabel: 'ASCII', name: 'ttfrmt', inputValue: 'ASCII', checked: true, | ||
250 | - listeners: { | ||
251 | - change: function (cb, nv, ov) { | ||
252 | - if (nv) Ext.getCmp('tf_tt').show(); | ||
253 | - else Ext.getCmp('tf_tt').hide(); | ||
254 | - } | ||
255 | - } | ||
256 | - }, | ||
257 | - {boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'} | ||
258 | - ]; | ||
259 | - | ||
260 | - var timeFormatId = 'tf_tt'; | ||
261 | - this.formatId = 'nsf_tt'; | ||
262 | - this.localUploadId = 'form-uploadtt'; | ||
263 | - var localUploadName ='localTTName'; | ||
264 | - var remoteUploadName ='remoteTT'; | ||
265 | - this.remoteUploadId = 'form-uploadtturl'; | ||
266 | - this.nodeType = 'amdaModel.TimeTableNode'; | ||
267 | - //TODO load XML | ||
268 | - var store = Ext.create('Ext.data.Store', { | ||
269 | - fields: ['value', 'name'], | ||
270 | - data : [] | ||
271 | - }); | ||
272 | - } | ||
273 | - | ||
274 | - var combo = Ext.create('Ext.form.ComboBox', { | ||
275 | - flex : 4, | ||
276 | - store: store, | ||
277 | - emptyText: 'Enter Remote Site URL (ftp)', | ||
278 | - queryMode: 'local', | ||
279 | - displayField: 'name', | ||
280 | - valueField: 'value' | ||
281 | - }); | 230 | + /* |
231 | + * panel config | ||
232 | + */ | ||
233 | + init : function(config) | ||
234 | + { | ||
235 | + this.isFile = config.panelType == 'file'? true : false; | ||
236 | + this.isTimeTable = config.panelType == 'timetable'? true : false; | ||
237 | + | ||
238 | + // file / time table / catalog settings | ||
239 | + if (this.isFile) | ||
240 | + { | ||
241 | + var title = 'File'; | ||
242 | + var items = [ | ||
243 | + { boxLabel: 'ASCII', name: 'filefrmt', inputValue: 'ASCII', checked: true, | ||
244 | + listeners: | ||
245 | + { | ||
246 | + change: function (cb, nv, ov) { | ||
247 | + if (nv) Ext.getCmp('tf').show(); | ||
248 | + else Ext.getCmp('tf').hide(); | ||
249 | + } | ||
250 | + } | ||
251 | + }, | ||
252 | + // { boxLabel: 'netCDF <img amda_clicktip="ncTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'NC' }, | ||
253 | + { boxLabel: 'CDF <img amda_clicktip="cdfTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', name: 'filefrmt', inputValue: 'CDF' }, | ||
254 | + // { boxLabel: 'CEF[GZ]', name: 'filefrmt', inputValue: 'CEF' }, | ||
255 | + { boxLabel: 'VOTable', name: 'filefrmt', inputValue: 'VOT' }]; | ||
256 | + var timeFormatId = 'tf'; | ||
257 | + this.formatId = 'nsf'; | ||
258 | + this.localUploadId = 'form-uploadfile'; | ||
259 | + var localUploadName ='localFileName'; | ||
260 | + var remoteUploadName ='remoteFile'; | ||
261 | + this.remoteUploadId = 'form-uploadurl'; | ||
262 | + this.nodeType = 'amdaModel.MyDataParamNode'; | ||
263 | + //TODO load XML | ||
264 | + var store = Ext.create('Ext.data.Store', { | ||
265 | + fields: ['value', 'name'], | ||
266 | + data : [ | ||
267 | + {"value":"ftp://cdaweb.gsfc.nasa.gov/pub/data/", "name":"CDAWEB/FTP"}/*, | ||
268 | + {"value":"ftp://ftp.ngdc.noaa.gov/STP/SOLAR_DATA/", "name":"Solar Data"}*/] | ||
269 | + }); | ||
270 | + } | ||
271 | + else if (this.isTimeTable) | ||
272 | + { | ||
273 | + var title = 'Time Table'; | ||
274 | + var items = [ | ||
275 | + { boxLabel: 'ASCII', name: 'ttfrmt', inputValue: 'ASCII', checked: true, | ||
276 | + listeners: { | ||
277 | + change: function (cb, nv, ov) { | ||
278 | + if (nv) Ext.getCmp('tf_tt').show(); | ||
279 | + else Ext.getCmp('tf_tt').hide(); | ||
280 | + } | ||
281 | + } | ||
282 | + }, | ||
283 | + { boxLabel: 'VOTable', name: 'ttfrmt', inputValue: 'VOT'}]; | ||
284 | + | ||
285 | + var timeFormatId = 'tf_tt'; | ||
286 | + this.formatId = 'nsf_tt'; | ||
287 | + this.localUploadId = 'form-uploadtt'; | ||
288 | + var localUploadName ='localTTName'; | ||
289 | + var remoteUploadName ='remoteTT'; | ||
290 | + this.remoteUploadId = 'form-uploadtturl'; | ||
291 | + this.nodeType = 'amdaModel.TimeTableNode'; | ||
292 | + //TODO load XML | ||
293 | + var store = Ext.create('Ext.data.Store', { | ||
294 | + fields: ['value', 'name'], | ||
295 | + data : [] | ||
296 | + }); | ||
297 | + } | ||
298 | + else | ||
299 | + { | ||
300 | + var title = 'Catalog'; | ||
301 | + var items = [ | ||
302 | + { boxLabel: 'VOTable', name: 'catfrmt', inputValue: 'VOT', checked: true }]; | ||
303 | + | ||
304 | + var timeFormatId = 'tf_cat'; | ||
305 | + this.formatId = 'nsf_cat'; | ||
306 | + this.localUploadId = 'form-uploadcat'; | ||
307 | + var localUploadName ='localCatName'; | ||
308 | + var remoteUploadName ='remoteCat'; | ||
309 | + | ||
310 | + this.remoteUploadId = 'form-uploadcaturl'; | ||
311 | + this.nodeType = 'amdaModel.CatalogNode'; | ||
312 | + //TODO load XML | ||
313 | + var store = Ext.create('Ext.data.Store', { | ||
314 | + fields: ['value', 'name'], | ||
315 | + data : [] | ||
316 | + }); | ||
317 | + } | ||
318 | + | ||
319 | + var combo = Ext.create('Ext.form.ComboBox', { | ||
320 | + flex : 4, | ||
321 | + store: store, | ||
322 | + emptyText: 'Enter Remote Site URL (ftp)', | ||
323 | + queryMode: 'local', | ||
324 | + displayField: 'name', | ||
325 | + valueField: 'value' | ||
326 | + }); | ||
282 | 327 | ||
283 | - var fieldcontainer = { xtype: 'fieldcontainer', | ||
284 | - fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0, | ||
285 | - layout: 'hbox', | ||
286 | - items: [ | ||
287 | - combo, | ||
288 | - { | ||
289 | - xtype : 'button', | ||
290 | - flex : 1, | ||
291 | - text: 'Browse It', | ||
292 | - handler: function(){ | ||
293 | - var form = this.up('form').getForm(); | ||
294 | - var site = form.getFields().getAt(0).getValue(); | ||
295 | - if (site) | ||
296 | - this.up('form').ownerCt.fireEvent('open', site); | ||
297 | - else | ||
298 | - myDesktopApp.warningMsg("Please Enter Remote Site URL"); | ||
299 | - } | ||
300 | - } | ||
301 | - ] | ||
302 | - }; | ||
303 | - var radioId = this.isFile ? 'filefrmt' : 'ttfrmt'; | ||
304 | - var fileFormat = Ext.create('Ext.form.FieldSet', { | ||
305 | - title: 'File Format', | ||
306 | - items : [ { | ||
307 | - xtype: 'radiogroup', | ||
308 | - id : radioId, | ||
309 | - columns: 3, | ||
310 | - cls: 'x-check-group-alt', | ||
311 | - items: items | ||
312 | - } | ||
313 | - ] | ||
314 | - }); | 328 | + var fieldcontainer = |
329 | + { | ||
330 | + xtype: 'fieldcontainer', | ||
331 | + fieldLabel: ' ', labelWidth: 0, labelSeparator : '', labelPad : 0, | ||
332 | + layout: 'hbox', | ||
333 | + items: [ | ||
334 | + combo, | ||
335 | + { | ||
336 | + xtype : 'button', | ||
337 | + flex : 1, | ||
338 | + text: 'Browse It', | ||
339 | + handler: function() | ||
340 | + { | ||
341 | + var form = this.up('form').getForm(); | ||
342 | + var site = form.getFields().getAt(0).getValue(); | ||
343 | + if (site) | ||
344 | + this.up('form').ownerCt.fireEvent('open', site); | ||
345 | + else | ||
346 | + myDesktopApp.warningMsg("Please Enter Remote Site URL"); | ||
347 | + } | ||
348 | + }] | ||
349 | + }; | ||
350 | + | ||
351 | + if (this.isFile) var radioId = 'filefrmt'; | ||
352 | + else if (this.isTimeTable) var radioId = 'ttfrmt'; | ||
353 | + else var radioId = 'catfrmt'; | ||
354 | + | ||
355 | + var fileFormat = Ext.create('Ext.form.FieldSet', { | ||
356 | + title: 'File Format', | ||
357 | + items : [{ | ||
358 | + xtype: 'radiogroup', | ||
359 | + id : radioId, | ||
360 | + columns: 3, | ||
361 | + cls: 'x-check-group-alt', | ||
362 | + items: items | ||
363 | + }] | ||
364 | + }); | ||
315 | 365 | ||
316 | - var Sampling = { xtype: 'radiogroup', | ||
317 | - fieldLabel: 'Time Sampling', | ||
318 | - labelWidth: 90, | ||
319 | - cls: 'x-check-group-alt', | ||
320 | - hidden : !this.isFile, | ||
321 | - defaults : {name : 'timesmpl'}, | ||
322 | - items: [ | ||
323 | - {boxLabel: 'constant', inputValue: 'constant', checked: true}, | ||
324 | - {boxLabel: 'variable <img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'} | ||
325 | - ] | ||
326 | - }; | 366 | + var Sampling = |
367 | + { | ||
368 | + xtype: 'radiogroup', | ||
369 | + fieldLabel: 'Time Sampling', | ||
370 | + labelWidth: 90, | ||
371 | + cls: 'x-check-group-alt', | ||
372 | + hidden : !this.isFile, | ||
373 | + defaults : {name : 'timesmpl'}, | ||
374 | + items: [ | ||
375 | + {boxLabel: 'constant', inputValue: 'constant', checked: true}, | ||
376 | + {boxLabel: 'variable <img amda_clicktip="variableSampling" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'variable'} | ||
377 | + ] | ||
378 | + }; | ||
327 | 379 | ||
328 | - var dayStart = { xtype: 'checkbox', | ||
329 | - name : 'doy', | ||
330 | - hidden : true, | ||
331 | - fieldLabel: 'DOY starts from 1', | ||
332 | - inputValue: '1' | ||
333 | - }; | ||
334 | - | ||
335 | - var nonStandardFormat = | ||
336 | - { | ||
337 | - xtype: 'fieldcontainer', | ||
338 | - defaultType: 'textfield', | ||
339 | - layout: 'anchor', | ||
340 | - defaults: { | ||
341 | - layout: '100%', | ||
342 | - labelWidth : 150 | ||
343 | - }, | ||
344 | - id : this.formatId, | ||
345 | - hidden : true, | ||
346 | - items: [ | ||
347 | - { | ||
348 | - fieldLabel : 'define time format', | ||
349 | - name : 'nonstd', | ||
350 | - value: 'Y-m-d H:i:s', | ||
351 | - enableKeyEvents: true, | ||
352 | - listeners : { | ||
353 | - keyUp : function() { | ||
354 | - if (this.getValue().indexOf('z') > 0) { | ||
355 | - this.nextSibling().show(); | ||
356 | - } | ||
357 | - if (this.getValue().indexOf('d') > 0) { | ||
358 | - this.nextSibling().hide(); | ||
359 | - } | ||
360 | - } | ||
361 | - } | ||
362 | - }, | ||
363 | - dayStart, | ||
364 | - { | ||
365 | - fieldLabel : 'define max time length', | ||
366 | - name : 'timelength', | ||
367 | - value: 'auto' | ||
368 | - } | ||
369 | - ], | ||
370 | - listeners : { | ||
371 | - hide : function() { | ||
372 | - this.items.getAt(1).hide(); | ||
373 | - } | ||
374 | - } | ||
375 | - }; | 380 | + var dayStart = |
381 | + { | ||
382 | + xtype: 'checkbox', | ||
383 | + name : 'doy', | ||
384 | + hidden : true, | ||
385 | + fieldLabel: 'DOY starts from 1', | ||
386 | + inputValue: '1' | ||
387 | + }; | ||
388 | + | ||
389 | + var nonStandardFormat = | ||
390 | + { | ||
391 | + xtype: 'fieldcontainer', | ||
392 | + defaultType: 'textfield', | ||
393 | + layout: 'anchor', | ||
394 | + defaults: | ||
395 | + { | ||
396 | + layout: '100%', | ||
397 | + labelWidth : 150 | ||
398 | + }, | ||
399 | + id : this.formatId, | ||
400 | + hidden : true, | ||
401 | + items: [ | ||
402 | + { | ||
403 | + fieldLabel : 'define time format', | ||
404 | + name : 'nonstd', | ||
405 | + value: 'Y-m-d H:i:s', | ||
406 | + enableKeyEvents: true, | ||
407 | + listeners : | ||
408 | + { | ||
409 | + keyUp : function() { | ||
410 | + if (this.getValue().indexOf('z') > 0) { | ||
411 | + this.nextSibling().show(); | ||
412 | + } | ||
413 | + if (this.getValue().indexOf('d') > 0) { | ||
414 | + this.nextSibling().hide(); | ||
415 | + } | ||
416 | + } | ||
417 | + } | ||
418 | + }, | ||
419 | + dayStart, | ||
420 | + { | ||
421 | + fieldLabel : 'define max time length', | ||
422 | + name : 'timelength', | ||
423 | + value: 'auto' | ||
424 | + }], | ||
425 | + listeners : | ||
426 | + { | ||
427 | + hide : function() { | ||
428 | + this.items.getAt(1).hide(); | ||
429 | + } | ||
430 | + } | ||
431 | + }; | ||
432 | + var isCatalog = !(this.isFile || this.isTimeTable); | ||
376 | 433 | ||
377 | - var timeFormat = Ext.create('Ext.form.FieldSet', { | ||
378 | - id: timeFormatId, | ||
379 | - title: 'Time Settings', | ||
380 | - items : [{ | ||
381 | - xtype: 'radiogroup', | ||
382 | - fieldLabel: 'Time Format', | ||
383 | - labelWidth: 90, | ||
384 | - cls: 'x-check-group-alt', | ||
385 | - defaults : { name : 'timefrmt'}, | ||
386 | - items: [ | ||
387 | - {boxLabel: 'standard <img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true}, | ||
388 | - {boxLabel: 'no <img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user', | ||
389 | - listeners: { | ||
390 | - scope : this, | ||
391 | - change: function (cb, nv, ov) { | ||
392 | - if (nv) | ||
393 | - Ext.getCmp(this.formatId).show(); | ||
394 | - else | ||
395 | - Ext.getCmp(this.formatId).hide(); | ||
396 | - } | ||
397 | - } | ||
398 | - } | ||
399 | - ] | ||
400 | - }, | ||
401 | - nonStandardFormat, | ||
402 | - Sampling | ||
403 | - ] | ||
404 | - }); | ||
405 | - | ||
406 | - var localFile = Ext.create('Ext.form.Panel', { | ||
407 | - id: this.localUploadId, | ||
408 | - fileUpload: true, | ||
409 | - hideLabels: true, | ||
410 | - frame: true, | ||
411 | - items: [{ | ||
412 | - xtype: 'fileuploadfield', | ||
413 | - emptyText: 'Select Your File', | ||
414 | - width: 300, | ||
415 | - name: localUploadName, | ||
416 | - buttonText: 'Browse', | ||
417 | - listeners: { | ||
418 | - scope : this, | ||
419 | - change: function (field, value, e) { | ||
420 | - this.updateFormat(value); | ||
421 | - } | ||
422 | - } | ||
423 | - }, | ||
424 | - { | ||
425 | - // it is common setting for Local and Remote files | ||
426 | - xtype : 'hiddenfield', | ||
427 | - name: 'MAX_FILE_SIZE', | ||
428 | - value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB | ||
429 | - } | ||
430 | - ] | ||
431 | - }); | ||
432 | - | ||
433 | - var remoteFile = Ext.create('Ext.form.Panel', { | ||
434 | - id: this.remoteUploadId, | ||
435 | - hideLabels: true, | ||
436 | - autoHeight: true, | ||
437 | - frame: true, | ||
438 | - hidden : true, | ||
439 | - items: [ fieldcontainer, | ||
440 | - { xtype : 'textfield', | ||
441 | - name : remoteUploadName, | ||
442 | - emptyText: 'Enter Remote File URL (http or ftp)', | ||
443 | - width: 310, | ||
444 | - listeners: { | ||
445 | - scope : this, | ||
446 | - change: function (field, value, e) { | ||
447 | - this.updateFormat(value); | ||
448 | - } | ||
449 | - } | ||
450 | - } | ||
451 | - ] | ||
452 | - }); | 434 | + var timeFormat = Ext.create('Ext.form.FieldSet', { |
435 | + id: timeFormatId, | ||
436 | + title: 'Time Settings', | ||
437 | + hidden : isCatalog, | ||
438 | + items : [ | ||
439 | + { | ||
440 | + xtype: 'radiogroup', | ||
441 | + fieldLabel: 'Time Format', | ||
442 | + labelWidth: 90, | ||
443 | + cls: 'x-check-group-alt', | ||
444 | + defaults : { name : 'timefrmt'}, | ||
445 | + items: [ | ||
446 | + { boxLabel: 'standard <img amda_clicktip="standardTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'standard', checked: true}, | ||
447 | + { boxLabel: 'no <img amda_clicktip="userTimeFormat" style="vertical-align:bottom" src="js/resources/images/16x16/info_mini.png"', inputValue: 'user', | ||
448 | + listeners: | ||
449 | + { | ||
450 | + scope : this, | ||
451 | + change: function (cb, nv, ov) { | ||
452 | + if (nv) | ||
453 | + Ext.getCmp(this.formatId).show(); | ||
454 | + else | ||
455 | + Ext.getCmp(this.formatId).hide(); | ||
456 | + } | ||
457 | + } | ||
458 | + }] | ||
459 | + }, | ||
460 | + nonStandardFormat, | ||
461 | + Sampling ] | ||
462 | + }); | ||
463 | + | ||
464 | + var localFile = Ext.create('Ext.form.Panel', { | ||
465 | + id: this.localUploadId, | ||
466 | + fileUpload: true, | ||
467 | + hideLabels: true, | ||
468 | + frame: true, | ||
469 | + items: [ | ||
470 | + { | ||
471 | + xtype: 'fileuploadfield', | ||
472 | + emptyText: 'Select Your File', | ||
473 | + width: 300, | ||
474 | + name: localUploadName, | ||
475 | + buttonText: 'Browse', | ||
476 | + listeners: | ||
477 | + { | ||
478 | + scope : this, | ||
479 | + change: function (field, value, e) { | ||
480 | + this.updateFormat(value); | ||
481 | + } | ||
482 | + } | ||
483 | + }, | ||
484 | + { | ||
485 | + // it is common setting for Local and Remote files | ||
486 | + xtype : 'hiddenfield', | ||
487 | + name: 'MAX_FILE_SIZE', | ||
488 | + value: myDesktopApp.MAX_UPLOADED_FILE_SIZE // 30MB | ||
489 | + }] | ||
490 | + }); | ||
491 | + | ||
492 | + var remoteFile = Ext.create('Ext.form.Panel', { | ||
493 | + id: this.remoteUploadId, | ||
494 | + hideLabels: true, | ||
495 | + autoHeight: true, | ||
496 | + frame: true, | ||
497 | + hidden : true, | ||
498 | + items: [ | ||
499 | + fieldcontainer, | ||
500 | + { | ||
501 | + xtype : 'textfield', | ||
502 | + name : remoteUploadName, | ||
503 | + emptyText: 'Enter Remote File URL (http or ftp)', | ||
504 | + width: 310, | ||
505 | + listeners: | ||
506 | + { | ||
507 | + scope : this, | ||
508 | + change: function (field, value, e) { | ||
509 | + this.updateFormat(value); | ||
510 | + } | ||
511 | + } | ||
512 | + }] | ||
513 | + }); | ||
453 | 514 | ||
454 | - var uploadForm = Ext.create('Ext.form.FieldSet',{ | ||
455 | - title: 'File Source', | ||
456 | - items : [{ xtype: 'radiogroup', | ||
457 | - cls: 'x-check-group-alt', | ||
458 | - items: [ | ||
459 | - {boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true, | ||
460 | - listeners: { | ||
461 | - scope : this, | ||
462 | - change: function (cb, nv, ov) { | ||
463 | - if (nv == ov) return; | ||
464 | - var local = Ext.getCmp(this.localUploadId); | ||
465 | - var remote = Ext.getCmp(this.remoteUploadId); | ||
466 | - if (nv) { | ||
467 | - remote.hide(); | ||
468 | - local.show(); | ||
469 | - } | ||
470 | - else { | ||
471 | - local.hide(); | ||
472 | - remote.show(); | ||
473 | - } | ||
474 | - } | ||
475 | - } | ||
476 | - }, | ||
477 | - {boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'}, | ||
478 | - ]}] | ||
479 | - }); | ||
480 | - | ||
481 | - var myConf = { | ||
482 | - title : title, | ||
483 | - layout: {type: 'vbox', align: 'stretch'}, | ||
484 | - bodyStyle: { background : '#dfe8f6'}, | ||
485 | - items : [ | ||
486 | - uploadForm, | ||
487 | - localFile, | ||
488 | - remoteFile, | ||
489 | - fileFormat, | ||
490 | - timeFormat | ||
491 | - ], | ||
492 | - buttons: [ | ||
493 | - { | ||
494 | - text: 'Upload', | ||
495 | - handler: function() | ||
496 | - { | ||
497 | - this.postUpload(); | ||
498 | - }, | ||
499 | - scope : this | ||
500 | - }, | ||
501 | - { | ||
502 | - text: 'Reset', | ||
503 | - handler: function(){ | ||
504 | - this.up('form').getForm().reset(); | ||
505 | - } | ||
506 | - } | ||
507 | - ], | ||
508 | - plugins: [{ptype: 'remoteSearchPlugin'}], | ||
509 | - listeners: { | ||
510 | - click: { | ||
511 | - element: 'el', | ||
512 | - fn: function(e,t) { | ||
513 | - var me = t, | ||
514 | - text = me.getAttribute('amda_clicktip'); | ||
515 | - if (text) { | ||
516 | - e.preventDefault(); | ||
517 | - AmdaAction.getInfo({name : text}, function(res,e) { | ||
518 | - if (res.success) myDesktopApp.infoMsg(res.result); | ||
519 | - }); | ||
520 | - } | ||
521 | - } | ||
522 | - } | ||
523 | - } | ||
524 | - }; | ||
525 | - | ||
526 | - Ext.apply (this, Ext.apply(arguments, myConf)); | ||
527 | - } | 515 | + var uploadForm = Ext.create('Ext.form.FieldSet',{ |
516 | + title: 'File Source', | ||
517 | + items : [ | ||
518 | + { | ||
519 | + xtype: 'radiogroup', | ||
520 | + cls: 'x-check-group-alt', | ||
521 | + items: [ | ||
522 | + { boxLabel: 'Local', name: 'filesrc', inputValue: 'LOCAL', checked: true, | ||
523 | + listeners: | ||
524 | + { | ||
525 | + scope : this, | ||
526 | + change: function (cb, nv, ov) { | ||
527 | + if (nv == ov) return; | ||
528 | + var local = Ext.getCmp(this.localUploadId); | ||
529 | + var remote = Ext.getCmp(this.remoteUploadId); | ||
530 | + if (nv) { | ||
531 | + remote.hide(); | ||
532 | + local.show(); | ||
533 | + } | ||
534 | + else { | ||
535 | + local.hide(); | ||
536 | + remote.show(); | ||
537 | + } | ||
538 | + } | ||
539 | + } | ||
540 | + }, | ||
541 | + { boxLabel: 'URL', name: 'filesrc', inputValue: 'URL'} ] | ||
542 | + }] | ||
543 | + }); | ||
544 | + | ||
545 | + var myConf = | ||
546 | + { | ||
547 | + title : title, | ||
548 | + layout: {type: 'vbox', align: 'stretch'}, | ||
549 | + bodyStyle: { background : '#dfe8f6'}, | ||
550 | + items : [ | ||
551 | + uploadForm, | ||
552 | + localFile, | ||
553 | + remoteFile, | ||
554 | + fileFormat, | ||
555 | + timeFormat | ||
556 | + ], | ||
557 | + buttons: [ | ||
558 | + { | ||
559 | + text: 'Upload', | ||
560 | + handler: function() | ||
561 | + { | ||
562 | + this.postUpload(); | ||
563 | + }, | ||
564 | + scope : this | ||
565 | + }, | ||
566 | + { | ||
567 | + text: 'Reset', | ||
568 | + handler: function(){ | ||
569 | + this.up('form').getForm().reset(); | ||
570 | + } | ||
571 | + }], | ||
572 | + plugins: [{ptype: 'remoteSearchPlugin'}], | ||
573 | + listeners: | ||
574 | + { | ||
575 | + click: | ||
576 | + { | ||
577 | + element: 'el', | ||
578 | + fn: function(e,t) { | ||
579 | + var me = t, | ||
580 | + text = me.getAttribute('amda_clicktip'); | ||
581 | + if (text) | ||
582 | + { | ||
583 | + e.preventDefault(); | ||
584 | + AmdaAction.getInfo({name : text}, function(res,e) { | ||
585 | + if (res.success) myDesktopApp.infoMsg(res.result); | ||
586 | + }); | ||
587 | + } | ||
588 | + } | ||
589 | + } | ||
590 | + } | ||
591 | + }; | ||
592 | + | ||
593 | + Ext.apply (this, Ext.apply(arguments, myConf)); | ||
594 | + } | ||
528 | }); | 595 | }); |
js/app/views/UploadUI.js
@@ -14,7 +14,7 @@ Ext.define('amdaUI.UploadUI', { | @@ -14,7 +14,7 @@ Ext.define('amdaUI.UploadUI', { | ||
14 | alias: 'widget.panelTabUpload', | 14 | alias: 'widget.panelTabUpload', |
15 | 15 | ||
16 | requires: [ | 16 | requires: [ |
17 | - 'amdaUI.UploadPanelUI' | 17 | + 'amdaUI.UploadPanelUI' |
18 | ], | 18 | ], |
19 | 19 | ||
20 | constructor: function(config) { | 20 | constructor: function(config) { |
@@ -22,43 +22,43 @@ Ext.define('amdaUI.UploadUI', { | @@ -22,43 +22,43 @@ Ext.define('amdaUI.UploadUI', { | ||
22 | this.callParent(arguments); | 22 | this.callParent(arguments); |
23 | }, | 23 | }, |
24 | 24 | ||
25 | - init : function(config) { | ||
26 | - | ||
27 | - var myConf = { | ||
28 | - layout: 'border', | ||
29 | - items: [ { | ||
30 | - xtype: 'tabpanel', | ||
31 | - region: 'center', | ||
32 | - activeTab : 0, | ||
33 | - items : | ||
34 | - [ | ||
35 | - { xtype: 'panelUpload', panelType : 'file'}, | ||
36 | - { xtype: 'panelUpload', panelType : 'timetable'} | ||
37 | - ] | ||
38 | - }, | ||
39 | - { | ||
40 | - xtype: 'panel', | ||
41 | - region: 'south', | ||
42 | - title: 'Information', | ||
43 | - collapsible: true, | ||
44 | - height: 100, | ||
45 | - autoHide: false, | ||
46 | - iconCls: 'icon-information', | ||
47 | - html: 'Select local or remote file (time table) to upload<br/>File size is limited to <b><i>' | ||
48 | - + myDesktopApp.MAX_UPLOADED_FILE_SIZE/1000000+'MB</i></b><br/>Milliseconds are ignored for the moment', | ||
49 | - autoScroll : true, | ||
50 | - loader: {} | ||
51 | - } | ||
52 | - ] | ||
53 | - }; | 25 | + init : function(config) |
26 | + { | ||
27 | + var myConf = | ||
28 | + { | ||
29 | + layout: 'border', | ||
30 | + items: [ | ||
31 | + { | ||
32 | + xtype: 'tabpanel', | ||
33 | + region: 'center', | ||
34 | + activeTab : 0, | ||
35 | + items : [ | ||
36 | + { xtype: 'panelUpload', panelType : 'file'}, | ||
37 | + { xtype: 'panelUpload', panelType : 'timetable'}, | ||
38 | + { xtype: 'panelUpload', panelType : 'catalog'}] | ||
39 | + }, | ||
40 | + { | ||
41 | + xtype: 'panel', | ||
42 | + region: 'south', | ||
43 | + title: 'Information', | ||
44 | + collapsible: true, | ||
45 | + height: 100, | ||
46 | + autoHide: false, | ||
47 | + iconCls: 'icon-information', | ||
48 | + html: 'Select local or remote file (time table, catalog) to upload<br/>File size is limited to <b><i>' | ||
49 | + + myDesktopApp.MAX_UPLOADED_FILE_SIZE/1000000+'MB</i></b><br/>Milliseconds are ignored for the moment', | ||
50 | + autoScroll : true, | ||
51 | + loader: {} | ||
52 | + }] | ||
53 | + }; | ||
54 | 54 | ||
55 | - Ext.apply (this, Ext.apply(arguments, myConf)); | ||
56 | - }, | 55 | + Ext.apply (this, Ext.apply(arguments, myConf)); |
56 | + }, | ||
57 | 57 | ||
58 | - forceUpload : function(url,format) { | ||
59 | - //this.setDisabled(true); | ||
60 | - this.items.items[0].items.items[0].forceUpload(url,format); | ||
61 | - //this.setDisabled(false); | ||
62 | - } | ||
63 | - | 58 | + forceUpload : function(url,format) |
59 | + { | ||
60 | + //this.setDisabled(true); | ||
61 | + this.items.items[0].items.items[0].forceUpload(url,format); | ||
62 | + //this.setDisabled(false); | ||
63 | + } | ||
64 | }); | 64 | }); |
php/classes/AmdaAction.php
@@ -602,9 +602,13 @@ class AmdaAction | @@ -602,9 +602,13 @@ class AmdaAction | ||
602 | case 'myDataParam' : | 602 | case 'myDataParam' : |
603 | $objectMgr = new FilesMgr(); | 603 | $objectMgr = new FilesMgr(); |
604 | break; | 604 | break; |
605 | + case 'catalog' : | ||
606 | + $objectMgr = new CatalogMgr(); | ||
607 | + break; | ||
605 | default: | 608 | default: |
606 | return array("error" => $nodeType." NOT_IMPLEMENTED_YET"); | 609 | return array("error" => $nodeType." NOT_IMPLEMENTED_YET"); |
607 | } | 610 | } |
611 | + | ||
608 | return $objectMgr->getUploadedObject($name, $format, true); | 612 | return $objectMgr->getUploadedObject($name, $format, true); |
609 | 613 | ||
610 | } | 614 | } |
@@ -1017,16 +1021,17 @@ class AmdaAction | @@ -1017,16 +1021,17 @@ class AmdaAction | ||
1017 | 1021 | ||
1018 | public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false) | 1022 | public function initTTCacheFromTmpObject($folderId, $name, $isCatalog = false) |
1019 | { | 1023 | { |
1020 | - if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); | ||
1021 | - | 1024 | + if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); |
1022 | else $cacheMgr = new CatalogCacheMgr(); | 1025 | else $cacheMgr = new CatalogCacheMgr(); |
1023 | 1026 | ||
1024 | return $cacheMgr->initFromTmpObject($folderId, $name); | 1027 | return $cacheMgr->initFromTmpObject($folderId, $name); |
1025 | } | 1028 | } |
1026 | 1029 | ||
1027 | - public function initTTCacheFromUploadedFile($name, $format) | 1030 | + public function initTTCacheFromUploadedFile($name, $format, $isCatalog = false) |
1028 | { | 1031 | { |
1029 | - $cacheMgr = new TimeTableCacheMgr(); | 1032 | + if (!$isCatalog) $cacheMgr = new TimeTableCacheMgr(); |
1033 | + else $cacheMgr = new CatalogCacheMgr(); | ||
1034 | + | ||
1030 | return $cacheMgr->initFromUploadedFile($name, $format); | 1035 | return $cacheMgr->initFromUploadedFile($name, $format); |
1031 | } | 1036 | } |
1032 | 1037 |
php/classes/CatalogCacheMgr.php
@@ -45,7 +45,7 @@ class CatIntervalCacheObject extends IntervalCacheObject | @@ -45,7 +45,7 @@ class CatIntervalCacheObject extends IntervalCacheObject | ||
45 | { | 45 | { |
46 | fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified)); | 46 | fwrite($handle,pack('L6',$this->id,$this->index,$this->start,$this->stop,$this->isNew,$this->isModified)); |
47 | for ($i = 0; $i < $paramsNumber; $i++) { | 47 | for ($i = 0; $i < $paramsNumber; $i++) { |
48 | - $paramString = $this->params[$i]; | 48 | + $paramString = $this->params[$i]; |
49 | $paramArray = explode(',',$this->params[$i]); | 49 | $paramArray = explode(',',$this->params[$i]); |
50 | for ($j = 0; $j < $paramsSizes[$i]; $j++) fwrite($handle,pack('d', $paramArray[$j])); | 50 | for ($j = 0; $j < $paramsSizes[$i]; $j++) fwrite($handle,pack('d', $paramArray[$j])); |
51 | } | 51 | } |
@@ -63,11 +63,12 @@ class CatIntervalCacheObject extends IntervalCacheObject | @@ -63,11 +63,12 @@ class CatIntervalCacheObject extends IntervalCacheObject | ||
63 | 63 | ||
64 | for ($i = 0; $i < $paramsNumber; $i++) { | 64 | for ($i = 0; $i < $paramsNumber; $i++) { |
65 | $this->params[$i] = null; | 65 | $this->params[$i] = null; |
66 | - for ($j = 0; $j < $paramsSizes[$i]; $j++) { | ||
67 | - $val = unpack('dval',fread($handle,8)); | ||
68 | - $this->params[$i] .= $val['val']; | ||
69 | - if ($j != $paramsSizes[$i] - 1) $this->params[$i] .= ','; | ||
70 | - } | 66 | + for ($j = 0; $j < $paramsSizes[$i]; $j++) |
67 | + { | ||
68 | + $val = unpack('dval',fread($handle,8)); | ||
69 | + $this->params[$i] .= $val['val']; | ||
70 | + if ($j != $paramsSizes[$i] - 1) $this->params[$i] .= ','; | ||
71 | + } | ||
71 | } | 72 | } |
72 | 73 | ||
73 | } | 74 | } |
@@ -306,8 +307,44 @@ class CatalogCacheMgr extends TimeTableCacheMgr | @@ -306,8 +307,44 @@ class CatalogCacheMgr extends TimeTableCacheMgr | ||
306 | $this->cache->updateIndexes(); | 307 | $this->cache->updateIndexes(); |
307 | 308 | ||
308 | //Save cache file | 309 | //Save cache file |
309 | - return array('success' => $this->saveToFile(), 'token' => $this->cache->getToken(), | ||
310 | - 'status' => $this->cache->getStatus(), 'parameters' => $paramHeaders); | 310 | + return array('success'=>$this->saveToFile(), 'token'=>$this->cache->getToken(), |
311 | + 'status'=>$this->cache->getStatus(), 'parameters'=>$paramHeaders); | ||
312 | + } | ||
313 | + | ||
314 | + public function initFromUploadedFile($name, $format) | ||
315 | + { | ||
316 | + //Create new cache | ||
317 | + $this->cache = new CatalogCacheObject(); | ||
318 | + | ||
319 | + //Load intervals from uploaded file | ||
320 | + $intervals_res = $this->ttMgr->getUploadedObject($name, $format); | ||
321 | + | ||
322 | + if (!isset($intervals_res)) | ||
323 | + return array('success' => false, 'message' => 'Cannot get Uploaded Object'); | ||
324 | + | ||
325 | + if (array_key_exists('intervals', $intervals_res)) | ||
326 | + { | ||
327 | + foreach ($intervals_res['intervals'] as $interval) | ||
328 | + { | ||
329 | + //Add interval | ||
330 | + $this->cache->addInterval($interval['start'], $interval['stop'], $interval['paramTable']); | ||
331 | + } | ||
332 | + } | ||
333 | + | ||
334 | + $this->cache->setIsModified(true); | ||
335 | + $paramHeaders = $intervals_res['parameters']; | ||
336 | + | ||
337 | + $this->cache->setParamsNumber(count($paramHeaders)); | ||
338 | + $this->cache->setParamsSizes($paramHeaders); | ||
339 | + | ||
340 | + unset($intervals_res); | ||
341 | + | ||
342 | + //Update cache | ||
343 | + $this->cache->updateIndexes(); | ||
344 | + | ||
345 | + //Save cache file | ||
346 | + return array('success'=>$this->saveToFile(), 'token'=>$this->cache->getToken(), | ||
347 | + 'status'=>$this->cache->getStatus(), 'parameters'=>$paramHeaders); | ||
311 | } | 348 | } |
312 | 349 | ||
313 | public function initFromTT($id, $typeTT) | 350 | public function initFromTT($id, $typeTT) |
php/classes/CatalogMgr.php
@@ -4,8 +4,8 @@ | @@ -4,8 +4,8 @@ | ||
4 | * @class CatalogMgr | 4 | * @class CatalogMgr |
5 | */ | 5 | */ |
6 | 6 | ||
7 | -class CatalogMgr extends TimeTableMgr { | ||
8 | - | 7 | +class CatalogMgr extends TimeTableMgr |
8 | +{ | ||
9 | function __construct($sharedObject = FALSE) { | 9 | function __construct($sharedObject = FALSE) { |
10 | parent::__construct('Tt.xml', $sharedObject); | 10 | parent::__construct('Tt.xml', $sharedObject); |
11 | $this->contentRootId = 'catalog-treeRootNode'; | 11 | $this->contentRootId = 'catalog-treeRootNode'; |
@@ -20,9 +20,21 @@ class CatalogMgr extends TimeTableMgr { | @@ -20,9 +20,21 @@ class CatalogMgr extends TimeTableMgr { | ||
20 | $this->xp = new domxpath($this->contentDom); | 20 | $this->xp = new domxpath($this->contentDom); |
21 | } | 21 | } |
22 | } | 22 | } |
23 | - | ||
24 | - public function getTmpObject($folderId, $name, $onlyDescription = false) { | ||
25 | 23 | ||
24 | + public function getUploadedObject($name, $format, $onlyDescription = false) | ||
25 | + { | ||
26 | + if ($format == 'VOT') | ||
27 | + { | ||
28 | + $attributesToReturn = $this->vot2amda(USERTEMPDIR.$name, $onlyDescription); | ||
29 | + } | ||
30 | + $attributesToReturn['objName'] = $name; | ||
31 | + $attributesToReturn['objFormat'] = $format; | ||
32 | + | ||
33 | + return $attributesToReturn; | ||
34 | + } | ||
35 | + | ||
36 | + public function getTmpObject($folderId, $name, $onlyDescription = false) | ||
37 | + { | ||
26 | $filePath = USERWORKINGDIR.$folderId.'/'.$name.'.xml'; | 38 | $filePath = USERWORKINGDIR.$folderId.'/'.$name.'.xml'; |
27 | 39 | ||
28 | if (!file_exists($filePath)) | 40 | if (!file_exists($filePath)) |
@@ -415,5 +427,78 @@ class CatalogMgr extends TimeTableMgr { | @@ -415,5 +427,78 @@ class CatalogMgr extends TimeTableMgr { | ||
415 | // return array ('error' => $e->getMessage()); | 427 | // return array ('error' => $e->getMessage()); |
416 | // } | 428 | // } |
417 | // } | 429 | // } |
430 | + | ||
431 | +/* | ||
432 | +* Uploaded vot catalog => convert to AMDA tmp | ||
433 | +*/ | ||
434 | + protected function vot2amda($tmp_file, $onlyDescription = false) | ||
435 | + { | ||
436 | + // Load Catalog | ||
437 | + $this->objectDom->load($tmp_file); | ||
438 | + $objToGet = $this->objectDom->getElementsByTagName('TABLEDATA')->item(0); | ||
439 | + | ||
440 | + $attributes = $objToGet->childNodes; | ||
441 | + $paramsNodes = $this->objectDom->getElementsByTagName('FIELD'); | ||
442 | + $paramsNumber = $paramsNodes->length; | ||
443 | + | ||
444 | + foreach($attributes as $attribute) | ||
445 | + { | ||
446 | + if ($attribute->tagName == 'TR') | ||
447 | + { | ||
448 | + $start = $attribute->getElementsByTagName('TD')->item(0)->nodeValue; | ||
449 | + $stop = $attribute->getElementsByTagName('TD')->item(1)->nodeValue; | ||
450 | + $params = array(); | ||
451 | + | ||
452 | + for ($i = 2; $i < $paramsNumber; $i++) | ||
453 | + { | ||
454 | + $param = $attribute->getElementsByTagName('TD')->item($i)->nodeValue; | ||
455 | + | ||
456 | + if ($paramsNodes->item($i)->hasAttribute('arraysize')) | ||
457 | + { | ||
458 | + $param = join(",",explode(" ",trim($param))); | ||
459 | + } | ||
460 | + $params[] = $param; | ||
461 | + } | ||
462 | + if (!$onlyDescription) | ||
463 | + $attributesToReturn['intervals'][] = array('start' => $start, 'stop' => $stop, 'paramTable' => $params); | ||
464 | + } | ||
465 | + } | ||
466 | + | ||
467 | + if ($paramsNumber > 2) | ||
468 | + { | ||
469 | + $paramsArray = array(); | ||
470 | + for ($i = 2; $i < $paramsNumber; $i++) | ||
471 | + { | ||
472 | + $oneParam = array(); | ||
473 | + $paramNode = $paramsNodes->item($i); | ||
474 | + | ||
475 | + if ($paramNode->hasAttribute('arraysize')) | ||
476 | + { | ||
477 | + $oneParam['size'] = $paramNode->getAttribute('arraysize'); | ||
478 | + } | ||
479 | + else | ||
480 | + { | ||
481 | + $oneParam['size'] = 1; | ||
482 | + } | ||
483 | + foreach ($paramNode->attributes as $attr) | ||
484 | + { | ||
485 | + if ($attr->nodeName == 'datatype') | ||
486 | + $oneParam['type'] = $attr->nodeValue;//'Double'; | ||
487 | + else if ($attr->nodeName != 'arraysize') | ||
488 | + $oneParam[$attr->nodeName] = $attr->nodeValue; | ||
489 | + } | ||
490 | + $paramsArray[] = $oneParam; | ||
491 | + } | ||
492 | + $attributesToReturn['success'] = true; | ||
493 | + $attributesToReturn['parameters'] = $paramsArray; | ||
494 | + } | ||
495 | + | ||
496 | + $suffix = explode('.', basename($tmp_file)); | ||
497 | + $attributesToReturn['name'] = basename($tmp_file, '.'.$suffix[1]); | ||
498 | + $attributesToReturn['created'] = date('Y-m-d')."T".date('H:i:s'); | ||
499 | + $attributesToReturn['description'] = htmlspecialchars($this->objectDom->getElementsByTagName('DESCRIPTION')->item(0)->nodeValue); | ||
500 | + | ||
501 | + return($attributesToReturn); | ||
502 | + } | ||
418 | } | 503 | } |
419 | ?> | 504 | ?> |
php/config.php
@@ -170,7 +170,7 @@ $API = array( | @@ -170,7 +170,7 @@ $API = array( | ||
170 | 'initTTCacheFromTT'=>array('len'=>2), | 170 | 'initTTCacheFromTT'=>array('len'=>2), |
171 | 'initForChart'=>array('len'=>4), | 171 | 'initForChart'=>array('len'=>4), |
172 | 'initTTCacheFromTmpObject'=>array('len'=>3), | 172 | 'initTTCacheFromTmpObject'=>array('len'=>3), |
173 | - 'initTTCacheFromUploadedFile'=>array('len'=>2), | 173 | + 'initTTCacheFromUploadedFile'=>array('len'=>3), |
174 | 'readTTCacheIntervals'=>array('len'=>1), | 174 | 'readTTCacheIntervals'=>array('len'=>1), |
175 | 'readIntervalsForChart'=>array('len'=>1), | 175 | 'readIntervalsForChart'=>array('len'=>1), |
176 | 'addTTCacheInterval'=>array('len'=>1), | 176 | 'addTTCacheInterval'=>array('len'=>1), |
php/uploadFile.php
@@ -7,296 +7,300 @@ | @@ -7,296 +7,300 @@ | ||
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | 9 | ||
10 | - function file_upload_error_message($error_code) { | ||
11 | - | ||
12 | - switch ($error_code) { | ||
13 | - case UPLOAD_ERR_INI_SIZE: | ||
14 | - return 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; | ||
15 | - case UPLOAD_ERR_FORM_SIZE: | ||
16 | - return 'The uploaded file exceeds max file size of '.maxSize; | ||
17 | - case UPLOAD_ERR_PARTIAL: | ||
18 | - return 'The uploaded file was only partially uploaded'; | ||
19 | - case UPLOAD_ERR_NO_FILE: | ||
20 | - return 'No file was uploaded'; | ||
21 | - case UPLOAD_ERR_NO_TMP_DIR: | ||
22 | - return 'Missing a temporary folder'; | ||
23 | - case UPLOAD_ERR_CANT_WRITE: | ||
24 | - return 'Failed to write file to disk'; | ||
25 | - case UPLOAD_ERR_EXTENSION: | ||
26 | - return 'File upload stopped by extension'; | ||
27 | - case UPLOAD_ERR_EMPTY: | ||
28 | - return 'File is empty'; | ||
29 | - default: | ||
30 | - return 'Unknown upload error'; | ||
31 | - } | ||
32 | - } | ||
33 | - | ||
34 | - function getUrlFileSize($URL) { | ||
35 | - $ch = curl_init($URL); | ||
36 | - curl_setopt($ch, CURLOPT_NOBODY, true); | ||
37 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
38 | - curl_setopt($ch, CURLOPT_HEADER, true); | ||
39 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
40 | - $data = curl_exec($ch); | ||
41 | - curl_close($ch); | 10 | + function file_upload_error_message($error_code) |
11 | + { | ||
12 | + switch ($error_code) | ||
13 | + { | ||
14 | + case UPLOAD_ERR_INI_SIZE: | ||
15 | + return 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; | ||
16 | + case UPLOAD_ERR_FORM_SIZE: | ||
17 | + return 'The uploaded file exceeds max file size of '.maxSize; | ||
18 | + case UPLOAD_ERR_PARTIAL: | ||
19 | + return 'The uploaded file was only partially uploaded'; | ||
20 | + case UPLOAD_ERR_NO_FILE: | ||
21 | + return 'No file was uploaded'; | ||
22 | + case UPLOAD_ERR_NO_TMP_DIR: | ||
23 | + return 'Missing a temporary folder'; | ||
24 | + case UPLOAD_ERR_CANT_WRITE: | ||
25 | + return 'Failed to write file to disk'; | ||
26 | + case UPLOAD_ERR_EXTENSION: | ||
27 | + return 'File upload stopped by extension'; | ||
28 | + case UPLOAD_ERR_EMPTY: | ||
29 | + return 'File is empty'; | ||
30 | + default: | ||
31 | + return 'Unknown upload error'; | ||
32 | + } | ||
33 | + } | ||
42 | 34 | ||
43 | - $ContentLength = 1000000000000000000; | ||
44 | - if (preg_match('/Content-Length: (\d+)/', $data, $matches)) { | ||
45 | - $ContentLength = (int)$matches[1]; | ||
46 | - } | ||
47 | - return $ContentLength; | ||
48 | - } | 35 | + function getUrlFileSize($URL) |
36 | + { | ||
37 | + $ch = curl_init($URL); | ||
38 | + curl_setopt($ch, CURLOPT_NOBODY, true); | ||
39 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
40 | + curl_setopt($ch, CURLOPT_HEADER, true); | ||
41 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
42 | + $data = curl_exec($ch); | ||
43 | + curl_close($ch); | ||
49 | 44 | ||
50 | - /** | ||
51 | - * Main | ||
52 | - */ | ||
53 | - define("UPLOAD_ERR_EMPTY",5); | 45 | + $ContentLength = 1000000000000000000; |
46 | + if (preg_match('/Content-Length: (\d+)/', $data, $matches)) { | ||
47 | + $ContentLength = (int)$matches[1]; | ||
48 | + } | ||
49 | + | ||
50 | + return $ContentLength; | ||
51 | + } | ||
54 | 52 | ||
55 | - require_once 'config.php'; | 53 | + /** |
54 | + * Main | ||
55 | + */ | ||
56 | + define("UPLOAD_ERR_EMPTY",5); | ||
56 | 57 | ||
57 | - // error_reporting(E_ERROR | E_WARNING | E_PARSE); | 58 | + require_once 'config.php'; |
58 | 59 | ||
59 | - if (!isset($_POST['sessionID'])) | ||
60 | - { | ||
61 | - $response = array( 'success' => false, 'error' => ': Check that uploaded file size is less than '.ini_get('upload_max_filesize')); | ||
62 | - die(json_encode($response)); | ||
63 | - } | 60 | + // error_reporting(E_ERROR | E_WARNING | E_PARSE); |
64 | 61 | ||
65 | - define('USERDATADIR', USERPATH."/".$_POST['sessionID']."/DATA/"); | ||
66 | - define('USERTEMPDIR', USERPATH."/".$_POST['sessionID']."/TEMP/"); | ||
67 | - define('USERWSDIR', USERPATH."/".$_POST['sessionID']."/WS/"); | ||
68 | - define('USERWORKINGDIR', USERPATH."/".$_POST['sessionID']."/RES/"); | ||
69 | - define('ATTACHMENTDIR', DATAPATH."/Feedback/Attach/"); | ||
70 | - define('maxSize',$_POST['MAX_FILE_SIZE'] < ini_get('upload_max_filesize')); | 62 | + if (!isset($_POST['sessionID'])) |
63 | + { | ||
64 | + $response = array( 'success' => false, 'error' => ': Check that uploaded file size is less than '.ini_get('upload_max_filesize')); | ||
65 | + die(json_encode($response)); | ||
66 | + } | ||
71 | 67 | ||
72 | - if (!is_dir(USERTEMPDIR)) mkdir(USERTEMPDIR.'/', 0755, true); | ||
73 | - if (!is_dir(ATTACHMENTDIR)) mkdir(ATTACHMENTDIR.'/', 0755, true); | 68 | + define('USERDATADIR', USERPATH."/".$_POST['sessionID']."/DATA/"); |
69 | + define('USERTEMPDIR', USERPATH."/".$_POST['sessionID']."/TEMP/"); | ||
70 | + define('USERWSDIR', USERPATH."/".$_POST['sessionID']."/WS/"); | ||
71 | + define('USERWORKINGDIR', USERPATH."/".$_POST['sessionID']."/RES/"); | ||
72 | + define('ATTACHMENTDIR', DATAPATH."/Feedback/Attach/"); | ||
73 | + define('maxSize',$_POST['MAX_FILE_SIZE'] < ini_get('upload_max_filesize')); | ||
74 | 74 | ||
75 | - if (!$_FILES['attachment'] && !$_FILES['localFileName'] && !$_FILES['localTTName'] && | ||
76 | - !$_POST['remoteFile'] && !$_POST['remoteTT']) | ||
77 | - { | ||
78 | - $response = array( 'success' => false, 'error' => 'UNDEFINED ACTION'); | ||
79 | - die(json_encode($response)); | ||
80 | - } | ||
81 | - | ||
82 | - $fileFrmt = $_POST['filefrmt']; | ||
83 | - $timeFrmt = $_POST['timefrmt'] ? $_POST['timefrmt'] : null; | ||
84 | - $timeSmplg = $_POST['timesmpl'] ? $_POST['timesmpl'] : null; | ||
85 | - $nonStd = $_POST['nonstd'] ? $_POST['nonstd'] : null; | ||
86 | - $timeLength = $_POST['timelength'] ? $_POST['timelength'] : null; | ||
87 | - $doy = $_POST['doy'] ? $_POST['doy'] : null; | 75 | + if (!is_dir(USERTEMPDIR)) mkdir(USERTEMPDIR.'/', 0755, true); |
76 | + if (!is_dir(ATTACHMENTDIR)) mkdir(ATTACHMENTDIR.'/', 0755, true); | ||
88 | 77 | ||
89 | - $allFormats = array('fileFormat' => $fileFrmt, 'timeFormat' => $timeFrmt, 'doy' => $doy, | ||
90 | - 'timeSampling' => $timeSmplg, 'nonStandard' => $nonStd, 'timeLength' => $timeLength); | 78 | + if (!$_FILES['attachment'] && !$_FILES['localFileName'] && !$_FILES['localTTName'] && !$_FILES['localCatName'] && |
79 | + !$_POST['remoteFile'] && !$_POST['remoteTT'] && !$_POST['remoteCat']) | ||
80 | + { | ||
81 | + $response = array( 'success' => false, 'error' => 'UNDEFINED ACTION'); | ||
82 | + die(json_encode($response)); | ||
83 | + } | ||
91 | 84 | ||
92 | - if ($_POST['filesrc'] == 'URL') | ||
93 | - $fromURL = true; | ||
94 | - else | ||
95 | - $fromURL = false; | ||
96 | - // to check ws sizw | ||
97 | - $wsMgr = new UserMgr(); | 85 | + $fileFrmt = $_POST['filefrmt']; |
86 | + $timeFrmt = $_POST['timefrmt'] ? $_POST['timefrmt'] : null; | ||
87 | + $timeSmplg = $_POST['timesmpl'] ? $_POST['timesmpl'] : null; | ||
88 | + $nonStd = $_POST['nonstd'] ? $_POST['nonstd'] : null; | ||
89 | + $timeLength = $_POST['timelength'] ? $_POST['timelength'] : null; | ||
90 | + $doy = $_POST['doy'] ? $_POST['doy'] : null; | ||
91 | + | ||
92 | + $allFormats = array('fileFormat' => $fileFrmt, 'timeFormat' => $timeFrmt, 'doy' => $doy, | ||
93 | + 'timeSampling' => $timeSmplg, 'nonStandard' => $nonStd, 'timeLength' => $timeLength); | ||
98 | 94 | ||
99 | - if ($fromURL) | ||
100 | - { | ||
101 | - // url files check | ||
102 | - if ($_POST['remoteFile']) | ||
103 | - { | ||
104 | - $remoteName = $_POST['remoteFile']; | ||
105 | - $fileName = substr(strrchr($remoteName,"/"),1); | ||
106 | - $localName = USERDATADIR.$fileName; | ||
107 | - $isFile = true; | ||
108 | - } | ||
109 | - else | ||
110 | - { | ||
111 | - $remoteName = $_POST['remoteTT']; | ||
112 | - $fileName = substr(strrchr($remoteName,"/"),1); | ||
113 | - $localName = USERTEMPDIR.$fileName; | ||
114 | - $isFile = false; | ||
115 | - } | 95 | + if ($_POST['filesrc'] == 'URL') $fromURL = true; |
96 | + else $fromURL = false; | ||
97 | + | ||
98 | + // to check ws sizw | ||
99 | + $wsMgr = new UserMgr(); | ||
100 | + | ||
101 | + if ($fromURL) | ||
102 | + { | ||
103 | + // url files check | ||
104 | + if ($_POST['remoteFile']) | ||
105 | + { | ||
106 | + $remoteName = $_POST['remoteFile']; | ||
107 | + $fileName = substr(strrchr($remoteName,"/"),1); | ||
108 | + $localName = USERDATADIR.$fileName; | ||
109 | + $isFile = true; | ||
110 | + } | ||
111 | + else | ||
112 | + { | ||
113 | + $isTimeTable = $_POST['remoteTT'] ? true : false; | ||
114 | + $remoteName = $isTimeTable ? $_POST['remoteTT'] : $_POST['remoteCat']; | ||
115 | + $fileName = substr(strrchr($remoteName,"/"),1); | ||
116 | + $localName = USERTEMPDIR.$fileName; | ||
117 | + $isFile = false; | ||
118 | + } | ||
116 | 119 | ||
117 | - $url = null; | 120 | + $url = null; |
118 | 121 | ||
119 | - if (substr($remoteName,0,4) == 'http') | ||
120 | - $url = 'http'; | ||
121 | - if (substr($remoteName,0,3) == 'ftp') | ||
122 | - $url = 'ftp'; | 122 | + if (substr($remoteName,0,4) == 'http') $url = 'http'; |
123 | + if (substr($remoteName,0,3) == 'ftp') $url = 'ftp'; | ||
123 | 124 | ||
124 | - if (!$url) | ||
125 | - { | ||
126 | - $response = array( 'success' => false, 'error' => 'Unknown net protocol'); | ||
127 | - die(json_encode($response)); | ||
128 | - } | 125 | + if (!$url) |
126 | + { | ||
127 | + $response = array( 'success' => false, 'error' => 'Unknown net protocol'); | ||
128 | + die(json_encode($response)); | ||
129 | + } | ||
129 | 130 | ||
130 | - if (file_exists($localName) && $isFile) | ||
131 | - { | ||
132 | - $response = array( 'success' => false, 'error' => 'File '.$fileName.' exists'); | ||
133 | - die(json_encode($response)); | ||
134 | - } | 131 | + if (file_exists($localName) && $isFile) |
132 | + { | ||
133 | + $response = array( 'success' => false, 'error' => 'File '.$fileName.' exists'); | ||
134 | + die(json_encode($response)); | ||
135 | + } | ||
135 | 136 | ||
136 | - if ($url == 'ftp') | ||
137 | - $fileSize = filesize($remoteName); | ||
138 | - else | ||
139 | - $fileSize = getUrlFileSize($remoteName); | 137 | + if ($url == 'ftp') $fileSize = filesize($remoteName); |
138 | + else $fileSize = getUrlFileSize($remoteName); | ||
140 | 139 | ||
141 | - if (!$fileSize) | ||
142 | - { | ||
143 | - $response = array( 'success' => false, 'error' => 'Can\'t estimate file size '.$fileName); | ||
144 | - die(json_encode($response)); | ||
145 | - } | 140 | + if (!$fileSize) |
141 | + { | ||
142 | + $response = array( 'success' => false, 'error' => 'Can\'t estimate file size '.$fileName); | ||
143 | + die(json_encode($response)); | ||
144 | + } | ||
146 | 145 | ||
147 | - if ($file['size'] > DISK_QUOTA) | ||
148 | - { | ||
149 | - $response = array( 'success' => false, 'error' => 'The file you selected is too big for allowed disk quota'); | ||
150 | - die(json_encode($response)); | ||
151 | - } | ||
152 | - | ||
153 | - if ($wsMgr->getWsSize() + $fileSize > DISK_QUOTA && $isFile) | ||
154 | - { | ||
155 | - $response = array( 'success' => false, 'error' => 'Please clean up you workspace. You are about to exceed available disk space'); | ||
156 | - die(json_encode($response)); | ||
157 | - } | 146 | + if ($file['size'] > DISK_QUOTA) |
147 | + { | ||
148 | + $response = array( 'success' => false, 'error' => 'The file you selected is too big for allowed disk quota'); | ||
149 | + die(json_encode($response)); | ||
150 | + } | ||
151 | + | ||
152 | + if ($wsMgr->getWsSize() + $fileSize > DISK_QUOTA && $isFile) | ||
153 | + { | ||
154 | + $response = array( 'success' => false, 'error' => 'Please clean up you workspace. You are about to exceed available disk space'); | ||
155 | + die(json_encode($response)); | ||
156 | + } | ||
158 | 157 | ||
159 | - if ($fileSize > maxSize) | ||
160 | - { | ||
161 | - $response = array( 'success' => false, 'error' => 'The uploaded file exceeds '.maxSize); | ||
162 | - die(json_encode($response)); | ||
163 | - } | 158 | + if ($fileSize > maxSize) |
159 | + { | ||
160 | + $response = array( 'success' => false, 'error' => 'The uploaded file exceeds '.maxSize); | ||
161 | + die(json_encode($response)); | ||
162 | + } | ||
164 | 163 | ||
165 | - if (!copy($remoteName, $localName)) | ||
166 | - { | ||
167 | - $response = array( 'success' => false, 'error' => 'Can\'t copy '.$fileName); | ||
168 | - die(json_encode($response)); | ||
169 | - } | 164 | + if (!copy($remoteName, $localName)) |
165 | + { | ||
166 | + $response = array( 'success' => false, 'error' => 'Can\'t copy '.$fileName); | ||
167 | + die(json_encode($response)); | ||
168 | + } | ||
170 | 169 | ||
171 | - if (is_executable($localName)) | ||
172 | - { | ||
173 | - $response = array( 'success' => false, 'error' => 'File '.$fileName.' is executable'); | ||
174 | - unlink($localName); | ||
175 | - die(json_encode($response)); | ||
176 | - } | 170 | + if (is_executable($localName)) |
171 | + { | ||
172 | + $response = array( 'success' => false, 'error' => 'File '.$fileName.' is executable'); | ||
173 | + unlink($localName); | ||
174 | + die(json_encode($response)); | ||
175 | + } | ||
177 | 176 | ||
178 | - if ($isFile) | ||
179 | - { | ||
180 | - $fileMgr = new FilesMgr(); | ||
181 | - $amdaStat = new AmdaStats($_POST['sessionID']); | ||
182 | - if ($amdaStat->success) | ||
183 | - $amdaStat->addTask('upload', $_POST['sessionID'], null); | ||
184 | - } | ||
185 | - // Time Table | ||
186 | - else | ||
187 | - { | ||
188 | - $response = array( 'success' => true, 'file' => $fileName, 'format' => $_POST['ttfrmt'] ); | ||
189 | - die(json_encode($response)); | ||
190 | - } | ||
191 | - } | ||
192 | - else | ||
193 | - { | ||
194 | - // local files check | ||
195 | - if ($_FILES['localFileName']) | ||
196 | - { | ||
197 | - $file = $_FILES['localFileName']; | ||
198 | - $localName = USERDATADIR.$file['name']; | ||
199 | - $isFile = true; | ||
200 | - } | ||
201 | - else if ($_FILES['attachment']) | ||
202 | - { | ||
203 | - if (!is_dir(ATTACHMENTDIR)) | ||
204 | - mkdir(ATTACHMENTDIR,755); | 177 | + if ($isFile) |
178 | + { | ||
179 | + $fileMgr = new FilesMgr(); | ||
180 | + $amdaStat = new AmdaStats($_POST['sessionID']); | ||
181 | + if ($amdaStat->success) $amdaStat->addTask('upload', $_POST['sessionID'], null); | ||
182 | + } | ||
183 | + // Time Table | ||
184 | + else if ($isTimeTable) | ||
185 | + { | ||
186 | + $response = array( 'success'=>true, 'file'=>$fileName, 'format'=>$_POST['ttfrmt'] ); | ||
187 | + die(json_encode($response)); | ||
188 | + } | ||
189 | + else | ||
190 | + { | ||
191 | + $response = array( 'success'=>true, 'file'=>$fileName, 'format'=>$_POST['catfrmt'] ); | ||
192 | + die(json_encode($response)); | ||
193 | + } | ||
194 | + } | ||
195 | + else | ||
196 | + { | ||
197 | + // local files check | ||
198 | + if ($_FILES['localFileName']) | ||
199 | + { | ||
200 | + $file = $_FILES['localFileName']; | ||
201 | + $localName = USERDATADIR.$file['name']; | ||
202 | + $isFile = true; | ||
203 | + } | ||
204 | + else if ($_FILES['attachment']) | ||
205 | + { | ||
206 | + if (!is_dir(ATTACHMENTDIR)) mkdir(ATTACHMENTDIR,755); | ||
205 | 207 | ||
206 | - $file = $_FILES['attachment']; | ||
207 | - $file['name'] = str_replace(" ","_",$file['name']); | ||
208 | - $file['name'] = $_POST['sessionID'].'_'.date("Y-m-d\TH:i:s").'_'.$file['name']; | ||
209 | - $localName = ATTACHMENTDIR.$file['name']; | ||
210 | - $isFile = false; | ||
211 | - } | ||
212 | - else | ||
213 | - { | ||
214 | - $file = $_FILES['localTTName']; | ||
215 | - $localName = USERTEMPDIR.$file['name']; | ||
216 | - $isFile = false; | ||
217 | - } | 208 | + $file = $_FILES['attachment']; |
209 | + $file['name'] = str_replace(" ","_",$file['name']); | ||
210 | + $file['name'] = $_POST['sessionID'].'_'.date("Y-m-d\TH:i:s").'_'.$file['name']; | ||
211 | + $localName = ATTACHMENTDIR.$file['name']; | ||
212 | + $isFile = false; | ||
213 | + } | ||
214 | + else | ||
215 | + { | ||
216 | + $isTimeTable = $_FILES['localTTName'] ? true : false; | ||
217 | + $file = $isTimeTable ? $_FILES['localTTName'] : $_FILES['localCatName']; | ||
218 | + $localName = USERTEMPDIR.$file['name']; | ||
219 | + $isFile = false; | ||
220 | + } | ||
218 | 221 | ||
219 | - if($file['size'] === 0 && $file['error'] === 0){ | ||
220 | - $file['error'] = 5; | ||
221 | - } | 222 | + if($file['size'] === 0 && $file['error'] === 0) |
223 | + { | ||
224 | + $file['error'] = 5; | ||
225 | + } | ||
222 | 226 | ||
223 | - if ($file['error'] !== 0) | ||
224 | - { | ||
225 | - $response = array( 'success' => false, 'error' => file_upload_error_message($file['error'])); | ||
226 | - die(json_encode($response)); | ||
227 | - } | 227 | + if ($file['error'] !== 0) |
228 | + { | ||
229 | + $response = array( 'success'=>false, 'error'=>file_upload_error_message($file['error'])); | ||
230 | + die(json_encode($response)); | ||
231 | + } | ||
228 | 232 | ||
229 | - if (file_exists($localName) && $isFile) | ||
230 | - { | ||
231 | - $response = array( 'success' => false, 'error' => 'File '.$file['name'].' exists'); | ||
232 | - die(json_encode($response)); | ||
233 | - } | 233 | + if (file_exists($localName) && $isFile) |
234 | + { | ||
235 | + $response = array( 'success'=>false, 'error'=>'File '.$file['name'].' exists'); | ||
236 | + die(json_encode($response)); | ||
237 | + } | ||
234 | 238 | ||
235 | - if (is_executable($file['tmp_name'])) | ||
236 | - { | ||
237 | - $response = array( 'success' => false, 'error' => 'File '.$file['name'].' is executable'); | ||
238 | - unlink($file['tmp_name']); | ||
239 | - die(json_encode($response)); | ||
240 | - } | 239 | + if (is_executable($file['tmp_name'])) |
240 | + { | ||
241 | + $response = array( 'success'=>false, 'error'=>'File '.$file['name'].' is executable'); | ||
242 | + unlink($file['tmp_name']); | ||
243 | + die(json_encode($response)); | ||
244 | + } | ||
241 | 245 | ||
242 | - if (!is_uploaded_file($file['tmp_name'])) | ||
243 | - { | ||
244 | - $response = array( 'success' => false, 'error' => 'File '.$file['name'].' WASN\'T UPLOADED'); | ||
245 | - unlink($file['tmp_name']); | ||
246 | - die(json_encode($response)); | ||
247 | - } | 246 | + if (!is_uploaded_file($file['tmp_name'])) |
247 | + { | ||
248 | + $response = array( 'success'=>false, 'error'=>'File '.$file['name'].' WASN\'T UPLOADED'); | ||
249 | + unlink($file['tmp_name']); | ||
250 | + die(json_encode($response)); | ||
251 | + } | ||
248 | 252 | ||
249 | - if ($file['size'] > DISK_QUOTA) | ||
250 | - { | ||
251 | - $response = array( 'success' => false, 'error' => 'The file you selected is too big for allowed disk quota'); | ||
252 | - die(json_encode($response)); | ||
253 | - } | 253 | + if ($file['size'] > DISK_QUOTA) |
254 | + { | ||
255 | + $response = array( 'success'=>false, 'error'=>'The file you selected is too big for allowed disk quota'); | ||
256 | + die(json_encode($response)); | ||
257 | + } | ||
254 | 258 | ||
255 | - if ($wsMgr->getWsSize() + $file['size'] > DISK_QUOTA) | ||
256 | - { | ||
257 | - $response = array( 'success' => false, 'error' => 'Please clean up your workspace. You are about to exceed available disk space'); | ||
258 | - die(json_encode($response)); | ||
259 | - } | 259 | + if ($wsMgr->getWsSize() + $file['size'] > DISK_QUOTA) |
260 | + { | ||
261 | + $response = array( 'success'=>false, 'error'=>'Please clean up your workspace. You are about to exceed available disk space'); | ||
262 | + die(json_encode($response)); | ||
263 | + } | ||
260 | 264 | ||
261 | - if (!rename($file['tmp_name'], $localName)) | ||
262 | - { | ||
263 | - $response = array( 'success' => false, 'error' => 'Cannot copy file '.$file['name']); | ||
264 | - unlink($file['tmp_name']); | ||
265 | - die(json_encode($response)); | ||
266 | - } | 265 | + if (!rename($file['tmp_name'], $localName)) |
266 | + { | ||
267 | + $response = array( 'success'=>false, 'error'=>'Cannot copy file '.$file['name']); | ||
268 | + unlink($file['tmp_name']); | ||
269 | + die(json_encode($response)); | ||
270 | + } | ||
267 | 271 | ||
268 | - if (file_exists($localName) && !$isFile) | ||
269 | - { | ||
270 | - if ($_POST['ttfrmt'] == 'VOT') | ||
271 | - { | ||
272 | - $votMgr = new VOTableMgr(); | ||
273 | - if (!$votMgr->load($localName) || !$votMgr->isValidSchema()) | ||
274 | - { | ||
275 | - $response = array( 'success' => false, 'error' => 'File '.$file['name'].' is not valid'); | ||
276 | - unlink($localName); | ||
277 | - die(json_encode($response)); | ||
278 | - } | ||
279 | - } | ||
280 | - } | 272 | + if (file_exists($localName) && !$isFile) |
273 | + { | ||
274 | + if ($_POST['ttfrmt'] == 'VOT' || $_POST['catfrmt'] == 'VOT') | ||
275 | + { | ||
276 | + $votMgr = new VOTableMgr(); | ||
277 | + if (!$votMgr->load($localName) || !$votMgr->isValidSchema()) | ||
278 | + { | ||
279 | + $response = array( 'success'=>false, 'error'=>'File '.$file['name'].' is not valid'); | ||
280 | + unlink($localName); | ||
281 | + die(json_encode($response)); | ||
282 | + } | ||
283 | + } | ||
284 | + } | ||
281 | 285 | ||
282 | - $fileName = $file['name']; | 286 | + $fileName = $file['name']; |
283 | 287 | ||
284 | - if ($isFile) | ||
285 | - { | ||
286 | - $fileMgr = new FilesMgr(); | ||
287 | - $amdaStat = new AmdaStats($_POST['sessionID']); | ||
288 | - if ($amdaStat->success) | ||
289 | - $amdaStat->addTask('upload', $_POST['sessionID'], null); | ||
290 | - } | ||
291 | - // Time Table | ||
292 | - else | ||
293 | - { | ||
294 | - $response = array( 'success' => true, 'file' => $fileName, 'format' => $_POST['ttfrmt'] ); | ||
295 | - die(json_encode($response)); | ||
296 | - } | ||
297 | - } | 288 | + if ($isFile) |
289 | + { | ||
290 | + $fileMgr = new FilesMgr(); | ||
291 | + $amdaStat = new AmdaStats($_POST['sessionID']); | ||
292 | + if ($amdaStat->success) $amdaStat->addTask('upload', $_POST['sessionID'], null); | ||
293 | + } | ||
294 | + // Time Table or Catalog | ||
295 | + else | ||
296 | + { | ||
297 | + $format = $isTimeTable ? $_POST['ttfrmt'] : $_POST['catfrmt']; | ||
298 | + $response = array( 'success'=>true, 'file'=>$fileName, 'format'=>$format ); | ||
299 | + die(json_encode($response)); | ||
300 | + } | ||
301 | + } | ||
298 | 302 | ||
299 | - $response = $fileMgr->addFile($fileName, $allFormats); | 303 | + $response = $fileMgr->addFile($fileName, $allFormats); |
300 | 304 | ||
301 | - echo json_encode($response); | 305 | + echo json_encode($response); |
302 | ?> | 306 | ?> |