mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-27 15:54:03 +02:00
IcingaScheduledDowntimeRangeTable: introduce, use
This commit is contained in:
parent
cb3d13ba3b
commit
0178bb4718
@ -5,7 +5,7 @@ namespace Icinga\Module\Director\Controllers;
|
|||||||
use Icinga\Module\Director\Forms\IcingaScheduledDowntimeRangeForm;
|
use Icinga\Module\Director\Forms\IcingaScheduledDowntimeRangeForm;
|
||||||
use Icinga\Module\Director\Objects\IcingaScheduledDowntime;
|
use Icinga\Module\Director\Objects\IcingaScheduledDowntime;
|
||||||
use Icinga\Module\Director\Web\Controller\ObjectController;
|
use Icinga\Module\Director\Web\Controller\ObjectController;
|
||||||
use Icinga\Module\Director\Web\Table\IcingaScheduledDowntimeTable;
|
use Icinga\Module\Director\Web\Table\IcingaScheduledDowntimeRangeTable;
|
||||||
|
|
||||||
class ScheduledDowntimeController extends ObjectController
|
class ScheduledDowntimeController extends ObjectController
|
||||||
{
|
{
|
||||||
@ -16,7 +16,7 @@ class ScheduledDowntimeController extends ObjectController
|
|||||||
$this->tabs()->activate('ranges');
|
$this->tabs()->activate('ranges');
|
||||||
$this->addTitle($this->translate('Time period ranges'));
|
$this->addTitle($this->translate('Time period ranges'));
|
||||||
$form = IcingaScheduledDowntimeRangeForm::load()
|
$form = IcingaScheduledDowntimeRangeForm::load()
|
||||||
->setTimePeriod($object);
|
->setScheduledDowntime($object);
|
||||||
|
|
||||||
if (null !== ($name = $this->params->get('range'))) {
|
if (null !== ($name = $this->params->get('range'))) {
|
||||||
$this->addBackLink($this->url()->without('range'));
|
$this->addBackLink($this->url()->without('range'));
|
||||||
@ -28,7 +28,7 @@ class ScheduledDowntimeController extends ObjectController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->content()->add($form->handleRequest());
|
$this->content()->add($form->handleRequest());
|
||||||
IcingaScheduledDowntimeTable::load($object)->renderTo($this);
|
IcingaScheduledDowntimeRangeTable::load($object)->renderTo($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\Objects\IcingaScheduledDowntime;
|
||||||
|
use dipl\Html\Link;
|
||||||
|
use dipl\Web\Table\ZfQueryBasedTable;
|
||||||
|
|
||||||
|
class IcingaScheduledDowntimeRangeTable extends ZfQueryBasedTable
|
||||||
|
{
|
||||||
|
/** @var IcingaScheduledDowntime */
|
||||||
|
protected $downtime;
|
||||||
|
|
||||||
|
protected $searchColumns = [
|
||||||
|
'range_key',
|
||||||
|
'range_value',
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param IcingaScheduledDowntime $downtime
|
||||||
|
* @return static
|
||||||
|
*/
|
||||||
|
public static function load(IcingaScheduledDowntime $downtime)
|
||||||
|
{
|
||||||
|
$table = new static($downtime->getConnection());
|
||||||
|
$table->downtime = $downtime;
|
||||||
|
$table->getAttributes()->set('data-base-target', '_self');
|
||||||
|
|
||||||
|
return $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderRow($row)
|
||||||
|
{
|
||||||
|
return $this::row([
|
||||||
|
Link::create(
|
||||||
|
$row->range_key,
|
||||||
|
'director/scheduled-downtime/ranges',
|
||||||
|
[
|
||||||
|
'name' => $this->downtime->getObjectName(),
|
||||||
|
'range' => $row->range_key,
|
||||||
|
'range_type' => 'include'
|
||||||
|
]
|
||||||
|
),
|
||||||
|
$row->range_value
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getColumnsToBeRendered()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
$this->translate('Day(s)'),
|
||||||
|
$this->translate('Timeperiods'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function prepareQuery()
|
||||||
|
{
|
||||||
|
return $this->db()->select()->from(
|
||||||
|
['r' => 'icinga_scheduled_downtime_range'],
|
||||||
|
[
|
||||||
|
'scheduled_downtime_id' => 'r.scheduled_downtime_id',
|
||||||
|
'range_key' => 'r.range_key',
|
||||||
|
'range_value' => 'r.range_value',
|
||||||
|
]
|
||||||
|
)->where('r.scheduled_downtime_id = ?', $this->downtime->id);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user