[icinga-checkins] icinga.org: icingaweb2-module-director/master: object/render: allow to render resolved object

git at icinga.org git at icinga.org
Sun Feb 28 17:12:40 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: 466b32ba2e85cb160c207cb0cab51ad024e5ffea
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=466b32ba2e85cb160c207cb0cab51ad024e5ffea

Author: Thomas Gelf <thomas at gelf.net>
Date:   Sun Feb 28 14:15:56 2016 +0100

object/render: allow to render resolved object

---

 application/views/scripts/object/show.phtml        |    3 ++
 .../Director/Web/Controller/ObjectController.php   |   32 ++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/application/views/scripts/object/show.phtml b/application/views/scripts/object/show.phtml
index 6611dd8..3a6e889 100644
--- a/application/views/scripts/object/show.phtml
+++ b/application/views/scripts/object/show.phtml
@@ -1,6 +1,9 @@
 <div class="controls">
 <?= $this->tabs ?>
 <h1><?= $this->escape($this->title) ?></h1>
+<span>
+<?= $this->actionLinks ?>
+</span>
 </div>
 
 <div class="content">
diff --git a/library/Director/Web/Controller/ObjectController.php b/library/Director/Web/Controller/ObjectController.php
index 745058d..da77880 100644
--- a/library/Director/Web/Controller/ObjectController.php
+++ b/library/Director/Web/Controller/ObjectController.php
@@ -75,10 +75,38 @@ abstract class ObjectController extends ActionController
     {
         $type = $this->getType();
         $this->getTabs()->activate('render');
-        $this->view->object = $this->object;
+        $object = $this->object;
+
+        if ($this->params->shift('resolved')) {
+            $this->view->object = $object::fromPlainObject(
+                $object->toPlainObject(true),
+                $object->getConnection()
+            );
+
+            if ($object->imports()->count() > 0) {
+                $this->view->actionLinks = $this->view->qlink(
+                    $this->translate('Show normal'),
+                    $this->getRequest()->getUrl()->without('resolved'),
+                    null,
+                    array('class' => 'icon-resize-small state-warning')
+                );
+            }
+        } else {
+            $this->view->object = $object;
+
+            if ($object->imports()->count() > 0) {
+                $this->view->actionLinks = $this->view->qlink(
+                    $this->translate('Show resolved'),
+                    $this->getRequest()->getUrl()->with('resolved', true),
+                    null,
+                    array('class' => 'icon-resize-full')
+                );
+            }
+        }
+
         $this->view->title = sprintf(
             $this->translate('Config preview: %s'),
-            $this->object->object_name
+            $object->object_name
         );
         $this->render('object/show', null, true);
     }



More information about the icinga-checkins mailing list