From ae535a63d927451e6914fbf1676687f6859417f0 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Sat, 22 Feb 2014 17:43:22 +0000 Subject: [PATCH] Move system information to the Netdisco "home" page --- Netdisco/Changes | 1 + Netdisco/lib/App/Netdisco/Web.pm | 2 +- .../Netdisco/Web/{About.pm => Statistics.pm} | 19 ++++--- Netdisco/share/public/css/netdisco.css | 5 ++ Netdisco/share/public/javascripts/netdisco.js | 2 +- .../views/{about.tt => ajax/statistics.tt} | 20 +++----- Netdisco/share/views/index.tt | 51 +++++++++++++++++-- Netdisco/share/views/inventory.tt | 5 +- 8 files changed, 75 insertions(+), 30 deletions(-) rename Netdisco/lib/App/Netdisco/Web/{About.pm => Statistics.pm} (84%) rename Netdisco/share/views/{about.tt => ajax/statistics.tt} (81%) diff --git a/Netdisco/Changes b/Netdisco/Changes index 04fbef3a..1ded84c4 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -15,6 +15,7 @@ * Add a spinner to all waiting messages * Try to make the Job Queue page a little faster * Require the Net::LDAP module for all installs + * Move system information to the Netdisco "home" page [BUG FIXES] diff --git a/Netdisco/lib/App/Netdisco/Web.pm b/Netdisco/lib/App/Netdisco/Web.pm index e04aa6b7..c6721da2 100644 --- a/Netdisco/lib/App/Netdisco/Web.pm +++ b/Netdisco/lib/App/Netdisco/Web.pm @@ -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; diff --git a/Netdisco/lib/App/Netdisco/Web/About.pm b/Netdisco/lib/App/Netdisco/Web/Statistics.pm similarity index 84% rename from Netdisco/lib/App/Netdisco/Web/About.pm rename to Netdisco/lib/App/Netdisco/Web/Statistics.pm index 3d80825f..00781309 100644 --- a/Netdisco/lib/App/Netdisco/Web/About.pm +++ b/Netdisco/lib/App/Netdisco/Web/Statistics.pm @@ -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; diff --git a/Netdisco/share/public/css/netdisco.css b/Netdisco/share/public/css/netdisco.css index ffc63734..56b97245 100644 --- a/Netdisco/share/public/css/netdisco.css +++ b/Netdisco/share/public/css/netdisco.css @@ -110,6 +110,11 @@ div.content > div.tab-content table.nd_floatinghead thead { font-weight: normal; } +/* for System Information bar */ +.nd_sysinfo-heading { + background-color: #eeeeee; +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* styles to adjust the hero box used for homepage + login */ diff --git a/Netdisco/share/public/javascripts/netdisco.js b/Netdisco/share/public/javascripts/netdisco.js index dcf55ebd..1750106d 100644 --- a/Netdisco/share/public/javascripts/netdisco.js +++ b/Netdisco/share/public/javascripts/netdisco.js @@ -34,7 +34,7 @@ function do_search (event, tab) { function(response, status, xhr) { if (status !== "success") { $(target).html( - '
' + + '
' + 'Search failed! Please contact your site administrator.
' ); return; diff --git a/Netdisco/share/views/about.tt b/Netdisco/share/views/ajax/statistics.tt similarity index 81% rename from Netdisco/share/views/about.tt rename to Netdisco/share/views/ajax/statistics.tt index 8293955b..78bdfe89 100644 --- a/Netdisco/share/views/about.tt +++ b/Netdisco/share/views/ajax/statistics.tt @@ -1,12 +1,4 @@ [% USE Number.Format %] -
-
-
-

About Netdisco

- Netdisco is a web-based network management tool designed for - network administrators. Data is collected into a PostgreSQL database - using SNMP. -

Built using Open Source

@@ -43,7 +35,7 @@ - SNMP::Info + SNMP::Info [% snmpinfo_ver | html_entity %] @@ -53,7 +45,7 @@
-
+

Statistics for this installation

@@ -67,19 +59,19 @@ using [% device_count + device_ip_count | format_number %] IPs - + - + - + +
[% device_links | format_number %] layer 2 links between devices.[% device_links | format_number %] layer 2 links between devices
[% node_count | format_number %] nodes in [% node_table_count | format_number %] entries. [% node_count | format_number %] nodes in [% node_table_count | format_number %] entries
[% ip_count | format_number %] IPs in [% ip_table_count | format_number %] entries.[% ip_count | format_number %] IPs in [% ip_table_count | format_number %] entries
Statistics took [% process_time %] seconds to process.
-
diff --git a/Netdisco/share/views/index.tt b/Netdisco/share/views/index.tt index 84fef330..a58e3ae5 100644 --- a/Netdisco/share/views/index.tt +++ b/Netdisco/share/views/index.tt @@ -34,7 +34,7 @@ [% END %]

Welcome to Netdisco

- Netdisco is an Open Source web-based network management tool. + Netdisco is an Open Source management tool designed for network administrators. [% IF NOT session.logged_in_user %]
+ [% IF session.logged_in_user %] +
+
+ +
+
+
+
+ Compiling statistics...
+
+
+
+
+
+ [% END %]
+ +[% IF session.logged_in_user %] + +[% END %] diff --git a/Netdisco/share/views/inventory.tt b/Netdisco/share/views/inventory.tt index 47cc0484..1b1dc13e 100644 --- a/Netdisco/share/views/inventory.tt +++ b/Netdisco/share/views/inventory.tt @@ -59,7 +59,8 @@
[% ELSE %] -
No devices found. Do you need to run a - Discover?
+ [% END %]