diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php index 55a873e0..f3ae1e8d 100644 --- a/application/controllers/EventController.php +++ b/application/controllers/EventController.php @@ -25,7 +25,7 @@ public function indexAction(): void $id = $this->params->getRequired('id'); $query = Event::on(Database::get()) - ->with(['object', 'object.source', 'incident', 'incident.object']) + ->with(['object', 'object.source', 'incident', 'incident.object', 'incident.object.source']) ->withColumns(['object.id_tags', 'incident.object.id_tags']) ->filter(Filter::equal('event.id', $id)); diff --git a/application/controllers/IncidentsController.php b/application/controllers/IncidentsController.php index 082a4f6a..a0a50a77 100644 --- a/application/controllers/IncidentsController.php +++ b/application/controllers/IncidentsController.php @@ -29,7 +29,7 @@ public function indexAction(): void $this->addTitleTab(t('Incidents')); $incidents = Incident::on(Database::get()) - ->with('object') + ->with(['object', 'object.source']) ->withColumns('object.id_tags'); $limitControl = $this->createLimitControl(); diff --git a/library/Notifications/Widget/Detail/IncidentDetail.php b/library/Notifications/Widget/Detail/IncidentDetail.php index e3fff80b..21965067 100644 --- a/library/Notifications/Widget/Detail/IncidentDetail.php +++ b/library/Notifications/Widget/Detail/IncidentDetail.php @@ -95,7 +95,6 @@ protected function createHistory() new IncidentHistoryList( $this->incident->incident_history ->with([ - 'incident.object.source', 'contact', 'rule', 'rule_escalation', diff --git a/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php b/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php index 21f70579..c4b5635b 100644 --- a/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php +++ b/library/Notifications/Widget/ItemList/IncidentHistoryListItem.php @@ -8,14 +8,13 @@ use Icinga\Module\Notifications\Model\Event; use Icinga\Module\Notifications\Model\IncidentHistory; use Icinga\Module\Notifications\Widget\IconBall; -use Icinga\Module\Notifications\Widget\SourceIcon; use ipl\Html\BaseHtmlElement; use ipl\Web\Common\BaseListItem; use ipl\Web\Widget\Icon; use ipl\Web\Widget\TimeAgo; /** - * Event item of an event list. Represents one database row. + * Incident history item of an incident history list. Represents one database row. */ class IncidentHistoryListItem extends BaseListItem { @@ -50,11 +49,6 @@ protected function assembleHeader(BaseHtmlElement $header): void } $header->addHtml($this->createCaption()); - if ($this->item->type === 'opened' || $this->item->type === 'incident_severity_changed') { - $header->add( - (new SourceIcon(SourceIcon::SIZE_BIG))->addHtml($this->item->incident->object->source->getIcon()) - ); - } $header->add(new TimeAgo($this->item->time->getTimestamp())); } diff --git a/library/Notifications/Widget/ItemList/IncidentListItem.php b/library/Notifications/Widget/ItemList/IncidentListItem.php index 57df92ca..4d7e3689 100644 --- a/library/Notifications/Widget/ItemList/IncidentListItem.php +++ b/library/Notifications/Widget/ItemList/IncidentListItem.php @@ -8,8 +8,14 @@ use Icinga\Module\Notifications\Common\Links; use Icinga\Module\Notifications\Model\Incident; use Icinga\Module\Notifications\Model\Objects; +use Icinga\Module\Notifications\Model\Source; +use Icinga\Module\Notifications\Widget\SourceIcon; +use ipl\Html\Attributes; use ipl\Html\BaseHtmlElement; +use ipl\Html\FormattedString; use ipl\Html\Html; +use ipl\Html\HtmlElement; +use ipl\I18n\Translation; use ipl\Web\Common\BaseListItem; use ipl\Web\Widget\Icon; use ipl\Web\Widget\Link; @@ -17,10 +23,12 @@ use ipl\Web\Widget\TimeSince; /** - * Event item of an event list. Represents one database row. + * Incident item of an incident list. Represents one database row. */ class IncidentListItem extends BaseListItem { + use Translation; + /** @var Incident The associated list item */ protected $item; @@ -73,19 +81,22 @@ protected function assembleTitle(BaseHtmlElement $title): void protected function assembleHeader(BaseHtmlElement $header): void { $header->add($this->createTitle()); + $meta = new HtmlElement('span', Attributes::create(['class' => 'meta'])); + + /** @var Source $source */ + $source = $this->item->object->source; + $meta->addHtml((new SourceIcon(SourceIcon::SIZE_BIG))->addHtml($source->getIcon())); if ($this->item->recovered_at !== null) { - $header->add(Html::tag( - 'span', - ['class' => 'meta'], - [ - 'closed ', - new TimeAgo($this->item->recovered_at->getTimestamp()) - ] + $meta->addHtml(FormattedString::create( + $this->translate('closed %s', '(incident) ... '), + new TimeAgo($this->item->recovered_at->getTimestamp()) )); } else { - $header->add(new TimeSince($this->item->started_at->getTimestamp())); + $meta->addHtml(new TimeSince($this->item->started_at->getTimestamp())); } + + $header->addHtml($meta); } protected function getSeverityIcon(): string diff --git a/public/css/common.less b/public/css/common.less index 9f704c66..bfb850f3 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -95,3 +95,11 @@ .full-width .add-new-component { margin: 0 0 1em 1em; } + +.event-list .list-item, +.incident-list .list-item { + .meta .source-icon { + margin-left: auto; + margin-right: 0.5em; + } +} \ No newline at end of file