This commit is contained in:
Jolien Trog 2025-10-09 19:09:48 +02:00
parent b5eed40255
commit f2833c195c
3 changed files with 82 additions and 0 deletions

View file

@ -0,0 +1,6 @@
// Controller für details zu einer Timeperiod
<!--/
indexAction
Detail; zeigt Display Name oben im Header, Name und Ranges im Content
/-->

View file

@ -0,0 +1,35 @@
// Controller für alle Timeperiods zeigt Liste
<!--/
indexAction
Liste; zeigt erst mal nur Display Name
/-->
<?php
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Controllers;
use Icinga\Application\Icinga;
use Icinga\Module\Icingadb\Model\Timeperiod;
use Icinga\Module\Icingadb\Widget\ItemTable\TimePeriodsTable;
use Icinga\Web\Controller;
use ipl\Web\Compat\CompatController;
class TimeperiodsController extends CompatController
{
public function indexAction(): void
{
$this->addTitleTab('Time Periods');
$db = $this->getDb();
$query = Timeperiod::on($db);
$this->addContent(new TimePeriodsTable($query));
}
}

View file

@ -0,0 +1,41 @@
<?php
/* Icinga DB Web | (c) 2022 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Widget\ItemTable;
use Icinga\Module\Icingadb\Common\DetailActions;
use Icinga\Module\Icingadb\Common\Links;
use ipl\Html\Html;
use ipl\Html\Table;
use ipl\Web\Url;
use ipl\Web\Widget\ItemTable;
use ipl\Web\Widget\Link;
class TimePeriodsTable extends Table
{
protected $defaultAttributes = ['class' => 'common-table'];
protected Query $timeperiods;
public function __construct($timeperiods)
{
$this->timeperiods = $timeperiods;
}
protected function assemble()
{
$tbody = $this->getBody();
foreach ($this->timeperiods as $timeperiod) {
$displayName = new Link($timeperiod->display_name, Url::fromPath('timeperiods/details', ['id' =>$timeperiod->id]));
$displayName = Html::tag('strong')->add($displayName->setBaseTarget('_next'));
$r = Table::row([
$displayName
]);
$tbody->addHtml($r);
}
}
}