working vlan search!!
This commit is contained in:
@@ -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')) {
|
||||||
|
|||||||
22
Netdisco/views/content/vlan.tt
Normal file
22
Netdisco/views/content/vlan.tt
Normal 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>
|
||||||
Reference in New Issue
Block a user