Module: nagvis
Branch: master
Commit: 2265503d7d45625dc6f79ae55eba2a7f2e85f170
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=2265503d7d45625dc6f79ae55eba2a7f2e85f170

Author: Lars Michelsen <[email protected]>
Date:   Sun Nov  7 01:22:58 2010 +0100

Added new parameter {parent_map} to map/automap global sections which is used 
in header/sidebar menus to draw a map hierarchy

---

 ChangeLog                                          |   10 +++--
 .../nagvis-js/classes/NagVisHeaderMenu.php         |   26 ++++++++++-
 share/userfiles/templates/default.css              |    5 ++
 share/userfiles/templates/default.header.html      |   43 +++++++------------
 4 files changed, 50 insertions(+), 34 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3df393b..d536b5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,13 @@
 1.1.6a1
 
 Core
-    * Added user/role profile config files located in 
nagvis/etc/profiles/(user|role).profile.
-      The profile files can contain user/role specific options like languages 
and so on.
-    * The language of a user is stored in the profile file now.
+    * Added user/role profile config files located in 
nagvis/etc/profiles/(user|role).profile
+      The profile files can contain user/role specific options like languages 
and so on
+    * The language of a user is stored in the profile file now
 
 Frontend
     * Added new sidebar for better navigation. It can be opened by klicking on
       the "Open" label in the header menu. The state of the sidebar and the
