diff --git a/src/InputOutput/IHMImpl/IHMInputOutputClass.php b/src/InputOutput/IHMImpl/IHMInputOutputClass.php index 06877ed..f423ab2 100644 --- a/src/InputOutput/IHMImpl/IHMInputOutputClass.php +++ b/src/InputOutput/IHMImpl/IHMInputOutputClass.php @@ -68,7 +68,7 @@ class IHMInputOutputClass implements InputOutputInterface break; case FunctionTypeEnumClass::ACTION : $this->inputOutput = new IHMInputOutputParamsPlotClass(); - $requestId = str_replace("_","",$input->folderId); + $requestId = "Plot"; break; case FunctionTypeEnumClass::PROCESSDELETE : $this->inputOutput = new IHMInputOutputDeleteProcessClass(); diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 30b29be..ffb4a41 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -16,8 +16,11 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass */ protected function unmarshallRequest($input) { - //save request - $this->saveIHMRequest($input); + if (isset($input->{'action'})) + $input = $this->unmarshallActionRequest($input); + else + //save request + $this->saveIHMRequest($input); //Request $requestIndex = 0; @@ -64,7 +67,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $filePrefix = "plot"; if ($input->{'file-prefix'} && ($input->{'file-prefix'} != "")) $filePrefix = $input->{'file-prefix'}; - $filePrefix .= $requestIndex; + $filePrefix .= $tab->{'id'}; $plotOutputNode->setFilePrefix($filePrefix); @@ -164,7 +167,10 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $waitingResultFile = $filePrefix.$compression; } - $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$requestIndex, $waitingResultFile); + if ($this->isInteractiveRequest) + $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY."_".$tab->{'id'}, $waitingResultFile); + else + $this->paramsData->addWaitingResult(PLOT_RESULT_FILE_KEY, $waitingResultFile); //Remove old result files foreach (glob($this->paramsData->getWorkingPath().$resultFile) as $oldFile) { @@ -1133,7 +1139,7 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass if (!$this->isInteractiveRequest) { //add to job - $commonRes = $this->commonMarshallResult($data,PLOT_RESULT_FILE_KEY."_0"); + $commonRes = $this->commonMarshallResult($data,PLOT_RESULT_FILE_KEY); return $commonRes; } @@ -1203,5 +1209,66 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass return NULL; return json_decode(file_get_contents($path)); } + + private function unmarshallActionRequest($input) + { + $plotInput = $this->loadIHMRequest(); + + if (!isset($plotInput)) + throw new Exception('Cannot retrieve request input for inetractive action.'); + + switch ($input->{'action'}) + { + case 'zoom' : + return $this->unmarshallZoom($input, $plotInput); + default : + throw new Exception('Interactive action not implemented.'); + } + } + + private function unmarshallZoom($input, $plotInput) + { + if ($input->{'axeId'} == 'timeAxis') + { + $plotInput = $plotInput; + $plotInput->{'timesrc'} = 'Interval'; + $plotInput->{'startDate'} = $input->{'min'}; + $plotInput->{'stopDate'} = $input->{'max'}; + $this->saveIHMRequest($plotInput); + return $plotInput; + } + + //Execute only concerning plot tabs + $interactiveInput = clone $plotInput; + $interactiveInput->{'tabs'} = array(); + foreach ($plotInput->{'tabs'} as $tab) + { + if ($input->{'tabId'} == PLOT_RESULT_FILE_KEY."_".$tab->{'id'}) + { + //Add current tab to interactive input + $interactiveInput->{'tabs'}[] = $tab; + foreach ($interactiveInput->{'tabs'}[0]->{'panels'} as $panel) + { + if ($input->{'panelId'} == $panel->{'id'}) + { + foreach ($panel->{'axes'} as $axis) + { + if ($input->{'axeId'} == $axis->{'id'}) + { + $axis->{'axis-range-extend'} = false; + $axis->{'axis-range-min'} = $input->{'min'}; + $axis->{'axis-range-max'} = $input->{'max'}; + $this->saveIHMRequest($plotInput); + return $interactiveInput; + } + } + throw new Exception('Cannot retrieve axis for zoom action.'); + } + } + throw new Exception('Cannot retrieve plot panel for zoom action.'); + } + } + throw new Exception('Cannot retrieve plot tab for zoom action.'); + } } ?> \ No newline at end of file -- libgit2 0.21.2