[icinga-checkins] icinga.org: icinga-web/master: Fixes missing filters, hostgroup doubles, cleanup

git at icinga.org git at icinga.org
Fri Oct 19 12:19:58 CEST 2012


Module: icinga-web
Branch: master
Commit: 04e5b4474131914e3b9b02b0b9f47df24600894e
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=04e5b4474131914e3b9b02b0b9f47df24600894e

Author: Marius Hein <marius.hein at netways.de>
Date:   Thu Aug 16 12:32:02 2012 +0200

Fixes missing filters, hostgroup doubles, cleanup

---

 app/modules/Api/config/views/host.xml              |   23 +++++++++++++-------
 app/modules/AppKit/lib/database/models/NsmUser.php |   17 ++++++++------
 .../Cronks/data/xml/grid/icinga-host-template.xml  |    3 --
 .../Cronks/lib/js/Cronk/grid/MetaGridPanel.js      |    8 +++---
 .../CronkGridTemplateWorkerFactory.class.php       |   12 +++++-----
 .../template/CronkGridTemplateXmlParser.class.php  |    9 +++++++
 .../DQLCronkTemplateWorker.class.php               |    2 +-
 pub/index.php                                      |    4 ---
 8 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/app/modules/Api/config/views/host.xml b/app/modules/Api/config/views/host.xml
index a414d5a..7131ab6 100644
--- a/app/modules/Api/config/views/host.xml
+++ b/app/modules/Api/config/views/host.xml
@@ -29,15 +29,13 @@
                 hs.notifications_enabled as notifications_enabled,
                 hs.problem_has_been_acknowledged as problem_acknowledged,
                 hs.scheduled_downtime_depth as scheduled_downtime_depth,
-                hs.has_been_checked as host_has_been_checked,
-                ohg.object_id as HOSTGROUP_OBJECT_ID
+                hs.has_been_checked as host_has_been_checked
             FROM IcingaHosts h
-            INNER JOIN h.instance i
-            INNER JOIN h.status hs
-            INNER JOIN h.object oh
-            INNER JOIN h.hostgroups hg
-            INNER JOIN hg.object ohg
-            INNER JOIN i.programstatus as ps
+            LEFT JOIN h.instance i
+            LEFT JOIN h.status hs
+            LEFT JOIN h.object oh
+            LEFT JOIN i.programstatus as ps
+            
             WHERE h.config_type = '${retained_flag}'
             ]]>
             </query>
@@ -61,6 +59,9 @@
             </credential>
 
             <credential name="IcingaHostgroup" type="dql">
