2017-09-07 05:08:24 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Icinga\Module\Graphite\Web\Controller;
|
|
|
|
|
|
|
|
|
|
use Icinga\Module\Graphite\Forms\TimeRangePicker\CommonForm;
|
|
|
|
|
use Icinga\Module\Graphite\Forms\TimeRangePicker\CustomForm;
|
|
|
|
|
use Icinga\Web\Request;
|
|
|
|
|
use Icinga\Web\Url;
|
|
|
|
|
use Icinga\Web\View;
|
|
|
|
|
|
|
|
|
|
trait TimeRangePickerTrait
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var CommonForm
|
|
|
|
|
*/
|
|
|
|
|
protected $timeRangePickerCommonForm;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var CustomForm
|
|
|
|
|
*/
|
|
|
|
|
protected $timeRangePickerCustomForm;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Process the given request using the forms
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request The request to be processed
|
|
|
|
|
*
|
|
|
|
|
* @return Request The request supposed to be processed
|
|
|
|
|
*/
|
|
|
|
|
protected function handleTimeRangePickerRequest(Request $request = null)
|
|
|
|
|
{
|
|
|
|
|
$this->getTimeRangePickerCommonForm()->handleRequest($request);
|
|
|
|
|
return $this->getTimeRangePickerCustomForm()->handleRequest($request);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render all needed forms and links
|
|
|
|
|
*
|
2017-09-07 07:11:50 -04:00
|
|
|
* @param View $view
|
|
|
|
|
*
|
|
|
|
|
* @return string
|
2017-09-07 05:08:24 -04:00
|
|
|
*/
|
2017-09-07 07:11:50 -04:00
|
|
|
protected function renderTimeRangePicker(View $view)
|
2017-09-07 05:08:24 -04:00
|
|
|
{
|
2017-11-16 09:05:35 -05:00
|
|
|
$url = Url::fromRequest()->getAbsoluteUrl();
|
2017-09-07 05:08:24 -04:00
|
|
|
|
2019-08-19 08:43:40 -04:00
|
|
|
return '<div class="timerangepicker-container">'
|
2018-03-19 12:10:44 -04:00
|
|
|
. $this->getTimeRangePickerCommonForm()
|
2022-03-07 07:44:01 -05:00
|
|
|
. '<div class="flyover flyover-arrow-top" data-flyover-suspends-auto-refresh id="'
|
2017-11-21 10:47:08 -05:00
|
|
|
. $view->protectId('graphite-customrange')
|
2017-11-16 09:05:35 -05:00
|
|
|
. '">'
|
|
|
|
|
. $view->qlink(null, '#', null, [
|
|
|
|
|
'title' => $view->translate('Specify custom time range'),
|
|
|
|
|
'class' => 'button-link flyover-toggle',
|
2019-08-19 08:43:57 -04:00
|
|
|
'icon' => 'service'
|
2017-11-16 09:05:35 -05:00
|
|
|
])
|
2019-07-09 10:03:53 -04:00
|
|
|
. '<div class="flyover-content">' . $this->getTimeRangePickerCustomForm() . '</div>'
|
2018-03-19 12:10:44 -04:00
|
|
|
. '</div>'
|
2017-11-21 12:15:55 -05:00
|
|
|
. '</div>';
|
2017-09-07 05:08:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get {@link timeRangePickerCommonForm}
|
|
|
|
|
*
|
|
|
|
|
* @return CommonForm
|
|
|
|
|
*/
|
|
|
|
|
public function getTimeRangePickerCommonForm()
|
|
|
|
|
{
|
|
|
|
|
if ($this->timeRangePickerCommonForm === null) {
|
|
|
|
|
$this->timeRangePickerCommonForm = new CommonForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->timeRangePickerCommonForm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set {@link timeRangePickerCommonForm}
|
|
|
|
|
*
|
|
|
|
|
* @param CommonForm $timeRangePickerCommonForm
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
|
|
|
|
public function setTimeRangePickerCommonForm(CommonForm $timeRangePickerCommonForm)
|
|
|
|
|
{
|
|
|
|
|
$this->timeRangePickerCommonForm = $timeRangePickerCommonForm;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get {@link timeRangePickerCustomForm}
|
|
|
|
|
*
|
|
|
|
|
* @return CustomForm
|
|
|
|
|
*/
|
|
|
|
|
public function getTimeRangePickerCustomForm()
|
|
|
|
|
{
|
|
|
|
|
if ($this->timeRangePickerCustomForm === null) {
|
|
|
|
|
$this->timeRangePickerCustomForm = new CustomForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->timeRangePickerCustomForm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set {@link timeRangePickerCustomForm}
|
|
|
|
|
*
|
|
|
|
|
* @param CustomForm $timeRangePickerCustomForm
|
|
|
|
|
*
|
|
|
|
|
* @return $this
|
|
|
|
|
*/
|
|
|
|
|
public function setTimeRangePickerCustomForm(CustomForm $timeRangePickerCustomForm)
|
|
|
|
|
{
|
|
|
|
|
$this->timeRangePickerCustomForm = $timeRangePickerCustomForm;
|
|
|
|
|
return $this;
|
|
|
|
|
}
|
|
|
|
|
}
|