Changeset 465


Ignore:
Timestamp:
08/06/10 16:30:33 (14 years ago)
Author:
Kris Deugau
Message:

/branches/htmlform

Convert showmaster page to template.
See #3.

Location:
branches/htmlform
Files:
1 added
2 edited

Legend:

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

    r463 r465  
    308308sub showMaster {
    309309
    310   print qq(<center><div class="heading">Summarizing routed blocks for ).
    311         qq($webvar{block}:</div></center><br>\n);
     310  $page->param(master => $webvar{block});
    312311
    313312  my %allocated;
    314313  my %free;
    315   my %routed;
     314  my %cities;
    316315  my %bigfree;
    317316
     
    331330    $bigfree{"$cidr"} = 128;
    332331    # Retain the routing destination
    333     $routed{"$cidr"} = $data[1];
     332    $cities{"$cidr"} = $data[1];
    334333  }
    335334
    336335  # Check if there were actually any blocks routed from this master
    337336  if ($i > 0) {
    338     startTable('Routed block','Routed to','Allocated blocks',
    339         'Free blocks','Largest free block');
    340337
    341338    # Count the allocations
     
    365362    }
    366363
    367     # Print the data.
    368     my $count=0;
     364    my @routed;
     365    my $rowclass = 0;
    369366    foreach my $master (@localmasters) {
    370       my @row = ("<a href=\"/ip/cgi-bin/main.cgi?action=showrouted&block=$master\">$master</a>",
    371         $routed{"$master"}, $allocated{"$master"},
    372         $free{"$master"},
    373         ( ($bigfree{"$master"} eq 128) ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
    374       );
    375       printRow(\@row, 'color1' ) if($count%2==0);
    376       printRow(\@row, 'color2' ) if($count%2!=0);
    377       $count++;
    378     }
    379   } else {
    380     # If a master block has no routed blocks, then by definition it has no
    381     # allocations, and can be deleted.
    382     print qq(<hr width="60%"><center><div class="heading">No allocations in ).
    383         qq($master.</div>\n).
    384         ($IPDBacl{$authuser} =~ /d/ ?
    385                 qq(<form action="/ip/cgi-bin/main.cgi" method=POST>\n).
    386                 qq(<input type=hidden name=action value="delete">\n).
    387                 qq(<input type=hidden name=block value="$master">\n).
    388                 qq(<input type=hidden name=alloctype value="mm">\n).
    389                 qq(<input type=submit value=" Remove this master ">\n).
    390                 qq(</form></center>\n) :
    391                 '');
     367      my %row = (
     368        rowclass => $rowclass % 2,
     369        block => "$master",
     370        city => $cities{"$master"},
     371        nsubs => $allocated{"$master"},
     372        nfree => $free{"$master"},
     373        lfree => ( ($bigfree{"$master"} eq 128) ? ("&lt;NONE&gt;") : ("/".$bigfree{"$master"}) )
     374        );
     375      push @routed, \%row;
     376      $rowclass++;
     377    }
     378    $page->param(routedlist => \@routed);
    392379
    393380  } # end check for existence of routed blocks in master
    394381
    395   print qq(</table>\n<hr width="60%">\n).
    396         qq(<center><div class="heading">Unrouted blocks in $master:</div></center><br>\n);
    397 
    398   startTable('Netblock','Range');
     382  $page->param(delmaster => ($IPDBacl{$authuser} =~ /d/));
    399383
    400384  # Snag the free blocks.
     
    403387        "routed='n' order by cidr");
    404388  $sth->execute();
     389  my @unrouted;
     390  my $rowclass = 0;
    405391  while (my @data = $sth->fetchrow_array()) {
    406392    my $cidr = new NetAddr::IP $data[0];
    407     my @row = ("$cidr", $cidr->range);
    408     printRow(\@row, 'color1' ) if($count%2==0);
    409     printRow(\@row, 'color2' ) if($count%2!=0);
    410     $count++;
    411   }
    412 
    413   print "</table>\n";
     393    my %row = (
     394        rowclass => $rowclass % 2,
     395        fblock => "$cidr",
     396        frange => $cidr->range
     397        );
     398    push @unrouted, \%row;
     399    $rowclass++;
     400  }
     401  $page->param(unrouted => \@unrouted);
     402
    414403} # showMaster
    415404
  • branches/htmlform/ipdb.css

    r463 r465  
    8888        margin-left: auto;
    8989        margin-right: auto;
     90        text-align: center;
    9091}
    9192
     
    106107}
    107108
     109hr.w60 {
     110        width: 60%;
     111}
     112
    108113/* legacy defs */
    109114tr.color0 {
     
    165170}
    166171
     172.tbltitle {
     173        text-align: center;
     174        font-size: 110%;
     175        font-weight: bold;
     176        font-family: Verdana, Arial, Helvetica, sans-serif;
     177}
    167178.tblsubtitle {
    168179        font-size: 105%;
Note: See TracChangeset for help on using the changeset viewer.