Device operating system added to inventory links and search sidebar

This commit is contained in:
Oliver Gorwits
2015-02-22 09:32:24 +00:00
parent 84d89fd311
commit 31b024eef3
6 changed files with 31 additions and 4 deletions

View File

@@ -1,4 +1,8 @@
2.031008 - 2015-02-18
2.031008 - 2015-02-22
[ENHANCEMENTS]
* Device operating system added to inventory links and search sidebar
[BUG FIXES]

View File

@@ -168,6 +168,10 @@ a description of the vendor operating system).
Will match exactly the C<model> field.
=item os
Will match exactly the C<os> field, which is the operating sytem.
=item os_ver
Will match exactly the C<os_ver> field, which is the operating sytem software version.
@@ -236,6 +240,8 @@ sub search_by_field {
($p->{model} ? ('me.model' =>
{ '-in' => $p->{model} }) : ()),
($p->{os} ? ('me.os' =>
{ '-in' => $p->{os} }) : ()),
($p->{os_ver} ? ('me.os_ver' =>
{ '-in' => $p->{os_ver} }) : ()),
($p->{vendor} ? ('me.vendor' =>

View File

@@ -14,7 +14,7 @@ register_search_tab(
# device with various properties or a default match-all
get '/ajax/content/search/device' => require_login sub {
my $has_opt = List::MoreUtils::any { param($_) }
qw/name location dns ip description model os_ver vendor layers/;
qw/name location dns ip description model os os_ver vendor layers/;
my $rs;
if ($has_opt) {

View File

@@ -56,7 +56,7 @@ hook 'before_template' => sub {
or index(request->path, uri_for('/ajax/content/search')->path) == 0);
# used in the device search sidebar template to set selected items
foreach my $opt (qw/model vendor os_ver/) {
foreach my $opt (qw/model vendor os os_ver/) {
my $p = (ref [] eq ref param($opt) ? param($opt)
: (param($opt) ? [param($opt)] : []));
$tokens->{"${opt}_lkp"} = { map { $_ => 1 } @$p };
@@ -114,12 +114,14 @@ get '/search' => require_login sub {
# used in the device search sidebar to populate select inputs
my $model_list = [ $s->resultset('Device')->get_distinct_col('model') ];
my $os_list = [ $s->resultset('Device')->get_distinct_col('os') ];
my $os_ver_list = [ $s->resultset('Device')->get_distinct_col('os_ver') ];
my $vendor_list = [ $s->resultset('Device')->get_distinct_col('vendor') ];
template 'search', {
search => params->{'tab'},
model_list => $model_list,
os_list => $os_list,
os_ver_list => $os_ver_list,
vendor_list => $vendor_list,
};

View File

@@ -49,7 +49,13 @@
[% FOREACH release IN releases.all %]
[% NEXT UNLESS (release.os OR release.os_ver) %]
<tr>
<th>[% release.os || 'unknown' | html_entity %]</th>
<th>
[% IF release.os %]
<a class="nd_linkcell"
href="[% search_device %]&q=[% release.os | uri %]&os=[% release.os | uri %]">
[% release.os | html_entity %]</a>
[% ELSE %]unknown[% END %]
</th>
<th>
[% IF release.os_ver %]
<a class="nd_linkcell"

View File

@@ -50,6 +50,15 @@
[% END %]
</select>
</div>
<div class="clearfix">
<select class="nd_side-select" size="[% os_list.size > 5 ? 5 : os_list.size %]"
multiple="on" name="os"
rel="tooltip" data-placement="left" data-offset="5" data-title="Operating System"/>
[% FOREACH opt IN os_list %]
<option[% ' selected="selected"' IF os_lkp.exists(opt) %]>[% opt | html_entity %]</option>
[% END %]
</select>
</div>
<div class="clearfix">
<select class="nd_side-select" size="[% os_ver_list.size > 5 ? 5 : os_ver_list.size %]"
multiple="on" name="os_ver"