diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PhonesDiscovered.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PhonesDiscovered.pm index b351b5ac..130f2718 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PhonesDiscovered.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/PhonesDiscovered.pm @@ -7,26 +7,30 @@ use Dancer::Plugin::Auth::Extensible; use App::Netdisco::Web::Plugin; register_report( - { category => 'Node', - tag => 'phonesdiscovered', - label => 'IP Phones discovered through LLDP/CDP', + { category => 'Node', + tag => 'phonesdiscovered', + label => 'IP Phones discovered through LLDP/CDP', provides_csv => 1, } ); get '/ajax/content/report/phonesdiscovered' => require_login sub { - my $set = schema('netdisco')->resultset('Virtual::PhonesDiscovered'); - return unless $set->count; + my @results = schema('netdisco')->resultset('Virtual::PhonesDiscovered') + ->hri->all; - if (request->is_ajax) { - template 'ajax/report/phonesdiscovered.tt', { results => $set, }, + return unless scalar @results; + + if ( request->is_ajax ) { + my $json = to_json( \@results ); + template 'ajax/report/phonesdiscovered.tt', { results => $json }, { layout => undef }; } else { header( 'Content-Type' => 'text/comma-separated-values' ); - template 'ajax/report/phonesdiscovered_csv.tt', { results => $set, }, - { layout => undef }; + template 'ajax/report/phonesdiscovered_csv.tt', + { results => \@results }, + { layout => undef }; } }; -true; +1; diff --git a/Netdisco/share/views/ajax/report/phonesdiscovered.tt b/Netdisco/share/views/ajax/report/phonesdiscovered.tt index f7d5b6e3..5b167e07 100644 --- a/Netdisco/share/views/ajax/report/phonesdiscovered.tt +++ b/Netdisco/share/views/ajax/report/phonesdiscovered.tt @@ -1,28 +1,54 @@ -
| Device | -Port | -Remote ID | -Remote IP | -Remote Port | -Remote Type | +Device | +Port | +Remote ID | +Remote IP | +Remote Port | +Remote Type |
|---|---|---|---|---|---|---|---|---|---|---|---|
| [% row.dns || row.name || row.ip | html_entity %] | -- [% row.port | html_entity %] | -[% row.remote_id | html_entity %] | -[% row.remote_ip | html_entity %] | -[% row.remote_port | html_entity %] | -[% row.remote_type | html_entity %] | -