blib/lib/App/Netdisco/Web/Plugin/Device/Modules.pm untested

filter: Statementstmt 0.0% 0 / 31 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 6 Podpod n/a totaltotal 0.0% 0 / 44 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package App::Netdisco::Web::Plugin::Device::Modules;
2  
3 use Dancer ':syntax';
4 use Dancer::Plugin::Ajax;
5 use Dancer::Plugin::DBIC;
6 use Dancer::Plugin::Auth::Extensible;
7  
8 use App::Netdisco::Util::Web (); # for sort_module
9 use App::Netdisco::Web::Plugin;
10  
11 register_device_tab({ tag => 'modules', label => 'Modules' });
12  
13 ajax '/ajax/content/device/modules' => require_login sub {
14 my $q = param('q');
15  
16 my $device = schema(vars->{'tenant'})->resultset('Device')
17 ->search_for_device($q) or send_error('Bad device', 400);
18 my @set = $device->modules->search({}, {order_by => { -asc => [qw/parent class pos index/] }});
19  
20 # sort modules (empty set would be a 'no records' msg)
21 my $results = &App::Netdisco::Util::Web::sort_modules( \@set );
22 return unless scalar %$results;
23  
24 content_type('text/html');
25 template 'ajax/device/modules.tt', {
26 nodes => $results,
27 }, { layout => 'noop' };
28 };
29  
30 true;