mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Add quick filter for event types to event overview
Add a new filter form for event types to the eventhistoryAction and add selected to filter on post refs #7695
This commit is contained in:
parent
cae813d4c7
commit
6269f6695b
@ -537,6 +537,24 @@ class Monitoring_ListController extends Controller
|
|||||||
}
|
}
|
||||||
$this->addTitleTab('eventhistory', $this->translate('Event Overview'));
|
$this->addTitleTab('eventhistory', $this->translate('Event Overview'));
|
||||||
|
|
||||||
|
$form = new EventOverviewForm();
|
||||||
|
$form->handleRequest($this->getRequest());
|
||||||
|
$this->view->form = $form;
|
||||||
|
|
||||||
|
if ($this->getRequest()->isPost()) {
|
||||||
|
// update filter string
|
||||||
|
$filters = $form->getFilter();
|
||||||
|
$url = $this->_request->getUrl();
|
||||||
|
$url->setQueryString($filters->toQueryString());
|
||||||
|
if ($this->getParam('sort') !== null) {
|
||||||
|
$url->setParam('sort', $this->getParam('sort'));
|
||||||
|
}
|
||||||
|
if ($this->getParam('dir') !== null) {
|
||||||
|
$url->setParam('dir', $this->getParam('dir'));
|
||||||
|
}
|
||||||
|
return $this->redirectNow($url);
|
||||||
|
}
|
||||||
|
|
||||||
$query = $this->backend->select()->from('eventHistory', array(
|
$query = $this->backend->select()->from('eventHistory', array(
|
||||||
'host_name',
|
'host_name',
|
||||||
'service_description',
|
'service_description',
|
||||||
@ -550,6 +568,9 @@ class Monitoring_ListController extends Controller
|
|||||||
'host',
|
'host',
|
||||||
'service'
|
'service'
|
||||||
));
|
));
|
||||||
|
if ($this->getParam('state')) {
|
||||||
|
$query->applyFilter(Filter::expression('state', '=', $this->getParam('state')));
|
||||||
|
}
|
||||||
|
|
||||||
$this->setupSortControl(array(
|
$this->setupSortControl(array(
|
||||||
'timestamp' => 'Occurence'
|
'timestamp' => 'Occurence'
|
||||||
|
160
modules/monitoring/application/forms/EventOverviewForm.php
Normal file
160
modules/monitoring/application/forms/EventOverviewForm.php
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
<?php
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
// {{{ICINGA_LICENSE_HEADER}}}
|
||||||
|
|
||||||
|
namespace Icinga\Module\Monitoring\Forms;
|
||||||
|
|
||||||
|
use Icinga\Data\Filter\FilterNot;
|
||||||
|
use Icinga\Web\Url;
|
||||||
|
use \Zend_Form;
|
||||||
|
use Icinga\Web\Form;
|
||||||
|
use Icinga\Data\Filter\Filter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configure the filter for the event overview
|
||||||
|
*/
|
||||||
|
class EventOverviewForm extends Form
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Initialize this form
|
||||||
|
*/
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$this->setName('form_event_overview');
|
||||||
|
$this->setDecorators(array(
|
||||||
|
'FormElements',
|
||||||
|
array('HtmlTag', array('tag' => 'div', 'class' => 'hbox')),
|
||||||
|
'Form'
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see Form::createElements()
|
||||||
|
*/
|
||||||
|
public function createElements(array $formData)
|
||||||
|
{
|
||||||
|
$decorators = array(
|
||||||
|
array('Label', array('class' => 'optional')),
|
||||||
|
'ViewHelper',
|
||||||
|
array('HtmlTag', array('tag' => 'div', 'class' => 'hbox-item optionbox')),
|
||||||
|
);
|
||||||
|
|
||||||
|
$url = Url::fromRequest()->getAbsoluteUrl();
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'statechange',
|
||||||
|
array(
|
||||||
|
'label' => t('State Changes'),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'decorators' => $decorators,
|
||||||
|
'value' => strpos($url, $this->stateChangeFilter()->toQueryString()) === false ? 0 : 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'downtime',
|
||||||
|
array(
|
||||||
|
'label' => t('Downtimes'),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'decorators' => $decorators,
|
||||||
|
'value' => strpos($url, $this->downtimeFilter()->toQueryString()) === false ? 0 : 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'comment',
|
||||||
|
array(
|
||||||
|
'label' => t('Comments'),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'decorators' => $decorators,
|
||||||
|
'value' => strpos($url, $this->commentFilter()->toQueryString()) === false ? 0 : 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'notification',
|
||||||
|
array(
|
||||||
|
'label' => t('Notifications'),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'decorators' => $decorators,
|
||||||
|
'value' => strpos($url, $this->notificationFilter()->toQueryString()) === false ? 0 : 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->addElement(
|
||||||
|
'checkbox',
|
||||||
|
'flapping',
|
||||||
|
array(
|
||||||
|
'label' => t('Flapping'),
|
||||||
|
'class' => 'autosubmit',
|
||||||
|
'decorators' => $decorators,
|
||||||
|
'value' => strpos($url, $this->flappingFilter()->toQueryString()) === false ? 0 : 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the corresponding filter-object
|
||||||
|
*
|
||||||
|
* @returns Filter
|
||||||
|
*/
|
||||||
|
public function getFilter()
|
||||||
|
{
|
||||||
|
$filters = array();
|
||||||
|
if ($this->getValue('statechange', 1)) {
|
||||||
|
$filters[] = $this->stateChangeFilter();
|
||||||
|
}
|
||||||
|
if ($this->getValue('comment', 1)) {
|
||||||
|
$filters[] = $this->commentFilter();
|
||||||
|
}
|
||||||
|
if ($this->getValue('notification', 1)) {
|
||||||
|
$filters[] = $this->notificationFilter();
|
||||||
|
}
|
||||||
|
if ($this->getValue('downtime', 1)) {
|
||||||
|
$filters[] = $this->downtimeFilter();
|
||||||
|
}
|
||||||
|
if ($this->getValue('flapping', 1)) {
|
||||||
|
$filters[] = $this->flappingFilter();
|
||||||
|
}
|
||||||
|
return Filter::matchAny($filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stateChangeFilter()
|
||||||
|
{
|
||||||
|
return Filter::matchAny(
|
||||||
|
Filter::expression('type', '=', 'hard_state'),
|
||||||
|
Filter::expression('type', '=', 'soft_state')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function commentFilter()
|
||||||
|
{
|
||||||
|
return Filter::matchAny(
|
||||||
|
Filter::expression('type', '=', 'comment'),
|
||||||
|
Filter::expression('type', '=', 'comment_deleted'),
|
||||||
|
Filter::expression('type', '=', 'dt_comment'),
|
||||||
|
Filter::expression('type', '=', 'dt_comment_deleted'),
|
||||||
|
Filter::expression('type', '=', 'ack')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function notificationFilter()
|
||||||
|
{
|
||||||
|
return Filter::expression('type', '=', 'notify');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function downtimeFilter()
|
||||||
|
{
|
||||||
|
return Filter::matchAny(
|
||||||
|
Filter::expression('type', '=', 'downtime_start'),
|
||||||
|
Filter::expression('type', '=', 'downtime_end')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function flappingFilter()
|
||||||
|
{
|
||||||
|
return Filter::matchAny(
|
||||||
|
Filter::expression('type', '=', 'flapping'),
|
||||||
|
Filter::expression('type', '=', 'flapping_deleted')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,9 @@
|
|||||||
<div style="margin: 1em" class="dontprint">
|
<div style="margin: 1em" class="dontprint">
|
||||||
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
|
<?= $this->translate('Sort by'); ?> <?= $this->sortControl->render($this); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?= $form ?>
|
||||||
|
<br/>
|
||||||
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $this->history->count())); ?>
|
<?= $this->widget('limiter', array('url' => $this->url, 'max' => $this->history->count())); ?>
|
||||||
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
|
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -195,3 +195,19 @@ textarea {
|
|||||||
input, select, textarea {
|
input, select, textarea {
|
||||||
display: inline;
|
display: inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.optionbox {
|
||||||
|
margin-left: 0em;
|
||||||
|
margin-right: 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.optionbox label {
|
||||||
|
max-width: 6.5em;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.optionbox input {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user