1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
}
}
}
|