mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
SyncRunTable: add new table, link and show it
This commit is contained in:
parent
5776a90a6a
commit
65b28fc2f6
@ -109,6 +109,20 @@ class SyncruleController extends ActionController
|
||||
$this->setViewScript('list/table');
|
||||
}
|
||||
|
||||
public function historyAction()
|
||||
{
|
||||
$this->view->stayHere = true;
|
||||
|
||||
$id = $this->params->get('id');
|
||||
$this->prepareRuleTabs($id)->activate('history');
|
||||
$this->view->title = $this->translate('Sync history');
|
||||
$this->view->table = $this->loadTable('syncRun')
|
||||
->enforceFilter(Filter::where('rule_id', $id))
|
||||
->setConnection($this->db());
|
||||
|
||||
$this->setViewScript('list/table');
|
||||
}
|
||||
|
||||
protected function prepareRuleTabs($ruleId = null)
|
||||
{
|
||||
if ($ruleId) {
|
||||
@ -120,6 +134,10 @@ class SyncruleController extends ActionController
|
||||
'label' => $this->translate('Properties'),
|
||||
'url' => 'director/syncrule/property',
|
||||
'urlParams' => array('rule_id' => $ruleId)
|
||||
))->add('history', array(
|
||||
'label' => $this->translate('History'),
|
||||
'url' => 'director/syncrule/history',
|
||||
'urlParams' => array('id' => $ruleId)
|
||||
));
|
||||
} else {
|
||||
return $this->getTabs()->add('add', array(
|
||||
|
78
application/tables/SyncRunTable.php
Normal file
78
application/tables/SyncRunTable.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Tables;
|
||||
|
||||
use Icinga\Module\Director\Web\Table\QuickTable;
|
||||
use Exception;
|
||||
|
||||
class SyncRunTable extends QuickTable
|
||||
{
|
||||
protected $revalidate = false;
|
||||
|
||||
public function getColumns()
|
||||
{
|
||||
return array(
|
||||
'id' => 'sr.id',
|
||||
'rule_id' => 'sr.rule_id',
|
||||
'rule_name' => 'sr.rule_name',
|
||||
'start_time' => 'sr.start_time',
|
||||
'duration_ms' => 'sr.duration_ms',
|
||||
'objects_deleted' => 'sr.objects_deleted',
|
||||
'objects_created' => 'sr.objects_created',
|
||||
'objects_modified' => 'sr.objects_modified',
|
||||
'last_former_activity' => 'sr.last_former_activity',
|
||||
'last_related_activity' => 'sr.last_related_activity',
|
||||
);
|
||||
}
|
||||
|
||||
protected function getActionUrl($row)
|
||||
{
|
||||
return $this->url(
|
||||
'director/syncrule/history',
|
||||
array(
|
||||
'id' => $row->rule_id,
|
||||
'run_id' => $row->id,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getTitles()
|
||||
{
|
||||
$singleRule = false;
|
||||
|
||||
foreach ($this->enforcedFilters as $filter) {
|
||||
if (in_array('rule_id', $filter->listFilteredColumns())) {
|
||||
$singleRule = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$view = $this->view();
|
||||
|
||||
if ($singleRule) {
|
||||
return array(
|
||||
'start_time' => $view->translate('Start time'),
|
||||
'objects_created' => $view->translate('Created'),
|
||||
'objects_modified' => $view->translate('Modified'),
|
||||
'objects_deleted' => $view->translate('Deleted'),
|
||||
);
|
||||
} else {
|
||||
return array(
|
||||
'rule_name' => $view->translate('Rule name'),
|
||||
'start_time' => $view->translate('Start time'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBaseQuery()
|
||||
{
|
||||
$db = $this->connection()->getConnection();
|
||||
|
||||
$query = $db->select()->from(
|
||||
array('sr' => 'sync_run'),
|
||||
array()
|
||||
)->order('rule_name');
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user