Port Log now viewable via an icon by device port name
This commit is contained in:
@@ -218,6 +218,16 @@ Note that this won't work for any target link - the path must be an
|
||||
App::Netdisco Dancer route handler. Please bug the App::Netdisco devs if you
|
||||
want arbitrary links supported.
|
||||
|
||||
An additional feature allows you to create Admin Tasks which do not appear in
|
||||
the Navbar menu. This is useful if the page is only linked directly from
|
||||
another (for example Port Log). To enable this feature add the C<hidden> key:
|
||||
|
||||
register_admin_task({
|
||||
tag => 'newfeature',
|
||||
label => 'My New Feature',
|
||||
hidden => true,
|
||||
});
|
||||
|
||||
=head1 Device Port Columns
|
||||
|
||||
You can also add columns to the Device Ports page. The canonical example of
|
||||
|
||||
39
Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm
Normal file
39
Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm
Normal file
@@ -0,0 +1,39 @@
|
||||
package App::Netdisco::Web::Plugin::AdminTask::PortLog;
|
||||
|
||||
use Dancer ':syntax';
|
||||
use Dancer::Plugin::Ajax;
|
||||
use Dancer::Plugin::DBIC;
|
||||
use Dancer::Plugin::Auth::Extensible;
|
||||
|
||||
use App::Netdisco::Web::Plugin;
|
||||
|
||||
register_admin_task({
|
||||
tag => 'portlog',
|
||||
label => 'Port Control Log',
|
||||
hidden => true,
|
||||
});
|
||||
|
||||
ajax '/ajax/content/admin/portlog' => require_role admin => sub {
|
||||
my $device = param('q');
|
||||
my $port = param('f');
|
||||
send_error('Bad Request', 400) unless $device and $port;
|
||||
|
||||
$device = schema('netdisco')->resultset('Device')
|
||||
->search_for_device($device);
|
||||
return unless $device;
|
||||
|
||||
my $set = schema('netdisco')->resultset('DevicePortLog')->search({
|
||||
ip => $device->ip,
|
||||
port => $port,
|
||||
}, {
|
||||
order_by => { -desc => [qw/creation/] },
|
||||
rows => 200,
|
||||
});
|
||||
|
||||
content_type('text/html');
|
||||
template 'ajax/admintask/portlog.tt', {
|
||||
results => $set,
|
||||
}, { layout => undef };
|
||||
};
|
||||
|
||||
true;
|
||||
Reference in New Issue
Block a user