mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-04-23 07:10:28 -04:00
Introduce new widget class ServiceItemTable
This commit is contained in:
parent
b9825748db
commit
a336428f67
3 changed files with 106 additions and 0 deletions
31
library/Icingadb/Widget/ItemTable/ServiceItemTable.php
Normal file
31
library/Icingadb/Widget/ItemTable/ServiceItemTable.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?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\Web\Url;
|
||||
|
||||
class ServiceItemTable extends StateItemTable
|
||||
{
|
||||
use DetailActions;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
$this->initializeDetailActions();
|
||||
$this->setMultiselectUrl(Links::servicesDetails());
|
||||
$this->setDetailUrl(Url::fromPath('icingadb/service'));
|
||||
}
|
||||
|
||||
protected function getItemClass(): string
|
||||
{
|
||||
return ServiceRowItem::class;
|
||||
}
|
||||
|
||||
protected function getVisualColumn(): string
|
||||
{
|
||||
return 'service.state.severity';
|
||||
}
|
||||
}
|
||||
64
library/Icingadb/Widget/ItemTable/ServiceRowItem.php
Normal file
64
library/Icingadb/Widget/ItemTable/ServiceRowItem.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
/* Icinga DB Web | (c) 2022 Icinga GmbH | GPLv2 */
|
||||
|
||||
namespace Icinga\Module\Icingadb\Widget\ItemTable;
|
||||
|
||||
use Icinga\Module\Icingadb\Common\Links;
|
||||
use Icinga\Module\Icingadb\Model\Service;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Stdlib\Filter;
|
||||
use ipl\Web\Widget\Link;
|
||||
|
||||
class ServiceRowItem extends StateRowItem
|
||||
{
|
||||
/** @var ServiceItemTable */
|
||||
protected $list;
|
||||
|
||||
/** @var Service */
|
||||
protected $item;
|
||||
|
||||
protected function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
$this->list->addMultiselectFilterAttribute(
|
||||
$this,
|
||||
Filter::all(
|
||||
Filter::equal('service.name', $this->item->name),
|
||||
Filter::equal('host.name', $this->item->host->name)
|
||||
)
|
||||
);
|
||||
$this->list->addDetailFilterAttribute(
|
||||
$this,
|
||||
Filter::all(
|
||||
Filter::equal('name', $this->item->name),
|
||||
Filter::equal('host.name', $this->item->host->name)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected function assembleCell(BaseHtmlElement $cell, string $path, $value)
|
||||
{
|
||||
switch ($path) {
|
||||
case 'name':
|
||||
case 'display_name':
|
||||
$cell->addHtml(new Link(
|
||||
$this->item->$path,
|
||||
Links::service($this->item, $this->item->host),
|
||||
[
|
||||
'class' => 'subject',
|
||||
'title' => $this->item->$path
|
||||
]
|
||||
));
|
||||
break;
|
||||
case 'host.name':
|
||||
case 'host.display_name':
|
||||
$column = substr($path, 5);
|
||||
$cell->addHtml(new Link($this->item->host->$column, Links::host($this->item->host)));
|
||||
break;
|
||||
default:
|
||||
parent::assembleCell($cell, $path, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,17 @@
|
|||
}
|
||||
|
||||
table.item-table {
|
||||
th.has-visual {
|
||||
button {
|
||||
display: inline-flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
span > .icon:before {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.visual {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue