[icinga-checkins] icinga.org: icingaweb2-module-director/feature/service-set-12891: IcingaServiceSetForm: prepare custom fields

git at icinga.org git at icinga.org
Wed Oct 26 01:12:35 CEST 2016


Module: icingaweb2-module-director
Branch: feature/service-set-12891
Commit: dedaea0319564243e5da17b355e0159aafe741da
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=dedaea0319564243e5da17b355e0159aafe741da

Author: Thomas Gelf <thomas at gelf.net>
Date:   Thu Oct 20 04:29:23 2016 +0000

IcingaServiceSetForm: prepare custom fields

---

 application/forms/IcingaServiceSetForm.php |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/application/forms/IcingaServiceSetForm.php b/application/forms/IcingaServiceSetForm.php
index a3cbc8c..efd9c1b 100644
--- a/application/forms/IcingaServiceSetForm.php
+++ b/application/forms/IcingaServiceSetForm.php
@@ -2,7 +2,8 @@
 
 namespace Icinga\Module\Director\Forms;
 
-use Icinga\Module\Director\Object\IcingaHost;
+use Icinga\Module\Director\Objects\IcingaHost;
+use Icinga\Module\Director\Objects\IcingaService;
 use Icinga\Module\Director\Web\Form\DirectorObjectForm;
 
 class IcingaServiceSetForm extends DirectorObjectForm
@@ -43,12 +44,26 @@ class IcingaServiceSetForm extends DirectorObjectForm
                 'rows'         => '5',
                 'multiOptions' => $this->enumServices(),
                 'required'     => true,
+                'class'        => 'autosubmit',
             ));
         } else {
             $this->addHidden('object_type', 'object');
             $this->addHidden('host_id', $this->host->id);
         }
 
+        $services = array();
+        foreach ($this->getSentOrObjectValue('service') as $name) {
+            $services[] = IcingaService::load(array(
+                'object_name' => $name,
+                'object_type' => 'template'
+            ), $this->db);
+        }
+
+        if ($this->assertResolvedImports()) {
+            $loader = $this->fieldLoader($this->object);
+            $loader->loadFieldsForMultipleObjects($services);
+        }
+
         $this->setButtons();
     }
 
@@ -63,7 +78,8 @@ class IcingaServiceSetForm extends DirectorObjectForm
         $db = $this->db->getDbAdapter();
         $query = $db->select()
             ->from('icinga_service', 'object_name')
-            ->where('object_type = ?', 'template');
+            ->where('object_type = ?', 'template')
+            ->order('object_name');
         $names = $db->fetchCol($query);
 
         return array_combine($names, $names);



More information about the icinga-checkins mailing list