mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-22 21:34:28 +02:00
Transform TimelineIntervalBox into a generic ListBox
Add options to control the changed url parameter and the displayed label to make it usable in generic cases.
This commit is contained in:
parent
ef2f332869
commit
dc05b2e933
@ -12,7 +12,7 @@ use Icinga\Util\DateTimeFactory;
|
|||||||
use Icinga\Module\Monitoring\Controller;
|
use Icinga\Module\Monitoring\Controller;
|
||||||
use Icinga\Module\Monitoring\Timeline\TimeLine;
|
use Icinga\Module\Monitoring\Timeline\TimeLine;
|
||||||
use Icinga\Module\Monitoring\Timeline\TimeRange;
|
use Icinga\Module\Monitoring\Timeline\TimeRange;
|
||||||
use Icinga\Module\Monitoring\Web\Widget\TimelineIntervalBox;
|
use Icinga\Module\Monitoring\Web\Widget\SelectBox;
|
||||||
use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView;
|
use Icinga\Module\Monitoring\DataView\EventHistory as EventHistoryView;
|
||||||
|
|
||||||
class Monitoring_TimelineController extends Controller
|
class Monitoring_TimelineController extends Controller
|
||||||
@ -85,7 +85,7 @@ class Monitoring_TimelineController extends Controller
|
|||||||
*/
|
*/
|
||||||
private function setupIntervalBox()
|
private function setupIntervalBox()
|
||||||
{
|
{
|
||||||
$box = new TimelineIntervalBox(
|
$box = new SelectBox(
|
||||||
'intervalBox',
|
'intervalBox',
|
||||||
array(
|
array(
|
||||||
'4h' => t('4 Hours'),
|
'4h' => t('4 Hours'),
|
||||||
@ -93,7 +93,9 @@ class Monitoring_TimelineController extends Controller
|
|||||||
'1w' => t('One week'),
|
'1w' => t('One week'),
|
||||||
'1m' => t('One month'),
|
'1m' => t('One month'),
|
||||||
'1y' => t('One year')
|
'1y' => t('One year')
|
||||||
)
|
),
|
||||||
|
t('TimeLine interval'),
|
||||||
|
'interval'
|
||||||
);
|
);
|
||||||
$box->applyRequest($this->getRequest());
|
$box->applyRequest($this->getRequest());
|
||||||
$this->view->intervalBox = $box;
|
$this->view->intervalBox = $box;
|
||||||
|
@ -8,10 +8,7 @@ use Icinga\Web\Form;
|
|||||||
use Icinga\Web\Request;
|
use Icinga\Web\Request;
|
||||||
use Icinga\Web\Widget\AbstractWidget;
|
use Icinga\Web\Widget\AbstractWidget;
|
||||||
|
|
||||||
/**
|
class SelectBox extends AbstractWidget
|
||||||
* @todo Might be better if this is a generic selection widget.
|
|
||||||
*/
|
|
||||||
class TimelineIntervalBox extends AbstractWidget
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The name of the form that will be created
|
* The name of the form that will be created
|
||||||
@ -27,6 +24,20 @@ class TimelineIntervalBox extends AbstractWidget
|
|||||||
*/
|
*/
|
||||||
private $values;
|
private $values;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The label displayed next to the select box
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the url parameter to set
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $parameter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request object used for initial form population
|
* A request object used for initial form population
|
||||||
*
|
*
|
||||||
@ -39,11 +50,15 @@ class TimelineIntervalBox extends AbstractWidget
|
|||||||
*
|
*
|
||||||
* @param string $name The name of the form that will be created
|
* @param string $name The name of the form that will be created
|
||||||
* @param array $values An array containing all intervals with their associated labels
|
* @param array $values An array containing all intervals with their associated labels
|
||||||
|
* @param string $label The label displayed next to the select box
|
||||||
|
* @param string $param The request parameter name to set
|
||||||
*/
|
*/
|
||||||
public function __construct($name, array $values)
|
public function __construct($name, array $values, $label = 'Select', $param = 'selection')
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->values = $values;
|
$this->values = $values;
|
||||||
|
$this->label = $label;
|
||||||
|
$this->parameter = $param;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,9 +103,9 @@ class TimelineIntervalBox extends AbstractWidget
|
|||||||
$form->setName($this->name);
|
$form->setName($this->name);
|
||||||
$form->addElement(
|
$form->addElement(
|
||||||
'select',
|
'select',
|
||||||
'interval',
|
$this->parameter,
|
||||||
array(
|
array(
|
||||||
'label' => 'Timeline Interval',
|
'label' => $this->label,
|
||||||
'multiOptions' => $this->values,
|
'multiOptions' => $this->values,
|
||||||
'class' => 'autosubmit'
|
'class' => 'autosubmit'
|
||||||
)
|
)
|
Loading…
x
Reference in New Issue
Block a user