Commit f60f0bd99883097e5de87187390f8f09ccdf8cc4

Authored by Benjamin Renard
1 parent 4607eaa0

Fix upload from samp notification (#5765)

js/app/controllers/UploadModule.js
... ... @@ -40,20 +40,20 @@ Ext.define('amdaDesktop.UploadModule', {
40 40 var desktop = myDesktopApp.getDesktop();
41 41 var win = desktop.getWindow(me.id);
42 42 if (!win) {
43   - loadMask.show();
44 43 this.createWindow(function (o)
45 44 {
46 45 win = desktop.getWindow(me.id);
47 46 if (win){
48   - win.items.items[0].forceUpload(url,format);
49   - win.close();
  47 + win.items.items[0].forceUpload(url,format, function() {
  48 + win.close();
  49 + });
50 50 }
51   - loadMask.hide();
52 51 });
53 52 }
54 53 else {
55   - win.items.items[0].forceUpload(url,format);
56   - win.close();
  54 + win.items.items[0].forceUpload(url,format,function() {
  55 + win.close();
  56 + });
57 57 }
58 58 }
59 59 });
... ...
js/app/views/UploadPanelUI.js
... ... @@ -176,10 +176,20 @@ Ext.define('amdaUI.UploadPanelUI', {
176 176 /*
177 177 *
178 178 */
179   - forceUpload : function (url,format)
  179 + forceUpload : function (url,format,onFinish)
180 180 {
181   - this.getForm().findField('filesrc').setValue('URL');
  181 + var re = /http:\/\/127.0.0.1:/;
  182 + var isRemoteUrl = !re.test(url);
  183 +
  184 + if (!isRemoteUrl) {
  185 + myDesktopApp.warningMsg("Cannot load data from a local application.");
  186 + if (onFinish)
  187 + onFinish();
  188 + return;
  189 + }
182 190  
  191 + this.getForm().findField('filesrc').setValue('URL');
  192 + this.getForm().findField('remoteFile').setValue(url);
183 193 switch (format)
184 194 {
185 195 case 'votable' :
... ... @@ -191,36 +201,39 @@ Ext.define('amdaUI.UploadPanelUI', {
191 201 default :
192 202 //ToDo Error - unknown format
193 203 return;
194   - }
195   - this.getForm().findField('remoteFile').setValue(url);
196   -
197   - this.postUpload();
  204 + }
  205 + this.postUpload(onFinish);
198 206 },
199 207  
200 208 /*
201 209 *
202 210 */
203   - postUpload : function()
  211 + postUpload : function(onFinish)
204 212 {
205 213 // 'global' form containing 'partial' forms
206 214 var form = this.getForm();
207 215  
208 216 // special validation
209 217 if(this.validate())
210   - {
  218 + {
  219 + loadMask.show();
211 220 form.submit({
212 221 scope: this,
213 222 url: 'php/uploadFile.php',
214 223 waitMsg: 'Uploading your file...',
215 224 success: function(form, o)
216   - {
  225 + {
  226 + if (onFinish)
  227 + onFinish();
217 228 this.tmpNode = Ext.create(this.nodeType,{leaf : true, text : o.result.file});
218   - loadMask.show();
219 229 AmdaAction.getUploadedObject(o.result.file, o.result.format, this.tmpNode.get('nodeType'), this.getObjectCallback, this);
  230 + loadMask.hide();
220 231 },
221 232 failure: function(form, o)
222   - {
223   - loadMask.hide();
  233 + {
  234 + if (onFinish)
  235 + onFinish();
  236 + loadMask.hide();
224 237 myDesktopApp.errorMsg('Error '+o.result.error);
225 238 }
226 239 });
... ...
js/app/views/UploadUI.js
... ... @@ -55,10 +55,10 @@ Ext.define('amdaUI.UploadUI', {
55 55 Ext.apply (this, Ext.apply(arguments, myConf));
56 56 },
57 57  
58   - forceUpload : function(url,format)
  58 + forceUpload : function(url,format,onFinish)
59 59 {
60 60 //this.setDisabled(true);
61   - this.items.items[0].items.items[0].forceUpload(url,format);
  61 + this.items.items[0].items.items[0].forceUpload(url,format,onFinish);
62 62 //this.setDisabled(false);
63 63 }
64 64 });
... ...
php/classes/AmdaObjectMgr.php
... ... @@ -124,7 +124,7 @@ class AmdaObjectMgr
124 124  
125 125 foreach($obj as $key => $value)
126 126 {
127   - if ($key != 'id' && $key != 'leaf' && $key != 'nodeType' && !is_array($value))
  127 + if ($key != 'id' && $key != 'leaf' && $key != 'nodeType' && !is_array($value) && !is_object($value))
128 128 {
129 129 $node = $this->objectDom->createElement($key,htmlspecialchars($value));
130 130 $root -> appendChild($node);
... ...
php/classes/VOTableMgr.php
... ... @@ -241,16 +241,9 @@ class VOTableMgr {
241 241  
242 242 public function getFirstTR()
243 243 {
244   - if (!$this->xp)
245   - return NULL;
246   -
247   - /*$trs = $this->xp->query($this->queryTR());
248   -
249   - if ($trs->length < 1)
  244 + if (!isset($this->xp))
250 245 return NULL;
251 246  
252   - return $trs->item(0);*/
253   -
254 247 $tabledatas = $this->xp->query($this->queryTableData());
255 248  
256 249 if ($tabledatas->length < 1)
... ... @@ -259,21 +252,23 @@ class VOTableMgr {
259 252 $tabledata = $tabledatas->item(0);
260 253  
261 254 $node = $tabledata->firstChild;
  255 + if (!isset($node))
  256 + return NULL;
262 257  
263   - while($node && ($node->nodeType != 1) && ($node->nodeName != "TR"))
264   - $node = $node->nextSibling;
  258 + if (($node->nodeType != XML_ELEMENT_NODE) || ($node->nodeName != "TR"))
  259 + return $this->getNextTR($node);
265 260  
266   - return $node;
  261 + return $node;
267 262 }
268 263  
269 264 public function getNextTR($tr)
270 265 {
271   - if (!$this->xp)
  266 + if (!isset($this->xp) || !isset($tr) || !isset($tr->nextSibling))
272 267 return NULL;
273 268  
274   - while($tr->nextSibling && ($tr->nextSibling->nodeType != 1) && ($node->nodeName != "TR"))
275   - $tr = $tr->nextSibling;
276   - return $tr->nextSibling;
  269 + if (($tr->nextSibling->nodeType != XML_ELEMENT_NODE) || ($tr->nextSibling->nodeName != "TR"))
  270 + return $this->getNextTR($tr->nextSibling);
  271 + return $tr->nextSibling;
277 272 }
278 273  
279 274 public function getTDValueByFieldIndex($tr,$field_index)
... ... @@ -392,24 +387,24 @@ class VOTableMgr {
392 387  
393 388 $tr = $this->getFirstTR();
394 389  
395   - if (!$tr)
  390 + if (!isset($tr))
396 391 return '0 0';
397 392  
398 393 $start = $this->getTDValueByFieldIndex($tr,$timeIndex);
399 394  
400 395 $stop = $start;
401   - while ($tr)
  396 + while (isset($tr))
402 397 {
403 398 $stop = $this->getTDValueByFieldIndex($tr,$timeIndex);
404 399 $tr = $this->getNextTR($tr);
405 400 }
406 401  
407   - if (!$start)
  402 + if (!isset($start))
408 403 $start = 0;
409 404 else
410 405 $start = strtotime($start);
411 406  
412   - if (!$stop)
  407 + if (!isset($stop))
413 408 $stop = 0;
414 409 else
415 410 $stop = strtotime($stop);
... ... @@ -663,11 +658,11 @@ class VOTableMgr {
663 658 "maxSampling" => 0);
664 659  
665 660 $prevTime = 0;
666   - while ($tr)
  661 + while (isset($tr))
667 662 {
668 663 $time = $this->getTDValueByFieldIndex($tr,$timeIndex);
669 664  
670   - if ($time)
  665 + if (isset($time))
671 666 {
672 667 $time = strtotime($time);
673 668 if (($prevTime > 0) && ($time-$prevTime > 0))
... ...