2015-06-01 12:18:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Tables;
|
|
|
|
|
|
|
|
use Icinga\Module\Director\Web\Table\QuickTable;
|
|
|
|
|
|
|
|
class ActivityLogTable extends QuickTable
|
|
|
|
{
|
2015-06-30 11:19:31 +02:00
|
|
|
protected $filters = array();
|
|
|
|
|
2016-03-16 22:45:29 +01:00
|
|
|
protected $lastDeployedId;
|
|
|
|
|
2015-11-17 21:16:09 +01:00
|
|
|
protected $extraParams = array();
|
|
|
|
|
2015-06-01 12:18:13 +02:00
|
|
|
public function getColumns()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
'id' => 'l.id',
|
|
|
|
'change_time' => 'l.change_time',
|
|
|
|
'author' => 'l.author',
|
2016-02-26 11:58:37 +01:00
|
|
|
'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '')"
|
2016-03-16 22:45:29 +01:00
|
|
|
. " || ' \"' || l.object_name || '\"')",
|
|
|
|
'action_name' => 'l.action_name',
|
2015-06-01 12:18:13 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-03-16 22:45:29 +01:00
|
|
|
public function setLastDeployedId($id)
|
|
|
|
{
|
|
|
|
$this->lastDeployedId = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2016-02-28 11:16:06 +01:00
|
|
|
protected function listTableClasses()
|
|
|
|
{
|
|
|
|
return array_merge(array('activity-log'), parent::listTableClasses());
|
|
|
|
}
|
|
|
|
|
2016-03-16 22:45:29 +01:00
|
|
|
protected function getRowClasses($row)
|
|
|
|
{
|
|
|
|
$action = 'action-' . $row->action_name . ' ';
|
|
|
|
|
|
|
|
if ($row->id > $this->lastDeployedId) {
|
|
|
|
return $action . 'undeployed';
|
|
|
|
} else {
|
|
|
|
return $action . 'deployed';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-01 12:42:40 +02:00
|
|
|
protected function getActionUrl($row)
|
2015-06-01 12:18:13 +02:00
|
|
|
{
|
2015-11-17 21:16:09 +01:00
|
|
|
return $this->url(
|
|
|
|
'director/show/activitylog',
|
2016-02-26 11:58:37 +01:00
|
|
|
array_merge(array('id' => $row->id), $this->extraParams)
|
|
|
|
);
|
2015-06-01 12:18:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getTitles()
|
|
|
|
{
|
|
|
|
$view = $this->view();
|
|
|
|
return array(
|
2015-11-17 21:16:37 +01:00
|
|
|
'change_time' => $view->translate('Timestamp'),
|
|
|
|
'author' => $view->translate('Author'),
|
|
|
|
'action' => $view->translate('Action'),
|
2015-06-01 12:18:13 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-06-30 11:19:31 +02:00
|
|
|
public function filterObject($type, $name)
|
|
|
|
{
|
|
|
|
$this->filters[] = array('l.object_type = ?', $type);
|
|
|
|
$this->filters[] = array('l.object_name = ?', $name);
|
2015-11-17 21:16:09 +01:00
|
|
|
$this->extraParams = array(
|
|
|
|
'type' => $type,
|
|
|
|
'name' => $name,
|
|
|
|
);
|
2015-06-30 11:19:31 +02:00
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-07-23 16:19:22 +02:00
|
|
|
public function getBaseQuery()
|
2015-06-01 12:18:13 +02:00
|
|
|
{
|
|
|
|
$db = $this->connection()->getConnection();
|
|
|
|
|
|
|
|
$query = $db->select()->from(
|
|
|
|
array('l' => 'director_activity_log'),
|
2015-07-23 16:19:22 +02:00
|
|
|
array()
|
2016-02-24 21:34:13 +01:00
|
|
|
)->order('change_time DESC')->order('id DESC');
|
2015-06-01 12:18:13 +02:00
|
|
|
|
2015-06-30 11:19:31 +02:00
|
|
|
foreach ($this->filters as $filter) {
|
|
|
|
$query->where($filter[0], $filter[1]);
|
|
|
|
}
|
|
|
|
|
2015-07-23 16:19:22 +02:00
|
|
|
return $query;
|
2015-06-01 12:18:13 +02:00
|
|
|
}
|
|
|
|
}
|