summaryrefslogtreecommitdiffstats
path: root/application/controllers/ShowController.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:30:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 13:30:50 +0000
commitd5f222b7ebf4d2c2d47d20a25adcc9aadf67fbd5 (patch)
treeda9b32212bf99154450a7668f61a75f65617a9fa /application/controllers/ShowController.php
parentInitial commit. (diff)
downloadicingaweb2-module-toplevelview-upstream.tar.xz
icingaweb2-module-toplevelview-upstream.zip
Adding upstream version 0.3.3.upstream/0.3.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/controllers/ShowController.php')
-rw-r--r--application/controllers/ShowController.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/application/controllers/ShowController.php b/application/controllers/ShowController.php
new file mode 100644
index 0000000..d0560f2
--- /dev/null
+++ b/application/controllers/ShowController.php
@@ -0,0 +1,93 @@
+<?php
+/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */
+
+namespace Icinga\Module\Toplevelview\Controllers;
+
+use Icinga\Module\Toplevelview\ViewConfig;
+use Icinga\Module\Toplevelview\Web\Controller;
+use Icinga\Web\Url;
+use Icinga\Web\Widget\Tab;
+
+class ShowController extends Controller
+{
+ public function init()
+ {
+ $tabs = $this->getTabs();
+
+ $tiles = Url::fromPath('toplevelview/show', array(
+ 'name' => $this->params->getRequired('name')
+ ));
+
+ $tabs->add(
+ 'index',
+ array(
+ 'title' => $this->translate('Tiles'),
+ 'url' => $tiles
+ )
+ );
+
+ if (($id = $this->getParam('id')) !== null) {
+ $tabs->add(
+ 'tree',
+ array(
+ 'title' => $this->translate('Tree'),
+ 'url' => Url::fromPath('toplevelview/show/tree', array(
+ 'name' => $this->params->getRequired('name'),
+ 'id' => $id
+ ))
+ )
+ );
+ }
+
+ $fullscreen = new Tab(array(
+ 'title' => $this->translate('Go Fullscreen'),
+ 'icon' => 'dashboard',
+ 'url' => ((string) $tiles) . '&view=compact&showFullscreen'
+ ));
+ $fullscreen->setTargetBlank();
+ $tabs->addAsDropdown('fullscreen', $fullscreen);
+
+ $action = $this->getRequest()->getActionName();
+ if ($tab = $tabs->get($action)) {
+ $tab->setActive();
+ }
+ }
+
+ public function indexAction()
+ {
+ $this->view->name = $name = $this->params->getRequired('name');
+ $this->view->view = $view = ViewConfig::loadByName($name);
+ $tree = $view->getTree();
+ $tree->setBackend($this->monitoringBackend());
+
+ if (($lifetime = $this->getParam('cache')) !== null) {
+ $tree->setCacheLifetime($lifetime);
+ }
+
+ $this->setAutorefreshInterval(30);
+ }
+
+ public function treeAction()
+ {
+ $this->view->name = $name = $this->params->getRequired('name');
+ $this->view->view = $view = ViewConfig::loadByName($name);
+ $tree = $view->getTree();
+ $this->view->node = $tree->getById($this->params->getRequired('id'));
+ $tree->setBackend($this->monitoringBackend());
+
+ if (($lifetime = $this->getParam('cache')) !== null) {
+ $tree->setCacheLifetime($lifetime);
+ }
+
+ $this->setAutorefreshInterval(30);
+ }
+
+ public function sourceAction()
+ {
+ $this->view->name = $name = $this->params->getRequired('name');
+ $this->view->view = $view = ViewConfig::loadByName($name);
+
+ $this->view->text = $view->getText();
+ $this->setViewScript('index', 'text');
+ }
+}