Merge branch 'master' into og-multiple-domain-suffix

This commit is contained in:
Oliver Gorwits
2019-09-03 09:45:25 +01:00
64 changed files with 548 additions and 232 deletions

View File

@@ -36,7 +36,7 @@ ajax '/ajax/control/admin/pseudodevice/add' => require_role admin => sub {
ip => param('ip'),
dns => param('dns'),
vendor => 'netdisco',
layers => '00000100',
layers => param('layers'),
last_discover => \'now()',
});
return unless $device;
@@ -87,6 +87,9 @@ ajax '/ajax/control/admin/pseudodevice/update' => require_role admin => sub {
})->delete;
}
}
# also set layers
$device->update({layers => param('layers')});
});
};

View File

@@ -41,6 +41,7 @@ ajax '/ajax/control/admin/users/add' => require_role setting('defanged_admin') =
password => _make_password(param('password')),
fullname => param('fullname'),
ldap => (param('ldap') ? \'true' : \'false'),
radius => (param('radius') ? \'true' : \'false'),
port_control => (param('port_control') ? \'true' : \'false'),
admin => (param('admin') ? \'true' : \'false'),
note => param('note'),
@@ -71,6 +72,7 @@ ajax '/ajax/control/admin/users/update' => require_role setting('defanged_admin'
: ()),
fullname => param('fullname'),
ldap => (param('ldap') ? \'true' : \'false'),
radius => (param('radius') ? \'true' : \'false'),
port_control => (param('port_control') ? \'true' : \'false'),
admin => (param('admin') ? \'true' : \'false'),
note => param('note'),

View File

@@ -31,7 +31,7 @@ get '/ajax/content/device/ports' => require_login sub {
# change wildcard chars to SQL
$f =~ s/\*/%/g;
$f =~ s/\?/_/g;
# set wilcards at param boundaries
# set wildcards at param boundaries
if ($f !~ m/[%_]/) {
$f =~ s/^\%*/%/;
$f =~ s/\%*$/%/;
@@ -82,6 +82,8 @@ get '/ajax/content/device/ports' => require_login sub {
});
}
delete $port_state{free};
# showing free ports requires showing down ports
++$port_state{down};
}
if (scalar keys %port_state < 3) {

View File

@@ -47,7 +47,7 @@ get '/ajax/content/report/nodevendor/data' => require_login sub {
my $match = $vendor eq 'blank' ? undef : $vendor;
$rs = $rs->search( { 'oui.abbrev' => $match },
{ '+columns' => [qw/ device.dns device.name oui.abbrev /],
{ '+columns' => [qw/ device.dns device.name oui.abbrev oui.company /],
join => [qw/ oui device /],
collapse => 1,
});
@@ -86,7 +86,7 @@ get '/ajax/content/report/nodevendor' => require_login sub {
my $match = $vendor eq 'blank' ? undef : $vendor;
$rs = $rs->search( { 'oui.abbrev' => $match },
{ '+columns' => [qw/ device.dns device.name oui.abbrev /],
{ '+columns' => [qw/ device.dns device.name oui.abbrev oui.company /],
join => [qw/ oui device /],
collapse => 1,
});
@@ -102,9 +102,9 @@ get '/ajax/content/report/nodevendor' => require_login sub {
$rs = $rs->search(
{ },
{ join => 'oui',
select => [ 'oui.abbrev', { count => {distinct => 'me.mac'}} ],
as => [qw/ vendor count /],
group_by => [qw/ oui.abbrev /]
select => [ 'oui.abbrev', 'oui.company', { count => {distinct => 'me.mac'}} ],
as => [qw/ abbrev vendor count /],
group_by => [qw/ oui.abbrev oui.company /]
}
)->order_by( { -desc => 'count' } );

View File

@@ -20,7 +20,7 @@ get '/ajax/content/report/portutilization' => require_login sub {
my $age_num = param('age_num') || 3;
my $age_unit = param('age_unit') || 'months';
my @results = schema('netdisco')->resultset('Virtual::PortUtilization')
->search(undef, { bind => [ "$age_num $age_unit" ] })->hri->all;
->search(undef, { bind => [ "$age_num $age_unit", "$age_num $age_unit", "$age_num $age_unit" ] })->hri->all;
if (request->is_ajax) {
my $json = to_json (\@results);

View File

@@ -6,6 +6,7 @@ use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
use NetAddr::IP::Lite ':lower';
use Regexp::Common 'net';
use NetAddr::MAC ();
use App::Netdisco::Web::Plugin;
@@ -23,10 +24,14 @@ ajax '/ajax/content/search/node' => require_login sub {
my ( $start, $end ) = param('daterange') =~ m/(\d+-\d+-\d+)/gmx;
my $mac = NetAddr::MAC->new(mac => $node);
undef $mac if ($mac and $mac->as_ieee and ($mac->as_ieee eq '00:00:00:00'));
my @active = (param('archived') ? () : (-bool => 'active'));
undef $mac if
($mac and $mac->as_ieee
and (($mac->as_ieee eq '00:00:00:00:00:00')
or ($mac->as_ieee !~ m/$RE{net}{MAC}/)));
my @active = (param('archived') ? () : (-bool => 'active'));
my (@times, @wifitimes, @porttimes);
if ( $start and $end ) {
$start = $start . ' 00:00:00';
$end = $end . ' 23:59:59';