From c969c663bfe6fff1d2e2f551730f93f9dd555679 Mon Sep 17 00:00:00 2001 From: "Eric A. Miller" Date: Mon, 26 May 2014 22:39:55 -0400 Subject: [PATCH] DataTables for device name / DNS mismatch report --- .../Web/Plugin/Report/DeviceDnsMismatch.pm | 18 ++++---- .../views/ajax/report/devicednsmismatch.tt | 41 +++++++++++++------ .../ajax/report/devicednsmismatch_csv.tt | 2 +- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceDnsMismatch.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceDnsMismatch.pm index 4aec2b25..96ecf5e0 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceDnsMismatch.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/Report/DeviceDnsMismatch.pm @@ -15,22 +15,26 @@ register_report( ); get '/ajax/content/report/devicednsmismatch' => require_login sub { - + my $suffix = setting('domain_suffix') || ''; - my $rs = schema('netdisco')->resultset('Virtual::DeviceDnsMismatch') - ->search( undef, { bind => [ $suffix, $suffix ] } ); + my @results + = schema('netdisco')->resultset('Virtual::DeviceDnsMismatch') + ->search( undef, { bind => [ $suffix, $suffix ] } ) + ->columns( [qw/ ip dns name location contact /] )->hri->all; - return unless $rs->has_rows; + return unless scalar @results; if ( request->is_ajax ) { - template 'ajax/report/devicednsmismatch.tt', { results => $rs, }, + my $results = to_json( \@results ); + template 'ajax/report/devicednsmismatch.tt', { results => $results }, { layout => undef }; } else { header( 'Content-Type' => 'text/comma-separated-values' ); - template 'ajax/report/devicednsmismatch_csv.tt', { results => $rs, }, - { layout => undef }; + template 'ajax/report/devicednsmismatch_csv.tt', + { results => \@results }, + { layout => undef }; } }; diff --git a/Netdisco/share/views/ajax/report/devicednsmismatch.tt b/Netdisco/share/views/ajax/report/devicednsmismatch.tt index 0945f24d..95801014 100644 --- a/Netdisco/share/views/ajax/report/devicednsmismatch.tt +++ b/Netdisco/share/views/ajax/report/devicednsmismatch.tt @@ -1,4 +1,4 @@ - +
@@ -8,16 +8,31 @@ - - [% WHILE (row = results.next) %] - - - - - - - [% END %] -
NameLocation
- [% row.name | html_entity %] - [% row.dns | html_entity %][% row.ip | html_entity %][% row.contact | html_entity %][% row.location | html_entity %]
+ + diff --git a/Netdisco/share/views/ajax/report/devicednsmismatch_csv.tt b/Netdisco/share/views/ajax/report/devicednsmismatch_csv.tt index 9dfbfe8b..86169a77 100644 --- a/Netdisco/share/views/ajax/report/devicednsmismatch_csv.tt +++ b/Netdisco/share/views/ajax/report/devicednsmismatch_csv.tt @@ -1,7 +1,7 @@ [% USE CSV -%] [% CSV.dump([ 'Name' 'DNS' 'IP Address' 'Contact' 'Location' ]) %] -[% WHILE (row = results.next) %] +[% FOREACH row IN results %] [% mylist = [] %] [% mylist.push(row.name) %] [% mylist.push(row.dns) %]