+                <join>h.hostgroups hg</join>
+                <join>hg.object ohg</join>
+
                 <andwhere>
                     <![CDATA[
                         ohg.name1 IN (${credential_value})
@@ -104,6 +105,12 @@
                 <join>hg.object ohg</join>
                 <select>ohg.name1 AS hostgroup_name</select>
             </filter>
+            
+            <filter name="hostgroup_object_id" type="dql">
+                <join>h.hostgroups hg</join>
+                <join>hg.object ohg</join>
+                <select>ohg.object_id AS hostgroup_object_id</select>
+            </filter>
 
             <filter name="host_is_pending" type="dql">
                 <resolve>((hs.has_been_checked-1)*-1)</resolve>
diff --git a/app/modules/AppKit/lib/database/models/NsmUser.php b/app/modules/AppKit/lib/database/models/NsmUser.php
index 70594bf..0d51bb7 100644
--- a/app/modules/AppKit/lib/database/models/NsmUser.php
+++ b/app/modules/AppKit/lib/database/models/NsmUser.php
@@ -47,6 +47,8 @@ class NsmUser extends BaseNsmUser {
      */
     private $principals_list    = null;
     
+    private $target_list        = null;
+    
     private $context = null;
     
     private $storage = null;
@@ -488,14 +490,15 @@ class NsmUser extends BaseNsmUser {
      * @return boolean
      */
     public function hasTarget($name) {
-        $q = $this->getTargetsQuery();
-        $q->andWhere('t.target_name=?', array($name));
-
-        if ($q->execute()->count() > 0) {
-            return true;
+        
+        if ($this->target_list === null) {
+            $res = $this->getTargetsQuery()->execute();
+            $this->target_list = array();
+            foreach ($res as $target) {
+                $this->target_list[$target->target_name] = true;
+            }
         }
-
-        return false;
+        return isset($this->target_list[$name]);
     }
 
     /**
diff --git a/app/modules/Cronks/data/xml/grid/icinga-host-template.xml b/app/modules/Cronks/data/xml/grid/icinga-host-template.xml
index c4edd99..178cf54 100644
--- a/app/modules/Cronks/data/xml/grid/icinga-host-template.xml
+++ b/app/modules/Cronks/data/xml/grid/icinga-host-template.xml
@@ -555,9 +555,6 @@
     <datasource>
         <parameter name="target">TARGET_HOST</parameter>
         <parameter name="countmode">field</parameter>
-        <parameter name="additional_fields">
-            <parameter name="hostgroup_object_id">HOSTGROUP_OBJECT_ID</parameter>
-        </parameter>
     </datasource>
     
     <!-- 
diff --git a/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js b/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js
index 51863d0..7bbcfba 100644
--- a/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js
+++ b/app/modules/Cronks/lib/js/Cronk/grid/MetaGridPanel.js
@@ -394,7 +394,7 @@ Ext.ns("Cronk.grid");
                     sortable: (field.order.enabled ? true : false),
                     hidden: (field.display.visible ? false : true)
                 });
-                AppKit.log(val, field.display.visible);
+
                 if (field.display.width) {
                     columns[i - 1].width = field.display.width;
                 }
@@ -616,8 +616,8 @@ Ext.ns("Cronk.grid");
                     filters.push(filter);
                 }
             });
-
-            Ext.iterate(this.getOption("template.option.filter", []), function (v, k) {
+            AppKit.log(this.getOption("template.option.filter", []));
+            Ext.iterate(this.getOption("template.option.filter", []), function (k, v) {
                 if (v.enabled === true && v.type === 'extjs') {
                     var f = v;
                     f.name = (f.name ? f.name : k);
@@ -626,7 +626,7 @@ Ext.ns("Cronk.grid");
                     filters.push(f);
                 }
             });
-
+            
             if (filters.length) {
                 var fw = new Cronk.grid.filter.Window();
 
diff --git a/app/modules/Cronks/lib/template/CronkGridTemplateWorkerFactory.class.php b/app/modules/Cronks/lib/template/CronkGridTemplateWorkerFactory.class.php
index b44785b..fed46ae 100644
--- a/app/modules/Cronks/lib/template/CronkGridTemplateWorkerFactory.class.php
+++ b/app/modules/Cronks/lib/template/CronkGridTemplateWorkerFactory.class.php
@@ -32,14 +32,14 @@
 class CronkGridTemplateWorkerFactory {
 
     static public function createWorker(CronkGridTemplateXmlParser $template, AgaviContext $context, $connection = "icinga") {
-        $sections = array_flip($template->getSections());
         
-        if(isset($sections["type"]) && class_exists($template->getSection("type")."CronkTemplateWorker")) {
-            $class = $template->getSection("type")."CronkTemplateWorker";
-            return new $class($template,$context, $connection);
+        if ($template->hasSection('type')) {
+            $className = $template->getSection('type'). 'CronkTemplateWorker';
+            if (class_exists($className)) {
+                return new $className($template,$context, $connection);
+            }
         }
-        return new GenericCronkTemplateWorker($template, $context);
-
         
+        return new GenericCronkTemplateWorker($template, $context);
     }
 }
diff --git a/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php b/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php
index 36a7bc0..5acf9c0 100644
--- a/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php
+++ b/app/modules/Cronks/lib/template/CronkGridTemplateXmlParser.class.php
@@ -175,6 +175,15 @@ class CronkGridTemplateXmlParser {
     public function getSections() {
         return array_keys($this->data);
     }
+    
+    /**
+     * Retun true if a section exists
+     * @param String $section
+     * @return Boolean
+     */
+    public function hasSection($section) {
+        return isset($this->data[$section]);
+    }
 
     /**
      * Returns a parameter object from section
diff --git a/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php b/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
index 4e16b2b..af93135 100644
--- a/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
+++ b/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
@@ -52,7 +52,7 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
         $this->connection = $connection;
         $view = $this->readDataSourceDefinition();
         $source = $template->getSection("datasource");
-
+        
         $this->parser = $context->getModel("Views.ApiDQLView","Api",array(
             "view" => $view,
             "parameters" => isset($source["parameters"]) ? $source["parameters"] : array(),
diff --git a/pub/index.php b/pub/index.php
index 73218f3..b8d7904 100755
--- a/pub/index.php
+++ b/pub/index.php
@@ -48,8 +48,4 @@ AgaviConfig::set('core.context_implementation', 'AppKitAgaviContext');
 
 AgaviContext::getInstance('web')->getController()->dispatch();
 
-// AppKitEventDispatcher::getInstance()->triggerSimpleEvent('agavi.afterdispatch', 'Agavi stoped, response is served');
-
 exit (0);
-
-?>





More information about the icinga-checkins mailing list