ActivityLog: add rudimentary table

This commit is contained in:
Thomas Gelf 2015-06-01 12:18:13 +02:00
parent a2502037fd
commit 01b44eb14c
2 changed files with 52 additions and 0 deletions

View File

@ -36,4 +36,11 @@ class Director_ListController extends ActionController
$this->view->table = $this->loadTable('icingaZone')->setConnection($this->db());
$this->render('table');
}
public function activitylogAction()
{
$this->view->title = $this->translate('Activity Log');
$this->view->table = $this->loadTable('activityLog')->setConnection($this->db());
$this->render('table');
}
}

View File

@ -0,0 +1,45 @@
<?php
namespace Icinga\Module\Director\Tables;
use Icinga\Module\Director\Web\Table\QuickTable;
class ActivityLogTable extends QuickTable
{
public function getColumns()
{
return array(
'id' => 'l.id',
'change_time' => 'l.change_time',
'author' => 'l.author',
'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '') || ' \"' || l.object_name || '\"')"
);
}
protected function getActionLinks($id)
{
return $this->view()->qlink('Show', 'director/show/activitylog', array('id' => $id));
}
public function getTitles()
{
$view = $this->view();
return array(
'change_time' => $view->translate('Timestamp'),
'author' => $view->translate('Author'),
'action' => $view->translate('Action'),
);
}
public function fetchData()
{
$db = $this->connection()->getConnection();
$query = $db->select()->from(
array('l' => 'director_activity_log'),
$this->getColumns()
)->order('change_time DESC');
return $db->fetchAll($query);
}
}