#24 Show device age in device search view
This commit is contained in:
4
Changes
4
Changes
@@ -6,6 +6,10 @@
|
||||
* #48 Node Monitor supports matching on OUI
|
||||
* #31 Configurable Free Time in Port Utilization Report
|
||||
|
||||
[ENHANCEMENTS]
|
||||
|
||||
* #24 Show device age in device search view
|
||||
|
||||
2.039015 - 2018-03-05
|
||||
|
||||
[BUG FIXES]
|
||||
|
||||
@@ -332,6 +332,19 @@ The format is in "X days/months/years" style, similar to:
|
||||
|
||||
sub uptime_age { return (shift)->get_column('uptime_age') }
|
||||
|
||||
=head2 first_seen_stamp
|
||||
|
||||
Formatted version of the C<creation> field, accurate to the minute.
|
||||
|
||||
The format is somewhat like ISO 8601 or RFC3339 but without the middle C<T>
|
||||
between the date stamp and time stamp. That is:
|
||||
|
||||
2012-02-06 12:49
|
||||
|
||||
=cut
|
||||
|
||||
sub first_seen_stamp { return (shift)->get_column('first_seen_stamp') }
|
||||
|
||||
=head2 last_discover_stamp
|
||||
|
||||
Formatted version of the C<last_discover> field, accurate to the minute.
|
||||
|
||||
@@ -16,12 +16,22 @@ will add the following additional synthesized columns to the result set:
|
||||
|
||||
=item uptime_age
|
||||
|
||||
=item first_seen_stamp
|
||||
|
||||
=item last_discover_stamp
|
||||
|
||||
=item last_macsuck_stamp
|
||||
|
||||
=item last_arpnip_stamp
|
||||
|
||||
=item since_first_seen
|
||||
|
||||
=item since_last_discover
|
||||
|
||||
=item since_last_macsuck
|
||||
|
||||
=item since_last_arpnip
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
@@ -36,9 +46,11 @@ sub with_times {
|
||||
'+columns' => {
|
||||
uptime_age => \("replace(age(timestamp 'epoch' + uptime / 100 * interval '1 second', "
|
||||
."timestamp '1970-01-01 00:00:00-00')::text, 'mon', 'month')"),
|
||||
first_seen_stamp => \"to_char(creation, 'YYYY-MM-DD HH24:MI')",
|
||||
last_discover_stamp => \"to_char(last_discover, 'YYYY-MM-DD HH24:MI')",
|
||||
last_macsuck_stamp => \"to_char(last_macsuck, 'YYYY-MM-DD HH24:MI')",
|
||||
last_arpnip_stamp => \"to_char(last_arpnip, 'YYYY-MM-DD HH24:MI')",
|
||||
since_first_seen => \"extract(epoch from (age(now(), creation)))",
|
||||
since_last_discover => \"extract(epoch from (age(now(), last_discover)))",
|
||||
since_last_macsuck => \"extract(epoch from (age(now(), last_macsuck)))",
|
||||
since_last_arpnip => \"extract(epoch from (age(now(), last_arpnip)))",
|
||||
|
||||
@@ -19,7 +19,7 @@ get '/ajax/content/search/device' => require_login sub {
|
||||
|
||||
if ($has_opt) {
|
||||
$rs = schema('netdisco')->resultset('Device')->columns(
|
||||
[ "ip", "dns", "name", "contact",
|
||||
[ "ip", "dns", "name",
|
||||
"location", "model", "os_ver", "serial"
|
||||
]
|
||||
)->with_times->search_by_field( scalar params );
|
||||
@@ -29,7 +29,7 @@ get '/ajax/content/search/device' => require_login sub {
|
||||
send_error( 'Missing query', 400 ) unless $q;
|
||||
|
||||
$rs = schema('netdisco')->resultset('Device')->columns(
|
||||
[ "ip", "dns", "name", "contact",
|
||||
[ "ip", "dns", "name",
|
||||
"location", "model", "os_ver", "serial"
|
||||
]
|
||||
)->with_times->search_fuzzy($q);
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Device</th>
|
||||
<th>Contact</th>
|
||||
<th>Location</th>
|
||||
<th>System Name</th>
|
||||
<th>Model</th>
|
||||
<th>OS Version</th>
|
||||
<th>Management IP</th>
|
||||
<th>Serial</th>
|
||||
<th>First Seen</th>
|
||||
<th>Last Discovered</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -24,11 +24,6 @@ $(document).ready(function() {
|
||||
"render": function(data, type, row, meta) {
|
||||
return '<a href="[% uri_for('/device') %]?q=' + encodeURIComponent(data) + '">' + he.encode(row.dns || row.name || row.ip) + '</a>';
|
||||
}
|
||||
}, {
|
||||
"data": 'contact',
|
||||
"render": function(data, type, row, meta) {
|
||||
return he.encode(data || '');
|
||||
}
|
||||
}, {
|
||||
"data": 'location',
|
||||
"render": function(data, type, row, meta) {
|
||||
@@ -59,6 +54,11 @@ $(document).ready(function() {
|
||||
"render": function(data, type, row, meta) {
|
||||
return he.encode(data || '');
|
||||
}
|
||||
}, {
|
||||
"data": 'first_seen_stamp',
|
||||
"render": function(data, type, row, meta) {
|
||||
return he.encode(data || '');
|
||||
}
|
||||
}, {
|
||||
"data": 'last_discover_stamp',
|
||||
"render": function(data, type, row, meta) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[% USE CSV -%]
|
||||
[% CSV.dump(['Device','Contact','Location','System Name','Model','OS Version','Management IP','Serial']) %]
|
||||
[% CSV.dump(['Device','Location','System Name','Model','OS Version','Management IP','Serial','First Seen','Last Discovered']) %]
|
||||
|
||||
[% FOREACH row IN results %]
|
||||
[% mylist = [] %]
|
||||
[% device = row.dns || row.ip %]
|
||||
[% FOREACH col IN [ device row.contact row.location row.name row.model row.os_ver row.ip row.serial] %]
|
||||
[% FOREACH col IN [ device row.location row.name row.model row.os_ver row.ip row.serial row.first_seen_stamp row.last_discover_stamp] %]
|
||||
[% mylist.push(col) %]
|
||||
[% END %]
|
||||
[% CSV.dump(mylist) %]
|
||||
|
||||
Reference in New Issue
Block a user