Changeset 808 for trunk/cgi-bin


Ignore:
Timestamp:
03/08/16 13:16:44 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Extend UI to browse into a VRF. See #54.
Also extend breadcrumb segment to show the VRF.

Location:
trunk/cgi-bin
Files:
2 edited

Legend:

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

    r806 r808  
    13911391sub getBreadCrumbs {
    13921392  my $dbh = shift;
    1393   my $parent = shift;
     1393  my $parent = shift || 0;
     1394  my $vrf = shift;      # if we're not browsing into netblocks yet, caller can pass the VRF for breadcrumbs
    13941395  my @result;
    13951396
    1396   my $sth = $dbh-> prepare("SELECT cidr,type,id,parent_id FROM allocations WHERE id=?");
     1397  my $sth = $dbh-> prepare("SELECT cidr,type,id,parent_id,vrf FROM allocations WHERE id=?");
    13971398
    13981399  while ($parent != 0) {
    13991400    $sth->execute($parent);
    1400     my ($cidr,$type,$id,$pid) = $sth->fetchrow_array;
    1401     push @result, {cidr => $cidr, link => $id, ispool => ($type =~ /^.[dp]$/ ? 1 : 0)};
     1401    my ($cidr,$type,$id,$pid,$bvrf) = $sth->fetchrow_array;
     1402    $vrf = $bvrf;
     1403    push @result, { cidr => $cidr, link => $id, ispool => ($type =~ /^.[dp]$/ ? 1 : 0) };
    14021404    $parent = $pid;
    14031405  }
    14041406
     1407  push @result, { cidr => "vrf:$vrf", link => $vrf, isvrf => 1 }
     1408        if $vrf;
     1409
    14051410  return \@result;
    1406 } # end getBread()
     1411} # end getBreadCrumbs()
    14071412
    14081413
  • trunk/cgi-bin/main.cgi

    r806 r808  
    108108if($webvar{action} eq 'index') {
    109109  showSummary();
     110} elsif ($webvar{action} eq 'showvrf') {
     111  showVRF();
    110112} elsif ($webvar{action} eq 'addmaster') {
    111113  if ($IPDBacl{$authuser} !~ /a/) {
     
    269271
    270272
     273# Show IP blocks in a VRF
     274sub showVRF {
     275  my $masterlist = listSummary($ip_dbh, $webvar{vrf});
     276  $page->param(vrf => $webvar{vrf});
     277  $page->param(masterlist => $masterlist);
     278
     279  # we don't have a netblock;  pass 0 for the block ID
     280  # Tree navigation
     281  my $crumbs = getBreadCrumbs($ip_dbh, 0, $webvar{vrf});
     282  my @rcrumbs = reverse (@$crumbs);
     283  $utilbar->param(breadcrumb => \@rcrumbs);
     284
     285  $page->param(addmaster => ($IPDBacl{$authuser} =~ /s/) );
     286} # showVRF
     287
     288
    271289# Display blocks immediately within a given parent
    272290sub showSubs {
     
    306324#$page->param(editme => 1) unless $pinfo->{type} ne 'mm';
    307325
    308   my $crumbs = getBreadCrumbs($ip_dbh, $pinfo->{parent_id});
     326  my $crumbs = getBreadCrumbs($ip_dbh, $pinfo->{parent_id}, $pinfo->{vrf});
    309327  my @rcrumbs = reverse (@$crumbs);
    310328  $utilbar->param(breadcrumb => \@rcrumbs);
Note: See TracChangeset for help on using the changeset viewer.