ActivityLogTable: fix range/author filtering
This commit is contained in:
parent
f89fab2a27
commit
cc01446269
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Module\Director\ConfigDiff;
|
||||
use Icinga\Module\Director\Forms\DeployConfigForm;
|
||||
use Icinga\Module\Director\Forms\SettingsForm;
|
||||
|
@ -127,14 +128,28 @@ class ConfigController extends ActionController
|
|||
$lastDeployedId = $this->db()->getLastDeploymentActivityLogId();
|
||||
$table = new ActivityLogTable($this->db());
|
||||
$table->setLastDeployedId($lastDeployedId);
|
||||
$filter = Filter::fromQueryString(
|
||||
$this->url()->without(['page', 'limit', 'q'])->getQueryString()
|
||||
);
|
||||
$table->applyFilter($filter);
|
||||
if ($this->url()->hasParam('author')) {
|
||||
$this->actions()->add(Link::create(
|
||||
$this->translate('All changes'),
|
||||
$this->url()
|
||||
->without(['author', 'page']),
|
||||
null,
|
||||
['class' => 'icon-users', 'data-base-target' => '_self']
|
||||
));
|
||||
} else {
|
||||
$this->actions()->add(Link::create(
|
||||
$this->translate('My changes'),
|
||||
$this->url()
|
||||
->with('author', $this->Auth()->getUser()->getUsername())
|
||||
->without('page'),
|
||||
null,
|
||||
array('class' => 'icon-user', 'data-base-target' => '_self')
|
||||
['class' => 'icon-user', 'data-base-target' => '_self']
|
||||
));
|
||||
}
|
||||
if ($this->hasPermission('director/deploy')) {
|
||||
$this->actions()->add(DeployConfigForm::load()
|
||||
->setDb($this->db())
|
||||
|
|
|
@ -26,10 +26,10 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||
protected $currentBody;
|
||||
|
||||
protected $searchColumns = array(
|
||||
'l.author',
|
||||
'l.object_name',
|
||||
'l.object_type',
|
||||
'l.action_name',
|
||||
'author',
|
||||
'object_name',
|
||||
'object_type',
|
||||
'action_name',
|
||||
);
|
||||
|
||||
public function assemble()
|
||||
|
@ -61,14 +61,15 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||
|
||||
protected function makeLink($row)
|
||||
{
|
||||
if (Util::hasPermission('director/showconfig')) {
|
||||
// Later on replacing, service_set -> serviceset
|
||||
$type = $row->object_type;
|
||||
$name = $row->object_name;
|
||||
if (substr($type, 0, 7) === 'icinga_') {
|
||||
$type = substr($type, 7);
|
||||
}
|
||||
|
||||
if (Util::hasPermission('director/showconfig')) {
|
||||
// Later on replacing, service_set -> serviceset
|
||||
|
||||
// multi column key :(
|
||||
if ($type === 'service' || $this->hasObjectFilter) {
|
||||
$object = "\"$name\"";
|
||||
|
@ -93,7 +94,13 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||
$object
|
||||
];
|
||||
} else {
|
||||
return $row->log_message;
|
||||
return sprintf(
|
||||
'[%s] %s %s "%s"',
|
||||
$row->author,
|
||||
$row->action,
|
||||
$type,
|
||||
$name
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,10 +109,6 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||
$this->hasObjectFilter = true;
|
||||
$this->filters[] = ['l.object_type = ?', $type];
|
||||
$this->filters[] = ['l.object_name = ?', $name];
|
||||
$this->extraParams = [
|
||||
'type' => $type,
|
||||
'name' => $name,
|
||||
];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -113,9 +116,6 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||
public function getColumns()
|
||||
{
|
||||
return [
|
||||
'log_message' => "'[' || l.author || '] ' || l.action_name || ' '"
|
||||
. " || REPLACE(l.object_type, 'icinga_', '')"
|
||||
. " || ' \"' || l.object_name || '\"'",
|
||||
'author' => 'l.author',
|
||||
'action' => 'l.action_name',
|
||||
'object_name' => 'l.object_name',
|
||||
|
|
Loading…
Reference in New Issue