[icinga-checkins] icinga.org: icinga-web/jmosshammer/multiconnection: * Multi connection parameters, fixed sorting in services for hosts causing wrong order

git at icinga.org git at icinga.org
Wed Apr 11 14:25:32 CEST 2012


Module: icinga-web
Branch: jmosshammer/multiconnection
Commit: d28b086aed3d4f33e1bbde8e4a330286037917dc
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=d28b086aed3d4f33e1bbde8e4a330286037917dc

Author: Jannis Mosshammer <jannis.mosshammer at netways.de>
Date:   Wed Apr 11 14:22:12 2012 +0200

* Multi connection parameters, fixed sorting in services for hosts causing wrong order

---

 app/config/routing.xml                             |    2 +
 .../listeners/IcingaPendingStateListener.class.php |   30 --------------------
 .../Cronks/data/xml/grid/icinga-host-template.xml  |    1 +
 .../lib/js/grid/renderer/IcingaColumnRenderer.js   |    2 +
 .../DQLCronkTemplateWorker.class.php               |    9 +++++-
 app/modules/Cronks/validate/System/ViewProc.xml    |    8 +++++
 .../views/System/ViewProcSuccessView.class.php     |    4 ++
 7 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/app/config/routing.xml b/app/config/routing.xml
index cfa0a35..294cd79 100644
--- a/app/config/routing.xml
+++ b/app/config/routing.xml
@@ -82,6 +82,8 @@
                         pattern="limit[({limit_start:\d*};)?(limit:\d*)]" />
                     <route name=".countcolumn" stop="false"
                         pattern="countColumn=(countColumn:\w*)" />
+                    <route name=".connection" stop="false"
+                        pattern="connection=(connection:\w*)" />
                     <route name=".withSLA" stop="false" pattern="withSLA=(withSLA:\d)" />
                     <route name=".withMeta" stop="false" pattern="withMeta=(withMeta:\d)" />
                     <route name=".output" stop="true" pattern="(output:json|xml|soap|rest)$"
diff --git a/app/modules/Api/lib/database/listeners/IcingaPendingStateListener.class.php b/app/modules/Api/lib/database/listeners/IcingaPendingStateListener.class.php
deleted file mode 100644
index fd43904..0000000
--- a/app/modules/Api/lib/database/listeners/IcingaPendingStateListener.class.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/**
- * Listeners that automatically updates objects with state (like hosts, services)
- * to respect pending states
- *
- * @author jmosshammer
- */
-class IcingaPendingStateListener extends Doctrine_Record_Listener {
-    public function preHydrate(Doctrine_Event $event) {
-
-        $objects = $event->data;
-        echo "!";
-        print_r($objects);
-    }
-    public function postHydrate(Doctrine_Event $event) {
-
-        $objects = $event->data;
-        echo "!";
-        print_r($objects);
-    }    
-    public function postDqlSelect(Doctrine_Event $event) {
-        
-        $objects = $event->data;
-        echo "!";
-        print_r($objects);
-    }
-}
-
-?>
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 99267d3..171d086 100644
--- a/app/modules/Cronks/data/xml/grid/icinga-host-template.xml
+++ b/app/modules/Cronks/data/xml/grid/icinga-host-template.xml
@@ -487,6 +487,7 @@
                             <parameter name="filterMap">
                                 <parameter name="host_object_id">host_object_id</parameter>
                             </parameter>
+                            <parameter name="additonalSort">service_name</parameter>
                             <parameter name="labelField">host_name</parameter>
                         </parameter>
                     </parameter>
diff --git a/app/modules/Cronks/lib/js/grid/renderer/IcingaColumnRenderer.js b/app/modules/Cronks/lib/js/grid/renderer/IcingaColumnRenderer.js
index fa358da..e7bce1e 100644
--- a/app/modules/Cronks/lib/js/grid/renderer/IcingaColumnRenderer.js
+++ b/app/modules/Cronks/lib/js/grid/renderer/IcingaColumnRenderer.js
@@ -36,6 +36,8 @@ Cronk.grid.IcingaColumnRenderer = {
                     filter["f[" + cfg.targetField + "-value]"] = record.data[ cfg.sourceField ];
                     filter["f[" + cfg.targetField + "-operator]"] = 50;
                 }
+                if(cfg.additionalSort)
+                    filter["additional_sort_field"] = cfg.additionalSort;
                 filter["connection"] = grid.selectedConnection;
                 Cronk.util.InterGridUtil.gridFilterLink(cronk, filter);
             }
diff --git a/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php b/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
index e11b0d9..9518419 100644
--- a/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
+++ b/app/modules/Cronks/lib/template/TemplateWorker/DQLCronkTemplateWorker.class.php
@@ -15,6 +15,8 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
     private $user;
     private $parser;
     private $resultMap = array();
+    private $connection;
+
     /**
      *
      * @var IcingaDoctrine_Query
@@ -25,8 +27,10 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
         $this->setTemplate($template);
         $this->setContext($context);
         $this->user = $context->getUser()->getNsmUser();
+        $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(),
@@ -119,6 +123,9 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
         $ds = $this->template->getSection("datasource");
         if(!isset($ds["countmode"]) || in_array($ds["countmode"],array("false","none","null")))
             return;
+        if($this->connection != "icinga")
+            $this->getContext()->getModel("DBALMetaManager","Api")
+                ->switchIcingaDatabase($this->connection);
         return $this->query->count();
     }
 
@@ -132,7 +139,7 @@ class DQLCronkTemplateWorker extends CronkGridTemplateWorker {
     }
 
     public function addOrderColumn($column, $direction = 'ASC') {
-        $this->query->orderBy($this->aliasToColumn($column)." ".$direction);
+        $this->query->addOrderBy($this->aliasToColumn($column)." ".$direction);
     }
 
     public function aliasToColumn($field) {
diff --git a/app/modules/Cronks/validate/System/ViewProc.xml b/app/modules/Cronks/validate/System/ViewProc.xml
index 84b0ab9..e050ff9 100644
--- a/app/modules/Cronks/validate/System/ViewProc.xml
+++ b/app/modules/Cronks/validate/System/ViewProc.xml
@@ -44,6 +44,14 @@
 				</errors>
 			</validator>
 
+			<validator class="string" name="additional_sort_field" required="false">
+				<argument>additional_sort_field</argument>
+
+				<errors>
+					<error>Validation of additional_sort_field failed!</error>
+				</errors>
+			</validator>
+
 			<validator class="string" name="sort_dir" required="false">
 				<argument>sort_dir</argument>
 
diff --git a/app/modules/Cronks/views/System/ViewProcSuccessView.class.php b/app/modules/Cronks/views/System/ViewProcSuccessView.class.php
index 131709c..47ad0fc 100644
--- a/app/modules/Cronks/views/System/ViewProcSuccessView.class.php
+++ b/app/modules/Cronks/views/System/ViewProcSuccessView.class.php
@@ -75,6 +75,10 @@ class Cronks_System_ViewProcSuccessView extends CronksBaseView {
 
             if ($rd->getParameter('sort_field', null) !== null) {
                 $worker->setOrderColumn($rd->getParameter('sort_field'), $rd->getParameter('sort_dir', 'ASC'));
+            
+                if($rd->getParameter('additional_sort_field',null) !== null) {
+                    $worker->addOrderColumn($rd->getParameter('additional_sort_field'), $rd->getParameter('sort_dir', 'ASC'));
+                }
             }
 
             // Apply the filter to our template worker





More information about the icinga-checkins mailing list