DataTables for device name / DNS mismatch report
This commit is contained in:
@@ -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 };
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<table class="table table-bordered table-condensed table-striped nd_floatinghead">
|
||||
<table id="data-table" class="table table-striped table-bordered" width="100%" cellspacing="0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
@@ -8,16 +8,31 @@
|
||||
<th>Location</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</tbody>
|
||||
[% WHILE (row = results.next) %]
|
||||
<tr>
|
||||
<td><a href="[% search_device %]&q=[% row.ip | uri %]">
|
||||
[% row.name | html_entity %]</a>
|
||||
<td>[% row.dns | html_entity %]</td>
|
||||
<td>[% row.ip | html_entity %]</td>
|
||||
<td>[% row.contact | html_entity %]</td>
|
||||
<td>[% row.location | html_entity %]</td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
var table = $('#data-table').dataTable({
|
||||
"deferRender": true,
|
||||
"data": [% results %],
|
||||
"columns": [
|
||||
{
|
||||
data: 'ip',
|
||||
render: function(data, type, row, meta) {
|
||||
return '<a search_device %]&q=' + data + '">' + (row.ip || row.name) + '</a>';
|
||||
}
|
||||
}, {
|
||||
data: 'dns'
|
||||
}, {
|
||||
data: 'ip'
|
||||
}, {
|
||||
data: 'contact'
|
||||
}, {
|
||||
data: 'location'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -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) %]
|
||||
|
||||
Reference in New Issue
Block a user