From a0901c4b7f2db488cb4fb3be2dd921a0308f4659 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:36:40 +0200 Subject: Adding upstream version 1.0.2. Signed-off-by: Daniel Baumann --- application/controllers/DowntimeController.php | 84 ++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 application/controllers/DowntimeController.php (limited to 'application/controllers/DowntimeController.php') diff --git a/application/controllers/DowntimeController.php b/application/controllers/DowntimeController.php new file mode 100644 index 0000000..a0a7fa0 --- /dev/null +++ b/application/controllers/DowntimeController.php @@ -0,0 +1,84 @@ +addTitleTab(t('Downtime')); + + $name = $this->params->getRequired('name'); + + $query = Downtime::on($this->getDb())->with([ + 'host', + 'host.state', + 'service', + 'service.state', + 'service.host', + 'service.host.state', + 'parent', + 'parent.host', + 'parent.host.state', + 'parent.service', + 'parent.service.state', + 'triggered_by', + 'triggered_by.host', + 'triggered_by.host.state', + 'triggered_by.service', + 'triggered_by.service.state' + ]); + $query->filter(Filter::equal('downtime.name', $name)); + + $this->applyRestrictions($query); + + $downtime = $query->first(); + if ($downtime === null) { + throw new NotFoundError(t('Downtime not found')); + } + + $this->downtime = $downtime; + } + + public function indexAction() + { + $detail = new DowntimeDetail($this->downtime); + + $this->addControl((new DowntimeList([$this->downtime])) + ->setViewMode('minimal') + ->setDetailActionsDisabled() + ->setCaptionDisabled() + ->setNoSubjectLink()); + + $this->addContent($detail); + + $this->setAutorefreshInterval(10); + } + + protected function fetchCommandTargets(): array + { + return [$this->downtime]; + } + + protected function getCommandTargetsUrl(): Url + { + return Links::downtime($this->downtime); + } +} -- cgit v1.2.3