Changeset 682 for trunk


Ignore:
Timestamp:
01/20/15 16:57:05 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Convert working hack for comparing container list layout into a
configuration switch, and pick a default.

Location:
trunk
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/IPDB.pm

    r681 r682  
    104104# (eg, NetAddr::IP->bits - NetAddr::IP->masklen)
    105105our $maxrevlist = 5;  # /27
     106
     107# UI layout for subblocks/containers
     108our $sublistlayout = 1;
    106109
    107110##
  • trunk/cgi-bin/MyIPDB.pm

    r681 r682  
    7878#$IPDB::maxrevlist = 8;  # v4 /24
    7979
     80## UI layout for showing subblocks
     81# 1 lists all containers in a group, then all end-use allocations (including pools) in a group
     82# 2 lists all entries in a container in CIDR order, and puts a secondary summary line under a container entry
     83# Both show free blocks in a group at the bottom as previously
     84# $IPDB::sublistlayout = 1;
     85
    8086## connectDB_My()
    8187# Wrapper for IPDB::connectDB
  • trunk/cgi-bin/main.cgi

    r677 r682  
    8787  $webvar{action} = "index";    #shuts up the warnings.
    8888}
     89
     90# collect variations in layout by way of $IPDB::sublistlayout
     91$webvar{action} = 'showsubs' if $webvar{action} =~ /^showsubs/;
    8992
    9093my $page;
     
    244247# Display blocks immediately within a given parent
    245248sub showSubs {
     249  # Which layout?
     250  if ($IPDB::sublistlayout == 2) {
     251
     252    # 2-part layout;  mixed containers and end-use allocations and free blocks.
     253    # Containers have a second line for the subblock metadata.
     254    # We need to load an alternate template for this case.
     255    $page = HTML::Template->new(filename => "showsubs2.tmpl", loop_context_vars => 1, global_vars => 1);
     256
     257    $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
     258
     259    my $sublist = listSubs($ip_dbh, parent => $webvar{parent});
     260    $page->param(sublist => $sublist);
     261
     262  } else {
     263
     264    # Default 3-part layout;  containers, end-use allocations, and free blocks
     265
     266    my $contlist = listContainers($ip_dbh, parent => $webvar{parent});
     267    $page->param(contlist => $contlist);
     268
     269    my $alloclist = listAllocations($ip_dbh, parent => $webvar{parent});
     270    $page->param(alloclist => $alloclist);
     271
     272    # only show "delete" button if we have no container or usage allocations
     273    $page->param(maydel => ($IPDBacl{$authuser} =~ /d/) && !(@$contlist || @$alloclist));
     274
     275  }
     276
     277  # Common elements
    246278  my $pinfo = getBlockData($ip_dbh, $webvar{parent});
    247279
     
    249281  $page->param(block => $pinfo->{block});
    250282  $page->param(mayadd => ($IPDBacl{$authuser} =~ /a/));
    251   $page->param(maydel => ($IPDBacl{$authuser} =~ /d/));
    252 
    253   my $sublist = listSubs($ip_dbh, parent => $webvar{parent});
    254   $page->param(sublist => $sublist);
    255283
    256284  my $flist = listFree($ip_dbh, parent => $webvar{parent});
  • trunk/templates/showsubs.tmpl

    r653 r682  
    11<div class="tbltitle">Subnets in <TMPL_VAR NAME=block></div>
    2 <br>
    32<TMPL_VAR NAME=addperm>
    43
    5 <TMPL_IF sublist>
     4<TMPL_IF contlist>
     5<br>
     6<hr class="w30">
     7<div class="tbltitle">Containers</div>
     8<br>
     9<table class="center" width="98%" cellspacing="0">
     10<tr>
     11<td class="heading">Container block</td>
     12<td class="heading">Location</td>
     13<td class="heading">Type</td>
     14<td class="heading">Description/Name</td>
     15<td class="heading">Allocations</td>
     16<td class="heading">Free blocks</td>
     17<td class="heading">Largest free block</td>
     18</tr>
     19
     20<TMPL_LOOP NAME=contlist>
     21<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
     22<td><a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=showsubs&amp;parent=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=block></a></td>
     23<td><TMPL_VAR NAME=city></td>
     24<td><TMPL_VAR NAME=type></td>
     25<td><TMPL_VAR NAME=desc></td>
     26<td><TMPL_VAR NAME=suballocs></td>
     27<td><TMPL_VAR NAME=subfree></td>
     28<td><TMPL_VAR ESCAPE=HTML NAME=lfree></td>
     29</TMPL_LOOP>
     30</table>
     31<TMPL_ELSE>
     32<hr class="w30">
     33<div class="tbltitle">No container blocks in <TMPL_VAR NAME=block></div>
     34</TMPL_IF>
     35
     36<TMPL_IF alloclist>
     37<br>
     38<hr class="w30">
     39<div class="tbltitle">Usage allocations</div>
     40<br>
    641<table width="98%" cellspacing="0" class="center">
    7 
    842<tr>
    9 <td class="heading">Netblock</td>
    10 <td class="heading">City</td>
     43<td class="heading">CIDR allocation</td>
     44<td class="heading">Location</td>
    1145<td class="heading">Type</td>
    1246<td class="heading">CustID</td>
     
    1549</tr>
    1650
    17 <TMPL_LOOP NAME=sublist>
     51<TMPL_LOOP NAME=alloclist>
    1852<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
    1953<td>
    20 <TMPL_IF hassubs>
    21 <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=showsubs&amp;parent=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=block></a>
    22 <TMPL_ELSE>
    2354<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;id=<TMPL_VAR NAME=id>&amp;basetype=b"><TMPL_VAR NAME=block></a>
    2455<TMPL_IF listpool> &nbsp; <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=listpool&amp;pool=<TMPL_VAR NAME=id>">List IPs</a></TMPL_IF>
    25 </TMPL_IF>
    2656</td>
    2757<td><TMPL_VAR NAME=city></td>
    2858<td><TMPL_VAR NAME=type></td>
    29 <td><a href="<TMPL_VAR NAME=webpath>/cgi-bin/search.cgi?stype=q&amp;input=<TMPL_VAR NAME=custid>"><TMPL_VAR NAME=custid></a></td>
     59<td><TMPL_VAR NAME=custid></td>
    3060<td><TMPL_VAR NAME=swip><TMPL_IF partswip><small>*</small></TMPL_IF></td>
    3161<td><TMPL_VAR NAME=desc></td>
    3262</tr>
    33 <TMPL_IF hassubs>
    34 <tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
    35 <td colspan=4>
    36 Containers: <TMPL_VAR NAME=subcontainers>, Allocations: <TMPL_VAR NAME=suballocs>, Free: <TMPL_VAR NAME=subfree>, Largest free: <TMPL_VAR ESCAPE=HTML NAME=lfree>
    37 </td><td colspan=2></td></tr>
    38 </TMPL_IF>
    3963</TMPL_LOOP>
    4064</table>
    4165<TMPL_ELSE>
    4266<hr class="w30">
    43 <div class="tbltitle">No allocations in <TMPL_VAR NAME=block>
     67<div class="tbltitle">No usage allocations in <TMPL_VAR NAME=block></div>
     68</TMPL_IF>
     69
    4470<TMPL_IF maydel>
     71<div class="tbltitle">
    4572<br>
    4673<form action="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi" method=POST>
     
    5279</fieldset>
    5380</form>
    54 </TMPL_IF>
    5581</div>
    5682</TMPL_IF>
  • trunk/templates/showsubs2.tmpl

    r678 r682  
    1818<tr class="row<TMPL_IF __odd__>0<TMPL_ELSE>1</TMPL_IF>">
    1919<td>
     20<TMPL_IF subblock>Sub </TMPL_IF>
    2021<TMPL_IF hassubs>
    2122<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=showsubs&amp;parent=<TMPL_VAR NAME=id>"><TMPL_VAR NAME=block></a>
Note: See TracChangeset for help on using the changeset viewer.