Skip to content

Commit

Permalink
Move source icon in incident detail to the header
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed May 3, 2024
1 parent 3224f65 commit a76399f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion application/controllers/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion application/controllers/IncidentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion library/Notifications/Widget/Detail/IncidentDetail.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ protected function createHistory()
->with([
'event',
'incident.object',
'incident.object.source',
'contact',
'rule',
'rule_escalation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Icinga\Module\Notifications\Model\Event;
use Icinga\Module\Notifications\Model\IncidentHistory;
use Icinga\Module\Notifications\Model\Objects;
use Icinga\Module\Notifications\Widget\SourceIcon;
use ipl\Html\BaseHtmlElement;
use ipl\Web\Widget\IcingaIcon;
use ipl\Web\Common\BaseListItem;
Expand Down Expand Up @@ -76,11 +75,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()));
}
Expand Down
25 changes: 16 additions & 9 deletions library/Notifications/Widget/ItemList/IncidentListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
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\Html;
use ipl\Html\HtmlElement;
use ipl\Web\Common\BaseListItem;
use ipl\Web\Widget\Icon;
use ipl\Web\Widget\Link;
Expand Down Expand Up @@ -73,19 +77,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->add([
'closed ',
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
Expand Down

0 comments on commit a76399f

Please sign in to comment.