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:
SourceDoctor
2019-12-24 17:01:26 +01:00
committed by PipoCanaja
parent 15e29a49b1
commit 299da2600e
2 changed files with 39 additions and 31 deletions

View File

@@ -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);
}
/**