diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php index 7108606d4..95c89e8ef 100644 --- a/application/controllers/EventController.php +++ b/application/controllers/EventController.php @@ -4,12 +4,10 @@ namespace Icinga\Module\Icingadb\Controllers; -use ArrayObject; use Icinga\Module\Icingadb\Model\History; use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Widget\Detail\EventDetail; -use Icinga\Module\Icingadb\Widget\ItemList\HistoryList; -use ipl\Orm\ResultSet; +use Icinga\Module\Icingadb\Widget\Detail\EventHeader; use ipl\Stdlib\Filter; class EventController extends Controller @@ -60,12 +58,7 @@ public function init() public function indexAction() { - $this->addControl((new HistoryList(new ResultSet(new ArrayObject([$this->event])))) - ->setViewMode('minimal') - ->setPageSize(1) - ->setCaptionDisabled() - ->setNoSubjectLink() - ->setDetailActionsDisabled()); + $this->addControl(new EventHeader($this->event)); $this->addContent((new EventDetail($this->event))->setTicketLinkEnabled()); } } diff --git a/library/Icingadb/Widget/Detail/EventHeader.php b/library/Icingadb/Widget/Detail/EventHeader.php new file mode 100644 index 000000000..749db984a --- /dev/null +++ b/library/Icingadb/Widget/Detail/EventHeader.php @@ -0,0 +1,52 @@ + 'event-header']; + + protected function getObject(): History + { + return $this->object; + } + + protected function getStateBallSize(): string + { + return StateBall::SIZE_BIG; + } + + protected function wantSubjectLink(): bool + { + return false; + } + + protected function assembleHeader(BaseHtmlElement $header): void + { + $header->addHtml($this->createTitle()); + $header->addHtml($this->createTimestamp()); + } + + protected function assembleMain(BaseHtmlElement $main): void + { + $main->addHtml($this->createHeader()); + } + + protected function assemble(): void + { + $this->addHtml($this->createVisual()); + $this->addHtml($this->createMain()); + } +} diff --git a/library/Icingadb/Widget/Detail/EventHeaderUtils.php b/library/Icingadb/Widget/Detail/EventHeaderUtils.php new file mode 100644 index 000000000..d7b31de5c --- /dev/null +++ b/library/Icingadb/Widget/Detail/EventHeaderUtils.php @@ -0,0 +1,443 @@ +getObject(); + switch ($event->event_type) { + case 'comment_add': + $visual->addHtml( + HtmlElement::create( + 'div', + ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], + new Icon(Icons::COMMENT) + ) + ); + + break; + case 'comment_remove': + case 'downtime_end': + case 'ack_clear': + $visual->addHtml( + HtmlElement::create( + 'div', + ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], + new Icon(Icons::REMOVE) + ) + ); + + break; + case 'downtime_start': + $visual->addHtml( + HtmlElement::create( + 'div', + ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], + new Icon(Icons::IN_DOWNTIME) + ) + ); + + break; + case 'ack_set': + $visual->addHtml( + HtmlElement::create( + 'div', + ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], + new Icon(Icons::IS_ACKNOWLEDGED) + ) + ); + + break; + case 'flapping_end': + case 'flapping_start': + $visual->addHtml( + HtmlElement::create( + 'div', + ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], + new Icon(Icons::IS_FLAPPING) + ) + ); + + break; + case 'notification': + $visual->addHtml( + HtmlElement::create( + 'div', + ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], + new Icon(Icons::NOTIFICATION) + ) + ); + + break; + case 'state_change': + if ($event->state->state_type === 'soft') { + $stateType = 'soft_state'; + $previousStateType = 'previous_soft_state'; + + if ($event->state->previous_soft_state === 0) { + $previousStateType = 'hard_state'; + } + + $visual->addHtml( + new CheckAttempt( + (int)$event->state->check_attempt, + (int)$event->state->max_check_attempts + ) + ); + } else { + $stateType = 'hard_state'; + $previousStateType = 'previous_hard_state'; + + if ($event->state->hard_state === $event->state->previous_hard_state) { + $previousStateType = 'previous_soft_state'; + } + } + + if ($event->object_type === 'host') { + $state = HostStates::text($event->state->$stateType); + $previousState = HostStates::text($event->state->$previousStateType); + } else { + $state = ServiceStates::text($event->state->$stateType); + $previousState = ServiceStates::text($event->state->$previousStateType); + } + + $stateChange = new StateChange($state, $previousState); + if ($stateType === 'soft_state') { + $stateChange->setCurrentStateBallSize(StateBall::SIZE_MEDIUM_LARGE); + } + + if ($previousStateType === 'previous_soft_state') { + $stateChange->setPreviousStateBallSize(StateBall::SIZE_MEDIUM_LARGE); + if ($stateType === 'soft_state') { + $visual->getAttributes()->add('class', 'small-state-change'); + } + } + + $visual->prependHtml($stateChange); + + break; + } + } + + protected function assembleTitle(BaseHtmlElement $title): void + { + $event = $this->getObject(); + switch ($event->event_type) { + case 'comment_add': + $subjectLabel = $this->translate('Comment added'); + + break; + case 'comment_remove': + if (! empty($event->comment->removed_by)) { + if ($event->comment->removed_by !== $event->comment->author) { + $subjectLabel = sprintf( + $this->translate('Comment removed by %s', '..'), + $event->comment->removed_by + ); + } else { + $subjectLabel = $this->translate('Comment removed by author'); + } + } elseif (isset($event->comment->expire_time)) { + $subjectLabel = $this->translate('Comment expired'); + } else { + $subjectLabel = $this->translate('Comment removed'); + } + + break; + case 'downtime_end': + if (! empty($event->downtime->cancelled_by)) { + if ($event->downtime->cancelled_by !== $event->downtime->author) { + $subjectLabel = sprintf( + $this->translate('Downtime cancelled by %s', '..'), + $event->downtime->cancelled_by + ); + } else { + $subjectLabel = $this->translate('Downtime cancelled by author'); + } + } elseif ($event->downtime->has_been_cancelled === 'y') { + $subjectLabel = $this->translate('Downtime cancelled'); + } else { + $subjectLabel = $this->translate('Downtime ended'); + } + + break; + case 'downtime_start': + $subjectLabel = $this->translate('Downtime started'); + + break; + case 'flapping_start': + $subjectLabel = $this->translate('Flapping started'); + + break; + case 'flapping_end': + $subjectLabel = $this->translate('Flapping stopped'); + + break; + case 'ack_set': + $subjectLabel = $this->translate('Acknowledgement set'); + + break; + case 'ack_clear': + if (! empty($event->acknowledgement->cleared_by)) { + if ($event->acknowledgement->cleared_by !== $event->acknowledgement->author) { + $subjectLabel = sprintf( + $this->translate('Acknowledgement cleared by %s', '..'), + $event->acknowledgement->cleared_by + ); + } else { + $subjectLabel = $this->translate('Acknowledgement cleared by author'); + } + } elseif (isset($event->acknowledgement->expire_time)) { + $subjectLabel = $this->translate('Acknowledgement expired'); + } else { + $subjectLabel = $this->translate('Acknowledgement cleared'); + } + + break; + case 'notification': + $subjectLabel = isset($event->notification->type) ? sprintf( + NotificationListItem::phraseForType($event->notification->type), + ucfirst($event->object_type) + ) : $event->event_type; + + break; + case 'state_change': + $state = $event->state->state_type === 'hard' + ? $event->state->hard_state + : $event->state->soft_state; + if ($state === 0) { + if ($event->object_type === 'service') { + $subjectLabel = $this->translate('Service recovered'); + } else { + $subjectLabel = $this->translate('Host recovered'); + } + } else { + if ($event->state->state_type === 'hard') { + $subjectLabel = $this->translate('Hard state changed'); + } else { + $subjectLabel = $this->translate('Soft state changed'); + } + } + + break; + default: + $subjectLabel = $event->event_type; + + break; + } + + if (! $this->wantSubjectLink()) { + $title->addHtml(HtmlElement::create('span', ['class' => 'subject'], $subjectLabel)); + } else { + $title->addHtml(new Link($subjectLabel, Links::event($event), ['class' => 'subject'])); + } + + if ($event->object_type === 'host') { + if (isset($event->host->id)) { + $link = $this->createHostLink($event->host, true); + } + } else { + if (isset($event->host->id, $event->service->id)) { + $link = $this->createServiceLink($event->service, $event->host, true); + } + } + + $title->addHtml(Text::create(' ')); + if (isset($link)) { + $title->addHtml($link); + } + } + + protected function assembleCaption(BaseHtmlElement $caption): void + { + $event = $this->getObject(); + switch ($event->event_type) { + case 'comment_add': + case 'comment_remove': + $markdownLine = new MarkdownLine($this->createTicketLinks($event->comment->comment)); + $caption->getAttributes()->add($markdownLine->getAttributes()); + $caption->add([ + new Icon(Icons::USER), + $event->comment->author, + ': ' + ])->addFrom($markdownLine); + + break; + case 'downtime_end': + case 'downtime_start': + $markdownLine = new MarkdownLine($this->createTicketLinks($event->downtime->comment)); + $caption->getAttributes()->add($markdownLine->getAttributes()); + $caption->add([ + new Icon(Icons::USER), + $event->downtime->author, + ': ' + ])->addFrom($markdownLine); + + break; + case 'flapping_start': + $caption + ->add( + sprintf( + t('State Change Rate: %.2f%%; Start Threshold: %.2f%%'), + $event->flapping->percent_state_change_start, + $event->flapping->flapping_threshold_high + ) + ) + ->getAttributes() + ->add('class', 'plugin-output'); + + break; + case 'flapping_end': + $caption + ->add( + sprintf( + t('State Change Rate: %.2f%%; End Threshold: %.2f%%; Flapping for %s'), + $event->flapping->percent_state_change_end, + $event->flapping->flapping_threshold_low, + isset($event->flapping->end_time) + ? DateFormatter::formatDuration( + $event->flapping->end_time->getTimestamp() + - $event->flapping->start_time->getTimestamp() + ) + : t('n. a.') + ) + ) + ->getAttributes() + ->add('class', 'plugin-output'); + + break; + case 'ack_clear': + case 'ack_set': + if (! isset($event->acknowledgement->comment) && ! isset($event->acknowledgement->author)) { + $caption->addHtml( + new EmptyState( + $this->translate('This acknowledgement was set before Icinga DB history recording') + ) + ); + } else { + $markdownLine = new MarkdownLine($this->createTicketLinks($event->acknowledgement->comment)); + $caption->getAttributes()->add($markdownLine->getAttributes()); + $caption->add([ + new Icon(Icons::USER), + $event->acknowledgement->author, + ': ' + ])->addFrom($markdownLine); + } + + break; + case 'notification': + if (! empty($event->notification->author)) { + $caption->add([ + new Icon(Icons::USER), + $event->notification->author, + ': ', + $event->notification->text + ]); + } else { + $commandName = $event->object_type === 'host' + ? $event->host->checkcommand_name + : $event->service->checkcommand_name; + if (isset($commandName)) { + if (empty($event->notification->text)) { + $caption->addHtml(new EmptyState($this->translate('Output unavailable.'))); + } else { + $caption->addHtml( + new PluginOutputContainer( + (new PluginOutput($event->notification->text)) + ->setCommandName($commandName) + ) + ); + } + } else { + $caption->addHtml( + new EmptyState($this->translate('Waiting for Icinga DB to synchronize the config.')) + ); + } + } + + break; + case 'state_change': + $commandName = $event->object_type === 'host' + ? $event->host->checkcommand_name + : $event->service->checkcommand_name; + if (isset($commandName)) { + if (empty($event->state->output)) { + $caption->addHtml(new EmptyState($this->translate('Output unavailable.'))); + } else { + $caption->addHtml( + new PluginOutputContainer( + (new PluginOutput($event->state->output)) + ->setCommandName($commandName) + ) + ); + } + } else { + $caption->addHtml( + new EmptyState($this->translate('Waiting for Icinga DB to synchronize the config.')) + ); + } + + break; + } + } + + protected function createTimestamp(): ?BaseHtmlElement + { + return new TimeAgo($this->getObject()->event_time->getTimestamp()); + } +} diff --git a/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php b/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php index 61da9fd1d..e79890a0c 100644 --- a/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php +++ b/library/Icingadb/Widget/ItemList/BaseHistoryListItem.php @@ -4,38 +4,14 @@ namespace Icinga\Module\Icingadb\Widget\ItemList; -use Icinga\Date\DateFormatter; -use Icinga\Module\Icingadb\Common\HostLink; -use Icinga\Module\Icingadb\Common\HostStates; -use Icinga\Module\Icingadb\Common\Icons; -use Icinga\Module\Icingadb\Common\Links; -use Icinga\Module\Icingadb\Common\NoSubjectLink; -use Icinga\Module\Icingadb\Common\TicketLinks; -use Icinga\Module\Icingadb\Widget\MarkdownLine; -use Icinga\Module\Icingadb\Common\ServiceLink; -use Icinga\Module\Icingadb\Common\ServiceStates; use Icinga\Module\Icingadb\Model\History; -use Icinga\Module\Icingadb\Util\PluginOutput; -use Icinga\Module\Icingadb\Widget\CheckAttempt; -use Icinga\Module\Icingadb\Widget\PluginOutputContainer; -use Icinga\Module\Icingadb\Widget\StateChange; +use Icinga\Module\Icingadb\Widget\Detail\EventHeaderUtils; use ipl\Stdlib\Filter; use ipl\Web\Common\BaseListItem; -use ipl\Web\Widget\EmptyState; -use ipl\Web\Widget\StateBall; -use ipl\Web\Widget\TimeAgo; -use ipl\Html\BaseHtmlElement; -use ipl\Html\HtmlElement; -use ipl\Html\Text; -use ipl\Web\Widget\Icon; -use ipl\Web\Widget\Link; abstract class BaseHistoryListItem extends BaseListItem { - use HostLink; - use NoSubjectLink; - use ServiceLink; - use TicketLinks; + use EventHeaderUtils; /** @var History */ protected $item; @@ -45,363 +21,17 @@ abstract class BaseHistoryListItem extends BaseListItem protected function init(): void { - $this->setNoSubjectLink($this->list->getNoSubjectLink()); $this->setTicketLinkEnabled($this->list->getTicketLinkEnabled()); $this->list->addDetailFilterAttribute($this, Filter::equal('id', bin2hex($this->item->id))); } - abstract protected function getStateBallSize(): string; - - protected function assembleCaption(BaseHtmlElement $caption): void - { - switch ($this->item->event_type) { - case 'comment_add': - case 'comment_remove': - $markdownLine = new MarkdownLine($this->createTicketLinks($this->item->comment->comment)); - $caption->getAttributes()->add($markdownLine->getAttributes()); - $caption->add([ - new Icon(Icons::USER), - $this->item->comment->author, - ': ' - ])->addFrom($markdownLine); - - break; - case 'downtime_end': - case 'downtime_start': - $markdownLine = new MarkdownLine($this->createTicketLinks($this->item->downtime->comment)); - $caption->getAttributes()->add($markdownLine->getAttributes()); - $caption->add([ - new Icon(Icons::USER), - $this->item->downtime->author, - ': ' - ])->addFrom($markdownLine); - - break; - case 'flapping_start': - $caption - ->add(sprintf( - t('State Change Rate: %.2f%%; Start Threshold: %.2f%%'), - $this->item->flapping->percent_state_change_start, - $this->item->flapping->flapping_threshold_high - )) - ->getAttributes() - ->add('class', 'plugin-output'); - - break; - case 'flapping_end': - $caption - ->add(sprintf( - t('State Change Rate: %.2f%%; End Threshold: %.2f%%; Flapping for %s'), - $this->item->flapping->percent_state_change_end, - $this->item->flapping->flapping_threshold_low, - isset($this->item->flapping->end_time) - ? DateFormatter::formatDuration( - $this->item->flapping->end_time->getTimestamp() - - $this->item->flapping->start_time->getTimestamp() - ) - : t('n. a.') - )) - ->getAttributes() - ->add('class', 'plugin-output'); - - break; - case 'ack_clear': - case 'ack_set': - if (! isset($this->item->acknowledgement->comment) && ! isset($this->item->acknowledgement->author)) { - $caption->addHtml(new EmptyState( - t('This acknowledgement was set before Icinga DB history recording') - )); - } else { - $markdownLine = new MarkdownLine($this->createTicketLinks($this->item->acknowledgement->comment)); - $caption->getAttributes()->add($markdownLine->getAttributes()); - $caption->add([ - new Icon(Icons::USER), - $this->item->acknowledgement->author, - ': ' - ])->addFrom($markdownLine); - } - - break; - case 'notification': - if (! empty($this->item->notification->author)) { - $caption->add([ - new Icon(Icons::USER), - $this->item->notification->author, - ': ', - $this->item->notification->text - ]); - } else { - $commandName = $this->item->object_type === 'host' - ? $this->item->host->checkcommand_name - : $this->item->service->checkcommand_name; - if (isset($commandName)) { - if (empty($this->item->notification->text)) { - $caption->addHtml(new EmptyState(t('Output unavailable.'))); - } else { - $caption->addHtml(new PluginOutputContainer( - (new PluginOutput($this->item->notification->text)) - ->setCommandName($commandName) - )); - } - } else { - $caption->addHtml(new EmptyState(t('Waiting for Icinga DB to synchronize the config.'))); - } - } - - break; - case 'state_change': - $commandName = $this->item->object_type === 'host' - ? $this->item->host->checkcommand_name - : $this->item->service->checkcommand_name; - if (isset($commandName)) { - if (empty($this->item->state->output)) { - $caption->addHtml(new EmptyState(t('Output unavailable.'))); - } else { - $caption->addHtml(new PluginOutputContainer( - (new PluginOutput($this->item->state->output)) - ->setCommandName($commandName) - )); - } - } else { - $caption->addHtml(new EmptyState(t('Waiting for Icinga DB to synchronize the config.'))); - } - - break; - } - } - - protected function assembleVisual(BaseHtmlElement $visual): void - { - switch ($this->item->event_type) { - case 'comment_add': - $visual->addHtml(HtmlElement::create( - 'div', - ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], - new Icon(Icons::COMMENT) - )); - - break; - case 'comment_remove': - case 'downtime_end': - case 'ack_clear': - $visual->addHtml(HtmlElement::create( - 'div', - ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], - new Icon(Icons::REMOVE) - )); - - break; - case 'downtime_start': - $visual->addHtml(HtmlElement::create( - 'div', - ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], - new Icon(Icons::IN_DOWNTIME) - )); - - break; - case 'ack_set': - $visual->addHtml(HtmlElement::create( - 'div', - ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], - new Icon(Icons::IS_ACKNOWLEDGED) - )); - - break; - case 'flapping_end': - case 'flapping_start': - $visual->addHtml(HtmlElement::create( - 'div', - ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], - new Icon(Icons::IS_FLAPPING) - )); - - break; - case 'notification': - $visual->addHtml(HtmlElement::create( - 'div', - ['class' => ['icon-ball', 'ball-size-' . $this->getStateBallSize()]], - new Icon(Icons::NOTIFICATION) - )); - - break; - case 'state_change': - if ($this->item->state->state_type === 'soft') { - $stateType = 'soft_state'; - $previousStateType = 'previous_soft_state'; - - if ($this->item->state->previous_soft_state === 0) { - $previousStateType = 'hard_state'; - } - - $visual->addHtml(new CheckAttempt( - (int) $this->item->state->check_attempt, - (int) $this->item->state->max_check_attempts - )); - } else { - $stateType = 'hard_state'; - $previousStateType = 'previous_hard_state'; - - if ($this->item->state->hard_state === $this->item->state->previous_hard_state) { - $previousStateType = 'previous_soft_state'; - } - } - - if ($this->item->object_type === 'host') { - $state = HostStates::text($this->item->state->$stateType); - $previousState = HostStates::text($this->item->state->$previousStateType); - } else { - $state = ServiceStates::text($this->item->state->$stateType); - $previousState = ServiceStates::text($this->item->state->$previousStateType); - } - - $stateChange = new StateChange($state, $previousState); - if ($stateType === 'soft_state') { - $stateChange->setCurrentStateBallSize(StateBall::SIZE_MEDIUM_LARGE); - } - - if ($previousStateType === 'previous_soft_state') { - $stateChange->setPreviousStateBallSize(StateBall::SIZE_MEDIUM_LARGE); - if ($stateType === 'soft_state') { - $visual->getAttributes()->add('class', 'small-state-change'); - } - } - - $visual->prependHtml($stateChange); - - break; - } - } - - protected function assembleTitle(BaseHtmlElement $title): void + protected function getObject(): History { - switch ($this->item->event_type) { - case 'comment_add': - $subjectLabel = t('Comment added'); - - break; - case 'comment_remove': - if (! empty($this->item->comment->removed_by)) { - if ($this->item->comment->removed_by !== $this->item->comment->author) { - $subjectLabel = sprintf( - t('Comment removed by %s', '..'), - $this->item->comment->removed_by - ); - } else { - $subjectLabel = t('Comment removed by author'); - } - } elseif (isset($this->item->comment->expire_time)) { - $subjectLabel = t('Comment expired'); - } else { - $subjectLabel = t('Comment removed'); - } - - break; - case 'downtime_end': - if (! empty($this->item->downtime->cancelled_by)) { - if ($this->item->downtime->cancelled_by !== $this->item->downtime->author) { - $subjectLabel = sprintf( - t('Downtime cancelled by %s', '..'), - $this->item->downtime->cancelled_by - ); - } else { - $subjectLabel = t('Downtime cancelled by author'); - } - } elseif ($this->item->downtime->has_been_cancelled === 'y') { - $subjectLabel = t('Downtime cancelled'); - } else { - $subjectLabel = t('Downtime ended'); - } - - break; - case 'downtime_start': - $subjectLabel = t('Downtime started'); - - break; - case 'flapping_start': - $subjectLabel = t('Flapping started'); - - break; - case 'flapping_end': - $subjectLabel = t('Flapping stopped'); - - break; - case 'ack_set': - $subjectLabel = t('Acknowledgement set'); - - break; - case 'ack_clear': - if (! empty($this->item->acknowledgement->cleared_by)) { - if ($this->item->acknowledgement->cleared_by !== $this->item->acknowledgement->author) { - $subjectLabel = sprintf( - t('Acknowledgement cleared by %s', '..'), - $this->item->acknowledgement->cleared_by - ); - } else { - $subjectLabel = t('Acknowledgement cleared by author'); - } - } elseif (isset($this->item->acknowledgement->expire_time)) { - $subjectLabel = t('Acknowledgement expired'); - } else { - $subjectLabel = t('Acknowledgement cleared'); - } - - break; - case 'notification': - $subjectLabel = isset($this->item->notification->type) ? sprintf( - NotificationListItem::phraseForType($this->item->notification->type), - ucfirst($this->item->object_type) - ) : $this->item->event_type; - - break; - case 'state_change': - $state = $this->item->state->state_type === 'hard' - ? $this->item->state->hard_state - : $this->item->state->soft_state; - if ($state === 0) { - if ($this->item->object_type === 'service') { - $subjectLabel = t('Service recovered'); - } else { - $subjectLabel = t('Host recovered'); - } - } else { - if ($this->item->state->state_type === 'hard') { - $subjectLabel = t('Hard state changed'); - } else { - $subjectLabel = t('Soft state changed'); - } - } - - break; - default: - $subjectLabel = $this->item->event_type; - - break; - } - - if ($this->getNoSubjectLink()) { - $title->addHtml(HtmlElement::create('span', ['class' => 'subject'], $subjectLabel)); - } else { - $title->addHtml(new Link($subjectLabel, Links::event($this->item), ['class' => 'subject'])); - } - - if ($this->item->object_type === 'host') { - if (isset($this->item->host->id)) { - $link = $this->createHostLink($this->item->host, true); - } - } else { - if (isset($this->item->host->id, $this->item->service->id)) { - $link = $this->createServiceLink($this->item->service, $this->item->host, true); - } - } - - $title->addHtml(Text::create(' ')); - if (isset($link)) { - $title->addHtml($link); - } + return $this->item; } - protected function createTimestamp(): ?BaseHtmlElement + protected function wantSubjectLink(): bool { - return new TimeAgo($this->item->event_time->getTimestamp()); + return ! $this->list->getNoSubjectLink(); } } diff --git a/public/css/widget/object-header.less b/public/css/widget/object-header.less index 0758068a8..0c7ecfc3e 100644 --- a/public/css/widget/object-header.less +++ b/public/css/widget/object-header.less @@ -191,3 +191,7 @@ } } } + +.event-header .check-attempt { + display: none; +}