MT#16355 show ngcp version and dpkg list

Change-Id: Ia26f669c21f37e7263e806f32d1cb547549fd57f
changes/60/3460/9
Gerhard Jungwirth 11 years ago
parent e5772e77c5
commit 74c3b01d5b

@ -2,6 +2,7 @@ package NGCP::Panel;
use Moose;
use Catalyst::Runtime 5.80;
use File::Slurp qw();
# Set flags and add plugins for the application.
#
@ -167,6 +168,7 @@ __PACKAGE__->config(
}
}
},
ngcp_version => get_ngcp_version(),
);
__PACKAGE__->config( default_view => 'HTML' );
@ -175,6 +177,13 @@ __PACKAGE__->log(Log::Log4perl::Catalyst->new($logger_config));
# Start the application
__PACKAGE__->setup();
sub get_ngcp_version {
my $content = File::Slurp::read_file("/etc/ngcp_version", err_mode => 'quiet');
$content //= '(unavailable)';
chomp($content);
return $content;
}
1;
# vim: set tabstop=4 expandtab:

@ -6,6 +6,7 @@ BEGIN { extends 'Catalyst::Controller' }
use Scalar::Util qw(blessed);
use NGCP::Panel::Utils::DateTime qw();
use NGCP::Panel::Utils::Statistics qw();
use DateTime qw();
use Time::HiRes qw();
use DateTime::Format::RFC3339 qw();
@ -254,7 +255,10 @@ sub error_page :Private {
if($c->request->path =~ /^api\/.+/) {
$c->response->content_type('application/json');
$c->response->body(JSON::to_json({ code => 404, message => 'Path not found' })."\n");
$c->response->body(JSON::to_json({
code => 404,
message => 'Path not found',
})."\n");
} else {
$c->stash(template => 'notfound_page.tt');
}

@ -125,6 +125,21 @@ sub rrd : Chained('/') :PathPart('statistics/rrd') :Args() {
return;
}
sub versions :Chained('/') :PathPart('statistics/versions') :Args() {
my ( $self, $c ) = @_;
my $versions_info = NGCP::Panel::Utils::Statistics::get_dpkg_versions();
$c->stash(versions_info => $versions_info,
#template => 'statistics/versions.tt',
);
return;
}
__PACKAGE__->meta->make_immutable;
1;
__END__
=head1 AUTHOR
Andreas Granig,,,
@ -136,8 +151,4 @@ it under the same terms as Perl itself.
=cut
__PACKAGE__->meta->make_immutable;
1;
# vim: set tabstop=4 expandtab:

@ -3,10 +3,11 @@ use strict;
use warnings;
use DateTime::TimeZone::OffsetOnly;
use Time::Local;
use POSIX;
use File::Find::Rule;
use File::Slurp qw(read_file);
use List::MoreUtils qw(apply);
use POSIX;
use Time::Local;
sub tz_offset {
use DateTime::TimeZone::OffsetOnly;
@ -69,6 +70,11 @@ sub get_rrd {
return $content;
}
sub get_dpkg_versions {
my ($self) = @_;
return `LANG=C dpkg-query -f '\${db:Status-Abbrev} \${Package} \${Version}\\n' -W 2>/dev/null`;
}
1;
# vim: set tabstop=4 expandtab:

@ -83,6 +83,9 @@
<div class="container">
<div class="row">
<div class="span6">
[% IF c.user.roles == 'admin' || c.user.roles == 'reseller'; -%]
<a href="[% c.uri_for("/statistics/versions") %]">[% c.config.ngcp_version %]</a>
[% END; -%]
© 2013 <a href="http://www.sipwise.com">Sipwise GmbH</a>, [% c.loc('all rights reserved') %].
</div>
</div>

@ -24,6 +24,15 @@ body {
display: none;
}
/* add horizontally scrollable pre (to boostrap stlyes) */
pre.pre-x-scrollable {
overflow: auto;
-ms-word-wrap: normal;
word-wrap: normal;
overflow-wrap: normal;
white-space: pre;
}
/* ---------
The modal
------------*/

@ -0,0 +1,16 @@
[% site_config.title = c.loc('Version Info') -%]
<div class="row">
<span>
<a class="btn btn-primary btn-large" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i> [% c.loc('Back') %]</a>
</span>
</div>
[% back_created = 1 -%]
<div class="ngcp-separator"></div>
<pre class="pre-x-scrollable">
[% versions_info | html %]
</pre>
[% # vim: set tabstop=4 syntax=html expandtab: -%]
Loading…
Cancel
Save