mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
ScheduledDowntimes: controllers, first form
This commit is contained in:
parent
3cb4a0cbe9
commit
0c2cb9e484
38
application/controllers/ScheduledDowntimeController.php
Normal file
38
application/controllers/ScheduledDowntimeController.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Icinga\Module\Director\Forms\IcingaScheduledDowntimeRangeForm;
|
||||
use Icinga\Module\Director\Objects\IcingaScheduledDowntime;
|
||||
use Icinga\Module\Director\Web\Controller\ObjectController;
|
||||
use Icinga\Module\Director\Web\Table\IcingaScheduledDowntimeTable;
|
||||
|
||||
class ScheduledDowntimeController extends ObjectController
|
||||
{
|
||||
public function rangesAction()
|
||||
{
|
||||
/** @var IcingaScheduledDowntime $object */
|
||||
$object = $this->object;
|
||||
$this->tabs()->activate('ranges');
|
||||
$this->addTitle($this->translate('Time period ranges'));
|
||||
$form = IcingaScheduledDowntimeRangeForm::load()
|
||||
->setTimePeriod($object);
|
||||
|
||||
if (null !== ($name = $this->params->get('range'))) {
|
||||
$this->addBackLink($this->url()->without('range'));
|
||||
$form->loadObject([
|
||||
'scheduled_downtime_id' => $object->get('id'),
|
||||
'range_key' => $name,
|
||||
'range_type' => $this->params->get('range_type')
|
||||
]);
|
||||
}
|
||||
|
||||
$this->content()->add($form->handleRequest());
|
||||
IcingaScheduledDowntimeTable::load($object)->renderTo($this);
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return 'scheduledDowntime';
|
||||
}
|
||||
}
|
@ -6,4 +6,13 @@ use Icinga\Module\Director\Web\Controller\ObjectsController;
|
||||
|
||||
class ScheduledDowntimesController extends ObjectsController
|
||||
{
|
||||
public function getType()
|
||||
{
|
||||
return 'scheduledDowntime';
|
||||
}
|
||||
|
||||
public function getBaseObjectUrl()
|
||||
{
|
||||
return 'scheduled-downtime';
|
||||
}
|
||||
}
|
43
application/forms/IcingaScheduledDowntimeForm.php
Normal file
43
application/forms/IcingaScheduledDowntimeForm.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Forms;
|
||||
|
||||
use Icinga\Module\Director\Web\Form\DirectorObjectForm;
|
||||
|
||||
class IcingaScheduledDowntimeForm extends DirectorObjectForm
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
$isTemplate = isset($_POST['object_type']) && $_POST['object_type'] === 'template';
|
||||
$this->addElement('select', 'object_type', array(
|
||||
'label' => $this->translate('Object type'),
|
||||
'description' => $this->translate('Whether this should be a template'),
|
||||
'class' => 'autosubmit',
|
||||
'multiOptions' => $this->optionalEnum(array(
|
||||
'object' => $this->translate('Object'),
|
||||
'template' => $this->translate('Template'),
|
||||
))
|
||||
));
|
||||
|
||||
if ($isTemplate) {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Template name'),
|
||||
'required' => true,
|
||||
));
|
||||
} else {
|
||||
$this->addElement('text', 'object_name', array(
|
||||
'label' => $this->translate('Downtime name'),
|
||||
'required' => true,
|
||||
));
|
||||
}
|
||||
|
||||
$this->addElement('text', 'display_name', array(
|
||||
'label' => $this->translate('Display Name'),
|
||||
'description' => $this->translate('the display name')
|
||||
));
|
||||
|
||||
$this->addImportsElement();
|
||||
|
||||
$this->setButtons();
|
||||
}
|
||||
}
|
@ -106,7 +106,7 @@ abstract class ObjectsController extends ActionController
|
||||
->addObjectsTabs()
|
||||
->setAutorefreshInterval(10)
|
||||
->addTitle($this->translate(ucfirst($this->getPluralType())))
|
||||
->actions(new ObjectsActionBar($type, $this->url()));
|
||||
->actions(new ObjectsActionBar($this->getBaseObjectUrl(), $this->url()));
|
||||
|
||||
if ($type === 'command' && $this->params->get('type') === 'external_object') {
|
||||
$this->tabs()->activate('external');
|
||||
@ -429,6 +429,11 @@ abstract class ObjectsController extends ActionController
|
||||
}
|
||||
}
|
||||
|
||||
protected function getBaseObjectUrl()
|
||||
{
|
||||
return $this->getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user