UI: config editor changed a bit
authorAlexey Andriyanov <alan@al-an.info>
Tue, 9 Apr 2013 20:57:40 +0000 (00:57 +0400)
committerAlexey Andriyanov <alan@al-an.info>
Tue, 9 Apr 2013 20:57:40 +0000 (00:57 +0400)
renderUIConfigEditForm, renderMyPreferences: merged into one
renderConfigEditor

renderConfigVarName: new func
renderUIConfig: use renderConfigVarName

ChangeLog
wwwroot/css/pi.css
wwwroot/inc/interface.php
wwwroot/inc/navigation.php

index a34d7dfc7265669b3f0ddc31d21f1da501cbfa8b..254bde997e4ea69b0db3207a2d336013acd77c5e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -31,6 +31,7 @@
        update: files may be linked to rows (#733)
        update: prevent deletion of system-level attributes (#761)
        update: hide controls in cacti tab if user doesn't have permission (#707)
+       update: configuration editor displays variable names along with descriptions
        new feature: configurable top-to-bottom units order in particular racks
                (#601)
        new feature: overridable tag names display style (via CSS and plug-ins)
index 062933ad0ae6461ad4f2b98c30f7eb3b3effadb6..4de821716c701e323b7ae3005e8f1aba032734af 100644 (file)
@@ -795,3 +795,14 @@ a.noclick {
        font-family: monospace;
        font-style: italic;
 }
+
+.varname {
+       font-family: "Courier New",Courier,monospace;
+       font-weight: bold;
+}
+
+.vardescr {
+       font-style: italic;
+       margin: 0 0;
+       font-size: 90%;
+}
index 52ada104c866b140198999a33011c63522669ef8..8cbe0f696d8db6e72c8bbaf15bfeb3884643b89a 100644 (file)
@@ -4469,6 +4469,14 @@ function dragon ()
        finishPortlet();
 }
 
+// $v is a $configCache item
+// prints HTML-formatted varname and description
+function renderConfigVarName ($v)
+{
+       echo '<span class="varname">' . $v['varname'] . '</span>';
+       echo '<p class="vardescr">' . $v['description'] . ($v['is_userdefined'] == 'yes' ? '' : ' (system-wide)') . '</p>';
+}
+
 function renderUIConfig ()
 {
        global $configCache, $nextorder;
@@ -4481,7 +4489,9 @@ function renderUIConfig ()
                if ($v['is_hidden'] != 'no')
                        continue;
                echo "<tr class=row_${order}>";
-               echo "<td nowrap valign=top class=tdright>${v['description']}</td>";
+               echo "<td nowrap valign=top class=tdright>";
+               renderConfigVarName ($v);
+               echo '</td>';
                echo "<td valign=top class=tdleft>${v['varvalue']}</td></tr>";
                $order = $nextorder[$order];
        }
@@ -4489,34 +4499,6 @@ function renderUIConfig ()
        finishPortlet();
 }
 
-function renderUIConfigEditForm ()
-{
-       global $configCache;
-       startPortlet ('Current configuration');
-       echo "<table cellspacing=0 cellpadding=5 align=center class=widetable width='50%'>\n";
-       echo "<tr><th class=tdleft>Option</th>";
-       echo "<th class=tdleft>Value</th></tr>";
-       printOpFormIntro ('upd');
-
-       $i = 0;
-       foreach ($configCache as $v)
-       {
-               if ($v['is_hidden'] != 'no')
-                       continue;
-               echo "<input type=hidden name=${i}_varname value='${v['varname']}'>";
-               echo "<tr><td class=tdright>${v['description']}</td>";
-               echo "<td class=tdleft><input type=text name=${i}_varvalue value='${v['varvalue']}' size=24></td>";
-               echo "</tr>\n";
-               $i++;
-       }
-       echo "<input type=hidden name=num_vars value=${i}>\n";
-       echo "<tr><td colspan=2>";
-       printImageHREF ('SAVE', 'Save changes', TRUE);
-       echo "</td></tr>";
-       echo "</form>";
-       finishPortlet();
-}
-
 function renderSNMPPortFinder ($object_id)
 {
        if (!extension_loaded ('snmp'))
@@ -5289,8 +5271,10 @@ function renderMyPasswordEditor ()
        echo '</table></form>';
 }
 
-function renderMyPreferences ()
+function renderConfigEditor ()
 {
+       global $pageno;
+       $per_user = ($pageno == 'myaccount');
        global $configCache;
        startPortlet ('Current configuration');
        echo "<table cellspacing=0 cellpadding=5 align=center class=widetable width='50%'>\n";
@@ -5303,17 +5287,17 @@ function renderMyPreferences ()
        {
                if ($v['is_hidden'] != 'no')
                        continue;
-               if ($v['is_userdefined'] != 'yes')
+               if ($per_user && $v['is_userdefined'] != 'yes')
                        continue;
                echo "<input type=hidden name=${i}_varname value='${v['varname']}'>";
-               echo "<tr><td class=\"tdright\">${v['description']}</td>";
-               echo "<td class=\"tdleft\"><input type=text name=${i}_varvalue value='${v['varvalue']}' size=24></td>";
-               if ($v['is_altered'] == 'yes')
-                       echo "<td class=\"tdleft\"><a href=\"".
-                               makeHrefProcess(array('op'=>'reset', 'varname'=>$v['varname']))
-                               ."\">reset</a></td>";
-               else
-                       echo "<td class=\"tdleft\">(default)</td>";
+               echo '<tr><td class="tdright">';
+               echo renderConfigVarName ($v);
+               echo '</td>';
+               echo "<td class=\"tdleft\"><input type=text name=${i}_varvalue value='" . htmlspecialchars ($v['varvalue'], ENT_QUOTES) . "' size=24></td>";
+               echo '<td class="tdleft">';
+               if ($per_user && $v['is_altered'] == 'yes')
+                       echo getOpLink (array('op'=>'reset', 'varname'=>$v['varname']), 'reset');
+               echo '</td>';
                echo "</tr>\n";
                $i++;
        }
index 4720a020a1261159d95e271aa97fd4f4110bb5fa..a4b8002d34972f47b922e56f163cb3a9e7806afd 100644 (file)
@@ -538,7 +538,7 @@ $tab['ui']['default'] = 'View';
 $tab['ui']['edit'] = 'Change';
 $tab['ui']['reset'] = 'Reset';
 $tabhandler['ui']['default'] = 'renderUIConfig';
-$tabhandler['ui']['edit'] = 'renderUIConfigEditForm';
+$tabhandler['ui']['edit'] = 'renderConfigEditor';
 $tabhandler['ui']['reset'] = 'renderUIResetForm';
 $ophandler['ui']['edit']['upd'] = 'updateUI';
 $ophandler['ui']['reset']['go'] = 'resetUIConfig';
@@ -562,7 +562,7 @@ $tab['myaccount']['qlinks'] = 'Quick links';
 $trigger['myaccount']['mypassword'] = 'trigger_passwdchange';
 $tabhandler['myaccount']['default'] = 'renderMyAccount';
 $tabhandler['myaccount']['mypassword'] = 'renderMyPasswordEditor';
-$tabhandler['myaccount']['interface'] = 'renderMyPreferences';
+$tabhandler['myaccount']['interface'] = 'renderConfigEditor';
 $tabhandler['myaccount']['qlinks'] = 'renderMyQuickLinks';
 $ophandler['myaccount']['mypassword']['changeMyPassword'] = 'changeMyPassword';
 $ophandler['myaccount']['interface']['upd'] = 'saveMyPreferences';