DataTables for device addresses without DNS entries report
This commit is contained in:
@@ -17,18 +17,18 @@ register_report(
|
|||||||
get '/ajax/content/report/deviceaddrnodns' => require_login sub {
|
get '/ajax/content/report/deviceaddrnodns' => require_login sub {
|
||||||
my @results = schema('netdisco')->resultset('Device')->search(
|
my @results = schema('netdisco')->resultset('Device')->search(
|
||||||
{ 'device_ips.dns' => undef },
|
{ 'device_ips.dns' => undef },
|
||||||
{ result_class => 'DBIx::Class::ResultClass::HashRefInflator',
|
{ select => [ 'ip', 'dns', 'name', 'location', 'contact' ],
|
||||||
select => [ 'ip', 'dns', 'name', 'location', 'contact' ],
|
|
||||||
join => [qw/device_ips/],
|
join => [qw/device_ips/],
|
||||||
'+columns' => [ { 'alias' => 'device_ips.alias' }, ],
|
'+columns' => [ { 'alias' => 'device_ips.alias' }, ],
|
||||||
order_by => { -asc => [qw/me.ip device_ips.alias/] },
|
order_by => { -asc => [qw/me.ip device_ips.alias/] },
|
||||||
}
|
}
|
||||||
)->all;
|
)->hri->all;
|
||||||
|
|
||||||
return unless scalar @results;
|
return unless scalar @results;
|
||||||
|
|
||||||
if ( request->is_ajax ) {
|
if ( request->is_ajax ) {
|
||||||
template 'ajax/report/deviceaddrnodns.tt', { results => \@results, },
|
my $results = to_json (\@results);
|
||||||
|
template 'ajax/report/deviceaddrnodns.tt', { results => $results, },
|
||||||
{ layout => undef };
|
{ layout => undef };
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -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 nd_floatinghead" width="100%" cellspacing="0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="nd_center-cell">Device</th>
|
<th class="nd_center-cell">Device</th>
|
||||||
@@ -7,15 +7,26 @@
|
|||||||
<th class="nd_center-cell">Location</th>
|
<th class="nd_center-cell">Location</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</tbody>
|
|
||||||
[% FOREACH row IN results %]
|
|
||||||
<tr>
|
|
||||||
<td class="nd_center-cell"><a href="[% search_device %]&q=[% row.ip | uri %]">
|
|
||||||
[% row.dns || row.name || row.ip | html_entity %]</a>
|
|
||||||
<td class="nd_center-cell">[% row.alias | html_entity %]</td>
|
|
||||||
<td class="nd_center-cell">[% row.contact | html_entity %]</td>
|
|
||||||
<td class="nd_center-cell">[% row.location | html_entity %]</td>
|
|
||||||
</tr>
|
|
||||||
[% END %]
|
|
||||||
</tbody>
|
|
||||||
</table>
|
</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 href="[% search_device %]&q=' + data + '">' + (row.dns || row.name || row.ip) + '</a>';
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
data: 'alias'
|
||||||
|
}, {
|
||||||
|
data: 'contact'
|
||||||
|
}, {
|
||||||
|
data: 'location'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
});</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user