Commit 4a7023e86dff9fa01e8e4abe76d459c11adace64

Authored by Benjamin Renard
1 parent 70e82c1f

Fix interactive navigation

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -37,7 +37,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -37,7 +37,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
37 { 37 {
38 $resetZoom = true; 38 $resetZoom = true;
39 //save request 39 //save request
40 - $this->saveIHMRequest($input); 40 + $this->saveIHMRequest(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $input);
41 } 41 }
42 42
43 //Request 43 //Request
@@ -1448,9 +1448,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1448,9 +1448,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1448 return "[".$r.",".$g.",".$b."]"; 1448 return "[".$r.",".$g.",".$b."]";
1449 } 1449 }
1450 1450
1451 - private function saveIHMRequest($input) 1451 + private function saveIHMRequest($interactiveId, $input)
1452 { 1452 {
1453 - $path = $this->getWorkingPath()."ihm.request"; 1453 + $path = $this->getWorkingPath()."ihm.request.".$interactiveId;
1454 if (!is_dir($this->getWorkingPath())) 1454 if (!is_dir($this->getWorkingPath()))
1455 mkdir($this->getWorkingPath(),0777); 1455 mkdir($this->getWorkingPath(),0777);
1456 $file = fopen($path, 'w'); 1456 $file = fopen($path, 'w');
@@ -1458,9 +1458,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1458,9 +1458,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1458 fclose($file); 1458 fclose($file);
1459 } 1459 }
1460 1460
1461 - private function loadIHMRequest() 1461 + private function loadIHMRequest($interactiveId)
1462 { 1462 {
1463 - $path = $this->getWorkingPath()."ihm.request"; 1463 + $path = $this->getWorkingPath()."ihm.request.".$interactiveId;
1464 if (!file_exists($path)) 1464 if (!file_exists($path))
1465 return NULL; 1465 return NULL;
1466 return json_decode(file_get_contents($path)); 1466 return json_decode(file_get_contents($path));
@@ -1470,7 +1470,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1470,7 +1470,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1470 { 1470 {
1471 $actionInput = $input->{'action'}; 1471 $actionInput = $input->{'action'};
1472 1472
1473 - $plotInput = $this->loadIHMRequest(); 1473 + $plotInput = $this->loadIHMRequest($actionInput->{'interactiveId'});
1474 1474
1475 if (!isset($plotInput)) 1475 if (!isset($plotInput))
1476 throw new Exception('Cannot retrieve request input for interactive action.'); 1476 throw new Exception('Cannot retrieve request input for interactive action.');
@@ -1723,22 +1723,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1723,22 +1723,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1723 1723
1724 private function unmarshallNavigation($input, $plotInput) 1724 private function unmarshallNavigation($input, $plotInput)
1725 { 1725 {
1726 - //Find current tab  
1727 - $crtTab = NULL;  
1728 - foreach ($plotInput->{'tabs'} as $tab)  
1729 - {  
1730 - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'})  
1731 - {  
1732 - $crtTab = $tab;  
1733 - break;  
1734 - }  
1735 - }  
1736 -  
1737 - if (!$crtTab)  
1738 - throw new Exception('Cannot retrieve plot tab for navigation action.');  
1739 -  
1740 - $startTime = $crtTab->{'startDate'};  
1741 - $stopTime = $crtTab->{'stopDate'}; 1726 + $startTime = $plotInput->{'startDate'};
  1727 + $stopTime = $plotInput->{'stopDate'};
1742 1728
1743 //Compute new start / stop time 1729 //Compute new start / stop time
1744 date_default_timezone_set('UTC'); 1730 date_default_timezone_set('UTC');
@@ -1781,12 +1767,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -1781,12 +1767,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
1781 $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp); 1767 $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp);
1782 1768
1783 //Update request 1769 //Update request
1784 - $crtTab->{'startDate'} = $startTime;  
1785 - $crtTab->{'stopDate'} = $stopTime; 1770 + $plotInput->{'startDate'} = $startTime;
  1771 + $plotInput->{'stopDate'} = $stopTime;
1786 1772
1787 - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'};  
1788 $plotInput->{'force-time-zoom-reset'} = true; 1773 $plotInput->{'force-time-zoom-reset'} = true;
1789 - $this->saveIHMRequest($plotInput); 1774 + $this->saveIHMRequest($input->interactiveId, $plotInput);
1790 return $plotInput; 1775 return $plotInput;
1791 } 1776 }
1792 1777