From b22f3f6b47433a6b56ae563c69ca4f3d4cc66c29 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Thu, 20 Mar 2014 16:18:11 +0100 Subject: [PATCH] The timeline object is NOT a form refs #4190 --- .../controllers/TimelineController.php | 7 +- .../views/scripts/timeline/show.phtml | 2 +- .../library/Monitoring/Timeline/TimeLine.php | 79 +++++-------------- 3 files changed, 21 insertions(+), 67 deletions(-) diff --git a/modules/monitoring/application/controllers/TimelineController.php b/modules/monitoring/application/controllers/TimelineController.php index 8052a8d24..49d07c7ef 100644 --- a/modules/monitoring/application/controllers/TimelineController.php +++ b/modules/monitoring/application/controllers/TimelineController.php @@ -45,12 +45,8 @@ class Monitoring_TimelineController extends ActionController { $this->setupIntervalBox(); $timeline = new TimeLine(); - $timeline->setName('Timeline'); - $timeline->setRequest($this->_request); $timeline->setConfiguration(Config::app()); - $timeline->buildForm(); // Necessary in order to populate request parameters - $timeline->populate($this->_request->getParams()); - $timeline->setAttrib('data-icinga-component', 'monitoring/timelineComponent'); + //$timeline->setAttrib('data-icinga-component', 'monitoring/timelineComponent'); list($displayRange, $forecastRange) = $this->buildTimeRanges($this->getTimelineInterval()); $timeline->setTimeRange($displayRange); $timeline->setDisplayData($this->loadData($displayRange)); @@ -62,7 +58,6 @@ class Monitoring_TimelineController extends ActionController { $this->setupIntervalBox(); $timeline = new TimeLine(); - $timeline->setRequest($this->_request); $timeline->setConfiguration(Config::app()); list($displayRange, $forecastRange) = $this->buildTimeRanges($this->getTimelineInterval()); $timeline->setTimeRange($displayRange); diff --git a/modules/monitoring/application/views/scripts/timeline/show.phtml b/modules/monitoring/application/views/scripts/timeline/show.phtml index 4bab9e26d..3249b5638 100644 --- a/modules/monitoring/application/views/scripts/timeline/show.phtml +++ b/modules/monitoring/application/views/scripts/timeline/show.phtml @@ -5,4 +5,4 @@ -timeline; ?> +timeline->buildTimeline(); ?> diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeLine.php b/modules/monitoring/library/Monitoring/Timeline/TimeLine.php index 56ace53fb..6b77d5bf9 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeLine.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeLine.php @@ -29,17 +29,11 @@ namespace Icinga\Module\Monitoring\Timeline; use \Zend_Config; -use \DateInterval; -use \Zend_View_Interface; -use Icinga\Web\Form; -use Icinga\Web\Form\Element\Note; /** * Represents a set of events in a specific time range - * - * @see Form */ -class TimeLine extends Form +class TimeLine { /** * The range of time represented by this timeline @@ -130,53 +124,6 @@ class TimeLine extends Form } } - /** - * Disable the CSRF token - */ - public function init() - { - $this->setTokenDisabled(); - } - - /** - * Render the form and timeline to HTML - * - * @param Zend_View_Interface $view - * @return string - */ - public function render(Zend_View_Interface $view = null) - { - $this->buildForm(); - $this->postCreate(); - return parent::render($view); - } - - /** - * Add timeline elements - */ - private function postCreate() - { - $timeline = new Note( - 'timeline', - array( - 'value' => '
' . $this->buildTimeline() . '
' - ) - ); - $this->addElement($timeline); // Form::addElement adjusts the element's decorators - $timeline->clearDecorators(); - $timeline->addDecorator('ViewHelper'); - - $legend = new Note( - 'legend', - array( - 'value' => '
' . $this->buildLegend() . '
' - ) - ); - $this->addElement($legend); - $legend->clearDecorators(); - $legend->addDecorator('ViewHelper'); - } - /** * Build the legend */ @@ -213,7 +160,7 @@ class TimeLine extends Form /** * Build the timeline */ - private function buildTimeline() + public function buildTimeline() { $timelineGroups = array(); foreach ($this->displayData as $group) { @@ -261,8 +208,8 @@ class TimeLine extends Form } } - $timeframeUrl = $this->getRequest()->getBaseUrl() . '/monitoring/list/eventhistory?timestamp<=' . - $timeframe->start->getTimestamp() . '×tamp>=' . $timeframe->end->getTimestamp(); + $timeframeUrl = '';/*$this->getRequest()->getBaseUrl() . '/monitoring/list/eventhistory?timestamp<=' . + $timeframe->start->getTimestamp() . '×tamp>=' . $timeframe->end->getTimestamp();*/ $elements[] = sprintf( '
%1$s
', implode('', $elementGroups), @@ -318,18 +265,18 @@ class TimeLine extends Form ) ); - $this->calculationBase = $this->getRequest()->getParam('calculationBase', 1); + $this->calculationBase = 1;//$this->getRequest()->getParam('calculationBase', 1); while (log($highestValue, $this->calculationBase) > 100) { $this->calculationBase += 0.01; } - $this->addElement( + /*$this->addElement( 'hidden', 'calculationBase', array( 'value' => $this->calculationBase ) - ); + );*/ } return intval($this->circleDiameter * (log($eventCount, $this->calculationBase) / 100)); @@ -395,6 +342,16 @@ class TimeLine extends Form } } + public function setConfiguration($config) + { + $this->config = $config; + } + + public function getConfiguration() + { + return $this->config; + } + /** * Get the application's global configuration or an empty one * @@ -419,6 +376,7 @@ class TimeLine extends Form */ private function getTimeFormat() { + return 'g:i A'; $globalConfig = $this->getGlobalConfiguration(); $preferences = $this->getUserPreferences(); return $preferences->get('app.timeFormat', $globalConfig->get('timeFormat', 'g:i A')); @@ -431,6 +389,7 @@ class TimeLine extends Form */ private function getDateFormat() { + return 'd/m/Y'; $globalConfig = $this->getGlobalConfiguration(); $preferences = $this->getUserPreferences(); return $preferences->get('app.dateFormat', $globalConfig->get('dateFormat', 'd/m/Y'));