summaryrefslogtreecommitdiffstats
path: root/application/controllers/EventController.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:36:40 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:36:40 +0000
commita0901c4b7f2db488cb4fb3be2dd921a0308f4659 (patch)
treefafb393cf330a60df129ff10d0059eb7b14052a7 /application/controllers/EventController.php
parentInitial commit. (diff)
downloadicingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.tar.xz
icingadb-web-a0901c4b7f2db488cb4fb3be2dd921a0308f4659.zip
Adding upstream version 1.0.2.upstream/1.0.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers/EventController.php')
-rw-r--r--application/controllers/EventController.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/application/controllers/EventController.php b/application/controllers/EventController.php
new file mode 100644
index 0000000..7108606
--- /dev/null
+++ b/application/controllers/EventController.php
@@ -0,0 +1,71 @@
+<?php
+
+/* Icinga DB Web | (c) 2021 Icinga GmbH | GPLv2 */
+
+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 ipl\Stdlib\Filter;
+
+class EventController extends Controller
+{
+ /** @var History */
+ protected $event;
+
+ public function init()
+ {
+ $this->addTitleTab(t('Event'));
+
+ $id = $this->params->getRequired('id');
+
+ $query = History::on($this->getDb())
+ ->with([
+ 'host',
+ 'host.state',
+ 'service',
+ 'service.state',
+ 'comment',
+ 'downtime',
+ 'downtime.parent',
+ 'downtime.parent.host',
+ 'downtime.parent.host.state',
+ 'downtime.parent.service',
+ 'downtime.parent.service.state',
+ 'downtime.triggered_by',
+ 'downtime.triggered_by.host',
+ 'downtime.triggered_by.host.state',
+ 'downtime.triggered_by.service',
+ 'downtime.triggered_by.service.state',
+ 'flapping',
+ 'notification',
+ 'acknowledgement',
+ 'state'
+ ])
+ ->filter(Filter::equal('id', hex2bin($id)));
+
+ $this->applyRestrictions($query);
+
+ $event = $query->first();
+ if ($event === null) {
+ $this->httpNotFound(t('Event not found'));
+ }
+
+ $this->event = $event;
+ }
+
+ public function indexAction()
+ {
+ $this->addControl((new HistoryList(new ResultSet(new ArrayObject([$this->event]))))
+ ->setViewMode('minimal')
+ ->setPageSize(1)
+ ->setCaptionDisabled()
+ ->setNoSubjectLink()
+ ->setDetailActionsDisabled());
+ $this->addContent((new EventDetail($this->event))->setTicketLinkEnabled());
+ }
+}