Changeset 670


Ignore:
Timestamp:
01/02/15 17:26:32 (10 years ago)
Author:
Kris Deugau
Message:

/trunk

Minimally update search tool for new database layout. Still needs a major rewrite.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/ipdb-2.7-3.0.sql

    r658 r670  
    3232-- probably need some more indexes
    3333
     34-- Need some additional fields to support search output.  Might arguably
     35-- move pool IPs into the allocations table;  we'll see.
     36DROP VIEW searchme;
     37CREATE VIEW "searchme" AS
     38    SELECT allocations.cidr, allocations.custid, allocations."type", allocations.city,
     39      allocations.description, allocations.notes, allocations.circuitid, allocations.id,
     40      allocations.parent_id, 'n' AS available
     41    FROM allocations
     42  UNION
     43    SELECT poolips.ip, poolips.custid, poolips.type, poolips.city,
     44      poolips.description, poolips.notes, poolips.circuitid, poolips.id,
     45      poolips.parent_id, poolips.available
     46    FROM poolips;
     47
    3448-- Relabel a few types to match the new structure
    3549UPDATE alloctypes SET listname='Routing aggregation', dispname='Routing aggregation' WHERE type='rm';
  • trunk/cgi-bin/search.cgi

    r526 r670  
    7878  $page = HTML::Template->new(filename => "search/compsearch.tmpl");
    7979} else {
    80   $page = HTML::Template->new(filename => "search/sresults.tmpl");
     80  $page = HTML::Template->new(filename => "search/sresults.tmpl", global_vars => 1);
     81  $page->param(webpath => $IPDB::webpath);
    8182}
    8283
     
    8485$header->param(version => $IPDB::VERSION);
    8586$header->param(addperm => $IPDBacl{$authuser} =~ /a/);
     87$header->param(webpath => $IPDB::webpath);
    8688print "Content-type: text/html\n\n", $header->output;
     89
     90# Columns actually returned.  Slightly better than hardcoding it
     91# in each (sub)select
     92my $cols = "cidr,custid,type,city,description,id,parent_id,available";
    8793
    8894# Handle the DB error first
     
    141147# Iff something has NOT been entered, we still include it but in
    142148# such a way that it does not actually filter anything out.
    143 
    144   # Columns actually returned.  Slightly better than hardcoding it
    145   # in each (sub)select
    146   my $cols = "cidr,custid,type,city,description";
    147149
    148150  # hack fix for undefined variables
     
    248250  # Node search.
    249251
    250   my $sql = "SELECT cidr,custid,type,city,description FROM searchme".
     252  my $sql = "SELECT $cols FROM searchme".
    251253        " WHERE cidr IN (SELECT block FROM noderef WHERE node_id=$webvar{node})";
    252254
     
    345347# 5) Invalid data which might be interpretable as an IP or something, but
    346348#    which probably shouldn't be for reasons of sanity.
    347 
    348   my $cols = "cidr,custid,type,city,description";
    349349
    350350  if ($category eq 'all') {
     
    469469  my $count = 0;
    470470  my @sresults;
    471   while (my ($block, $custid, $type, $city, $desc) = $sth->fetchrow_array) {
     471  while (my ($block, $custid, $type, $city, $desc, $id, $parent, $avail) = $sth->fetchrow_array) {
    472472    my %row = (
    473473        rowclass => $count++ % 2,
    474474        issub => ($type =~ /^.r$/ ? 1 : 0),
     475        ispool => ($type =~ /^.[pd]$/ ? 1 : 0),
     476        basetype => ($type =~ /^.i/ ? 'i' : 'b'),
     477        freeip => ($avail eq 'y'),
     478        parent => $parent,
    475479        block => $block,
    476         ispool => ($type =~ /^.[pd]$/ ? 1 : 0),
    477480        custid => $custid,
    478481        disptype => $disp_alloctypes{$type},
    479482        city => $city,
    480         desc => $desc
     483        desc => $desc,
     484        id => $id,
    481485        );
    482486    push @sresults, \%row;
  • trunk/templates/search/sresults.tmpl

    r517 r670  
    1717<TMPL_LOOP NAME=sresults>
    1818<tr class="row<TMPL_VAR NAME=rowclass>">
    19 <td><TMPL_IF issub>Sub </TMPL_IF><a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;block=<TMPL_VAR NAME=block>"><TMPL_VAR NAME=block></a><TMPL_IF ispool>&nbsp; <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=listpool&amp;pool=<TMPL_VAR NAME=block>">List IPs</a></TMPL_IF></td>
     19<td><TMPL_IF issub>Sub </TMPL_IF>
     20<TMPL_IF freeip>
     21<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=assign&amp;block=<TMPL_VAR NAME=id>&amp;parent=<TMPL_VAR NAME=parent>&amp;fbtype=i"><TMPL_VAR NAME=block></a>
     22<TMPL_ELSE>
     23<a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=edit&amp;id=<TMPL_VAR NAME=id>&amp;basetype=<TMPL_VAR NAME=basetype>"><TMPL_VAR NAME=block></a><TMPL_IF ispool>&nbsp; <a href="<TMPL_VAR NAME=webpath>/cgi-bin/main.cgi?action=listpool&amp;pool=<TMPL_VAR NAME=id>">List IPs</a></TMPL_IF>
     24</TMPL_IF>
     25</td>
    2026<td><TMPL_VAR NAME=custid></td>
    2127<td><TMPL_VAR NAME=disptype></td>
Note: See TracChangeset for help on using the changeset viewer.