diff --git a/Netdisco/lib/Netdisco/Web.pm b/Netdisco/lib/Netdisco/Web.pm index a16b96dd..d0360ede 100644 --- a/Netdisco/lib/Netdisco/Web.pm +++ b/Netdisco/lib/Netdisco/Web.pm @@ -10,6 +10,7 @@ use HTML::Entities (); # to ensure dependency is met use Netdisco::Web::AuthN; use Netdisco::Web::Search; use Netdisco::Web::Device; +use Netdisco::Web::Inventory; hook 'before_template' => sub { my $tokens = shift; diff --git a/Netdisco/lib/Netdisco/Web/AuthN.pm b/Netdisco/lib/Netdisco/Web/AuthN.pm index 74db8240..27053beb 100644 --- a/Netdisco/lib/Netdisco/Web/AuthN.pm +++ b/Netdisco/lib/Netdisco/Web/AuthN.pm @@ -33,7 +33,7 @@ post '/login' => sub { } } } - redirect '/?failed=1'; + redirect uri_for('/', {failed => 1}); }; get '/logout' => sub { diff --git a/Netdisco/lib/Netdisco/Web/Inventory.pm b/Netdisco/lib/Netdisco/Web/Inventory.pm new file mode 100644 index 00000000..5cf8bbbb --- /dev/null +++ b/Netdisco/lib/Netdisco/Web/Inventory.pm @@ -0,0 +1,23 @@ +package Netdisco::Web::Inventory; + +use Dancer ':syntax'; +use Dancer::Plugin::DBIC; + +get '/inventory' => sub { + template 'inventory', { + models => scalar schema('netdisco')->resultset('Device')->search({},{ + select => [ 'vendor', 'model', { count => 'ip' } ], + as => [qw/vendor model count/], + group_by => [qw/vendor model/], + order_by => [{-asc => 'vendor'}, {-desc => 'count'}, {-asc => 'model'}], + }), + releases => scalar schema('netdisco')->resultset('Device')->search({},{ + select => [ 'os', 'os_ver', { count => 'ip' } ], + as => [qw/os os_ver count/], + group_by => [qw/os os_ver/], + order_by => [{-asc => 'os'}, {-desc => 'count'}, {-asc => 'os_ver'}], + }), + }; +}; + +true; diff --git a/Netdisco/lib/Netdisco/Web/Search.pm b/Netdisco/lib/Netdisco/Web/Search.pm index 7e416e80..d0015195 100644 --- a/Netdisco/lib/Netdisco/Web/Search.pm +++ b/Netdisco/lib/Netdisco/Web/Search.pm @@ -185,10 +185,12 @@ get '/search' => sub { schema('netdisco')->resultset('Device')->get_distinct('vendor') ]); - params->{'q'} ||= '_'; # FIXME a cheat Inventory, for now - my $q = param('q'); - if ($q and not param('tab')) { + if (not param('tab')) { + if (not $q) { + redirect uri_for('/'); + } + # pick most likely tab for initial results if ($q =~ m/^\d+$/) { params->{'tab'} = 'vlan'; diff --git a/Netdisco/public/css/netdisco.css b/Netdisco/public/css/netdisco.css index da85b7b3..28e69d97 100644 --- a/Netdisco/public/css/netdisco.css +++ b/Netdisco/public/css/netdisco.css @@ -17,11 +17,16 @@ body { padding-top: 11px; } -/* on both main content and sidebar, hidden overflow is weird and wrong?! */ +/* on both main content and sidebar, default is hidden */ .tab-content { overflow: visible; } +/* ajax results should fill all available */ +.tab-content table { + width: 100%; +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* various styles to adjust the hero box used for homepage + login */ @@ -38,6 +43,35 @@ body { margin-bottom: 0px; } +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* styles for Reports */ + +/* from Bootstrap doc style sheet */ +.nd_show-grid [class*="span"] { + background-color: cornsilk; + text-align: center; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + min-height: 30px; + line-height: 30px; +} + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ +/* styles for Inventory */ + +#nd_dev_age_form { + margin-top: 10px; + margin-bottom: 12px; +} + +.nd_inv_tbl_head { + text-align: center; + color: lightSlateGray; + margin-top: 6px; + margin-bottom: 3px; +} + /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ /* results table links */ diff --git a/Netdisco/public/img/glyphicons-halflings-white.png b/Netdisco/public/img/glyphicons-halflings-white.png new file mode 100644 index 00000000..a20760bf Binary files /dev/null and b/Netdisco/public/img/glyphicons-halflings-white.png differ diff --git a/Netdisco/public/img/glyphicons-halflings.png b/Netdisco/public/img/glyphicons-halflings.png new file mode 100644 index 00000000..92d4445d Binary files /dev/null and b/Netdisco/public/img/glyphicons-halflings.png differ diff --git a/Netdisco/views/index.tt b/Netdisco/views/index.tt index 7de9df2c..4f5ca4c5 100644 --- a/Netdisco/views/index.tt +++ b/Netdisco/views/index.tt @@ -31,11 +31,6 @@ × Log in to the Demo with username "demo" and password "demo". - [% ELSE %] -
- × - Hit Enter in the Search box to view the current Inventory (temporary feature). -
[% END %]

Welcome to Netdisco

diff --git a/Netdisco/views/inventory.tt b/Netdisco/views/inventory.tt new file mode 100644 index 00000000..d2d8f8bb --- /dev/null +++ b/Netdisco/views/inventory.tt @@ -0,0 +1,62 @@ +
+ [% IF models.count %] +
+
+

By Platform

+ + + + + + + + + + [% FOREACH platform IN models.all %] + + + + + + [% END %] + +
VendorModelCount
+ + [% platform.vendor %] + + + [% platform.model %] + [% platform.get_column('count') %]
+
+
+

By Software Release

+ + + + + + + + + + [% FOREACH release IN releases.all %] + + + + + + [% END %] + +
OSVersionCount
[% release.os %] + + [% release.os_ver %] + [% release.get_column('count') %]
+
+
+ [% ELSE %] +
No devices found. Do you need to run a Discover?
+ [% END %] +
diff --git a/Netdisco/views/layouts/main.tt b/Netdisco/views/layouts/main.tt index 4925589a..bf20e5ea 100644 --- a/Netdisco/views/layouts/main.tt +++ b/Netdisco/views/layouts/main.tt @@ -43,12 +43,13 @@ Netdisco [% IF session.user %]