mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-25 14:54:25 +02:00
Notification: form and rendering improvements
This commit is contained in:
parent
8b903486d3
commit
f971839f82
@ -22,9 +22,91 @@ class IcingaNotificationForm extends DirectorObjectForm
|
|||||||
|
|
||||||
$this->addDisabledElement()
|
$this->addDisabledElement()
|
||||||
->addImportsElement()
|
->addImportsElement()
|
||||||
|
->addIntervalElement()
|
||||||
|
->addPeriodElement()
|
||||||
|
->addTimesElements()
|
||||||
->addDisabledElement()
|
->addDisabledElement()
|
||||||
|
->addCommandElements()
|
||||||
->addEventFilterElements()
|
->addEventFilterElements()
|
||||||
->groupMainProperties()
|
->groupMainProperties()
|
||||||
->setButtons();
|
->setButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function addIntervalElement()
|
||||||
|
{
|
||||||
|
$this->addElement(
|
||||||
|
'text',
|
||||||
|
'notification_interval',
|
||||||
|
array(
|
||||||
|
'label' => $this->translate('Notification interval'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'The notification interval (in seconds). This interval is'
|
||||||
|
. ' used for active notifications. Defaults to 30 minutes.'
|
||||||
|
. ' If set to 0, re-notifications are disabled.'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addTimesElements()
|
||||||
|
{
|
||||||
|
$this->addElement(
|
||||||
|
'text',
|
||||||
|
'times_begin',
|
||||||
|
array(
|
||||||
|
'label' => $this->translate('First notification delay'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'Delay unless the first notification should be sent'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addElement(
|
||||||
|
'text',
|
||||||
|
'times_end',
|
||||||
|
array(
|
||||||
|
'label' => $this->translate('Times end'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'When the last notification should be sent'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addPeriodElement()
|
||||||
|
{
|
||||||
|
$this->addElement(
|
||||||
|
'select',
|
||||||
|
'period',
|
||||||
|
array(
|
||||||
|
'label' => $this->translate('Time period'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'The name of a time period which determines when this'
|
||||||
|
. ' notification should be triggered. Not set by default.'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addCommandElements()
|
||||||
|
{
|
||||||
|
if (! $this->isTemplate()) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addElement('select', 'command_id', array(
|
||||||
|
'label' => $this->translate('Notification command'),
|
||||||
|
'description' => $this->translate('Check command definition'),
|
||||||
|
'multiOptions' => $this->optionalEnum($this->db->enumNotificationCommands()),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Objects;
|
namespace Icinga\Module\Director\Objects;
|
||||||
|
|
||||||
|
use Icinga\Module\Director\IcingaConfig\IcingaConfigHelper as c;
|
||||||
|
|
||||||
class IcingaNotification extends IcingaObject
|
class IcingaNotification extends IcingaObject
|
||||||
{
|
{
|
||||||
protected $table = 'icinga_notification';
|
protected $table = 'icinga_notification';
|
||||||
@ -42,7 +44,44 @@ class IcingaNotification extends IcingaObject
|
|||||||
'period' => 'IcingaTimePeriod',
|
'period' => 'IcingaTimePeriod',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $intervalProperties = array(
|
||||||
|
'notification_interval' => 'notification_interval',
|
||||||
|
'times_begin' => 'times_begin',
|
||||||
|
'times_end' => 'times_end',
|
||||||
|
);
|
||||||
|
|
||||||
// listOfRelations -> users, user_groups
|
// listOfRelations -> users, user_groups
|
||||||
|
protected function renderTimes_begin()
|
||||||
|
{
|
||||||
|
$times = (object) array(
|
||||||
|
'begin' => c::renderInterval($this->times_begin)
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->times_end !== null) {
|
||||||
|
$times->end = c::renderInterval($this->times_end);
|
||||||
|
}
|
||||||
|
|
||||||
|
return c::renderKeyValue(
|
||||||
|
'times',
|
||||||
|
c::renderDictionary($times)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function renderTimes_end()
|
||||||
|
{
|
||||||
|
if ($this->times_begin !== null) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$times = (object) array(
|
||||||
|
'end' => c::renderInterval($this->times_end)
|
||||||
|
);
|
||||||
|
|
||||||
|
return c::renderKeyValue(
|
||||||
|
'times',
|
||||||
|
c::renderDictionary($times)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
protected function setKey($key)
|
protected function setKey($key)
|
||||||
{
|
{
|
||||||
|
@ -416,6 +416,8 @@ abstract class DirectorObjectForm extends QuickForm
|
|||||||
'address6',
|
'address6',
|
||||||
'groups',
|
'groups',
|
||||||
'command_id', // Notification
|
'command_id', // Notification
|
||||||
|
'notification_interval',
|
||||||
|
'period',
|
||||||
'email',
|
'email',
|
||||||
'pager',
|
'pager',
|
||||||
'enable_notifications',
|
'enable_notifications',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user