[icinga-checkins] icinga.org: icingaweb2-module-director/master: show/activities: show diff also for create/delete

git at icinga.org git at icinga.org
Tue Nov 8 16:40:21 CET 2016


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

Author: Thomas Gelf <thomas at gelf.net>
Date:   Tue Nov  8 16:21:54 2016 +0100

show/activities: show diff also for create/delete

fixes #13077

---

 application/controllers/ShowController.php |   20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/application/controllers/ShowController.php b/application/controllers/ShowController.php
index 30ced66..624a5b2 100644
--- a/application/controllers/ShowController.php
+++ b/application/controllers/ShowController.php
@@ -97,7 +97,11 @@ class ShowController extends ActionController
 
         $oldConfig = $this->oldConfig($entry);
         $newConfig = $this->newConfig($entry);
+        $this->showConfigDiff($oldConfig, $newConfig);
+    }
 
+    protected function showConfigDiff(IcingaConfig $oldConfig, IcingaConfig $newConfig)
+    {
         $oldFilenames = $oldConfig->getFileNames();
         $newFilenames = $newConfig->getFileNames();
 
@@ -130,14 +134,14 @@ class ShowController extends ActionController
     {
         $this->view->title = sprintf('%s former config', $entry->object_name);
         $this->getTabs()->activate('old');
-        $this->showConfig($this->oldConfig($entry));
+        $this->showConfigDiff($this->oldConfig($entry), new IcingaConfig($this->db()));
     }
 
     protected function showNew($entry)
     {
         $this->view->title = sprintf('%s new config', $entry->object_name);
         $this->getTabs()->activate('new');
-        $this->showConfig($this->newConfig($entry));
+        $this->showConfigDiff(new IcingaConfig($this->db()), $this->newConfig($entry));
     }
 
     protected function oldObject($entry)
@@ -160,18 +164,6 @@ class ShowController extends ActionController
         );
     }
 
-    protected function showConfig(IcingaConfig $config)
-    {
-        $this->view->diffs = array();
-        foreach ($config->getFileNames() as $filename) {
-            $this->view->diffs[$filename] = sprintf(
-                '<pre>%s</pre>',
-                $this->view->escape($config->getFile($filename)->getContent())
-            );
-        }
-        return $this;
-    }
-
     protected function showInfo($entry)
     {
         $typeName = $this->translate(



More information about the icinga-checkins mailing list