Changeset 466


Ignore:
Timestamp:
08/12/10 11:52:22 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Give up on proper spelling of "centre" in CSS class names and
defs - browsers only understand an alignment of "center".
Adjust width of some <hr>'s
Visual row0/row1 classes got switched somehow, somewhere
Remove legacy "color0/color1/color2" row class defs
Convert showrouted to template
See #3.

Location:
branches/htmlform
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/htmlform/cgi-bin/main.cgi

    r465 r466  
    417417  $sth = $ip_dbh->prepare("select city from routed where cidr='$master'");
    418418  $sth->execute;
    419   my @data = $sth->fetchrow_array;
    420 
    421   print qq(<center><div class="heading">Summarizing allocated blocks for ).
    422         qq($master ($data[0]):</div></center><br>\n);
    423 
    424   startTable('CIDR allocation','Customer Location','Type','CustID','SWIPed?','Description/Name');
     419  my ($rcity) = $sth->fetchrow_array;
     420
     421  $page->param(master => "$master");
     422  $page->param(rcity => $rcity);
    425423
    426424  # Snag the allocations for this block
     
    433431  my $custsth = $ip_dbh->prepare("select count(*) from customers where custid=?");
    434432
    435   my $count=0;
    436   while (my @data = $sth->fetchrow_array()) {
    437     # cidr,city,type,custid,swip,description, as per the SELECT
    438     my $cidr = new NetAddr::IP $data[0];
    439 
    440     # Clean up extra spaces that are borking things.
    441 #    $data[2] =~ s/\s+//g;
    442 
    443     $custsth->execute($data[3]);
     433  my $rowclass = 0;
     434  my @blocklist;
     435  while (my ($cidr,$city,$type,$custid,$swip,$desc) = $sth->fetchrow_array()) {
     436    $custsth->execute($custid);
    444437    my ($ncust) = $custsth->fetchrow_array();
    445438
    446     # Prefix subblocks with "Sub "
    447     my @row = ( (($data[2] =~ /^.r$/) ? 'Sub ' : '').
    448         qq(<a href="/ip/cgi-bin/main.cgi?action=edit&block=$data[0]">$data[0]</a>),
    449         $data[1], $disp_alloctypes{$data[2]}, $data[3],
    450         ($data[4] eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'), $data[5]);
    451     # If the allocation is a pool, allow listing of the IPs in the pool.
    452     if ($data[2] =~ /^.[pd]$/) {
    453       $row[0] .= ' &nbsp; <a href="/ip/cgi-bin/main.cgi?action=listpool'.
    454         "&pool=$data[0]\">List IPs</a>";
    455     }
    456 
    457     printRow(\@row, 'color1') if ($count%2 == 0);
    458     printRow(\@row, 'color2') if ($count%2 != 0);
    459     $count++;
    460   }
    461 
    462   print "</table>\n";
    463 
    464   # If the routed block has no allocations, by definition it only has
    465   # one free block, and therefore may be deleted.
    466   if ($count == 0) {
    467     print qq(<hr width="60%"><center><div class="heading">No allocations in ).
    468         qq($master.</div></center>\n).
    469         ($IPDBacl{$authuser} =~ /d/ ?
    470                 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n).
    471                 qq(<input type=hidden name=action value="delete">\n).
    472                 qq(<input type=hidden name=block value="$master">\n).
    473                 qq(<input type=hidden name=alloctype value="rm">\n).
    474                 qq(<input type=submit value=" Remove this block ">\n).
    475                 qq(</form>\n) :
    476                 '');
    477   }
    478 
    479   print qq(<hr width="60%">\n<center><div class="heading">Free blocks within routed ).
    480         qq(submaster $master</div></center>\n);
    481 
    482   startTable('CIDR block','Range');
     439    my %row = (
     440        rowclass => $rowclass++ % 2,
     441        block => $cidr,
     442        city => $city,
     443        type => $disp_alloctypes{$type},
     444        custid => $custid,
     445        swip => ($swip eq 'y' ? ($ncust == 0 ? 'Yes<small>*</small>' : 'Yes') : 'No'),
     446        desc => $desc
     447        );
     448    $row{subblock} = ($type =~ /^.r$/);         # hmf.  wonder why these won't work in the hash declaration...
     449    $row{listpool} = ($type =~ /^.[pd]$/);
     450    push (@blocklist, \%row);
     451  }
     452  $page->param(blocklist => \@blocklist);
     453
     454  $page->param(delrouted => $IPDBacl{$authuser} =~ /d/);
    483455
    484456  # Snag the free blocks.  We don't really *need* to be pedantic about avoiding
    485457  # unrouted free blocks, but it's better to let the database do the work if we can.
    486   $count = 0;
     458  $rowclass = 0;
     459  my @unassigned;
    487460  $sth = $ip_dbh->prepare("select cidr,routed from freeblocks where cidr <<= '$master'".
    488461        " order by cidr");
    489462  $sth->execute();
    490   while (my @data = $sth->fetchrow_array()) {
    491     # cidr,routed
    492     my $cidr = new NetAddr::IP $data[0];
    493     # Include some HairyPerl(TM) to prefix subblocks with "Sub "
    494     my @row = ((($data[1] ne 'y' && $data[1] ne 'n') ? 'Sub ' : '').
    495         ($IPDBacl{$authuser} =~ /a/ ? qq(<a href="/ip/cgi-bin/main.cgi?action=assign&block=$cidr&fbtype=$data[1]">$cidr</a>) : $cidr),
    496         $cidr->range);
    497     printRow(\@row, 'color1') if ($count%2 == 0);
    498     printRow(\@row, 'color2') if ($count%2 != 0);
    499     $count++;
    500   }
    501 
    502   print "</table>\n";
     463  while (my ($cidr_db,$routed) = $sth->fetchrow_array()) {
     464    my $cidr = new NetAddr::IP $cidr_db;
     465
     466    my %row = (
     467        rowclass => $rowclass++ % 2,
     468        subblock => ($routed ne 'y' && $routed ne 'n'),
     469        fblock => $cidr_db,
     470        fbtype => $routed,
     471        frange => $cidr->range,
     472        );
     473    push @unassigned, \%row;
     474  }
     475  $page->param(unassigned => \@unassigned);
     476
    503477} # showRBlock
    504478
  • branches/htmlform/ipdb.css

    r465 r466  
    8585a:active        { color:#cc0000; }      /* selected link */
    8686
    87 table.centre {
     87table.center {
    8888        margin-left: auto;
    8989        margin-right: auto;
     
    9797}
    9898tr.row0 {
    99         background-color: #A8C4D0;
     99        background-color: #D0E0E0;
    100100        font-family: Verdana, Arial, Helvetica, sans-serif;
    101101        font-size: 90%;
    102102}
    103103tr.row1 {
    104         background-color: #d0e0e0;
     104        background-color: #A8C4D0;
    105105        font-family: Verdana, Arial, Helvetica, sans-serif;
    106106        font-size: 90%;
     
    110110        width: 60%;
    111111}
     112hr.w30 {
     113        width: 30%;
     114}
    112115
    113116/* legacy defs */
    114 tr.color0 {
    115         background-color: #A8C4D0;
    116         font-family: Verdana, Arial, Helvetica, sans-serif;
    117         font-size: 90%;
    118 }
    119 
    120 tr.color1 {
    121         background-color: #d0e0e0;
    122         font-family: Verdana, Arial, Helvetica, sans-serif;
    123         font-size: 90%;
    124 }
    125 
    126 tr.color2 {
    127         background-color: #A8C4D0;
    128         font-family: Verdana, Arial, Helvetica, sans-serif;
    129         font-size: 90%;
    130 }
    131 
    132117tr.hack {
    133118        background-color: #E4EEE8;
  • branches/htmlform/templates/index.tmpl

    r451 r466  
    11<br>
    22<div class="center">
    3 <table class="centre" width="98%" cellspacing="0">
     3<table class="center" width="98%" cellspacing="0">
    44<tr class="heading">
    55<td>Master netblock</td>
  • branches/htmlform/templates/showmaster.tmpl

    r465 r466  
    33
    44<TMPL_IF routedlist>
    5 <table class="centre" width="98%" cellspacing="0">
     5<table class="center" width="98%" cellspacing="0">
    66<tr>
    77<td class="heading">Routed block</td>
     
    2323</table>
    2424<TMPL_ELSE>
    25 <hr class="w60">
     25<hr class="w30">
    2626<div class="tbltitle">No allocations in <TMPL_VAR NAME=master>.
    2727<TMPL_IF delmaster>
     
    4141<br>
    4242<hr class="w60">
    43 <br>
    4443
    4544<div class="tbltitle">Unrouted blocks in <TMPL_VAR NAME=master>:</div>
     
    4746
    4847<TMPL_IF NAME=unrouted>
    49 <table class="centre" width="98%" cellspacing="0">
     48<table class="center" width="98%" cellspacing="0">
    5049<tr>
    5150<td class="heading">Netblock</td>
     
    6261</table>
    6362<TMPL_ELSE>
    64 <hr class="w60">
     63<hr class="w30">
    6564<div class="tbltitle">No unrouted blocks in <TMPL_VAR NAME=master>.</div>
    6665</TMPL_IF>
Note: See TracChangeset for help on using the changeset viewer.