Add filter functionality to eventhistory view and fix default order direction

refs #5589
This commit is contained in:
Johannes Meyer 2014-02-21 12:59:32 +01:00
parent 6167e6a4f8
commit c89f3b6140
7 changed files with 23 additions and 29 deletions

View File

@ -67,7 +67,7 @@ icon = "img/icons/notification.png"
[History.Events]
title = "All Events"
url = "monitoring/list/eventhistory"
url = "monitoring/list/eventhistory?raw_timestamp>=-2+days"
icon = "img/icons/history.png"
[System.Performance]

View File

@ -362,7 +362,7 @@ class Monitoring_ListController extends MonitoringController
public function eventhistoryAction()
{
$query = EventHistoryView::fromRequest(
$dataview = EventHistoryView::fromRequest(
$this->getRequest(),
array(
'host_name',
@ -378,12 +378,18 @@ class Monitoring_ListController extends MonitoringController
'host',
'service'
)
)->getQuery();
);
$this->setupFilterControl($dataview, 'eventhistory');
$this->setupSortControl(
array(
'raw_timestamp' => 'Occurence'
)
);
$query = $dataview->getQuery();
$this->handleFormatRequest($query);
$this->view->history = $query->paginate();
$this->setupSortControl(
array()
);
}
/**

View File

@ -10,6 +10,15 @@
<div data-icinga-component="app/mainDetailGrid" data-icinga-grid-selection-type="single">
<div class="container pull-left">
<div class="row">
<div class="col-md-5">
<?= $this->filterBox->render($this); ?>
</div>
<div class="col-md-7">
<?= $this->sortControl->render($this); ?>
</div>
</div>
<div class="row">
<?= $this->paginationControl($history, null, null, array('preserve' => $this->preserve)); ?>
</div>

View File

@ -3,7 +3,6 @@
namespace Icinga\Module\Monitoring\Backend\Ido\Query;
use \Zend_Db_Select;
use Icinga\Exception\ProgrammingError;
class EventHistoryQuery extends IdoQuery
{
@ -37,17 +36,9 @@ class EventHistoryQuery extends IdoQuery
);
protected $useSubqueryCount = true;
protected $maxCount = 1000;
protected function joinBaseTables()
{
// $start = date('Y-m-d H:i:s', time() - 3600 * 24 * 1);
$start = date('Y-m-d H:i:s', time() - 3600 * 24 * 2);
$end = date('Y-m-d H:i:s');
// TODO: $this->dbTime(...)
//$start = null;
//$end = null;
$columns = array(
'raw_timestamp',
'timestamp',
@ -68,16 +59,6 @@ class EventHistoryQuery extends IdoQuery
$this->createSubQuery('Notificationhistory', $columns)
);
if ($start) {
foreach ($this->subQueries as $query) {
$query->where('timestamp > ?', $start);
}
}
if ($end) {
foreach ($this->subQueries as $query) {
$query->where('timestamp < ? ', $end);
}
}
$sub = $this->db->select()->union($this->subQueries, Zend_Db_Select::SQL_UNION_ALL);
$this->baseQuery = $this->db->select()->from(
array('eho' => $this->prefix . 'objects'),

View File

@ -55,7 +55,6 @@ class Contact extends DataView
{
return array(
'contact_alias' => array(
'default_dir' => self::SORT_ASC,
'order' => self::SORT_DESC
)
);

View File

@ -33,7 +33,6 @@ class Contactgroup extends DataView
{
return array(
'contactgroup_name' => array(
'default_dir' => self::SORT_ASC,
'order' => self::SORT_DESC
)
);

View File

@ -63,10 +63,10 @@ class EventHistory extends DataView
{
return array(
'raw_timestamp' => array(
'default_dir' => self::SORT_DESC
'order' => self::SORT_DESC
),
'timestamp' => array(
'default_dir' => self::SORT_DESC
'order' => self::SORT_DESC
)
);
}