Move system information to the Netdisco "home" page

This commit is contained in:
Oliver Gorwits
2014-02-22 17:43:22 +00:00
parent 5623422452
commit ae535a63d9
8 changed files with 75 additions and 30 deletions

View File

@@ -20,7 +20,7 @@ use App::Netdisco::Web::Report;
use App::Netdisco::Web::AdminTask;
use App::Netdisco::Web::TypeAhead;
use App::Netdisco::Web::PortControl;
use App::Netdisco::Web::About;
use App::Netdisco::Web::Statistics;
sub _load_web_plugins {
my $plugin_list = shift;

View File

@@ -1,14 +1,17 @@
package App::Netdisco::Web::About;
package App::Netdisco::Web::Statistics;
use Dancer ':syntax';
use Dancer::Plugin::DBIC;
use Dancer::Plugin::Auth::Extensible;
get '/about' => require_login sub {
get '/ajax/content/statistics' => require_login sub {
my $time1 = time;
my $schema = schema('netdisco');
my $devices = $schema->resultset('Device')->search(
my $devices = $schema->resultset('Device');
# used only to get the PostgreSQL version
my $users = $schema->resultset('User')->search(
{},
{ select => [ { version => '' } ],
as => [qw/ version /],
@@ -50,16 +53,15 @@ get '/about' => require_login sub {
my $process_time = $time2 - $time1;
my $disco_ver = $App::Netdisco::VERSION;
my $db_version = $devices->next->get_column('version');
my $db_version = $users->next->get_column('version');
my $dbi_ver = $DBI::VERSION;
my $dbdpg_ver = $DBD::Pg::VERSION;
eval 'require SNMP::Info';
my $snmpinfo_ver = ($@ ? 'n/a' : $SNMP::Info::VERSION);
var( nav => 'about' );
template 'about',
var( nav => 'statistics' );
template 'ajax/statistics.tt',
{
device_count => $device_count,
device_ip_count => $device_ip_count,
@@ -76,7 +78,8 @@ get '/about' => require_login sub {
dbdpg_ver => $dbdpg_ver,
snmpinfo_ver => $snmpinfo_ver,
schema_ver => $schema_version,
};
},
{ layout => undef };
};
true;