add a new tab to device -> vlans (#483)
* first steps for vlan tab * export sort_vlans, use strict/warnings * update manifest, get worker closer to functioning * remove ie 9 script & extra ./th * make it work * cleanup * readd internet explorer code * start for csv output * move things to debug logging instead of info * use message which was discussed * fix for address table sorting * link os * final touches thx to ollyg * fetch origin/master * VLAN is the preferred style for user interface usage * does a missing libexpat-dev make travis builds complain? * Revert "does a missing libexpat-dev make travis builds complain?" This reverts commit 0cebc66f42708ff0f946213aab4bcbcc1b1b1379.
This commit is contained in:
36
lib/App/Netdisco/Web/Plugin/Device/Vlans.pm
Normal file
36
lib/App/Netdisco/Web/Plugin/Device/Vlans.pm
Normal file
@@ -0,0 +1,36 @@
|
||||
package App::Netdisco::Web::Plugin::Device::Vlans;
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_device_tab({ tag => 'vlans', label => 'VLANs', provides_csv => 1 });
|
||||
|
||||
get '/ajax/content/device/vlans' => require_login sub {
|
||||
my $q = param('q');
|
||||
|
||||
my $device = schema('netdisco')->resultset('Device')
|
||||
->search_for_device($q) or send_error('Bad device', 400);
|
||||
my @results = $device->vlans->search( {}, { order_by => 'vlan' } )->hri->all;
|
||||
|
||||
return unless scalar @results;
|
||||
|
||||
if (request->is_ajax) {
|
||||
my $json = to_json( \@results );
|
||||
template 'ajax/device/vlans.tt', { results => $json },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/device/vlans_csv.tt', { results => \@results },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
Reference in New Issue
Block a user