Changeset 697 for trunk/cgi-bin


Ignore:
Timestamp:
02/18/15 17:16:21 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Add "breadcrumb" navigation trace to most pages.

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

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

    r696 r697  
    3131        &listSummary &listSubs &listContainers &listAllocations &listFree &listPool
    3232        &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    33         &ipParent &subParent &blockParent &getRoutedCity
     33        &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity
    3434        &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS &getRDNSbyIP
    3535        &getNodeList &getNodeName &getNodeInfo
     
    4646                &listSummary &listSubs &listContainers &listAllocations &listFree &listPool
    4747                &getMasterList &getTypeList &getPoolSelect &findAllocateFrom
    48                 &ipParent &subParent &blockParent &getRoutedCity
     48                &ipParent &subParent &blockParent &getBreadCrumbs &getRoutedCity
    4949                &allocateBlock &updateBlock &deleteBlock &getBlockData &getBlockRDNS &getRDNSbyIP
    5050                &getNodeList &getNodeName &getNodeInfo
     
    950950
    951951
     952## IPDB::getBreadCrumbs()
     953# Retrieve the ID and CIDR of a block's parent(s) up to the master block
     954# Returns an arrayref to a list of hashrefs with CIDR and block ID
     955sub getBreadCrumbs {
     956  my $dbh = shift;
     957  my $parent = shift;
     958  my @result;
     959
     960  my $sth = $dbh-> prepare("SELECT cidr,type,id,parent_id FROM allocations WHERE id=?");
     961
     962  while ($parent != 0) {
     963    $sth->execute($parent);
     964    my ($cidr,$type,$id,$pid) = $sth->fetchrow_array;
     965    push @result, {cidr => $cidr, link => $id, ispool => ($type =~ /^.[dp]$/ ? 1 : 0)};
     966    $parent = $pid;
     967  }
     968
     969  return \@result;
     970} # end getBread()
     971
     972
    952973## IPDB::getRoutedCity()
    953974# Get the city for a routed block.
  • trunk/cgi-bin/main.cgi

    r695 r697  
    7474my $header = HTML::Template->new(filename => "header.tmpl");
    7575my $footer = HTML::Template->new(filename => "footer.tmpl");
     76my $utilbar = HTML::Template->new(filename => "utilbar.tmpl", loop_context_vars => 1, global_vars => 1);
     77
     78print "Content-type: text/html\n\n";
    7679
    7780$header->param(version => $IPDB::VERSION);
    7881$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
    7982$header->param(webpath => $IPDB::webpath);
    80 print "Content-type: text/html\n\n", $header->output;
     83
     84$utilbar->param(webpath => $IPDB::webpath);
     85
     86print $header->output;
    8187
    8288
     
    221227#print "Content-type: text/html\n\n", $header->output;
    222228$page->param(webpath => $IPDB::webpath);
     229print $utilbar->output;
    223230print $page->output;
    224231
     
    278285#$page->param(editme => 1) unless $pinfo->{type} ne 'mm';
    279286
     287  my $crumbs = getBreadCrumbs($ip_dbh, $pinfo->{parent_id});
     288  my @rcrumbs = reverse (@$crumbs);
     289  $utilbar->param(breadcrumb => \@rcrumbs);
     290
    280291  $page->param(self_id => $webvar{parent});
    281292  $page->param(block => $pinfo->{block});
     
    292303  my $poolinfo = getBlockData($ip_dbh, $webvar{pool});
    293304  my $cidr = new NetAddr::IP $poolinfo->{block};
     305
     306  # Tree navigation
     307  my $crumbs = getBreadCrumbs($ip_dbh, $poolinfo->{parent_id});
     308  my @rcrumbs = reverse (@$crumbs);
     309  $utilbar->param(breadcrumb => \@rcrumbs);
    294310
    295311  $page->param(block => $cidr);
     
    348364    # seems reasonable that a new allocation would share a VRF with its parent
    349365    $page->param(pvrf => $pinfo->{vrf});
     366
     367    # Tree navigation
     368    my $crumbs = getBreadCrumbs($ip_dbh, $webvar{parent});
     369    my @rcrumbs = reverse (@$crumbs);
     370    $utilbar->param(breadcrumb => \@rcrumbs);
    350371
    351372    $webvar{fbtype} = '' if !$webvar{fbtype};
     
    441462
    442463    if ($webvar{fbassign} && $webvar{fbassign} eq 'y') {
     464
     465      # Tree navigation
     466      my $crumbs = getBreadCrumbs($ip_dbh, $webvar{parent});
     467      my @rcrumbs = reverse (@$crumbs);
     468      $utilbar->param(breadcrumb => \@rcrumbs);
     469
    443470      $cidr = new NetAddr::IP $webvar{block};
    444471      $alloc_from = new NetAddr::IP $webvar{allocfrom};
     
    685712      $page->param(alloctype => $disp_alloctypes{$webvar{alloctype}});
    686713      $page->param(custid => $webvar{custid});
     714
    687715      # breadcrumbs lite!  provide at least a link to the parent of the block we just allocated.
    688716      my $binfo = getBlockData($ip_dbh, $webvar{parent});
    689717      $page->param(parentid => $webvar{parent});
    690718      $page->param(parentblock => $binfo->{block});
     719
     720      # Full breadcrumbs
     721      my $crumbs = getBreadCrumbs($ip_dbh, $webvar{parent});
     722      my @rcrumbs = reverse (@$crumbs);
     723      $utilbar->param(breadcrumb => \@rcrumbs);
     724
    691725      if ($webvar{alloctype} eq 'pr' && $webvar{billinguser}) {
    692726        $page->param(billinguser => $webvar{billinguser});
     
    829863  $page->param(id       => $webvar{id});
    830864  $page->param(basetype => $webvar{basetype});
     865
     866  # Tree navigation
     867  my $crumbs = getBreadCrumbs($ip_dbh, $blockinfo->{parent_id});
     868  my @rcrumbs = reverse (@$crumbs);
     869  $utilbar->param(breadcrumb => \@rcrumbs);
    831870
    832871  # Clean up extra whitespace on alloc type.  Mainly a legacy-data cleanup.
Note: See TracChangeset for help on using the changeset viewer.