Merge branch 'master' into og-reset-cookie
This commit is contained in:
@@ -1,28 +1,33 @@
|
||||
package App::Netdisco::Web::Plugin::Device::Addresses;
|
||||
|
||||
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 => 'addresses', label => 'Addresses' });
|
||||
register_device_tab( { tag => 'addresses', label => 'Addresses', provides_csv => 1 } );
|
||||
|
||||
# device interface addresses
|
||||
ajax '/ajax/content/device/addresses' => require_login sub {
|
||||
get '/ajax/content/device/addresses' => require_login sub {
|
||||
my $q = param('q');
|
||||
|
||||
my $device = schema('netdisco')->resultset('Device')
|
||||
->search_for_device($q) or send_error('Bad device', 400);
|
||||
my $device
|
||||
= schema('netdisco')->resultset('Device')->search_for_device($q)
|
||||
or send_error( 'Bad device', 400 );
|
||||
|
||||
my $set = $device->device_ips->search({}, {order_by => 'alias'});
|
||||
my $set = $device->device_ips->search( {}, { order_by => 'alias' } );
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/device/addresses.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/device/addresses.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/device/addresses_csv.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package App::Netdisco::Web::Plugin::Report::ApChannelDist;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
@@ -11,10 +10,11 @@ register_report(
|
||||
{ category => 'Wireless',
|
||||
tag => 'apchanneldist',
|
||||
label => 'Access Point Channel Distribution',
|
||||
provides_csv => 1,
|
||||
}
|
||||
);
|
||||
|
||||
ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
||||
get '/ajax/content/report/apchanneldist' => require_login sub {
|
||||
my $set = schema('netdisco')->resultset('DevicePortWireless')->search(
|
||||
{ channel => { '!=', '0' } },
|
||||
{ select => [ 'channel', { count => 'channel' } ],
|
||||
@@ -23,12 +23,17 @@ ajax '/ajax/content/report/apchanneldist' => require_login sub {
|
||||
order_by => { -desc => [qw/count/] },
|
||||
},
|
||||
);
|
||||
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/report/apchanneldist.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/report/apchanneldist.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/apchanneldist_csv.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
package App::Netdisco::Web::Plugin::Report::DuplexMismatch;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_report({
|
||||
category => 'Port',
|
||||
tag => 'duplexmismatch',
|
||||
label => 'Duplex Mismatches Between Devices',
|
||||
});
|
||||
register_report(
|
||||
{ category => 'Port',
|
||||
tag => 'duplexmismatch',
|
||||
label => 'Duplex Mismatches Between Devices',
|
||||
provides_csv => 1,
|
||||
}
|
||||
);
|
||||
|
||||
ajax '/ajax/content/report/duplexmismatch' => require_login sub {
|
||||
get '/ajax/content/report/duplexmismatch' => require_login sub {
|
||||
my $set = schema('netdisco')->resultset('Virtual::DuplexMismatch');
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/report/duplexmismatch.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/report/duplexmismatch.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/duplexmismatch_csv.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package App::Netdisco::Web::Plugin::Report::HalfDuplex;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
@@ -11,19 +10,26 @@ register_report({
|
||||
category => 'Port',
|
||||
tag => 'halfduplex',
|
||||
label => 'Ports in Half Duplex Mode',
|
||||
provides_csv => 1,
|
||||
});
|
||||
|
||||
ajax '/ajax/content/report/halfduplex' => require_login sub {
|
||||
get '/ajax/content/report/halfduplex' => require_login sub {
|
||||
my $format = param('format');
|
||||
my $set = schema('netdisco')->resultset('DevicePort')->search(
|
||||
{ up => 'up', duplex => { '-ilike' => 'half' } },
|
||||
{ order_by => [qw/device.dns port/], prefetch => 'device' },
|
||||
);
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/report/halfduplex.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/report/halfduplex.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/halfduplex_csv.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
package App::Netdisco::Web::Plugin::Report::PortUtilization;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_report({
|
||||
category => 'Device',
|
||||
tag => 'portutilization',
|
||||
label => 'Port Utilization',
|
||||
});
|
||||
register_report(
|
||||
{ category => 'Device',
|
||||
tag => 'portutilization',
|
||||
label => 'Port Utilization',
|
||||
provides_csv => 1,
|
||||
}
|
||||
);
|
||||
|
||||
ajax '/ajax/content/report/portutilization' => require_login sub {
|
||||
get '/ajax/content/report/portutilization' => require_login sub {
|
||||
return unless schema('netdisco')->resultset('Device')->count;
|
||||
my $set = schema('netdisco')->resultset('Virtual::PortUtilization');
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/report/portutilization.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/report/portutilization.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/report/portutilization_csv.tt', { results => $set, },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package App::Netdisco::Web::Plugin::Search::Device;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
@@ -9,10 +8,12 @@ use List::MoreUtils ();
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_search_tab({ tag => 'device', label => 'Device' });
|
||||
register_search_tab({ tag => 'device', label => 'Device', provides_csv => 1 });
|
||||
|
||||
my $headers = ['Device','Contact','Location','System Name','Model','OS Version','Management IP','Serial'];
|
||||
|
||||
# device with various properties or a default match-all
|
||||
ajax '/ajax/content/search/device' => require_login sub {
|
||||
get '/ajax/content/search/device' => require_login sub {
|
||||
my $has_opt = List::MoreUtils::any {param($_)}
|
||||
qw/name location dns ip description model os_ver vendor/;
|
||||
my $set;
|
||||
@@ -28,10 +29,17 @@ ajax '/ajax/content/search/device' => require_login sub {
|
||||
}
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/search/device.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/search/device.tt', {results => $set},
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/search/device_csv.tt', {
|
||||
results => $set,
|
||||
headers => $headers,
|
||||
}, { layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package App::Netdisco::Web::Plugin::Search::Port;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_search_tab({ tag => 'port', label => 'Port' });
|
||||
register_search_tab({ tag => 'port', label => 'Port', provides_csv => 1 });
|
||||
|
||||
# device ports with a description (er, name) matching
|
||||
ajax '/ajax/content/search/port' => require_login sub {
|
||||
get '/ajax/content/search/port' => require_login sub {
|
||||
my $q = param('q');
|
||||
send_error('Missing query', 400) unless $q;
|
||||
my $set;
|
||||
@@ -30,10 +29,15 @@ ajax '/ajax/content/search/port' => require_login sub {
|
||||
}
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/search/port.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/search/port.tt', {results => $set},
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/search/port_csv.tt', {results => $set},
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
@@ -1,32 +1,38 @@
|
||||
package App::Netdisco::Web::Plugin::Search::VLAN;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_search_tab({ tag => 'vlan', label => 'VLAN' });
|
||||
register_search_tab( { tag => 'vlan', label => 'VLAN', provides_csv => 1 } );
|
||||
|
||||
# devices carrying vlan xxx
|
||||
ajax '/ajax/content/search/vlan' => require_login sub {
|
||||
get '/ajax/content/search/vlan' => require_login sub {
|
||||
my $q = param('q');
|
||||
send_error('Missing query', 400) unless $q;
|
||||
send_error( 'Missing query', 400 ) unless $q;
|
||||
my $set;
|
||||
|
||||
if ($q =~ m/^\d+$/) {
|
||||
$set = schema('netdisco')->resultset('Device')->carrying_vlan({vlan => $q});
|
||||
if ( $q =~ m/^\d+$/ ) {
|
||||
$set = schema('netdisco')->resultset('Device')
|
||||
->carrying_vlan( { vlan => $q } );
|
||||
}
|
||||
else {
|
||||
$set = schema('netdisco')->resultset('Device')->carrying_vlan_name({name => $q});
|
||||
$set = schema('netdisco')->resultset('Device')
|
||||
->carrying_vlan_name( { name => $q } );
|
||||
}
|
||||
return unless $set->count;
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/search/vlan.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
if (request->is_ajax) {
|
||||
template 'ajax/search/vlan.tt', { results => $set },
|
||||
{ layout => undef };
|
||||
}
|
||||
else {
|
||||
header( 'Content-Type' => 'text/comma-separated-values' );
|
||||
template 'ajax/search/vlan_csv.tt', { results => $set },
|
||||
{ layout => undef };
|
||||
}
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
Reference in New Issue
Block a user