-      single nodes is stored in user specific profile files.
+      single nodes is stored in user specific profile files
+    * Added new parameter {parent_map} to map/automap global sections which is
+      used in header/sidebar menus to draw a map hierarchy
diff --git a/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php 
b/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
index 4f2a434..01e594e 100644
--- a/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
+++ b/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
@@ -142,6 +142,7 @@ class NagVisHeaderMenu {
        private function getMapList($type, $maps) {
                $permEditAnyMap = false;
                $aMaps = Array();
+               $childMaps = Array();
                foreach($maps AS $mapName) {
                        $map = Array();
                        
@@ -167,6 +168,7 @@ class NagVisHeaderMenu {
                        
                        $map['mapName'] = $MAPCFG1->getName();
                        $map['mapAlias'] = $MAPCFG1->getValue('global', '0', 
'alias');
+                       $map['childs'] = Array();
                        if($type == 'maps') {
                                $map['urlParams'] = '';
                                $map['permittedEdit'] = 
$this->CORE->getAuthorization()->isPermitted('Map', 'edit', $mapName);
@@ -176,16 +178,32 @@ class NagVisHeaderMenu {
                                $map['urlParams'] = str_replace('&', '&amp;', 
$MAPCFG1->getValue('global', 0, 'default_params'));
                        
                        // auto select current map and apply map specific 
optins to the header menu
-                       if ($this->OBJ !== null && ($this->aMacros['mod'] == 
'Map' || $this->aMacros['mod'] == 'AutoMap') && $mapName == 
$this->OBJ->getName()) {
+                       if($this->OBJ !== null && ($this->aMacros['mod'] == 
'Map' || $this->aMacros['mod'] == 'AutoMap') && $mapName == 
$this->OBJ->getName()) {
                                $map['selected'] = True;
                                
+                               // Override header fade option with map config
                                $this->aMacros['bEnableFade'] = 
$MAPCFG1->getValue('global', 0, 'header_fade');
                        }
                        
-                       $aMaps[] = $map;
+                       $map['parent'] = $MAPCFG1->getValue('global', 0, 
'parent_map');
+
+                       if($map['parent'] === '')
+                               $aMaps[$map['mapName']] = $map;
+                       else {
+                               if(!isset($childMaps[$map['parent']]))
+                                       $childMaps[$map['parent']] = Array();
+                               $childMaps[$map['parent']][$map['mapName']] = 
$map;
+                       }
                }
 
-               return Array($aMaps, $permEditAnyMap);
+               return Array($this->mapListToTree($aMaps, $childMaps), 
$permEditAnyMap);
+       }
+
+       private function mapListToTree($maps, $childMaps) {
+               foreach(array_keys($maps) AS $freeParent)
+                       if(isset($childMaps[$freeParent]))
+                               $maps[$freeParent]['childs'] = 
$this->mapListToTree($childMaps[$freeParent], $childMaps);
+               return $maps;
        }
        
        /**
@@ -282,6 +300,8 @@ class NagVisHeaderMenu {
                        'langHostgroup' => 
$this->CORE->getLang()->getText('hostgroup'),
                        'langServicegroup' => 
$this->CORE->getLang()->getText('servicegroup'),
                        'langMap' => $this->CORE->getLang()->getText('map'),
+                       'langMaps' => $this->CORE->getLang()->getText('Maps'),
+                       'langAutomaps' => 
$this->CORE->getLang()->getText('Automaps'),
                        'langTextbox' => 
$this->CORE->getLang()->getText('textbox'),
                        'langShape' => $this->CORE->getLang()->getText('shape'),
                        'langStateless' => 
$this->CORE->getLang()->getText('Stateless'),
diff --git a/share/userfiles/templates/default.css 
b/share/userfiles/templates/default.css
index 092af05..86aeef4 100644
--- a/share/userfiles/templates/default.css
+++ b/share/userfiles/templates/default.css
@@ -560,6 +560,11 @@ td#popupWindowContent fieldset.form label {
 #sidebar li.spacerbottom {border-bottom:1px dotted #a4a4a4}
 #sidebar li.spacertop {border-top:1px dotted #a4a4a4}
 #sidebar li a 
{display:block;padding-left:20px;width:180px;color:#43B3CF;text-decoration:none;}
+#sidebar li.lvl2 a{padding-left:30px;width:170px}
+#sidebar li.lvl3 a{padding-left:40px;width:160px}
+#sidebar li.lvl3 a{padding-left:50px;width:150px}
+#sidebar li.lvl4 a{padding-left:60px;width:140px}
+#sidebar li.lvl5 a{padding-left:70px;width:130px}
 #sidebar li.open a.title {background: 
url('../images/templates/default.folder_open.gif') no-repeat left #eaf0f2;}
 #sidebar li.closed a.title {background: 
url('../images/templates/default.folder_closed.gif') no-repeat left #eaf0f2;}
 #sidebar li a:hover {background-color:#d9e1e4;color:#779D2A}
diff --git a/share/userfiles/templates/default.header.html 
b/share/userfiles/templates/default.header.html
index d5b4098..72cef20 100644
--- a/share/userfiles/templates/default.header.html
+++ b/share/userfiles/templates/default.header.html
@@ -18,13 +18,9 @@
                                        {/if}
                                        {if count($maps) > 0}
                                        {foreach $maps map}<li>
-                                               {if $map.configError == true}
-                                                       <a class="left error" 
href="#">{$map.mapAlias}</a>
-                                               {else}
-                                                       <a class="left" 
href="{$pathBase}/frontend/nagvis-js/index.php?mod=Map&amp;act=view&amp;show={$map.mapName}{$map.urlParams}">{$map.mapAlias}</a>
-                                               {/if}
-                                               {if $map.permittedEdit}<a 
class="right" 
href="{$pathBase}/frontend/wui/index.php?mod=Map&amp;act=edit&amp;show={$map.mapName}{$map.urlParams}">Edit</a>
-                                               {else}<a 
class="right">&nbsp;</a>{/if}
+                                               {if $map.configError == true}<a 
class="left error" href="#">{$map.mapAlias}</a>
+                                               {else}<a class="left" 
href="{$pathBase}/frontend/nagvis-js/index.php?mod=Map&amp;act=view&amp;show={$map.mapName}{$map.urlParams}">{$map.mapAlias}</a>
 {/if}
+                                               {if $map.permittedEdit}<a 
class="right" 
href="{$pathBase}/frontend/wui/index.php?mod=Map&amp;act=edit&amp;show={$map.mapName}{$map.urlParams}">Edit</a>{else}<a
 class="right">&nbsp;</a>{/if}
                                        </li>{/foreach}
                                        <li class="spacer"><hr /></li>
                                        {/if}
@@ -190,30 +186,23 @@
 </ul>
 </div>
 
+{template sideMaps maps pathBase type indent=1}
+{foreach $maps map}
+       {if $map.configError == true}<li 
class="lvl{$indent}">{$map.mapAlias}</li>
+       {else}<li class="lvl{$indent}"><a class="left" 
href="{$pathBase}/frontend/nagvis-js/index.php?mod={$type}&amp;act=view&amp;show={$map.mapName}{$map.urlParams}">{$map.mapAlias}</a></li>{/if}
+       {if $map.childs}
+               {sideMaps $map.childs $pathBase $type $indent+1}
+       {/if}
+{/foreach}
+{/template}
 <div id="sidebar">
 <ul>
        {if $permittedOverview}<li class="spacerbottom"><a 
href="{$pathBase}/frontend/nagvis-js/index.php">{$langOverview}</a></li>{/if}
-       <li class="closed"><a class="title" href="#" 
onclick="sidebarToggleSubtree(this)">Maps</a>
-               <ul style="display:none;">
-                       {foreach $maps map}
-                               {if $map.configError == true}
-                                       <li>{$map.mapAlias}</li>
-                               {else}
-                                       <li><a class="left" 
href="{$pathBase}/frontend/nagvis-js/index.php?mod=Map&amp;act=view&amp;show={$map.mapName}{$map.urlParams}">{$map.mapAlias}</a></li>
-                               {/if}
-                       {/foreach}
-               </ul>
+       <li class="closed"><a class="title" href="#" 
onclick="sidebarToggleSubtree(this)">{$langMaps}</a>
+               <ul style="display:none;">{sideMaps $maps $pathBase "Map"}</ul>
        </li>
-       <li class="closed"><a class="title" href="#" 
onclick="sidebarToggleSubtree(this)">Automaps</a>
-               <ul style="display:none;">
-                       {foreach $automaps map}
-                               {if $map.configError == true}
-                                       <li>{$map.mapAlias}</li>
-                               {else}
-                                       <li><a class="left" 
href="{$pathBase}/frontend/nagvis-js/index.php?mod=AutoMap&amp;act=view&amp;show={$map.mapName}{$map.urlParams}">{$map.mapAlias}</a></li>
-                               {/if}
-                       {/foreach}
-               </ul>
+       <li class="closed"><a class="title" href="#" 
onclick="sidebarToggleSubtree(this)">{$langAutomaps}</a>
+               <ul style="display:none;">{sideMaps $automaps $pathBase 
"AutoMap"}</ul>
        </li>
        {if $permittedEditAnyMap}<li class="spacertop"><a 
href="{$pathBase}/frontend/wui/index.php" 
class="underline">{$langWui}</a></li>{/if}
 </ul>


------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to