#1064 display device and device port tags in web ui

This commit is contained in:
Oliver Gorwits
2023-07-19 13:01:51 +01:00
parent 4b99f0bb9c
commit 04ee1e1613
6 changed files with 52 additions and 19 deletions

View File

@@ -7,6 +7,8 @@ use Dancer::Plugin::Auth::Extensible;
use App::Netdisco::Web::Plugin;
use List::MoreUtils 'singleton';
register_device_tab({ tag => 'details', label => 'Details' });
# device details table
@@ -40,10 +42,14 @@ ajax '/ajax/content/device/details' => require_login sub {
],
})->order_by('pos')->get_column('serial')->all;
# filter the tags by hide_tags setting
my @hide = @{ setting('hide_tags')->{'device'} };
content_type('text/html');
template 'ajax/device/details.tt', {
d => $results[0], p => \@power,
interfaces => \@interfaces,
filtered_tags => [ singleton (@{ $device->tags || [] }, @hide, @hide) ],
serials => [sort keys %{ { map {($_ => $_)} (@serials, ($device->serial ? $device->serial : ())) } }],
}, { layout => undef };
};

View File

@@ -9,6 +9,8 @@ use App::Netdisco::Util::Port 'port_reconfig_check';
use App::Netdisco::Util::Web (); # for sort_port
use App::Netdisco::Web::Plugin;
use List::MoreUtils 'singleton';
register_device_tab({ tag => 'ports', label => 'Ports', provides_csv => 1 });
# device ports with a description (er, name) matching
@@ -254,6 +256,10 @@ get '/ajax/content/device/ports' => require_login sub {
map {$_->{portctl} = (port_reconfig_check($_, $device, logged_in_user) ? false : true)} @results;
}
# filter the tags by hide_tags setting
my @hide = @{ setting('hide_tags')->{'device_port'} };
map { $_->{filtered_tags} = [ singleton (@{ $_->tags || [] }, @hide, @hide) ] } @results;
# empty set would be a 'no records' msg
return unless scalar @results;