mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix Device Mouseover View (#10962)
* fix device mouseover view * move function to App/Models/Device.php * load OS Setting in Device Constructor * retrigger travis
This commit is contained in:
@@ -1497,37 +1497,7 @@ function load_os(&$device)
|
||||
*/
|
||||
function load_all_os($existing = false, $cached = true)
|
||||
{
|
||||
$install_dir = Config::get('install_dir');
|
||||
$cache_file = $install_dir . '/cache/os_defs.cache';
|
||||
|
||||
if ($cached && is_file($cache_file) && (time() - filemtime($cache_file) < Config::get('os_def_cache_time'))) {
|
||||
// Cached
|
||||
$os_defs = unserialize(file_get_contents($cache_file));
|
||||
|
||||
if ($existing) {
|
||||
// remove unneeded os
|
||||
$os_defs = array_diff_key($os_defs, dbFetchColumn('SELECT DISTINCT(`os`) FROM `devices`'));
|
||||
}
|
||||
|
||||
Config::set('os', array_replace_recursive($os_defs, Config::get('os')));
|
||||
} else {
|
||||
// load from yaml
|
||||
if ($existing) {
|
||||
$os_list = array_map(function ($os) use ($install_dir) {
|
||||
return $install_dir . '/includes/definitions/' . $os . '.yaml';
|
||||
}, dbFetchColumn('SELECT DISTINCT(`os`) FROM `devices`'));
|
||||
} else {
|
||||
$os_list = glob($install_dir . '/includes/definitions/*.yaml');
|
||||
}
|
||||
|
||||
foreach ($os_list as $file) {
|
||||
if (is_readable($file)) {
|
||||
$tmp = Symfony\Component\Yaml\Yaml::parse(file_get_contents($file));
|
||||
|
||||
Config::set("os.{$tmp['os']}", array_replace_recursive($tmp, Config::get("os.{$tmp['os']}", [])));
|
||||
}
|
||||
}
|
||||
}
|
||||
Device::loadAllOs($existing, $cached);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user