[LON-CAPA-cvs] cvs: loncom /auth lonlogin.pm

raeburn raeburn@source.lon-capa.org
Thu, 03 Mar 2011 06:37:30 -0000


raeburn		Thu Mar  3 06:37:30 2011 EDT

  Modified files:              
    /loncom/auth	lonlogin.pm 
  Log:
  - Improve changes in rev 1.145.
    - No display of table rows for User Load, Server Load, or Version if
      there are no numbers to display.
  
  
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.146 loncom/auth/lonlogin.pm:1.147
--- loncom/auth/lonlogin.pm:1.146	Fri Feb 11 10:41:59 2011
+++ loncom/auth/lonlogin.pm	Thu Mar  3 06:37:30 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.146 2011/02/11 10:41:59 bisitz Exp $
+# $Id: lonlogin.pm,v 1.147 2011/03/03 06:37:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -151,10 +151,14 @@
 	$loadavg=<$loadfile>;
     }
     $loadavg =~ s/\s.*//g;
-    my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
-    unless ($loadlim) { $loadpercent='---'; }
-    my $userloadpercent=&Apache::lonnet::userload();
-    unless ($uloadlim) { $userloadpercent='---'; }
+
+    my ($loadpercent,$userloadpercent);
+    if ($loadlim) {
+        $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
+    }
+    if ($uloadlim) {
+        $userloadpercent=&Apache::lonnet::userload();
+    }
 
     my $firsturl=
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
@@ -464,10 +468,8 @@
 </div>
 <hr style="clear:both;" />
 ENDTOP
-
-$r->print(<<ENDDOCUMENT);
-    <div style="float: left;">
-     <table border="0" cellspacing="0" cellpadding="0">
+    my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
+    $domainrow = <<"END";
       <tr>
        <td  align="left" valign="top">
         <small><b>$lt{'dom'}:&nbsp;</b></small>
@@ -476,6 +478,8 @@
         <small><tt>&nbsp;$domain</tt></small>
        </td>
       </tr>
+END
+    $serverrow = <<"END";
       <tr>
        <td  align="left" valign="top">
         <small><b>$lt{'serv'}:&nbsp;</b></small>
@@ -484,6 +488,9 @@
         <small><tt>&nbsp;$lonhost ($role)</tt></small>
        </td>
       </tr>
+END
+    if ($loadlim) {
+        $loadrow = <<"END";
       <tr>
        <td align="left" valign="top">
         <small><b>$lt{'load'}:&nbsp;</b></small>
@@ -492,6 +499,10 @@
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
        </td>
       </tr>
+END
+    }
+    if ($uloadlim) {
+        $userloadrow = <<"END";
       <tr>
        <td align="left" valign="top">
         <small><b>$lt{'userload'}:&nbsp;</b></small>
@@ -500,11 +511,26 @@
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
        </td>
       </tr>
+END
+    }
+    if (($version ne '') && ($version ne '<!-- VERSION -->')) {
+        $versionrow = <<"END";
       <tr>
        <td colspan="2" align="left">
         <small>$version</small>
        </td>
       </tr>
+END
+    }
+
+$r->print(<<ENDDOCUMENT);
+    <div style="float: left;">
+     <table border="0" cellspacing="0" cellpadding="0">
+$domainrow
+$serverrow
+$loadrow    
+$userloadrow
+$versionrow
      </table>
     </div>
     <div style="float: right;">