DataTables for IP inventory report
This commit is contained in:
		| @@ -153,7 +153,8 @@ get '/ajax/content/report/ipinventory' => require_login sub { | ||||
|     return unless scalar @results; | ||||
|  | ||||
|     if ( request->is_ajax ) { | ||||
|         template 'ajax/report/ipinventory.tt', { results => \@results, }, | ||||
|         my $json = to_json( \@results ); | ||||
|         template 'ajax/report/ipinventory.tt', { results => $json }, | ||||
|             { layout => undef }; | ||||
|     } | ||||
|     else { | ||||
|   | ||||
| @@ -1,30 +1,49 @@ | ||||
| <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>Node</th> | ||||
|       <th class="nd_center-cell">DNS</th> | ||||
|       <th class="nd_center-cell">Last Used</th>       | ||||
|       <th class="nd_center-cell">First Discovered</th> | ||||
|       <th>DNS</th> | ||||
|       <th>Last Used</th>       | ||||
|       <th>First Discovered</th> | ||||
|     </tr> | ||||
|   </thead> | ||||
|   </tbody> | ||||
|     [% FOREACH row IN results %] | ||||
|     <tr> | ||||
|     [% IF row.time_last && row.node %] | ||||
|       <td><a href="[% search_node %]&q=[% row.ip | uri %][% '&archived=on' IF NOT row.active %]"> | ||||
|         [% row.ip | html_entity %]</a> | ||||
|         [% ' <i class="icon-book text-warning"></i> ' IF NOT row.active %] | ||||
|       </td> | ||||
|     [% ELSIF row.time_last %] | ||||
|       <td><a href="[% search_device %]&q=[% row.ip | uri %]">[% row.ip | html_entity %]</a> | ||||
|       </td> | ||||
|     [% ELSE %] | ||||
|       <td>[% row.ip | html_entity %]</td> | ||||
|     [% END %] | ||||
|       <td class="nd_center-cell">[% row.dns | html_entity %]</td> | ||||
|       <td class="nd_center-cell">[% row.age || 'Never' | html_entity %]</td> | ||||
|       <td class="nd_center-cell">[% row.time_first || 'Never' | 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) { | ||||
|           var cell_str = he.encode(data); | ||||
|           if (row.time_last && row.node) { | ||||
|             cell_str = '<a href="[% search_node %]&q=' + encodeURIComponent(data) + (row.active ? '' : '&archived=on') + '">' + he.encode(data) + (row.active ? '' : ' <i class="icon-book text-warning"></i> ') + '</a>'; | ||||
|           } | ||||
|           else if (row.time_last) { | ||||
|             cell_str = '<a href="[% search_device %]&q=' + encodeURIComponent(data) + '">' + he.encode(data) + '</a>'; | ||||
|           } | ||||
|           return cell_str; | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'dns', | ||||
|         "render": function(data, type, row, meta) { | ||||
|           return he.encode(data || ''); | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'age', | ||||
|         "render": function(data, type, row, meta) { | ||||
|           return he.encode(data || 'Never'); | ||||
|         } | ||||
|       }, { | ||||
|         "data": 'time_first', | ||||
|         "render": function(data, type, row, meta) { | ||||
|           return he.encode(data || 'Never'); | ||||
|         } | ||||
|       } | ||||
|     ] | ||||
|   }); | ||||
| }); | ||||
| </script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user