blob: 6a8320c29713bf5d73ef5d913c27075eddb1b598 (
plain)
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
|
<?php
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
namespace Icinga\Module\Icingadb\Widget\ItemList;
use Icinga\Module\Icingadb\Common\BaseTableRowItem;
use Icinga\Module\Icingadb\Common\Links;
use Icinga\Module\Icingadb\Common\NoSubjectLink;
use Icinga\Module\Icingadb\Model\Servicegroup;
use Icinga\Module\Icingadb\Widget\Detail\ServiceStatistics;
use ipl\Html\Attributes;
use ipl\Html\BaseHtmlElement;
use ipl\Html\HtmlDocument;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
use ipl\Stdlib\Filter;
use ipl\Web\Widget\Link;
/**
* Servicegroup item of a servicegroup list. Represents one database row.
*
* @property Servicegroup $item
* @property ServicegroupList $list
*/
class ServicegroupListItem extends BaseTableRowItem
{
use NoSubjectLink;
protected function init()
{
$this->setNoSubjectLink($this->list->getNoSubjectLink());
$this->list->addDetailFilterAttribute($this, Filter::equal('name', $this->item->name));
}
protected function assembleColumns(HtmlDocument $columns)
{
$serviceStats = new ServiceStatistics($this->item);
$serviceStats->setBaseFilter(Filter::equal('servicegroup.name', $this->item->name));
if ($this->list->hasBaseFilter()) {
$serviceStats->setBaseFilter(
Filter::all($serviceStats->getBaseFilter(), $this->list->getBaseFilter())
);
}
$columns->addFrom($serviceStats, function (BaseHtmlElement $item) {
$item->getAttributes()->add(['class' => 'col']);
$item->setTag('div');
return $item;
});
}
protected function assembleTitle(BaseHtmlElement $title)
{
$title->addHtml(
$this->getNoSubjectLink()
? new HtmlElement(
'span',
Attributes::create(['class' => 'subject']),
Text::create($this->item->display_name)
)
: new Link($this->item->display_name, Links::servicegroup($this->item), ['class' => 'subject']),
new HtmlElement('br'),
Text::create($this->item->name)
);
}
}
|