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
65
66
67
68
69
70
|
<?php
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Widget\ItemList;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Common\NoSubjectLink;
use Icinga\Module\Icingadb\Model\Service;
use ipl\Html\Attributes;
use ipl\Html\Html;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Stdlib\Filter;
use ipl\Web\Widget\Link;
use ipl\Web\Widget\StateBall;
/**
* Service item of a service list. Represents one database row.
*
* @property Service $item
* @property ServiceList $list
*/
abstract class BaseServiceListItem extends StateListItem
{
use NoSubjectLink;
protected function createSubject()
{
$service = $this->item->display_name;
$host = [
new StateBall($this->item->host->state->getStateText(), StateBall::SIZE_MEDIUM),
' ',
$this->item->host->display_name
];
$host = new Link($host, Links::host($this->item->host), ['class' => 'subject']);
if ($this->getNoSubjectLink()) {
$service = new HtmlElement('span', Attributes::create(['class' => 'subject']), Text::create($service));
} else {
$service = new Link($service, Links::service($this->item, $this->item->host), ['class' => 'subject']);
}
return [Html::sprintf(t('%s on %s', '<service> on <host>'), $service, $host)];
}
protected function init()
{
parent::init();
if ($this->list->getNoSubjectLink()) {
$this->setNoSubjectLink();
}
$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)
)
);
}
}
|