[icinga-checkins] icinga.org: icinga-web/next: Icinga-web update 1.8 - Custom cronks don' t work anymore

git at icinga.org git at icinga.org
Fri Apr 5 11:55:44 CEST 2013


Module: icinga-web
Branch: next
Commit: 46f8beda9632243882ac048e218201c56c380231
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=46f8beda9632243882ac048e218201c56c380231

Author: Marius Hein <marius.hein at netways.de>
Date:   Fri Apr  5 11:54:27 2013 +0200

Icinga-web update 1.8 - Custom cronks don't work anymore

2nd try. Try to repair index beween nativeState and colModel

refs #3431

---

 etc/lib/CronkStruct.php      |   81 ++++++++++++++++++++++++++++++++++++++++++
 etc/lib/cronkUpgradeTask.php |   15 ++++----
 2 files changed, 89 insertions(+), 7 deletions(-)

diff --git a/etc/lib/CronkStruct.php b/etc/lib/CronkStruct.php
index 4812cf1..87c5297 100644
--- a/etc/lib/CronkStruct.php
+++ b/etc/lib/CronkStruct.php
@@ -300,4 +300,85 @@ class CronkStruct {
 
         return $return;
     }
+
+    /**
+     * Try to fix old relations between columns
+     *
+     * EXPERIMENTAL
+     *
+     * @return bool
+     */
+    public function fixOldColumns()
+    {
+
+        /**
+         * Columns we can drop, becase they
+         * moved into the row expander
+         */
+        $removeIndex = array(
+            'pnp4nagios_host_link',
+            'pnp4nagios_host_image_hover',
+            'pnp4nagios_service_link',
+            'pnp4nagios_service_image_hover',
+            'service_info',
+            'service_history_link',
+            'service_to_host_link',
+            'host_info',
+            'host_history_link'
+        );
+
+        /**
+         * Test columns that they are hidden, always
+         */
+        $hideIndex = array(
+            'instance_name',
+            'host_object_id',
+            'service_object_id'
+        );
+
+        if (isset($this->json['colModel']['columns'])) {
+            $colModel = $this->json['colModel']['columns'];
+            $colIndex = $this->json['nativeState']['columns'];
+
+            // ----------------------------------------------------------------
+            // Drop columns
+            // ----------------------------------------------------------------
+            foreach ($colModel as $index => $column) {
+                foreach ($removeIndex as $dataIndex) {
+
+                    if ($column['dataIndex'] === $dataIndex) {
+
+                        if (isset($colIndex[$index])) {
+                            // All this special columns are small!
+                            if ($colIndex[$index]['width'] < 100) {
+                                array_splice($colIndex, $index, 1); // < Drop column
+                            }
+                        }
+
+                        array_splice($colModel, $index, 1);
+                    }
+
+                }
+            }
+
+            // ----------------------------------------------------------------
+            // Hide columns
+            // ----------------------------------------------------------------
+            foreach ($colModel as $index => $column) {
+                foreach ($hideIndex as $dataIndex) {
+                    if ($column['dataIndex'] === $dataIndex) {
+                        $column['hidden'] = true;
+                        $colModel[$index] = $column;
+                    }
+                }
+            }
+
+            $this->json['colModel']['columns'] = $colModel;
+            $this->json['nativeState']['columns'] = $colIndex;
+
+            return true;
+        }
+
+        return false;
+    }
 }
\ No newline at end of file
diff --git a/etc/lib/cronkUpgradeTask.php b/etc/lib/cronkUpgradeTask.php
index d2a277f..52d3b3b 100644
--- a/etc/lib/cronkUpgradeTask.php
+++ b/etc/lib/cronkUpgradeTask.php
@@ -44,13 +44,14 @@ class cronkUpgradeTask extends agaviConsoleTask {
         foreach ($cronks as $cronk) {
             $cronkStruct = new CronkStruct($cronk);
             $this->log('Testing cronk '. $cronkStruct->getName());
-            $status = $cronkStruct->upgradeEventSubFrame();
-            if ($status === true) {
-                $update = $cronkStruct->persistToDatabase();
-                if ($update) {
-                    $this->log('Columns upgraded', Project::MSG_WARN);
-                    continue;
-                }
+
+            $cronkStruct->upgradeEventSubFrame();
+            $cronkStruct->fixOldColumns();
+
+            $update = $cronkStruct->persistToDatabase();
+            if ($update) {
+                $this->log('Columns upgraded', Project::MSG_WARN);
+                continue;
             }
 
             $this->log('Nothing to to', Project::MSG_INFO);





More information about the icinga-checkins mailing list