2017-08-16 09:23:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Icinga\Module\Director\Web\Table;
|
|
|
|
|
2019-05-02 13:23:06 +02:00
|
|
|
use gipfl\IcingaWeb2\Link;
|
|
|
|
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
2017-08-16 09:23:45 +02:00
|
|
|
|
|
|
|
class ImportsourceTable extends ZfQueryBasedTable
|
|
|
|
{
|
|
|
|
protected $searchColumns = [
|
|
|
|
'source_name',
|
|
|
|
'description',
|
|
|
|
];
|
|
|
|
|
|
|
|
public function getColumnsToBeRendered()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
$this->translate('Source name'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function assemble()
|
|
|
|
{
|
2018-05-05 00:24:49 +02:00
|
|
|
$this->getAttributes()->add('class', 'syncstate');
|
2017-08-16 09:23:45 +02:00
|
|
|
parent::assemble();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function renderRow($row)
|
|
|
|
{
|
|
|
|
$caption = [Link::create(
|
|
|
|
$row->source_name,
|
|
|
|
'director/importsource',
|
|
|
|
['id' => $row->id]
|
|
|
|
)];
|
|
|
|
if ($row->description !== null) {
|
|
|
|
$caption[] = ': ' . $row->description;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($row->import_state === 'failing' && $row->last_error_message) {
|
|
|
|
$caption[] = ' (' . $row->last_error_message . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
$tr = $this::row([$caption]);
|
2018-05-05 00:24:49 +02:00
|
|
|
$tr->getAttributes()->add('class', $row->import_state);
|
2017-08-16 09:23:45 +02:00
|
|
|
|
|
|
|
return $tr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function prepareQuery()
|
|
|
|
{
|
|
|
|
return $this->db()->select()->from(
|
|
|
|
['s' => 'import_source'],
|
|
|
|
[
|
|
|
|
'id' => 's.id',
|
|
|
|
'source_name' => 's.source_name',
|
|
|
|
'provider_class' => 's.provider_class',
|
|
|
|
'import_state' => 's.import_state',
|
|
|
|
'last_error_message' => 's.last_error_message',
|
|
|
|
'description' => 's.description',
|
|
|
|
]
|
|
|
|
)->order('source_name ASC');
|
|
|
|
}
|
|
|
|
}
|