Commit 33519521a0828044495682f176d2796fab767886
1 parent
fb23b7fe
Exists in
master
and in
81 other branches
Fix saved requests tooltips (#9414)
Showing
2 changed files
with
86 additions
and
29 deletions
Show diff stats
php/classes/AmdaAction.php
... | ... | @@ -168,35 +168,13 @@ class AmdaAction |
168 | 168 | 'info' => $child->getAttribute('info') |
169 | 169 | ]; |
170 | 170 | break; |
171 | + | |
171 | 172 | case 'download': |
172 | - $objectMgr = new RequestMgr($nodeType); | |
173 | - $objdown = $objectMgr->getObject($id); | |
174 | - $info = "Empty"; | |
175 | - if (!empty($objdown->list)) { | |
176 | - $params_list = array(); | |
177 | - foreach ($objdown->list as $p) { | |
178 | - if (!in_array($p->paramid, $params_list)) | |
179 | - $params_list[] = $p->paramid; | |
180 | - } | |
181 | - if (!empty($params_list)) { | |
182 | - $info = implode('<br/>',$params_list); | |
183 | - } | |
184 | - } | |
185 | - break; | |
186 | 173 | case 'condition': |
174 | + case 'request': | |
187 | 175 | $objectMgr = new RequestMgr($nodeType); |
188 | - $info = $objectMgr->getObject($id)->expression; | |
176 | + $info = $objectMgr->getObjectInfo($id); | |
189 | 177 | break; |
190 | - case 'request': | |
191 | - $objectMgr = new RequestMgr($nodeType); | |
192 | - $objplot = $objectMgr->getObject($id); | |
193 | - if (isset($objplot->name)) { | |
194 | - $info = $objplot->name; | |
195 | - } | |
196 | - else { | |
197 | - $info = $id; | |
198 | - } | |
199 | - break; | |
200 | 178 | |
201 | 179 | case 'timeTable': |
202 | 180 | case 'catalog': | ... | ... |
php/classes/RequestMgr.php
... | ... | @@ -177,17 +177,14 @@ class RequestMgr extends AmdaObjectMgr |
177 | 177 | if ($this->type == 'condition') |
178 | 178 | { |
179 | 179 | $p->expression = $this->resetAlias($p->expression); |
180 | - $info = $p->expression; | |
181 | 180 | } |
182 | 181 | else if ($this->type == 'request') |
183 | 182 | { |
184 | - $info = ''; | |
185 | 183 | for ($i=0; $i < count($p->children); $i++) |
186 | 184 | { |
187 | 185 | for ($j=0; $j < count($p->children[$i]->children); $j++) |
188 | 186 | { |
189 | 187 | $p->children[$i]->children[$j]->name = $this->resetAlias($p->children[$i]->children[$j]->name); |
190 | - $info = $info.' '.$p->children[$i]->children[$j]->name; | |
191 | 188 | } |
192 | 189 | } |
193 | 190 | } |
... | ... | @@ -205,7 +202,7 @@ class RequestMgr extends AmdaObjectMgr |
205 | 202 | |
206 | 203 | $this -> addToContent($p, $folder); |
207 | 204 | |
208 | - return array('id' => $this->id, 'info' => $info, 'last_update' => $p->last_update) + $additional; | |
205 | + return array('id' => $this->id, 'info' => $this->getObjectInfo($p->id), 'last_update' => $p->last_update) + $additional; | |
209 | 206 | } |
210 | 207 | |
211 | 208 | public static function checkRequest($obj) |
... | ... | @@ -355,5 +352,87 @@ class RequestMgr extends AmdaObjectMgr |
355 | 352 | |
356 | 353 | return array('success' => true); |
357 | 354 | } |
355 | + | |
356 | + public function getObjectInfo($id) { | |
357 | + $info = "Request ID: ".$id."<br/>"; | |
358 | + | |
359 | + if (!file_exists(USERREQDIR.$id)) { | |
360 | + $info .= "<b>ERROR:</b> Cannot retrieve request definition file"; | |
361 | + return $info; | |
362 | + } | |
363 | + | |
364 | + $obj = json_decode(file_get_contents(USERREQDIR.$id)); | |
365 | + if (empty($obj)) { | |
366 | + $info .= "<b>ERROR:</b> Cannot load request definition file"; | |
367 | + return $info; | |
368 | + } | |
369 | + | |
370 | + switch ($this->type) { | |
371 | + case 'request': | |
372 | + $info .= "Plot: "; | |
373 | + $panels_list = array(); | |
374 | + if (!empty($obj->panels)) { | |
375 | + foreach ($obj->panels as $p) { | |
376 | + $panel_info = "Panel #".$p->{"panel-index"}.": "; | |
377 | + if (empty($p->params)) { | |
378 | + $panel_info .= "Empty"; | |
379 | + } | |
380 | + else { | |
381 | + $params_list = array(); | |
382 | + if (!empty($p->params)) { | |
383 | + foreach ($p->params as $p) { | |
384 | + if (!in_array($p->paramid, $params_list)) | |
385 | + $params_list[] = $p->paramid; | |
386 | + } | |
387 | + } | |
388 | + if (!empty($params_list)) { | |
389 | + $panel_info .= implode(', ', $params_list); | |
390 | + } | |
391 | + else { | |
392 | + $panel_info .= "Empty"; | |
393 | + } | |
394 | + } | |
395 | + $panels_list[] = $panel_info; | |
396 | + } | |
397 | + } | |
398 | + if (!empty($panels_list)) { | |
399 | + $info .= '<br/>'.implode('<br/>', $panels_list); | |
400 | + } | |
401 | + else { | |
402 | + $info .= "Empty"; | |
403 | + } | |
404 | + break; | |
405 | + case 'condition': | |
406 | + $info .= "Data Mining: ".htmlspecialchars($obj->expression); | |
407 | + break; | |
408 | + case 'download': | |
409 | + $info .= "Download: "; | |
410 | + $params_list = array(); | |
411 | + if (!empty($obj->list)) { | |
412 | + foreach ($obj->list as $p) { | |
413 | + if (!in_array($p->paramid, $params_list)) | |
414 | + $params_list[] = $p->paramid; | |
415 | + } | |
416 | + } | |
417 | + if (!empty($params_list)) { | |
418 | + $info .= implode(', ',$params_list); | |
419 | + } | |
420 | + else { | |
421 | + $info .= "Empty"; | |
422 | + } | |
423 | + break; | |
424 | + default: | |
425 | + $info .= "<b>ERROR:</b> Unknown request type"; | |
426 | + } | |
427 | + | |
428 | + return $info; | |
429 | + } | |
430 | + | |
431 | + function modifyObject($p) | |
432 | + { | |
433 | + $result = parent::modifyObject($p); | |
434 | + $result["info"] = $this->getObjectInfo($p->id); | |
435 | + return $result; | |
436 | + } | |
358 | 437 | } |
359 | 438 | ?> | ... | ... |