working vlan search!!

This commit is contained in:
Oliver Gorwits
2012-01-07 18:06:04 +00:00
parent e9470a14f3
commit 3aa0a56de5
2 changed files with 43 additions and 0 deletions

View File

@@ -22,6 +22,27 @@ ajax '/ajax/content/search/:thing' => sub {
return '<p>Hello '. param('thing') .'.</p>'; return '<p>Hello '. param('thing') .'.</p>';
}; };
# devices carrying vlan xxx
ajax '/ajax/content/search/vlan' => sub {
my $q = param('q');
return unless $q and $q =~ m/^\d+$/;
my $set = schema('netdisco')->resultset('Device')->carrying_vlan($q);
return unless $set->count;
content_type('text/html');
template 'content/vlan.tt', {
results => $set,
columns => [
{ key => 'dns', label => 'Device' },
{ key => [qw/vlan description/], label => 'Description' },
{ key => 'model', label => 'Model' },
{ key => 'os', label => 'OS' },
{ key => 'vendor', label => 'Vendor' },
],
}, { layout => undef };
};
get '/search' => sub { get '/search' => sub {
my $q = param('q'); my $q = param('q');
if ($q and not param('tab')) { if ($q and not param('tab')) {

View File

@@ -0,0 +1,22 @@
<table class="bordered-table condensed-table zebra-striped">
<thead>
<tr>
[% FOREACH col IN columns %]
<th>[% col.label %]</th>
[% END %]
</tr>
</thead>
</tbody>
[% WHILE (row = results.next) %]
<tr>
[% FOREACH col IN columns %]
[% SET val = row %]
[% FOREACH method IN col.key %]
[% SET val = val.$method %]
[% END %]
<td>[% val %]</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>