diff --git a/library/Notifications/Common/Links.php b/library/Notifications/Common/Links.php index fbdd03e5e..d611afcd0 100644 --- a/library/Notifications/Common/Links.php +++ b/library/Notifications/Common/Links.php @@ -11,8 +11,12 @@ */ abstract class Links { - public static function event(int $id): Url + public static function event(?int $id = null): Url { + if ($id === null) { + return Url::fromPath('notifications/event'); + } + return Url::fromPath('notifications/event', ['id' => $id]); } @@ -26,8 +30,12 @@ public static function incidents(): Url return Url::fromPath('notifications/incidents'); } - public static function incident(int $id): Url + public static function incident(?int $id = null): Url { + if ($id === null) { + return Url::fromPath('notifications/incident'); + } + return Url::fromPath('notifications/incident', ['id' => $id]); } @@ -36,8 +44,12 @@ public static function contacts(): Url return Url::fromPath('notifications/contacts'); } - public static function contact(int $id): Url + public static function contact(?int $id = null): Url { + if ($id === null) { + return Url::fromPath('notifications/contact'); + } + return Url::fromPath('notifications/contact', ['id' => $id]); } @@ -46,8 +58,12 @@ public static function eventRules(): Url return Url::fromPath('notifications/event-rules'); } - public static function eventRule(int $id): Url + public static function eventRule(?int $id = null): Url { + if ($id === null) { + return Url::fromPath('notifications/event-rule'); + } + return Url::fromPath('notifications/event-rule', ['id' => $id]); } @@ -56,8 +72,12 @@ public static function schedules(): Url return Url::fromPath('notifications/schedules'); } - public static function schedule(int $id): Url + public static function schedule(?int $id = null): Url { + if ($id === null) { + return Url::fromPath('notifications/schedule'); + } + return Url::fromPath('notifications/schedule', ['id' => $id]); } @@ -86,8 +106,12 @@ public static function contactGroupsSuggestMember(): Url return Url::fromPath('notifications/contact-groups/suggest-member'); } - public static function contactGroup(int $id): Url + public static function contactGroup(?int $id = null): Url { + if ($id === null) { + return Url::fromPath('notifications/contact-group'); + } + return Url::fromPath('notifications/contact-group', ['id' => $id]); } diff --git a/library/Notifications/Widget/ItemList/ContactGroupList.php b/library/Notifications/Widget/ItemList/ContactGroupList.php index 99fc351ee..a7c23aa80 100644 --- a/library/Notifications/Widget/ItemList/ContactGroupList.php +++ b/library/Notifications/Widget/ItemList/ContactGroupList.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Notifications\Widget\ItemList; +use Icinga\Module\Notifications\Common\Links; use ipl\Web\Common\BaseItemList; class ContactGroupList extends BaseItemList @@ -14,4 +15,10 @@ protected function getItemClass(): string { return ContactGroupListItem::class; } + + protected function init(): void + { + $this->getAttributes() + ->set('data-icinga-detail-url', (string) Links::contactGroup()); + } } diff --git a/library/Notifications/Widget/ItemList/ContactGroupListItem.php b/library/Notifications/Widget/ItemList/ContactGroupListItem.php index e792e0666..b408549ae 100644 --- a/library/Notifications/Widget/ItemList/ContactGroupListItem.php +++ b/library/Notifications/Widget/ItemList/ContactGroupListItem.php @@ -10,7 +10,9 @@ use ipl\Html\BaseHtmlElement; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Stdlib\Filter; use ipl\Web\Common\BaseListItem; +use ipl\Web\Filter\QueryString; use ipl\Web\Widget\Link; class ContactGroupListItem extends BaseListItem @@ -23,7 +25,9 @@ class ContactGroupListItem extends BaseListItem protected function init(): void { - $this->getAttributes()->set('data-action-item', true); + $this->getAttributes() + ->set('data-action-item', true) + ->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id))); } protected function assembleVisual(BaseHtmlElement $visual): void diff --git a/library/Notifications/Widget/ItemList/ContactList.php b/library/Notifications/Widget/ItemList/ContactList.php index 7735a1154..aafa1b3fd 100644 --- a/library/Notifications/Widget/ItemList/ContactList.php +++ b/library/Notifications/Widget/ItemList/ContactList.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Notifications\Widget\ItemList; +use Icinga\Module\Notifications\Common\Links; use ipl\Web\Common\BaseItemList; class ContactList extends BaseItemList @@ -14,4 +15,10 @@ protected function getItemClass(): string { return ContactListItem::class; } + + protected function init(): void + { + $this->getAttributes() + ->set('data-icinga-detail-url', (string) Links::contact()); + } } diff --git a/library/Notifications/Widget/ItemList/ContactListItem.php b/library/Notifications/Widget/ItemList/ContactListItem.php index e80d6026d..fab2ff9f1 100644 --- a/library/Notifications/Widget/ItemList/ContactListItem.php +++ b/library/Notifications/Widget/ItemList/ContactListItem.php @@ -9,7 +9,9 @@ use ipl\Html\BaseHtmlElement; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Stdlib\Filter; use ipl\Web\Common\BaseListItem; +use ipl\Web\Filter\QueryString; use ipl\Web\Url; use ipl\Web\Widget\Icon; use ipl\Web\Widget\Link; @@ -28,7 +30,8 @@ class ContactListItem extends BaseListItem protected function init(): void { $this->getAttributes() - ->set('data-action-item', true); + ->set('data-action-item', true) + ->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id))); } protected function assembleVisual(BaseHtmlElement $visual): void diff --git a/library/Notifications/Widget/ItemList/EventList.php b/library/Notifications/Widget/ItemList/EventList.php index 96d3b9a6c..551cd5002 100644 --- a/library/Notifications/Widget/ItemList/EventList.php +++ b/library/Notifications/Widget/ItemList/EventList.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Notifications\Widget\ItemList; +use Icinga\Module\Notifications\Common\Links; use Icinga\Module\Notifications\Common\LoadMore; use Icinga\Module\Notifications\Common\NoSubjectLink; use Icinga\Module\Notifications\Hook\ObjectsRendererHook; @@ -37,6 +38,9 @@ protected function init(): void $this->on(self::ON_ASSEMBLED, function () { ObjectsRendererHook::load(); }); + + $this->getAttributes() + ->set('data-icinga-detail-url', (string) Links::event()); } protected function getItemClass(): string diff --git a/library/Notifications/Widget/ItemList/EventListItem.php b/library/Notifications/Widget/ItemList/EventListItem.php index 2da23be77..d5faa3a66 100644 --- a/library/Notifications/Widget/ItemList/EventListItem.php +++ b/library/Notifications/Widget/ItemList/EventListItem.php @@ -15,8 +15,10 @@ use ipl\Html\BaseHtmlElement; use ipl\Html\Html; use ipl\Html\HtmlElement; +use ipl\Stdlib\Filter; use ipl\Stdlib\Str; use ipl\Web\Common\BaseListItem; +use ipl\Web\Filter\QueryString; use ipl\Web\Widget\Icon; use ipl\Web\Widget\Link; use ipl\Web\Widget\TimeAgo; @@ -47,6 +49,9 @@ protected function init(): void $this->getAttributes() ->set('data-action-item', true); } + + $this->getAttributes() + ->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id))); } protected function assembleVisual(BaseHtmlElement $visual): void diff --git a/library/Notifications/Widget/ItemList/EventRuleList.php b/library/Notifications/Widget/ItemList/EventRuleList.php index 533448fcf..ce8b6711d 100644 --- a/library/Notifications/Widget/ItemList/EventRuleList.php +++ b/library/Notifications/Widget/ItemList/EventRuleList.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Notifications\Widget\ItemList; +use Icinga\Module\Notifications\Common\Links; use Icinga\Module\Notifications\Common\LoadMore; use ipl\Web\Common\BaseItemList; @@ -17,4 +18,10 @@ protected function getItemClass(): string { return EventRuleListItem::class; } + + protected function init(): void + { + $this->getAttributes() + ->set('data-icinga-detail-url', (string) Links::eventRule()); + } } diff --git a/library/Notifications/Widget/ItemList/EventRuleListItem.php b/library/Notifications/Widget/ItemList/EventRuleListItem.php index cb4127a04..371af46e5 100644 --- a/library/Notifications/Widget/ItemList/EventRuleListItem.php +++ b/library/Notifications/Widget/ItemList/EventRuleListItem.php @@ -10,7 +10,9 @@ use Icinga\Module\Notifications\Widget\RuleEscalationRecipientBadge; use ipl\Html\BaseHtmlElement; use ipl\Html\Html; +use ipl\Stdlib\Filter; use ipl\Web\Common\BaseListItem; +use ipl\Web\Filter\QueryString; use ipl\Web\Widget\Icon; use ipl\Web\Widget\Link; @@ -28,7 +30,8 @@ class EventRuleListItem extends BaseListItem protected function init(): void { $this->getAttributes() - ->set('data-action-item', true); + ->set('data-action-item', true) + ->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id))); } protected function assembleVisual(BaseHtmlElement $visual): void diff --git a/library/Notifications/Widget/ItemList/IncidentList.php b/library/Notifications/Widget/ItemList/IncidentList.php index ba66e37a3..9091038a5 100644 --- a/library/Notifications/Widget/ItemList/IncidentList.php +++ b/library/Notifications/Widget/ItemList/IncidentList.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Notifications\Widget\ItemList; +use Icinga\Module\Notifications\Common\Links; use Icinga\Module\Notifications\Hook\ObjectsRendererHook; use Icinga\Module\Notifications\Model\Incident; use ipl\Web\Common\BaseItemList; @@ -24,6 +25,9 @@ protected function init(): void $this->on(self::ON_ASSEMBLED, function () { ObjectsRendererHook::load(); }); + + $this->getAttributes() + ->set('data-icinga-detail-url', (string) Links::incident()); } protected function getItemClass(): string diff --git a/library/Notifications/Widget/ItemList/IncidentListItem.php b/library/Notifications/Widget/ItemList/IncidentListItem.php index acf1bc9a4..d31d1a620 100644 --- a/library/Notifications/Widget/ItemList/IncidentListItem.php +++ b/library/Notifications/Widget/ItemList/IncidentListItem.php @@ -16,7 +16,9 @@ use ipl\Html\Html; use ipl\Html\HtmlElement; use ipl\I18n\Translation; +use ipl\Stdlib\Filter; use ipl\Web\Common\BaseListItem; +use ipl\Web\Filter\QueryString; use ipl\Web\Widget\Icon; use ipl\Web\Widget\Link; use ipl\Web\Widget\TimeAgo; @@ -41,6 +43,9 @@ protected function init(): void $this->getAttributes() ->set('data-action-item', true); } + + $this->getAttributes() + ->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id))); } protected function assembleVisual(BaseHtmlElement $visual): void diff --git a/library/Notifications/Widget/ItemList/ScheduleList.php b/library/Notifications/Widget/ItemList/ScheduleList.php index 983143c8a..db0141650 100644 --- a/library/Notifications/Widget/ItemList/ScheduleList.php +++ b/library/Notifications/Widget/ItemList/ScheduleList.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Notifications\Widget\ItemList; +use Icinga\Module\Notifications\Common\Links; use ipl\Web\Common\BaseItemList; class ScheduleList extends BaseItemList @@ -14,4 +15,10 @@ protected function getItemClass(): string { return ScheduleListItem::class; } + + protected function init(): void + { + $this->getAttributes() + ->set('data-icinga-detail-url', (string) Links::schedule()); + } } diff --git a/library/Notifications/Widget/ItemList/ScheduleListItem.php b/library/Notifications/Widget/ItemList/ScheduleListItem.php index 24e9f9d80..8a0156da2 100644 --- a/library/Notifications/Widget/ItemList/ScheduleListItem.php +++ b/library/Notifications/Widget/ItemList/ScheduleListItem.php @@ -7,7 +7,9 @@ use Icinga\Module\Notifications\Common\Links; use Icinga\Module\Notifications\Model\Schedule; use ipl\Html\BaseHtmlElement; +use ipl\Stdlib\Filter; use ipl\Web\Common\BaseListItem; +use ipl\Web\Filter\QueryString; use ipl\Web\Widget\Link; /** @@ -24,7 +26,8 @@ class ScheduleListItem extends BaseListItem protected function init(): void { $this->getAttributes() - ->set('data-action-item', true); + ->set('data-action-item', true) + ->set('data-icinga-detail-filter', QueryString::render(Filter::equal('id', $this->item->id))); } protected function assembleTitle(BaseHtmlElement $title): void