r2651 - added new option RACKS_PER_ROW
authorDenis Ovsienko <infrastation@yandex.ru>
Thu, 16 Apr 2009 14:20:54 +0000 (14:20 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Thu, 16 Apr 2009 14:20:54 +0000 (14:20 +0000)
 - renderRackspace(): treat RACKS_PER_ROW, when rendering
 - renderRow: ditto

ChangeLog
inc/interface.php
inc/ophandlers.php
install/init-dictbase.sql
upgrade.php

index 73583068125e237e276c538e1c9443b448e1caa4..b8ef5889465a5e8fb4b1f8595864ebb6c84062ae 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
        new feature: vendor sieve for stickers
        new feature: RackCode expressions as source for load balancer lists
        new feature: wireless hardware in dictionary
+       new feature: "racks per row" option (by Frank Brodbeck)
        update: display row name when listing objects. closes ticket 16 (by Aaron)
        update: ability to manage rows from the Rackspace page in addition to the Dictionary (by Aaron)
        update: IPv4 calculations were optimized for better speed
index dc8df43dd58f6e32991777717044a93ba26899a5..52461367fea82e9b0590599f41ee4f72ca6b12c9 100644 (file)
@@ -285,25 +285,36 @@ function renderRackspace ()
        $rackrowList = getRackspace ($tagfilter);
        global $nextorder;
        $rackwidth = getRackImageWidth();
+       // Zero value effectively disables the limit.
+       $maxPerRow = getConfigVar ('RACKS_PER_ROW');
        $order = 'odd';
        foreach ($rackrowList as $rackrow)
        {
-               echo "<tr class=row_${order}><th class=tdleft>";
-               echo "<a href='".makeHref(array('page'=>'row', 'row_id'=>$rackrow['row_id']))."${tagfilter_str}'>";
-               echo "${rackrow['row_name']}</a></th>";
                $rackList = getRacksForRow ($rackrow['row_id'], $tagfilter);
-               echo "<td><table border=0 cellspacing=5><tr>";
+               $rackListIdx = 0;
                foreach ($rackList as $rack)
                {
+                       if ($rackListIdx % $maxPerRow == 0)
+                       {
+                               if ($rackListIdx > 0)
+                                       echo '</tr></table></tr>';
+                               echo "<tr class=row_${order}><th class=tdleft>";
+                               echo "<a href='".makeHref(array('page'=>'row', 'row_id'=>$rackrow['row_id']))."${tagfilter_str}'>";
+                               echo "${rackrow['row_name']}</a>";
+                               if ($rackListIdx > 0)
+                                       echo ' (continued)';
+                               echo "</th><td><table border=0 cellspacing=5><tr>";
+                               $order = $nextorder[$order];
+                       }
                        echo "<td align=center><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$rack['id']))."'>";
                        echo "<img border=0 width=${rackwidth} height=";
                        echo getRackImageHeight ($rack['height']);
                        echo " title='${rack['height']} units'";
                        echo "src='render_image.php?img=minirack&rack_id=${rack['id']}'>";
                        echo "<br>${rack['name']}</a></td>";
+                       $rackListIdx++;
                }
                echo "</tr></table></tr>\n";
-               $order = $nextorder[$order];
        }
        echo "</table>\n";
        echo "</td></tr></table>\n";
@@ -383,17 +394,27 @@ function renderRow ($row_id = 0)
 
        global $nextorder;
        $rackwidth = getRackImageWidth() * getConfigVar ('ROW_SCALE');
+       // Maximum number of racks per row is proportionally less, but at least 1.
+       $maxPerRow = max (floor (getConfigVar ('RACKS_PER_ROW') / getConfigVar ('ROW_SCALE')), 1);
+       $rackListIdx = 0;
        $order = 'odd';
        startPortlet ('Racks');
        echo "<table border=0 cellspacing=5 align='center'><tr>";
        foreach ($rackList as $rack)
        {
+               if ($rackListIdx % $maxPerRow == 0)
+               {
+                       if ($rackListIdx > 0)
+                               echo '</tr>';
+                       echo '<tr>';
+               }
                echo "<td align=center class=row_${order}><a href='".makeHref(array('page'=>'rack', 'rack_id'=>$rack['id']))."'>";
                echo "<img border=0 width=${rackwidth} height=" . (getRackImageHeight ($rack['height']) * getConfigVar ('ROW_SCALE'));
                echo " title='${rack['height']} units'";
                echo "src='render_image.php?img=minirack&rack_id=${rack['id']}'>";
                echo "<br>${rack['name']}</a></td>";
                $order = $nextorder[$order];
+               $rackListIdx++;
        }
        echo "</tr></table>\n";
        finishPortlet();
index 83dfc9279b0a5d9383c1a9fdc4cf58d7e4c487ec..2d3a3217f6aff002dc5e847996728a022526a3a3 100644 (file)
@@ -940,6 +940,7 @@ function resetUIConfig()
        setConfigVar ('IPV4NAT_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}');
        setConfigVar ('ASSETWARN_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}');
        setConfigVar ('NAMEWARN_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}');
+       setConfigVar ('RACKS_PER_ROW','12');
        return buildRedirectURL (__FUNCTION__, 'OK');
 }
 
index 141c6ea9d137e01e7ae65d424f10d621e50a31db..f435e9097c9a8554b9d1db708ef7d6293845631e 100644 (file)
@@ -291,6 +291,7 @@ INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, descriptio
 ('IPV4NAT_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}','string','yes','no','List source: IPv4 NAT performers'),
 ('ASSETWARN_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}','string','yes','no','List source: object, for which asset tag should be set'),
 ('NAMEWARN_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}','string','yes','no','List source: object, for which common name should be set'),
+('RACKS_PER_ROW','12','unit','yes','no','Racks per row'),
 ('DB_VERSION','0.17.0','string','no','yes','Database version.');
 
 INSERT INTO `Script` VALUES ('RackCode','allow {$userid_1}');
index f30201e32f44a812f87bd3178a917941bd3da711..946bca6b786e6492b4088b925249f39fb1067403 100644 (file)
@@ -182,6 +182,7 @@ CREATE TABLE `FileLink` (
                        $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('IPV4NAT_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}','string','yes','no','List source: IPv4 NAT performers')";
                        $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('ASSETWARN_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}','string','yes','no','List source: object, for which asset tag should be set')";
                        $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('NAMEWARN_LISTSRC','{$typeid_4} or {$typeid_7} or {$typeid_8}','string','yes','no','List source: object, for which common name should be set')";
+                       $query[] = "INSERT INTO `Config` (varname, varvalue, vartype, emptyok, is_hidden, description) VALUES ('RACKS_PER_ROW','12','unit','yes','no','Racks per row')";
                        $query[] = "delete from Config where varname = 'USER_AUTH_SRC'";
                        $query[] = "delete from Config where varname = 'COOKIE_TTL'";
                        $query[] = "delete from Config where varname = 'rtwidth_0'";