mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix devices page search & OS loading (#9752)
* Fix devices page search * add a definition_loaded flag to prevent false positives for already loaded OS * Fix copy paste error * and another
This commit is contained in:
@@ -75,7 +75,7 @@ class DeviceController extends TableController
|
||||
$query = Device::hasAccess($request->user())->with('location')->select('devices.*');
|
||||
|
||||
// if searching or sorting the location field, join the locations table
|
||||
if ($request->get('term') || in_array('location', array_keys($request->get('sort', [])))) {
|
||||
if ($request->get('searchPhrase') || in_array('location', array_keys($request->get('sort', [])))) {
|
||||
$query->leftJoin('locations', 'locations.id', 'devices.location_id');
|
||||
}
|
||||
|
||||
|
||||
@@ -188,7 +188,7 @@ class Device extends BaseModel
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($config['os'][$this->os]) || $force) {
|
||||
if (empty($config['os'][$this->os]['definition_loaded']) || $force) {
|
||||
$os = \Symfony\Component\Yaml\Yaml::parse(
|
||||
file_get_contents(base_path('/includes/definitions/' . $this->os . '.yaml'))
|
||||
);
|
||||
@@ -198,6 +198,8 @@ class Device extends BaseModel
|
||||
} else {
|
||||
$config['os'][$this->os] = $os;
|
||||
}
|
||||
|
||||
$config['os'][$this->os]['definition_loaded'] = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1535,7 +1535,12 @@ function load_os(&$device)
|
||||
global $config;
|
||||
|
||||
if (!isset($device['os'])) {
|
||||
d_echo('No OS to load');
|
||||
d_echo("No OS to load\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($config['os'][$device['os']]['definition_loaded'])) {
|
||||
d_echo("OS already loaded\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1562,6 +1567,8 @@ function load_os(&$device)
|
||||
} else {
|
||||
unset($device['os_group']);
|
||||
}
|
||||
|
||||
$config['os'][$device['os']]['definition_loaded'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user