Squashed commit of the following:

commit 4b6f3de36cbf508c05fbf7f18acee1758bc838ed
Merge: 94ed8b8 200dd2d
Author: Eric A. Miller <emiller@cpan.org>
Date:   Mon Nov 4 19:30:04 2013 -0500

    Merge branch 'master' into em-poe-report

commit 94ed8b8cf01963030a40829fd71bff529750719e
Author: Eric A. Miller <emiller@cpan.org>
Date:   Sun Nov 3 23:34:07 2013 -0500

    Show PoE module statistics in device details if available

commit 652974b312c11d6017cf6f3c0693d62085774e80
Author: Eric A. Miller <emiller@cpan.org>
Date:   Sun Nov 3 23:31:02 2013 -0500

    Move PoE statistics to model from controller
    Add missing div in PoE status report

commit f94f68b1c84d23b2f252d985509757d95be5c0d0
Author: Eric A. Miller <emiller@cpan.org>
Date:   Tue Oct 22 22:38:45 2013 -0400

    Device PoE status report
This commit is contained in:
Eric A. Miller
2013-11-04 19:45:49 -05:00
parent 200dd2d3d1
commit 9f29204676
9 changed files with 252 additions and 2 deletions

View File

@@ -13,11 +13,16 @@ register_device_tab({ tag => 'details', label => 'Details' });
ajax '/ajax/content/device/details' => require_login sub {
my $q = param('q');
my $device = schema('netdisco')->resultset('Device')
->with_times()->search_for_device($q) or send_error('Bad device', 400);
->search_for_device($q) or send_error('Bad device', 400);
my $results
= schema('netdisco')->resultset('Device')
->search( { 'me.ip' => $device->ip } )->with_times()
->with_poestats_as_hashref;
content_type('text/html');
template 'ajax/device/details.tt', {
d => $device,
d => $results->[0],
}, { layout => undef };
};

View File

@@ -0,0 +1,35 @@
package App::Netdisco::Web::Plugin::Report::DevicePoeStatus;
use Dancer ':syntax';
use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
use App::Netdisco::Web::Plugin;
register_report(
{ category => 'Device',
tag => 'devicepoestatus',
label => 'Power over Ethernet (PoE) Status',
provides_csv => 1,
}
);
get '/ajax/content/report/devicepoestatus' => require_login sub {
my $results = schema('netdisco')->resultset('Device')
->with_poestats_as_hashref;
return unless scalar $results;
if ( request->is_ajax ) {
template 'ajax/report/devicepoestatus.tt', { results => $results, },
{ layout => undef };
}
else {
header( 'Content-Type' => 'text/comma-separated-values' );
template 'ajax/report/devicepoestatus_csv.tt',
{ results => $results, },
{ layout => undef };
}
};
1;