diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index 9211540d2..77117b206 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -58,6 +58,13 @@ class Url */ private $params = array(); + /** + * An array to map aliases to valid parameters + * + * @var array + */ + private $aliases = array(); + /** * The site anchor after the '#' * @@ -197,6 +204,31 @@ class Url return preg_replace('/#.*$/', '', $url); } + /** + * Set the array to be used to map aliases to valid parameters + * + * @param array $aliases The array to be used (alias => param) + * + * @return self + */ + public function setAliases(array $aliases) + { + $this->aliases = $aliases; + return $this; + } + + /** + * Return the parameter for the given alias + * + * @param string $alias The alias to translate + * + * @return string The parameter name + */ + public function translateAlias($alias) + { + return array_key_exists($alias, $this->aliases) ? $this->aliases[$alias] : $alias; + } + /** * Overwrite the baseUrl. * @@ -256,7 +288,11 @@ class Url if (empty($this->params)) { return ltrim($this->path, '/') . $this->anchor; } - return ltrim($this->path, '/') . '?' . http_build_query($this->params, '', '&') . $this->anchor; + $params = array(); + foreach ($this->params as $param => $value) { + $params[$this->translateAlias($param)] = $value; + } + return ltrim($this->path, '/') . '?' . http_build_query($params, '', '&') . $this->anchor; } /** diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index df6aa811d..e276e517d 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -5,6 +5,7 @@ use \DateTime; use \DateInterval; use \Zend_Config; +use Icinga\Web\Url; use Icinga\Application\Config; use Icinga\Web\Controller\ActionController; use Icinga\Module\Monitoring\Timeline\TimeLine; @@ -20,7 +21,17 @@ class Monitoring_TimelineController extends ActionController $this->setupIntervalBox(); list($displayRange, $forecastRange) = $this->buildTimeRanges(); - $detailUrl = '/monitoring/list/eventhistory?raw_timestamp<=%s&raw_timestamp>=%s&type=%s'; + $detailUrl = Url::fromPath( + '/monitoring/list/eventhistory', + Url::fromRequest()->getParams() + )->setAliases( + array( + 'name' => 'type', + 'end' => 'raw_timestamp>', + 'start' => 'raw_timestamp<' + ) + )->remove(array('start', 'end', 'extend', 'interval')); + $timeline = new TimeLine( EventHistoryView::fromRequest( $this->getRequest(), diff --git a/modules/monitoring/application/views/scripts/timeline/index.phtml b/modules/monitoring/application/views/scripts/timeline/index.phtml index 20c166ade..bb4055965 100644 --- a/modules/monitoring/application/views/scripts/timeline/index.phtml +++ b/modules/monitoring/application/views/scripts/timeline/index.phtml @@ -67,12 +67,11 @@ $extrapolatedCircleWidth = $timeline->getExtrapolatedCircleWidth($timeInfo[1][$g ((float) substr($circleWidth, 0, -2) / 2) . 'em', $timeInfo[1][$groupName]->getColor(), $circleWidth - ); ?>" href="href( - sprintf( - $timeInfo[1][$groupName]->getDetailUrl(), - $timeInfo[0]->start->getTimestamp(), - $timeInfo[0]->end->getTimestamp(), - $groupName + ); ?>" href="getDetailUrl()->overwriteParams( + array( + 'start' => $timeInfo[0]->start->getTimestamp(), + 'end' => $timeInfo[0]->end->getTimestamp(), + 'name' => $groupName ) ); ?>" title="getValue(); ?> "> @@ -82,7 +81,7 @@ $extrapolatedCircleWidth = $timeline->getExtrapolatedCircleWidth($timeInfo[1][$g -