From 4a7023e86dff9fa01e8e4abe76d459c11adace64 Mon Sep 17 00:00:00 2001 From: Benjamin Renard <benjamin.renard@akka.eu> Date: Wed, 8 Apr 2020 10:42:15 +0200 Subject: [PATCH] Fix interactive navigation --- src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 77f93e3..69fb2e7 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -37,7 +37,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass { $resetZoom = true; //save request - $this->saveIHMRequest($input); + $this->saveIHMRequest(PLOT_RESULT_FILE_KEY."_".$input->{'tab-index'}, $input); } //Request @@ -1448,9 +1448,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass return "[".$r.",".$g.",".$b."]"; } - private function saveIHMRequest($input) + private function saveIHMRequest($interactiveId, $input) { - $path = $this->getWorkingPath()."ihm.request"; + $path = $this->getWorkingPath()."ihm.request.".$interactiveId; if (!is_dir($this->getWorkingPath())) mkdir($this->getWorkingPath(),0777); $file = fopen($path, 'w'); @@ -1458,9 +1458,9 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass fclose($file); } - private function loadIHMRequest() + private function loadIHMRequest($interactiveId) { - $path = $this->getWorkingPath()."ihm.request"; + $path = $this->getWorkingPath()."ihm.request.".$interactiveId; if (!file_exists($path)) return NULL; return json_decode(file_get_contents($path)); @@ -1470,7 +1470,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass { $actionInput = $input->{'action'}; - $plotInput = $this->loadIHMRequest(); + $plotInput = $this->loadIHMRequest($actionInput->{'interactiveId'}); if (!isset($plotInput)) throw new Exception('Cannot retrieve request input for interactive action.'); @@ -1723,22 +1723,8 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass private function unmarshallNavigation($input, $plotInput) { - //Find current tab - $crtTab = NULL; - foreach ($plotInput->{'tabs'} as $tab) - { - if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) - { - $crtTab = $tab; - break; - } - } - - if (!$crtTab) - throw new Exception('Cannot retrieve plot tab for navigation action.'); - - $startTime = $crtTab->{'startDate'}; - $stopTime = $crtTab->{'stopDate'}; + $startTime = $plotInput->{'startDate'}; + $stopTime = $plotInput->{'stopDate'}; //Compute new start / stop time date_default_timezone_set('UTC'); @@ -1781,12 +1767,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $stopTime = date("Y-m-d\TH:i:s",$stopTimeStamp); //Update request - $crtTab->{'startDate'} = $startTime; - $crtTab->{'stopDate'} = $stopTime; + $plotInput->{'startDate'} = $startTime; + $plotInput->{'stopDate'} = $stopTime; - $plotInput->{'last-plotted-tab'} = $crtTab->{'id'}; $plotInput->{'force-time-zoom-reset'} = true; - $this->saveIHMRequest($plotInput); + $this->saveIHMRequest($input->interactiveId, $plotInput); return $plotInput; } -- libgit2 0.21.2