diff --git a/Netdisco/lib/App/Netdisco/DB/Result/DevicePortLog.pm b/Netdisco/lib/App/Netdisco/DB/Result/DevicePortLog.pm index a764902a..2c9d1f7b 100644 --- a/Netdisco/lib/App/Netdisco/DB/Result/DevicePortLog.pm +++ b/Netdisco/lib/App/Netdisco/DB/Result/DevicePortLog.pm @@ -40,10 +40,19 @@ __PACKAGE__->add_columns( }, ); +=head1 ADDITIONAL COLUMNS -# Created by DBIx::Class::Schema::Loader v0.07015 @ 2012-01-07 14:20:02 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5moCbYoDG2BqT7VrP/MRkA +=head2 creation_stamp + +Formatted version of the C field, accurate to the second. + +The format is somewhat like ISO 8601 or RFC3339 but without the middle C +between the date stamp and time stamp. That is: + + 2012-02-06 12:49:23 + +=cut + +sub creation_stamp { return (shift)->get_column('creation_stamp') } - -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePortLog.pm b/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePortLog.pm new file mode 100644 index 00000000..c631f1be --- /dev/null +++ b/Netdisco/lib/App/Netdisco/DB/ResultSet/DevicePortLog.pm @@ -0,0 +1,39 @@ +package App::Netdisco::DB::ResultSet::DevicePortLog; +use base 'App::Netdisco::DB::ResultSet'; + +use strict; +use warnings FATAL => 'all'; + +__PACKAGE__->load_components(qw/ + +App::Netdisco::DB::ExplicitLocking +/); + +=head1 ADDITIONAL METHODS + +=head2 with_times + +This is a modifier for any C which will add the following additional +synthesized column to the result set: + +=over 4 + +=item creation_stamp + +=back + +=cut + +sub with_times { + my ($rs, $cond, $attrs) = @_; + + return $rs + ->search_rs($cond, $attrs) + ->search({}, + { + '+columns' => { + creation_stamp => \"to_char(creation, 'YYYY-MM-DD HH24:MI:SS')", + }, + }); +} + +1; diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm index b95b9732..cc88d0ee 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PortLog.pm @@ -28,7 +28,7 @@ ajax '/ajax/content/admin/portlog' => require_role admin => sub { }, { order_by => { -desc => [qw/creation/] }, rows => 200, - }); + })->with_times; content_type('text/html'); template 'ajax/admintask/portlog.tt', { diff --git a/Netdisco/share/views/ajax/admintask/portlog.tt b/Netdisco/share/views/ajax/admintask/portlog.tt index 618e9622..10055480 100644 --- a/Netdisco/share/views/ajax/admintask/portlog.tt +++ b/Netdisco/share/views/ajax/admintask/portlog.tt @@ -15,7 +15,7 @@ [% WHILE (row = results.next) %] - [% row.creation | html_entity %] + [% row.creation_stamp | html_entity %] [% row.username | html_entity %] [% row.userip | html_entity %] [% row.action | html_entity %]