summaryrefslogtreecommitdiffstats
path: root/application/controllers/CommentController.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:44:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-13 11:44:46 +0000
commitb18bc644404e02b57635bfcc8258e85abb141146 (patch)
tree686512eacb2dba0055277ef7ec2f28695b3418ea /application/controllers/CommentController.php
parentInitial commit. (diff)
downloadicingadb-web-b18bc644404e02b57635bfcc8258e85abb141146.tar.xz
icingadb-web-b18bc644404e02b57635bfcc8258e85abb141146.zip
Adding upstream version 1.1.1.upstream/1.1.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers/CommentController.php')
-rw-r--r--application/controllers/CommentController.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/application/controllers/CommentController.php b/application/controllers/CommentController.php
new file mode 100644
index 0000000..b184d6b
--- /dev/null
+++ b/application/controllers/CommentController.php
@@ -0,0 +1,72 @@
+<?php
+
+/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
+
+namespace Icinga\Module\Icingadb\Controllers;
+
+use Icinga\Exception\NotFoundError;
+use Icinga\Module\Icingadb\Common\CommandActions;
+use Icinga\Module\Icingadb\Common\Links;
+use Icinga\Module\Icingadb\Model\Comment;
+use Icinga\Module\Icingadb\Web\Controller;
+use Icinga\Module\Icingadb\Widget\Detail\CommentDetail;
+use Icinga\Module\Icingadb\Widget\ItemList\CommentList;
+use ipl\Stdlib\Filter;
+use ipl\Web\Url;
+
+class CommentController extends Controller
+{
+ use CommandActions;
+
+ /** @var Comment The comment object */
+ protected $comment;
+
+ public function init()
+ {
+ $this->addTitleTab(t('Comment'));
+
+ $name = $this->params->getRequired('name');
+
+ $query = Comment::on($this->getDb())->with([
+ 'host',
+ 'host.state',
+ 'service',
+ 'service.state',
+ 'service.host',
+ 'service.host.state'
+ ]);
+ $query->filter(Filter::equal('comment.name', $name));
+
+ $this->applyRestrictions($query);
+
+ $comment = $query->first();
+ if ($comment === null) {
+ throw new NotFoundError(t('Comment not found'));
+ }
+
+ $this->comment = $comment;
+ }
+
+ public function indexAction()
+ {
+ $this->addControl((new CommentList([$this->comment]))
+ ->setViewMode('minimal')
+ ->setDetailActionsDisabled()
+ ->setCaptionDisabled()
+ ->setNoSubjectLink());
+
+ $this->addContent((new CommentDetail($this->comment))->setTicketLinkEnabled());
+
+ $this->setAutorefreshInterval(10);
+ }
+
+ protected function fetchCommandTargets(): array
+ {
+ return [$this->comment];
+ }
+
+ protected function getCommandTargetsUrl(): Url
+ {
+ return Links::comment($this->comment);
+ }
+}