mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Rewrite devices page backend (and a little frontend) (#9726)
* Implement devices table data output * initial filter * Add select2 filters improve table header layout improve init_select2 * bump versions to be safe * add group filtering fix location sorting * allow filter value morphing * add missing state filter * remove the old devices endpoint
This commit is contained in:
@@ -151,6 +151,18 @@ class Device extends BaseModel
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
public function name()
|
||||
{
|
||||
$displayName = $this->displayName();
|
||||
if ($this->sysName !== $displayName) {
|
||||
return $this->sysName;
|
||||
} elseif ($this->hostname !== $displayName && $this->hostname !== $this->ip) {
|
||||
return $this->hostname;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
public function isUnderMaintenance()
|
||||
{
|
||||
$query = AlertSchedule::isActive()
|
||||
@@ -172,6 +184,23 @@ class Device extends BaseModel
|
||||
return $query->exists();
|
||||
}
|
||||
|
||||
public function loadOs($force = false)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if (empty($config['os'][$this->os]) || $force) {
|
||||
$os = \Symfony\Component\Yaml\Yaml::parse(
|
||||
file_get_contents(base_path('/includes/definitions/' . $this->os . '.yaml'))
|
||||
);
|
||||
|
||||
if (isset($config['os'][$this->os])) {
|
||||
$config['os'][$this->os] = array_replace_recursive($os, $config['os'][$this->os]);
|
||||
} else {
|
||||
$config['os'][$this->os] = $os;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the shortened display name of this device.
|
||||
* Length is always overridden by shorthost_target_length.
|
||||
@@ -575,4 +604,9 @@ class Device extends BaseModel
|
||||
{
|
||||
return $this->hasMany('App\Models\Vrf', 'device_id');
|
||||
}
|
||||
|
||||
public function wirelessSensors()
|
||||
{
|
||||
return $this->hasMany('App\Models\WirelessSensor', 'device_id');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user