BasketSnapshotTable: split by day - and more

This commit is contained in:
Thomas Gelf 2018-10-08 11:59:07 +02:00
parent 83248f8f12
commit f0878a9bcd

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Web\Table; namespace Icinga\Module\Director\Web\Table;
use dipl\Html\Html;
use dipl\Html\Link; use dipl\Html\Link;
use dipl\Web\Table\ZfQueryBasedTable; use dipl\Web\Table\ZfQueryBasedTable;
use Icinga\Date\DateFormatter; use Icinga\Date\DateFormatter;
@ -13,6 +14,7 @@ class BasketSnapshotTable extends ZfQueryBasedTable
{ {
protected $searchColumns = [ protected $searchColumns = [
'basket_name', 'basket_name',
'summary'
]; ];
/** @var Basket */ /** @var Basket */
@ -28,23 +30,28 @@ class BasketSnapshotTable extends ZfQueryBasedTable
public function renderRow($row) public function renderRow($row)
{ {
$this->splitByDay($row->ts_create_seconds);
$hexUuid = bin2hex($row->uuid); $hexUuid = bin2hex($row->uuid);
$link = $this->linkToSnapshot($this->renderSummary($row->summary), $row); $link = $this->linkToSnapshot($this->renderSummary($row->summary), $row);
if ($this->basket === null) { if ($this->basket === null) {
$columns = [ $columns = [
$link, [
new Link( new Link(
$row->basket_name, Html::tag('strong', $row->basket_name),
'director/basket', 'director/basket',
['uuid' => $hexUuid] ['uuid' => $hexUuid]
), ),
DateFormatter::formatDateTime($row->ts_create / 1000), Html::tag('br'),
$link,
],
DateFormatter::formatTime($row->ts_create / 1000),
]; ];
} else { } else {
$columns = [ $columns = [
$link, $link,
DateFormatter::formatDateTime($row->ts_create / 1000), DateFormatter::formatTime($row->ts_create / 1000),
]; ];
} }
return $this::row($columns); return $this::row($columns);
@ -88,22 +95,6 @@ class BasketSnapshotTable extends ZfQueryBasedTable
]); ]);
} }
public function getColumnsToBeRendered()
{
if ($this->basket === null) {
return [
$this->translate('Content'),
$this->translate('Basket'),
$this->translate('Created'),
];
} else {
return [
$this->translate('Content'),
$this->translate('Created'),
];
}
}
public function prepareQuery() public function prepareQuery()
{ {
$query = $this->db()->select()->from([ $query = $this->db()->select()->from([
@ -112,6 +103,7 @@ class BasketSnapshotTable extends ZfQueryBasedTable
'b.uuid', 'b.uuid',
'b.basket_name', 'b.basket_name',
'bs.ts_create', 'bs.ts_create',
'ts_create_seconds' => '(bs.ts_create / 1000)',
'bs.content_checksum', 'bs.content_checksum',
'bc.summary', 'bc.summary',
])->join( ])->join(