From f66ab8dae2f3d0418759f81a3a64dc9517a62449 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:17:31 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- application/controllers/DashboardController.php | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 application/controllers/DashboardController.php (limited to 'application/controllers/DashboardController.php') diff --git a/application/controllers/DashboardController.php b/application/controllers/DashboardController.php new file mode 100644 index 0000000..95c1cd0 --- /dev/null +++ b/application/controllers/DashboardController.php @@ -0,0 +1,78 @@ +isMultiDbSetup()) { + $form = new DbSelectorForm( + $this->getResponse(), + $this->Window(), + $this->listAllowedDbResourceNames() + ); + $this->content()->add($form); + $form->handleRequest($this->getServerRequest()); + } + } + + public function indexAction() + { + if ($this->getRequest()->isGet()) { + $this->setAutorefreshInterval(10); + } + + $mainDashboards = [ + 'Objects', + 'Alerts', + 'Branches', + 'Automation', + 'Deployment', + 'Director', + 'Data', + ]; + $this->setTitle($this->translate('Icinga Director - Main Dashboard')); + $names = $this->params->getValues('name', $mainDashboards); + if (! $this->params->has('name')) { + $this->addDbSelection(); + } + if (count($names) === 1) { + $name = $names[0]; + $dashboard = Dashboard::loadByName($name, $this->db()); + $this->tabs($dashboard->getTabs())->activate($name); + } else { + $this->tabs(new MainTabs($this->Auth(), $this->getDbResourceName()))->activate('main'); + } + + $cntDashboards = 0; + foreach ($names as $name) { + if ($name instanceof Dashboard) { + $dashboard = $name; + } else { + $dashboard = Dashboard::loadByName($name, $this->db()); + } + if ($dashboard->isAvailable()) { + $cntDashboards++; + $this->content()->add($dashboard); + } + } + + if ($cntDashboards === 0) { + $msg = $this->translate( + 'No dashboard available, you might have not enough permissions' + ); + $this->content()->add($msg); + } + } +} -- cgit v1.2.3