2019-10-29 19:55:28 -04:00
|
|
|
<?php
|
|
|
|
|
|
2020-03-13 03:38:01 -04:00
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
namespace Icinga\Module\Icingadb\Common;
|
2019-10-29 19:55:28 -04:00
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
use Icinga\Module\Icingadb\Model\Host;
|
|
|
|
|
use Icinga\Module\Icingadb\Model\Service;
|
2021-09-22 04:21:15 -04:00
|
|
|
use ipl\Html\FormattedString;
|
2019-10-29 19:55:28 -04:00
|
|
|
use ipl\Html\Html;
|
|
|
|
|
use ipl\Web\Widget\StateBall;
|
|
|
|
|
|
|
|
|
|
trait ServiceLink
|
|
|
|
|
{
|
2021-09-22 04:21:15 -04:00
|
|
|
protected function createServiceLink(Service $service, Host $host, bool $withStateBall = false): FormattedString
|
2019-10-29 19:55:28 -04:00
|
|
|
{
|
|
|
|
|
$content = [];
|
|
|
|
|
|
|
|
|
|
if ($withStateBall) {
|
|
|
|
|
$content[] = new StateBall($service->state->getStateText(), StateBall::SIZE_MEDIUM);
|
|
|
|
|
$content[] = ' ';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$content[] = $service->display_name;
|
|
|
|
|
|
2021-06-22 04:29:25 -04:00
|
|
|
return Html::sprintf(
|
2020-05-20 03:55:23 -04:00
|
|
|
t('%s on %s', '<service> on <host>'),
|
2021-11-04 09:56:39 -04:00
|
|
|
Html::tag('a', ['href' => Links::service($service, $host), 'class' => 'subject'], $content),
|
2019-10-29 19:55:28 -04:00
|
|
|
Html::tag(
|
|
|
|
|
'a',
|
2021-11-04 09:56:39 -04:00
|
|
|
['href' => Links::host($host), 'class' => 'subject'],
|
2019-10-29 19:55:28 -04:00
|
|
|
[
|
|
|
|
|
new StateBall($host->state->getStateText(), StateBall::SIZE_MEDIUM),
|
|
|
|
|
' ',
|
|
|
|
|
$host->display_name
|
|
|
|
|
]
|
|
|
|
|
)
|
2021-06-22 04:29:25 -04:00
|
|
|
);
|
2019-10-29 19:55:28 -04:00
|
|
|
}
|
|
|
|
|
}
|