mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Add ranges view for time period detail
This commit is contained in:
parent
e7d758d520
commit
db4bcc2b64
5 changed files with 76 additions and 61 deletions
|
|
@ -4,12 +4,13 @@
|
|||
|
||||
namespace Icinga\Module\Icingadb\Controllers;
|
||||
|
||||
use Icinga\Module\Icingadb\Widget\Detail\TimePeriodDetailsTable;
|
||||
use Icinga\Exception\NotFoundError;
|
||||
use Icinga\Module\Icingadb\Model\TimeperiodRange;
|
||||
use Icinga\Module\Icingadb\Widget\Detail\TimePeriodDetail;
|
||||
use ipl\Stdlib\Filter;
|
||||
use Icinga\Module\Icingadb\Model\Timeperiod;
|
||||
use Icinga\Module\Icingadb\Web\Controller;
|
||||
use Icinga\Module\Icingadb\Widget\ItemTable\TimePeriodsTable;
|
||||
use ipl\Web\Compat\CompatController;
|
||||
|
||||
|
||||
class TimeperiodController extends Controller
|
||||
{
|
||||
|
|
@ -22,16 +23,11 @@ class TimeperiodController extends Controller
|
|||
->filter(Filter::equal('id', $timePeriodId))
|
||||
->first();
|
||||
|
||||
// $query = Timeperiod::on($db);
|
||||
$ranges = TimeperiodRange::on($this->getDb())
|
||||
->filter(Filter::equal('timeperiod_id', $timePeriodId));
|
||||
|
||||
$this->addContent(new TimePeriodDetailsTable($timePeriod));
|
||||
|
||||
$this->addContent(new TimePeriodDetail($timePeriod, $ranges));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Controller für details zu einer Timeperiod
|
||||
|
||||
//indexAction
|
||||
//
|
||||
//Detail; zeigt Display Name oben im Header, Name und Ranges im Content
|
||||
|
|
|
|||
|
|
@ -15,18 +15,10 @@ class TimeperiodsController extends Controller
|
|||
{
|
||||
$this->addTitleTab('Time Periods');
|
||||
|
||||
|
||||
$db = $this->getDb();
|
||||
|
||||
$query = Timeperiod::on($db);
|
||||
|
||||
$this->addContent(new TimePeriodsTable($query));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Controller für alle Timeperiods zeigt Liste
|
||||
|
||||
//indexAction
|
||||
//Liste; zeigt erst mal nur Display Name
|
||||
|
|
|
|||
58
library/Icingadb/Widget/Detail/TimePeriodDetail.php
Normal file
58
library/Icingadb/Widget/Detail/TimePeriodDetail.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
||||
|
||||
namespace Icinga\Module\Icingadb\Widget\Detail;
|
||||
|
||||
use ipl\Html\HtmlElement;
|
||||
use ipl\Html\Table;
|
||||
use ipl\Html\Text;
|
||||
use ipl\Orm\Model;
|
||||
use ipl\Orm\Query;
|
||||
|
||||
use ipl\Web\Widget\EmptyState;
|
||||
use ipl\Web\Widget\HorizontalKeyValue;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class TimePeriodDetail extends Table
|
||||
{
|
||||
|
||||
protected $defaultAttributes = ['class' => 'common-table'];
|
||||
|
||||
protected Model $timePeriod;
|
||||
protected Query $range;
|
||||
|
||||
public function __construct(Model $timePeriod, Query $range)
|
||||
{
|
||||
$this->timePeriod = $timePeriod;
|
||||
$this->range = $range;
|
||||
}
|
||||
|
||||
protected function assemble(): void
|
||||
{
|
||||
$this->getHeader()->addHtml(self::row([
|
||||
// new Ball(Ball::SIZE_BIG),
|
||||
$this->timePeriod->display_name,
|
||||
$this->timePeriod->name,
|
||||
], null, 'th'));
|
||||
$tbody = $this->getBody();
|
||||
|
||||
$this->addHtml( new HtmlElement('h2', null, Text::create(t('Ranges'))));
|
||||
|
||||
foreach ($this->range as $r) {
|
||||
$detail = [
|
||||
new HorizontalKeyValue(t('Day'), $r->range_key),
|
||||
new HorizontalKeyValue(t('Time'), $r->range_value),
|
||||
];
|
||||
|
||||
$tbody->addHtml(self::row([
|
||||
$detail
|
||||
]));
|
||||
}
|
||||
|
||||
if (empty($detail)) {
|
||||
$this->addHtml(new EmptyState('No ranges have been configured'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
||||
|
||||
namespace Icinga\Module\Icingadb\Widget\Detail;
|
||||
|
||||
use ipl\Html\Table;
|
||||
use ipl\Orm\Model;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class TimePeriodDetailsTable extends Table
|
||||
{
|
||||
|
||||
protected $defaultAttributes = ['class' => 'common-table'];
|
||||
|
||||
protected Model $timePeriod;
|
||||
|
||||
public function __construct(Model $timePeriod)
|
||||
{
|
||||
$this->timePeriod = $timePeriod;
|
||||
}
|
||||
|
||||
protected function assemble(): void
|
||||
{
|
||||
$this->getHeader()->addHtml(self::row([
|
||||
$this->timePeriod->display_name,
|
||||
], null, 'th'));
|
||||
|
||||
$tbody = $this->getBody();
|
||||
|
||||
$tbody->addHtml(self::row([
|
||||
|
||||
$this->timePeriod->display_name,
|
||||
$this->timePeriod->name,
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,8 @@ use ipl\Html\Html;
|
|||
use ipl\Html\Table;
|
||||
use ipl\Orm\Query;
|
||||
use ipl\Web\Url;
|
||||
use ipl\Web\Widget\Ball;
|
||||
use ipl\Web\Widget\Icon;
|
||||
use ipl\Web\Widget\ItemTable;
|
||||
use ipl\Web\Widget\Link;
|
||||
|
||||
|
|
@ -29,14 +31,19 @@ class TimePeriodsTable extends Table
|
|||
$tbody = $this->getBody();
|
||||
|
||||
foreach ($this->timePeriods as $timePeriod) {
|
||||
|
||||
$displayName = new Link($timePeriod->display_name, Url::fromPath('icingadb/timeperiod/index', ['id' =>$timePeriod->id]));
|
||||
$icon = new Icon('clock');
|
||||
// $icon = new Ball(Ball::SIZE_BIG);
|
||||
|
||||
$displayName = Html::tag('strong')->add($displayName->setBaseTarget('_next'));
|
||||
$r = Table::row([
|
||||
|
||||
$displayNameRow = Table::row([
|
||||
$icon,
|
||||
$displayName
|
||||
// hier muss noch rage rein!
|
||||
]);
|
||||
$tbody->addHtml($r);
|
||||
|
||||
$tbody->addHtml($displayNameRow);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue