From 42e5568370a5154c288787950f6b018f5f18bd4f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sun, 3 Nov 2013 11:32:33 +0000 Subject: [PATCH] Add Slow Devices admin report --- Netdisco/Changes | 1 + .../Netdisco/DB/Result/Virtual/SlowDevices.pm | 42 +++++++++++++++++++ .../Web/Plugin/AdminTask/SlowDevices.pm | 24 +++++++++++ .../share/views/ajax/admintask/slowdevices.tt | 28 +++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 Netdisco/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm create mode 100644 Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/SlowDevices.pm create mode 100644 Netdisco/share/views/ajax/admintask/slowdevices.tt diff --git a/Netdisco/Changes b/Netdisco/Changes index 326a78d7..e0053103 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -5,6 +5,7 @@ * Can now set untagged VLAN on trunking and non-trunking ports * Add user activity log to frontend admin menu * Add Poller Performance admin report + * Add Slow Devices admin report [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm b/Netdisco/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm new file mode 100644 index 00000000..6b522153 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/DB/Result/Virtual/SlowDevices.pm @@ -0,0 +1,42 @@ +package App::Netdisco::DB::Result::Virtual::SlowDevices; + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +__PACKAGE__->table_class('DBIx::Class::ResultSource::View'); + +__PACKAGE__->table('slow_devices'); +__PACKAGE__->result_source_instance->is_virtual(1); +__PACKAGE__->result_source_instance->view_definition(<add_columns( + "action", + { data_type => "text", is_nullable => 1 }, + "device", + { data_type => "inet", is_nullable => 1 }, + "started", + { data_type => "timestamp", is_nullable => 1 }, + "finished", + { data_type => "timestamp", is_nullable => 1 }, + "elapsed", + { data_type => "interval", is_nullable => 1 }, +); + +1; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/SlowDevices.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/SlowDevices.pm new file mode 100644 index 00000000..a15b88f5 --- /dev/null +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/SlowDevices.pm @@ -0,0 +1,24 @@ +package App::Netdisco::Web::Plugin::AdminTask::SlowDevices; + +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 => 'slowdevices', + label => 'Slowest Devices', +}); + +ajax '/ajax/content/admin/slowdevices' => require_role admin => sub { + my $set = schema('netdisco')->resultset('Virtual::SlowDevices'); + + content_type('text/html'); + template 'ajax/admintask/slowdevices.tt', { + results => $set, + }, { layout => undef }; +}; + +true; diff --git a/Netdisco/share/views/ajax/admintask/slowdevices.tt b/Netdisco/share/views/ajax/admintask/slowdevices.tt new file mode 100644 index 00000000..bb4537cd --- /dev/null +++ b/Netdisco/share/views/ajax/admintask/slowdevices.tt @@ -0,0 +1,28 @@ +[% IF results.count == 0 %] +
The aren't enough jobs to report.
+[% ELSE %] + + + + + + + + + + + + [% WHILE (row = results.next) %] + + + + + + + + [% END %] + +
ActionDeviceStartedFinishedTime Elapsed
[% row.action.ucfirst | html_entity %][% row.device | html_entity %][% row.started | html_entity %][% row.finished | html_entity %][% row.elapsed | html_entity %]
+[% END %] +