Importrun: allow to show it's rows

This commit is contained in:
Thomas Gelf 2015-07-26 15:39:37 +02:00
parent c9e5f16d3e
commit ec80dc9d87
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,25 @@
<?php
use Icinga\Module\Director\Web\Controller\ActionController;
use Icinga\Module\Director\Web\Hook\ImportSourceHook;
use Icinga\Module\Director\Util;
use Icinga\Module\Director\Objects\ImportSource;
use Icinga\Module\Director\Import\Import;
use Icinga\Exception\InvalidPropertyException;
use Icinga\Web\Notification;
class Director_ImportrunController extends ActionController
{
public function indexAction()
{
$this->view->title = $this->translate('Import run');
$this->view->table = $this->applyPaginationLimits(
$this->loadTable('importedrows')
->setChecksum(
$this->db()->getImportrunRowsetChecksum($this->params->get('id'))
)
->setConnection($this->db())
);
$this->render('list/table', null, true);
}
}

View File

@ -0,0 +1,60 @@
<?php
namespace Icinga\Module\Director\Tables;
use Icinga\Module\Director\Web\Table\QuickTable;
class ImportedrowsTable extends QuickTable
{
protected $checksum;
public function getColumns()
{
$db = $this->connection();
return $db->listImportedRowsetColumnNames($this->checksum);
}
public function setChecksum($checksum)
{
$this->checksum = $checksum;
return $this;
}
public function getTitles()
{
$view = $this->view();
$cols = $this->getColumns();
return array(
'object_name' => $view->translate('Object name'),
) + array_combine($cols, $cols);
}
public function count()
{
$db = $this->connection()->getConnection();
$query = $db->select()
->from('imported_rowset_row', 'COUNT(*)')
->where('rowset_checksum = ?', $this->checksum);
return $db->fetchOne($query);
}
public function fetchData()
{
$db = $this->connection()->getConnection();
$query = $this->getBaseQuery();
if ($this->hasLimit() || $this->hasOffset()) {
$query->limit($this->getLimit(), $this->getOffset());
}
return $db->fetchAll($query);
}
public function getBaseQuery()
{
return $this->connection()->createImportedRowsetRowsQuery(
$this->checksum
)->order('object_name');
}
}