This commit is contained in:
Oliver Gorwits
2021-08-14 13:28:13 +01:00
parent f3478571a3
commit 2498d9766b
8 changed files with 26 additions and 10 deletions

View File

@@ -11,7 +11,7 @@ __PACKAGE__->load_namespaces(
);
our # try to hide from kwalitee
$VERSION = 65; # schema version used for upgrades, keep as integer
$VERSION = 66; # schema version used for upgrades, keep as integer
use Path::Class;
use File::ShareDir 'dist_dir';

View File

@@ -41,6 +41,8 @@ __PACKAGE__->add_columns(
{ data_type => "macaddr", is_nullable => 1 },
"serial",
{ data_type => "text", is_nullable => 1 },
"chassis_id",
{ data_type => "text", is_nullable => 1 },
"model",
{ data_type => "text", is_nullable => 1 },
"ps1_type",

View File

@@ -358,6 +358,8 @@ The following fields are inspected for a match:
=item serial
=item chassis_id
=item module serials (exact)
=item location
@@ -413,10 +415,11 @@ sub search_fuzzy {
->search(
{
-or => [
'me.contact' => { '-ilike' => $q },
'me.serial' => { '-ilike' => $q },
'me.location' => { '-ilike' => $q },
'me.name' => { '-ilike' => $q },
'me.contact' => { '-ilike' => $q },
'me.serial' => { '-ilike' => $q },
'me.chassis_id' => { '-ilike' => $q },
'me.location' => { '-ilike' => $q },
'me.name' => { '-ilike' => $q },
'me.description' => { '-ilike' => $q },
'me.ip' => { '-in' =>
$rs->search({ 'modules.serial' => $qc },

View File

@@ -15,7 +15,7 @@ register_search_tab({
api_endpoint => 1,
api_parameters => [
q => {
description => 'Partial match of Device contact, serial, module serials, location, name, description, dns, or any IP alias',
description => 'Partial match of Device contact, serial, chassis ID, module serials, location, name, description, dns, or any IP alias',
},
name => {
description => 'Partial match of the Device name',
@@ -67,7 +67,7 @@ get '/ajax/content/search/device' => require_login sub {
if ($has_opt) {
$rs = schema('netdisco')->resultset('Device')->columns(
[ "ip", "dns", "name",
"location", "model", "os_ver", "serial"
"location", "model", "os_ver", "serial", "chassis_id"
]
)->with_times->search_by_field( scalar params );
}
@@ -77,7 +77,7 @@ get '/ajax/content/search/device' => require_login sub {
$rs = schema('netdisco')->resultset('Device')->columns(
[ "ip", "dns", "name",
"location", "model", "os_ver", "serial"
"location", "model", "os_ver", "serial", "chassis_id"
]
)->with_times->search_fuzzy($q);
}

View File

@@ -47,8 +47,10 @@ register_worker({ phase => 'early', driver => 'snmp' }, sub {
(my $model = Encode::decode('UTF-8', ($snmp->model || ''))) =~ s/\s+$//;
(my $serial = Encode::decode('UTF-8', ($snmp->serial || ''))) =~ s/\s+$//;
(my $chassis_id = Encode::decode('UTF-8', ($snmp->serial1 || ''))) =~ s/\s+$//;
$device->set_column( model => $model );
$device->set_column( serial => $serial );
$device->set_column( chassis_id => (($chassis_id ne $serial) ? $chassis_id : '') );
$device->set_column( contact => Encode::decode('UTF-8', $snmp->contact) );
$device->set_column( location => Encode::decode('UTF-8', $snmp->location) );