display clean version of creation stamp on port log

This commit is contained in:
Oliver Gorwits
2014-02-13 20:31:51 +00:00
parent f3eb4ce7bd
commit b9db2545d5
4 changed files with 54 additions and 6 deletions

View File

@@ -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<creation> field, accurate to the second.
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: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;

View File

@@ -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<search()> 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;

View File

@@ -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', {

View File

@@ -15,7 +15,7 @@
</tbody>
[% WHILE (row = results.next) %]
<tr>
<td class="nd_center-cell">[% row.creation | html_entity %]</td>
<td class="nd_center-cell">[% row.creation_stamp | html_entity %]</td>
<td class="nd_center-cell">[% row.username | html_entity %]</td>
<td class="nd_center-cell">[% row.userip | html_entity %]</td>
<td class="nd_center-cell">[% row.action | html_entity %]</td>